diff --git a/pitest-entry/src/main/java/org/pitest/mutationtest/build/intercept/staticinitializers/StaticInitializerInterceptorFactory.java b/pitest-entry/src/main/java/org/pitest/mutationtest/build/intercept/staticinitializers/StaticInitializerInterceptorFactory.java index 4062cb258..828444943 100644 --- a/pitest-entry/src/main/java/org/pitest/mutationtest/build/intercept/staticinitializers/StaticInitializerInterceptorFactory.java +++ b/pitest-entry/src/main/java/org/pitest/mutationtest/build/intercept/staticinitializers/StaticInitializerInterceptorFactory.java @@ -22,7 +22,7 @@ public StaticInitializerInterceptorFactory() { } public StaticInitializerInterceptorFactory(Function> delayedExecutionTypes) { - this.delayedExecutionTypes = delayedExecutionTypes.andThen(this::jdkFunctionalClasses); + this.delayedExecutionTypes = delayedExecutionTypes.andThen(this::functionalInterfaces); } @Override @@ -43,9 +43,9 @@ public Feature provides() { .withDescription("Filters mutations in static initializers and code called only from them"); } - private Set jdkFunctionalClasses(Set existing) { + private Set functionalInterfaces(Set existing) { Set classes = new HashSet<>(existing); - try (BufferedReader r = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("/jdkfunctionalinterfaces.txt")))) { + try (BufferedReader r = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("/functional_interfaces.txt")))) { String line = r.readLine(); while (line != null) { classes.add(line); @@ -53,7 +53,7 @@ private Set jdkFunctionalClasses(Set existing) { } return classes; } catch (IOException e) { - throw new RuntimeException("Could not read embedded jdk class list!"); + throw new RuntimeException("Could not read embedded list of functional interfaces!"); } } } diff --git a/pitest-entry/src/main/resources/functional_interfaces.txt b/pitest-entry/src/main/resources/functional_interfaces.txt new file mode 100644 index 000000000..4240ce000 --- /dev/null +++ b/pitest-entry/src/main/resources/functional_interfaces.txt @@ -0,0 +1,133 @@ +java/io/FileFilter +java/io/FilenameFilter +java/io/ObjectInputFilter +java/lang/Runnable +java/util/Comparator +java/util/concurrent/Callable +java/util/function/BiConsumer +java/util/function/BiFunction +java/util/function/BiPredicate +java/util/function/BinaryOperator +java/util/function/BooleanSupplier +java/util/function/Consumer +java/util/function/DoubleBinaryOperator +java/util/function/DoubleConsumer +java/util/function/DoubleFunction +java/util/function/DoublePredicate +java/util/function/DoubleSupplier +java/util/function/DoubleToIntFunction +java/util/function/DoubleToLongFunction +java/util/function/DoubleUnaryOperator +java/util/function/Function +java/util/function/IntBinaryOperator +java/util/function/IntConsumer +java/util/function/IntFunction +java/util/function/IntPredicate +java/util/function/IntSupplier +java/util/function/IntToDoubleFunction +java/util/function/IntToLongFunction +java/util/function/IntUnaryOperator +java/util/function/LongBinaryOperator +java/util/function/LongConsumer +java/util/function/LongFunction +java/util/function/LongPredicate +java/util/function/LongSupplier +java/util/function/LongToDoubleFunction +java/util/function/LongToIntFunction +java/util/function/LongUnaryOperator +java/util/function/ObjDoubleConsumer +java/util/function/ObjIntConsumer +java/util/function/ObjLongConsumer +java/util/function/Predicate +java/util/function/Supplier +java/util/function/ToDoubleBiFunction +java/util/function/ToDoubleFunction +java/util/function/ToIntBiFunction +java/util/function/ToIntFunction +java/util/function/ToLongBiFunction +java/util/function/ToLongFunction +java/util/function/UnaryOperator +java/util/stream/DoubleStream$DoubleMapMultiConsumer +java/util/stream/IntStream$IntMapMultiConsumer +java/util/stream/LongStream$LongMapMultiConsumer +org/pitest/sequence/Match +org/apache/commons/text/lookup/BiStringLookup +org/apache/commons/text/lookup/StringLookup +org/apache/commons/lang3/Functions$FailableBiConsumer +org/apache/commons/lang3/Functions$FailableBiFunction +org/apache/commons/lang3/Functions$FailableBiPredicate +org/apache/commons/lang3/Functions$FailableCallable +org/apache/commons/lang3/Functions$FailableConsumer +org/apache/commons/lang3/Functions$FailableFunction +org/apache/commons/lang3/Functions$FailablePredicate +org/apache/commons/lang3/Functions$FailableRunnable +org/apache/commons/lang3/Functions$FailableSupplier +org/apache/commons/lang3/ThreadUtils$ThreadGroupPredicate +org/apache/commons/lang3/ThreadUtils$ThreadPredicate +org/apache/commons/lang3/function/FailableBiConsumer +org/apache/commons/lang3/function/FailableBiFunction +org/apache/commons/lang3/function/FailableBiPredicate +org/apache/commons/lang3/function/FailableBooleanSupplier +org/apache/commons/lang3/function/FailableCallable +org/apache/commons/lang3/function/FailableConsumer +org/apache/commons/lang3/function/FailableDoubleBinaryOperator +org/apache/commons/lang3/function/FailableDoubleConsumer +org/apache/commons/lang3/function/FailableDoubleFunction +org/apache/commons/lang3/function/FailableDoublePredicate +org/apache/commons/lang3/function/FailableDoubleSupplier +org/apache/commons/lang3/function/FailableDoubleToIntFunction +org/apache/commons/lang3/function/FailableDoubleToLongFunction +org/apache/commons/lang3/function/FailableFunction +org/apache/commons/lang3/function/FailableIntBinaryOperator +org/apache/commons/lang3/function/FailableIntConsumer +org/apache/commons/lang3/function/FailableIntFunction +org/apache/commons/lang3/function/FailableIntPredicate +org/apache/commons/lang3/function/FailableIntSupplier +org/apache/commons/lang3/function/FailableIntToDoubleFunction +org/apache/commons/lang3/function/FailableIntToLongFunction +org/apache/commons/lang3/function/FailableLongBinaryOperator +org/apache/commons/lang3/function/FailableLongConsumer +org/apache/commons/lang3/function/FailableLongFunction +org/apache/commons/lang3/function/FailableLongPredicate +org/apache/commons/lang3/function/FailableLongSupplier +org/apache/commons/lang3/function/FailableLongToDoubleFunction +org/apache/commons/lang3/function/FailableLongToIntFunction +org/apache/commons/lang3/function/FailableObjDoubleConsumer +org/apache/commons/lang3/function/FailableObjIntConsumer +org/apache/commons/lang3/function/FailableObjLongConsumer +org/apache/commons/lang3/function/FailablePredicate +org/apache/commons/lang3/function/FailableRunnable +org/apache/commons/lang3/function/FailableShortSupplier +org/apache/commons/lang3/function/FailableSupplier +org/apache/commons/lang3/function/FailableToDoubleBiFunction +org/apache/commons/lang3/function/FailableToDoubleFunction +org/apache/commons/lang3/function/FailableToIntBiFunction +org/apache/commons/lang3/function/FailableToIntFunction +org/apache/commons/lang3/function/FailableToLongBiFunction +org/apache/commons/lang3/function/FailableToLongFunction +org/apache/commons/lang3/function/ToBooleanBiFunction +org/apache/commons/lang3/function/TriFunction +com/google/errorprone/matchers/Matcher +com/google/common/base/Function +com/google/common/base/Predicate +com/google/common/base/Supplier +com/google/common/cache/RemovalListener +com/google/common/cache/Weigher +com/google/common/collect/Maps$EntryTransformer +com/google/common/util/concurrent/AsyncCallable +com/google/common/util/concurrent/AsyncFunction +com/google/common/util/concurrent/ClosingFuture$AsyncClosingCallable +com/google/common/util/concurrent/ClosingFuture$AsyncClosingFunction +com/google/common/util/concurrent/ClosingFuture$ClosingCallable +com/google/common/util/concurrent/ClosingFuture$ClosingFunction +com/google/common/util/concurrent/ClosingFuture$Combiner$AsyncCombiningCallable +com/google/common/util/concurrent/ClosingFuture$Combiner$CombiningCallable +com/google/common/util/concurrent/ClosingFuture$Combiner2$AsyncClosingFunction2 +com/google/common/util/concurrent/ClosingFuture$Combiner2$ClosingFunction2 +com/google/common/util/concurrent/ClosingFuture$Combiner3$AsyncClosingFunction3 +com/google/common/util/concurrent/ClosingFuture$Combiner3$ClosingFunction3 +com/google/common/util/concurrent/ClosingFuture$Combiner4$AsyncClosingFunction4 +com/google/common/util/concurrent/ClosingFuture$Combiner4$ClosingFunction4 +com/google/common/util/concurrent/ClosingFuture$Combiner5$AsyncClosingFunction5 +com/google/common/util/concurrent/ClosingFuture$Combiner5$ClosingFunction5 +com/google/common/util/concurrent/ClosingFuture$ValueAndCloserConsumer \ No newline at end of file diff --git a/pitest-entry/src/main/resources/jdkfunctionalinterfaces.txt b/pitest-entry/src/main/resources/jdkfunctionalinterfaces.txt deleted file mode 100644 index 8c09fd3d6..000000000 --- a/pitest-entry/src/main/resources/jdkfunctionalinterfaces.txt +++ /dev/null @@ -1,94 +0,0 @@ -java/io/FileFilter -java/io/FilenameFilter -java/io/ObjectInputFilter -java/lang/Runnable -java/lang/Thread$UncaughtExceptionHandler -java/nio/file/DirectoryStream$Filter -java/nio/file/PathMatcher -java/security/PrivilegedAction -java/security/PrivilegedExceptionAction -java/time/temporal/TemporalAdjuster -java/time/temporal/TemporalQuery -java/util/Comparator -java/util/concurrent/Callable -java/util/concurrent/Flow$Publisher -java/util/function/BiConsumer -java/util/function/BiFunction -java/util/function/BiPredicate -java/util/function/BinaryOperator -java/util/function/BooleanSupplier -java/util/function/Consumer -java/util/function/DoubleBinaryOperator -java/util/function/DoubleConsumer -java/util/function/DoubleFunction -java/util/function/DoublePredicate -java/util/function/DoubleSupplier -java/util/function/DoubleToIntFunction -java/util/function/DoubleToLongFunction -java/util/function/DoubleUnaryOperator -java/util/function/Function -java/util/function/IntBinaryOperator -java/util/function/IntConsumer -java/util/function/IntFunction -java/util/function/IntPredicate -java/util/function/IntSupplier -java/util/function/IntToDoubleFunction -java/util/function/IntToLongFunction -java/util/function/IntUnaryOperator -java/util/function/LongBinaryOperator -java/util/function/LongConsumer -java/util/function/LongFunction -java/util/function/LongPredicate -java/util/function/LongSupplier -java/util/function/LongToDoubleFunction -java/util/function/LongToIntFunction -java/util/function/LongUnaryOperator -java/util/function/ObjDoubleConsumer -java/util/function/ObjIntConsumer -java/util/function/ObjLongConsumer -java/util/function/Predicate -java/util/function/Supplier -java/util/function/ToDoubleBiFunction -java/util/function/ToDoubleFunction -java/util/function/ToIntBiFunction -java/util/function/ToIntFunction -java/util/function/ToLongBiFunction -java/util/function/ToLongFunction -java/util/function/UnaryOperator -java/util/regex/Pattern$CharPredicate -java/util/stream/DoubleStream$DoubleMapMultiConsumer -java/util/stream/IntStream$IntMapMultiConsumer -java/util/stream/LongStream$LongMapMultiConsumer -jdk/internal/access/JavaObjectInputStreamAccess -jdk/internal/access/JavaObjectInputStreamReadString -sun/net/www/protocol/http/AuthenticatorKeys$AuthenticatorKeyAccess -sun/nio/ch/MembershipRegistry$ThrowingConsumer -sun/security/pkcs12/PKCS12KeyStore$RetryWithZero -java/awt/KeyEventDispatcher -java/awt/KeyEventPostProcessor -javax/management/remote/JMXConnectorFactory$ConnectorFactory -com/sun/naming/internal/ObjectFactoriesFilter$FactoryInfo -java/util/logging/Filter -java/net/http/HttpResponse$BodyHandler -jdk/internal/net/http/common/Cancelable -jdk/internal/net/http/common/MinimalFuture$ExceptionalSupplier -jdk/internal/net/http/common/SequentialScheduler$RestartableTask -jdk/internal/net/http/frame/FramesDecoder$FrameProcessor -jdk/internal/net/http/hpack/DecodingCallback -jdk/internal/net/http/hpack/HPACK$BufferUpdateConsumer -jdk/internal/net/http/websocket/TransportFactory -java/util/prefs/PreferenceChangeListener -jdk/dynalink/beans/MissingMemberHandlerFactory -jdk/dynalink/linker/GuardedInvocationTransformer -jdk/dynalink/linker/MethodHandleTransformer -jdk/dynalink/linker/MethodTypeConversionStrategy -jdk/incubator/foreign/SegmentAllocator -jdk/incubator/foreign/SymbolLookup -jdk/internal/foreign/abi/BindingInterpreter$LoadFunc -jdk/internal/foreign/abi/BindingInterpreter$StoreFunc -jdk/internal/org/jline/reader/Widget -jdk/internal/org/jline/utils/Colors$Distance -jdk/jpackage/internal/AppImageBundler$ParamsValidator -jdk/jpackage/internal/IOUtils$XmlConsumer -jdk/jpackage/internal/LibProvidersLookup$PackageLookup -jdk/jpackage/internal/OverridableResource$SourceHandler \ No newline at end of file diff --git a/pitest-entry/src/test/java/org/pitest/mutationtest/build/intercept/staticinitializers/FunctionalInterfaceScannerTest.java b/pitest-entry/src/test/java/org/pitest/mutationtest/build/intercept/staticinitializers/FunctionalInterfaceScannerTest.java index 85b889a97..aef14f206 100644 --- a/pitest-entry/src/test/java/org/pitest/mutationtest/build/intercept/staticinitializers/FunctionalInterfaceScannerTest.java +++ b/pitest-entry/src/test/java/org/pitest/mutationtest/build/intercept/staticinitializers/FunctionalInterfaceScannerTest.java @@ -3,9 +3,6 @@ import org.junit.Test; import org.pitest.bytecode.analysis.ClassTree; import org.pitest.classinfo.ClassByteArraySource; -import org.pitest.classinfo.ClassHash; -import org.pitest.classinfo.ClassName; -import org.pitest.classpath.ClassPath; import org.pitest.classpath.ClassloaderByteArraySource; import org.pitest.classpath.CodeSource; import org.pitest.mutationtest.FixedCodeSource; @@ -13,9 +10,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.List; import java.util.function.Function; -import java.util.stream.Collectors; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; @@ -35,17 +30,23 @@ public void recognisesFunctionalInterfaces() { assertThat(underTest.apply(codeSourceFor(functional, not))).containsExactly("java/util/function/Function"); } - /* not a test + + /* @Test public void wholeClassPath() throws Exception { ClassPath cp = new ClassPath(); List classes = cp.classNames().stream() .map(n -> source.getBytes(n)) .map(b -> ClassTree.fromBytes(b.get())) + .filter(ClassTree::isInterface) .flatMap(t -> underTest.apply(codeSourceFor(t)).stream()) + .distinct() .collect(Collectors.toList()); + + System.out.println(classes.stream() + .collect(Collectors.joining("\n"))); } - */ +*/ /* // not a test and only works with java 9+