Skip to content

Commit

Permalink
disable functional interface scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
hcoles committed Aug 30, 2024
1 parent 376d386 commit b374736
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.pitest.mutationtest.build.intercept.staticinitializers;

import org.pitest.classpath.CodeSource;
import org.pitest.mutationtest.build.InterceptorParameters;
import org.pitest.mutationtest.build.MutationInterceptor;
import org.pitest.mutationtest.build.MutationInterceptorFactory;
Expand All @@ -11,29 +10,17 @@
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function;

public class StaticInitializerInterceptorFactory implements MutationInterceptorFactory {

private final Function<CodeSource, Set<String>> delayedExecutionTypes;

public StaticInitializerInterceptorFactory() {
this(new FunctionalInterfaceScanner());
}

public StaticInitializerInterceptorFactory(Function<CodeSource, Set<String>> delayedExecutionTypes) {
this.delayedExecutionTypes = delayedExecutionTypes.andThen(this::functionalInterfaces);
}

@Override
public String description() {
return "Static initializer code detector plugin";
}

@Override
public MutationInterceptor createInterceptor(InterceptorParameters params) {
Set<String> types = delayedExecutionTypes.apply(params.code());
return new StaticInitializerInterceptor(types);
return new StaticInitializerInterceptor(functionalInterfaces());
}

@Override
Expand All @@ -43,8 +30,8 @@ public Feature provides() {
.withDescription("Filters mutations in static initializers and code called only from them");
}

private Set<String> functionalInterfaces(Set<String> existing) {
Set<String> classes = new HashSet<>(existing);
private Set<String> functionalInterfaces() {
Set<String> classes = new HashSet<>();
try (BufferedReader r = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("/functional_interfaces.txt")))) {
String line = r.readLine();
while (line != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.example.staticinitializers.delayedexecution.StaticListOfUnannotatedInterfaces;
import com.example.staticinitializers.delayedexecution.StaticSupplierField;
import com.example.staticinitializers.ThirdLevelPrivateMethods;
import org.junit.Ignore;
import org.junit.Test;
import org.pitest.mutationtest.FixedCodeSource;
import org.pitest.mutationtest.engine.MutationDetails;
Expand Down Expand Up @@ -268,6 +269,7 @@ public void mutatesMethodsStoredInStaticListOfFunctions() {
}

@Test
@Ignore("functionality disabled, may get re-introduced")
public void recognisesCustomFunctionalInterfaces() {
v.forClass(StaticListOfFunctionalInterface.class)
.forMethod("canMutate")
Expand Down

0 comments on commit b374736

Please sign in to comment.