Skip to content

Commit 1a3e079

Browse files
authored
Merge pull request #1407 from hcoles/feature/classloader_logging
Feature/classloader logging
2 parents 12a41f4 + 30217d5 commit 1a3e079

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: 'Checkout from Git'
2626
uses: actions/checkout@v3
2727
- name: 'Set up JDK ${{ matrix.java }}'
28-
uses: actions/setup-java@v3
28+
uses: actions/setup-java@v4
2929
with:
3030
java-version: ${{ matrix.java }}
3131
distribution: adopt

pitest/src/main/java/org/pitest/mutationtest/execute/CatchNewClassLoadersTransformer.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import org.pitest.boot.HotSwapAgent;
44
import org.pitest.classinfo.ClassName;
5+
import org.pitest.util.Log;
56

67
import java.lang.instrument.ClassFileTransformer;
78
import java.security.ProtectionDomain;
89
import java.util.Collections;
910
import java.util.Map;
1011
import java.util.WeakHashMap;
12+
import java.util.logging.Logger;
1113

1214
/**
1315
* Pitest mainly inserts mutants by calling Instrumentation.redefineClasses using
@@ -28,6 +30,8 @@
2830
*/
2931
public class CatchNewClassLoadersTransformer implements ClassFileTransformer {
3032

33+
private static final Logger LOG = Log.getLogger();
34+
3135
private static String targetClass;
3236
private static byte[] currentMutant;
3337

@@ -38,6 +42,9 @@ public class CatchNewClassLoadersTransformer implements ClassFileTransformer {
3842
public static synchronized void setMutant(String className, byte[] mutant) {
3943
targetClass = className;
4044
currentMutant = mutant;
45+
46+
logClassloaders();
47+
4148
for (ClassLoader each : CLASS_LOADERS.keySet()) {
4249
final Class<?> clazz = checkClassForLoader(each, className);
4350
if (clazz != null) {
@@ -83,4 +90,10 @@ private boolean shouldTransform(ClassLoader loader) {
8390
return !loader.getClass().getName().startsWith("com.google.gwtmockito.");
8491
}
8592

93+
private static void logClassloaders() {
94+
if (CLASS_LOADERS.size() > 1) {
95+
LOG.fine("Accumulated " + CLASS_LOADERS.size() + " classloaders");
96+
}
97+
}
98+
8699
}

pom.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
</property>
100100
</activation>
101101
<modules>
102-
<module>pitest-maven-verification</module>
102+
<module>pitest-maven-verification</module>
103103
</modules>
104104
</profile>
105105
<profile>
@@ -404,4 +404,11 @@
404404
</plugins>
405405
</build>
406406

407+
<distributionManagement>
408+
<snapshotRepository>
409+
<id>central</id>
410+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
411+
</snapshotRepository>
412+
</distributionManagement>
413+
407414
</project>

0 commit comments

Comments
 (0)