Skip to content

Commit

Permalink
Merge pull request #1350 from hcoles/feature/transformation_plugin_ba…
Browse files Browse the repository at this point in the history
…ckwards_compat

api backwards compatibility
hcoles authored Sep 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 0df4d1a + bb80c00 commit ff524db
Showing 4 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
@@ -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);
}
}
}

Original file line number Diff line number Diff line change
@@ -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
@@ -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;
@@ -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);
}
}
}

Original file line number Diff line number Diff line change
@@ -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."),

0 comments on commit ff524db

Please sign in to comment.