Skip to content

Commit

Permalink
Merge pull request #884 from hcoles/duplicate_classes
Browse files Browse the repository at this point in the history
Remove duplicate classes
  • Loading branch information
hcoles authored Apr 20, 2021
2 parents 83d62d6 + b937ba0 commit 4e6bb87
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 835 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,19 @@ private ClassPointer resolveClass(final String clazz) {
}

}

class DeferredClassPointer implements ClassPointer {
private final Repository repository;
private final ClassName name;

DeferredClassPointer(final Repository repository, final ClassName name) {
this.repository = repository;
this.name = name;
}

@Override
public Optional<ClassInfo> fetch() {
return this.repository.fetchClass(this.name);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.pitest.classinfo.ClassByteArraySource;
import org.pitest.classinfo.ClassInfo;
import org.pitest.classinfo.ClassInfoSource;
import org.pitest.classinfo.ClassName;
Expand All @@ -21,7 +22,7 @@
/**
* Provides access to code and tests on the classpath
*/
public class CodeSource implements ClassInfoSource {
public class CodeSource implements ClassInfoSource, ClassByteArraySource {

private final ProjectClassPaths classPath;
private final Repository classRepository;
Expand Down Expand Up @@ -75,7 +76,6 @@ public Collection<ClassInfo> getClassInfo(final Collection<ClassName> classes) {
.collect(Collectors.toList());
}

// not used but keep to allow plugins to query bytecode
public Optional<byte[]> fetchClassBytes(final ClassName clazz) {
return this.classRepository.querySource(clazz);
}
Expand All @@ -90,4 +90,8 @@ private Function<ClassName, Stream<ClassInfo>> nameToClassInfo() {
.andThen(Streams::fromOptional);
}

@Override
public Optional<byte[]> getBytes(String clazz) {
return fetchClassBytes(ClassName.fromString(clazz));
}
}

This file was deleted.

124 changes: 0 additions & 124 deletions pitest-entry/src/test/java/org/pitest/classinfo/ClassInfoTest.java

This file was deleted.

14 changes: 0 additions & 14 deletions pitest/src/main/java/org/pitest/classinfo/AddlerHash.java

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions pitest/src/main/java/org/pitest/classinfo/ClassPointer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,4 @@ public Optional<ClassInfo> fetch() {

}

class DeferredClassPointer implements ClassPointer {
private final Repository repository;
private final ClassName name;

DeferredClassPointer(final Repository repository, final ClassName name) {
this.repository = repository;
this.name = name;
}

@Override
public Optional<ClassInfo> fetch() {
return this.repository.fetchClass(this.name);
}

}
20 changes: 0 additions & 20 deletions pitest/src/main/java/org/pitest/classinfo/NameToClassInfo.java

This file was deleted.

49 changes: 0 additions & 49 deletions pitest/src/main/java/org/pitest/classinfo/TestToClassMapper.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import org.pitest.classinfo.ClassByteArraySource;
import org.pitest.classinfo.ClassName;
import org.pitest.classpath.CodeSource;
import org.pitest.coverage.BlockLocation;
import org.pitest.coverage.LineMap;
import java.util.Optional;
Expand All @@ -18,9 +18,9 @@

public class LineMapper implements LineMap {

private final CodeSource source;
private final ClassByteArraySource source;

public LineMapper(final CodeSource source) {
public LineMapper(final ClassByteArraySource source) {
this.source = source;
}

Expand All @@ -29,7 +29,7 @@ public Map<BlockLocation, Set<Integer>> mapLines(final ClassName clazz) {

final Map<BlockLocation, Set<Integer>> map = new HashMap<>();

final Optional<byte[]> maybeBytes = this.source.fetchClassBytes(clazz);
final Optional<byte[]> maybeBytes = this.source.getBytes(clazz.asInternalName());
// classes generated at runtime eg by mocking frameworks
// will be instrumented but not available on the classpath
if (maybeBytes.isPresent()) {
Expand Down
Loading

0 comments on commit 4e6bb87

Please sign in to comment.