Skip to content

Commit

Permalink
api backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
hcoles committed Sep 16, 2024
1 parent 0df4d1a commit bb80c00
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.lang.instrument.ClassFileTransformer;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -123,7 +124,10 @@ public static void main(final String[] args) {
private static void enableTransformations() {
ClientPluginServices plugins = ClientPluginServices.makeForContextLoader();
for (TransformationPlugin each : plugins.findTransformations()) {
HotSwapAgent.addTransformer(each.makeCoverageTransformer());
ClassFileTransformer transformer = each.makeCoverageTransformer();
if (transformer != null) {
HotSwapAgent.addTransformer(transformer);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@
import java.lang.instrument.ClassFileTransformer;

public interface TransformationPlugin extends ClientClasspathPlugin {
ClassFileTransformer makeCoverageTransformer();
ClassFileTransformer makeMutationTransformer();

@Deprecated
default ClassFileTransformer makeTransformer() {
return makeMutationTransformer();
}

default ClassFileTransformer makeCoverageTransformer() {
return null;
}

default ClassFileTransformer makeMutationTransformer() {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import javax.management.NotificationListener;
import javax.management.openmbean.CompositeData;
import java.io.IOException;
import java.lang.instrument.ClassFileTransformer;
import java.lang.management.MemoryNotificationInfo;
import java.net.Socket;
import java.util.Collection;
Expand Down Expand Up @@ -169,7 +170,10 @@ private static List<TestUnit> findTestsForTestClasses(
private static void enableTransformations() {
ClientPluginServices plugins = ClientPluginServices.makeForContextLoader();
for (TransformationPlugin each : plugins.findTransformations()) {
HotSwapAgent.addTransformer(each.makeMutationTransformer());
ClassFileTransformer transformer = each.makeMutationTransformer();
if (transformer != null) {
HotSwapAgent.addTransformer(transformer);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ private static InputStream returnNormalBytes(final Object classPath,
// so the best we can do is exclude pitest itself and some common classes.
private static Predicate<String> excluded() {
return Prelude.or(
startsWith("org.objenesis."),
startsWith("net.bytebuddy."),
startsWith("javassist."),
startsWith("org.pitest."),
startsWith("com.groupcdg."),
startsWith("com.arcmutate."),
startsWith("java."),
startsWith("javax."),
startsWith("com.sun."),
Expand Down

0 comments on commit bb80c00

Please sign in to comment.