diff --git a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/CoverageTransformer.java b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/CoverageTransformer.java index 6401898..1fe2629 100644 --- a/org.jacoco.agent.rt/src/org/jacoco/agent/rt/CoverageTransformer.java +++ b/org.jacoco.agent.rt/src/org/jacoco/agent/rt/CoverageTransformer.java @@ -47,6 +47,16 @@ public class CoverageTransformer implements ClassFileTransformer { private final WildcardMatcher exclClassloader; private final ClassFileDumper classFileDumper; + + private boolean coverXboot; + +public void setCoverXboot(boolean b){ +coverXboot=b; +} + +public boolean getCoverXboot(){ +return coverXboot; +} /** * New transformer with the given delegates. @@ -68,6 +78,7 @@ public class CoverageTransformer implements ClassFileTransformer { excludes = new WildcardMatcher(toVMName(options.getExcludes())); exclClassloader = new WildcardMatcher(options.getExclClassloader()); classFileDumper = new ClassFileDumper(options.getClassDumpDir()); + setCoverXboot(options.getXboot()); } public byte[] transform(final ClassLoader loader, final String classname, @@ -107,6 +118,32 @@ public class CoverageTransformer implements ClassFileTransformer { * @return true if the class should be instrumented */ protected boolean filter(final ClassLoader loader, final String classname) { + if (getCoverXboot()){ + boolean a=true; + /*if (classname.contains("jacoco")) { + a=false; + } + if (classname.contains("lang")) { + a=false; + } + + if (classname.contains("java") && classname.contains("util")) { + a=false; + } + */ + a= + // loader != null && + + //!classname.startsWith(AGENT_PREFIX) && + + //!exclClassloader.matches(loader.getClass().getName()) && + + includes.matches(classname) && + + !excludes.matches(classname); + + return a; + }else{ // Don't instrument classes of the bootstrap loader: return loader != null && @@ -117,6 +154,7 @@ public class CoverageTransformer implements ClassFileTransformer { includes.matches(classname) && !excludes.matches(classname); +} } private static String toVMName(final String srcName) { diff --git a/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java b/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java index b3744f6..252f763 100644 --- a/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java +++ b/org.jacoco.core/src/org/jacoco/core/runtime/AgentOptions.java @@ -30,6 +30,12 @@ import java.util.Map; public final class AgentOptions { /** + * default is false, if true, then also bootclasspath is included + * This needs havy includes/excludes tuning, so use with caution + */ + public static final String XBOOT = "xboot"; + + /** * Specifies the output file for execution data. Default is * jacoco.exec in the working directory. */ @@ -157,7 +163,7 @@ public final class AgentOptions { private static final Collection VALID_OPTIONS = Arrays.asList( DESTFILE, APPEND, INCLUDES, EXCLUDES, EXCLCLASSLOADER, SESSIONID, - DUMPONEXIT, OUTPUT, ADDRESS, PORT, CLASSDUMPDIR); + DUMPONEXIT, OUTPUT, ADDRESS, PORT, CLASSDUMPDIR, XBOOT); private final Map options; @@ -329,6 +335,26 @@ public final class AgentOptions { } /** + * Returns whether coverage data should calcualted with bootclasspath + * + * @return true if coverage data will be calcualted also from boot classpath + */ + public boolean getXboot() { + return getOption(XBOOT, false); + } + + /** + * Sets whether coverage data should be calcualted also from bootclassapth + * + * @param xboot + * true if coverage data should calcualted also + * from bootclasspath + */ + public void setXboot(final boolean xboot) { + setOption(XBOOT, xboot); + } + + /** * Returns whether coverage data should be dumped on exit * * @return true if coverage data will be written on VM exit