# HG changeset patch # User Jie Kang # Date 1472496675 14400 # Node ID 95d4e43f484fc2ed7b292b68ebac75bc2af69d18 # Parent 189fa2a6b1f5f4c993027dd8f1b8b00978abb757 Use a bundled copy of asm for the profiler. Backport of: http://icedtea.classpath.org/hg/thermostat/rev/c0c30665da2c PR3154 Reviewed-by: omajid Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-August/020733.html diff -r 189fa2a6b1f5 -r 95d4e43f484f .hgignore --- a/.hgignore Mon Aug 29 14:50:28 2016 -0400 +++ b/.hgignore Mon Aug 29 14:51:15 2016 -0400 @@ -2,6 +2,9 @@ # standalone integration-test's shade plugin seems to generate this # pom. As it's derivable, hgignore it :) integration-tests/standalone/dependency-reduced-pom.xml +# vm-profiler's shade plugin seems to generate this +# pom. As it's derivable, hgignore it :) +vm-profiler/jvm-agent/dependency-reduced-pom.xml # Keyring autogenerated files keyring/Makefile.in diff -r 189fa2a6b1f5 -r 95d4e43f484f distribution/packaging/shared/man/thermostat.1 --- a/distribution/packaging/shared/man/thermostat.1 Mon Aug 29 14:50:28 2016 -0400 +++ b/distribution/packaging/shared/man/thermostat.1 Mon Aug 29 14:51:15 2016 -0400 @@ -55,7 +55,7 @@ available. --boot-delegation Boot delegation string passed on to the OSGi framework. Defaults to - "com.redhat.thermostat.vm.profiler.agent.jvm,org.objectweb.asm,org.objectweb.asm.commons" + "com.redhat.thermostat.vm.profiler.agent.jvm,com.redhat.thermostat.vm.profiler.agent.asm,com.redhat.thermostat.vm.profiler.agent.asm.commons" .SS "Command Options and Command Arguments" Please see diff -r 189fa2a6b1f5 -r 95d4e43f484f main/src/main/java/com/redhat/thermostat/main/impl/FrameworkOptions.java --- a/main/src/main/java/com/redhat/thermostat/main/impl/FrameworkOptions.java Mon Aug 29 14:50:28 2016 -0400 +++ b/main/src/main/java/com/redhat/thermostat/main/impl/FrameworkOptions.java Mon Aug 29 14:51:15 2016 -0400 @@ -122,8 +122,8 @@ // correctly by default globalOptions.put(Option.BOOT_DELEGATION, "com.redhat.thermostat.vm.profiler.agent.jvm," + - "org.objectweb.asm," + - "org.objectweb.asm.commons"); + "com.redhat.thermostat.vm.profiler.agent.asm," + + "com.redhat.thermostat.vm.profiler.agent.asm.commons"); } diff -r 189fa2a6b1f5 -r 95d4e43f484f vm-profiler/agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/internal/VmProfiler.java --- a/vm-profiler/agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/internal/VmProfiler.java Mon Aug 29 14:50:28 2016 -0400 +++ b/vm-profiler/agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/internal/VmProfiler.java Mon Aug 29 14:51:15 2016 -0400 @@ -87,7 +87,6 @@ private final RemoteProfilerCommunicator remote; private final String agentJarPath; - private final String asmJarPath; public VmProfiler(String agentId, Properties configuration, ProfileDAO dao, MXBeanConnectionPool pool) { this(agentId, configuration, dao, new SystemClock(), new ProfileUploaderCreator(), new RemoteProfilerCommunicator(pool)); @@ -104,7 +103,6 @@ // requireNonNull protects against bad config with missing values agentJarPath = Objects.requireNonNull(configuration.getProperty("AGENT_JAR")); - asmJarPath = Objects.requireNonNull(configuration.getProperty("ASM_JAR")); } public synchronized void vmStarted(String vmId, int pid) { @@ -142,7 +140,7 @@ } if (!vmsWithAgentLoaded.contains((Integer)pid)) { - String jarsToLoad = asmJarPath + ":" + agentJarPath; + String jarsToLoad = agentJarPath; logger.info("Asking " + pid + " to load agent '" + agentJarPath + "' with arguments '" + jarsToLoad + "'"); remote.loadAgentIntoPid(pid, agentJarPath, jarsToLoad); diff -r 189fa2a6b1f5 -r 95d4e43f484f vm-profiler/agent/src/main/resources/com/redhat/thermostat/vm/profiler/agent/internal/settings.properties --- a/vm-profiler/agent/src/main/resources/com/redhat/thermostat/vm/profiler/agent/internal/settings.properties Mon Aug 29 14:50:28 2016 -0400 +++ b/vm-profiler/agent/src/main/resources/com/redhat/thermostat/vm/profiler/agent/internal/settings.properties Mon Aug 29 14:51:15 2016 -0400 @@ -1,3 +1,2 @@ # These values are prefixed with thermostat home at run-time AGENT_JAR = plugins/vm-profiler/thermostat-vm-profiler-jvm-agent-${project.version}.jar -ASM_JAR = plugins/vm-profiler/asm-all-${asm.version}.jar diff -r 189fa2a6b1f5 -r 95d4e43f484f vm-profiler/agent/src/test/java/com/redhat/thermostat/vm/profiler/agent/internal/VmProfilerTest.java --- a/vm-profiler/agent/src/test/java/com/redhat/thermostat/vm/profiler/agent/internal/VmProfilerTest.java Mon Aug 29 14:50:28 2016 -0400 +++ b/vm-profiler/agent/src/test/java/com/redhat/thermostat/vm/profiler/agent/internal/VmProfilerTest.java Mon Aug 29 14:51:15 2016 -0400 @@ -66,7 +66,7 @@ private static final String AGENT_JAR = "foo"; private static final String ASM_JAR = "bar"; - private static final String AGENT_OPTIONS = ASM_JAR + ":" + AGENT_JAR; + private static final String AGENT_OPTIONS = AGENT_JAR; private static final long TIMESTAMP = 1_000_000_000; private VmProfiler profiler; diff -r 189fa2a6b1f5 -r 95d4e43f484f vm-profiler/distribution/pom.xml --- a/vm-profiler/distribution/pom.xml Mon Aug 29 14:50:28 2016 -0400 +++ b/vm-profiler/distribution/pom.xml Mon Aug 29 14:51:15 2016 -0400 @@ -117,11 +117,6 @@ thermostat-vm-profiler-jvm-agent ${project.version} - - org.ow2.asm - asm-all - ${asm.version} - diff -r 189fa2a6b1f5 -r 95d4e43f484f vm-profiler/jvm-agent/pom.xml --- a/vm-profiler/jvm-agent/pom.xml Mon Aug 29 14:50:28 2016 -0400 +++ b/vm-profiler/jvm-agent/pom.xml Mon Aug 29 14:51:15 2016 -0400 @@ -74,6 +74,31 @@ 1.6 + + org.apache.maven.plugins + maven-shade-plugin + + + + *:asm-all + + + + + org.objectweb.asm + com.redhat.thermostat.vm.profiler.agent.asm + + + + + + package + + shade + + + + @@ -89,15 +114,15 @@ test - org.ow2.asm - asm-all - ${asm.version} - - com.redhat.thermostat thermostat-annotations ${project.version} test + + org.ow2.asm + asm-all + ${asm.version} + diff -r 189fa2a6b1f5 -r 95d4e43f484f vm-profiler/jvm-agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/jvm/ProfilerAgent.java --- a/vm-profiler/jvm-agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/jvm/ProfilerAgent.java Mon Aug 29 14:50:28 2016 -0400 +++ b/vm-profiler/jvm-agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/jvm/ProfilerAgent.java Mon Aug 29 14:51:15 2016 -0400 @@ -75,6 +75,7 @@ } private static void addJarsToClassPath(String jars, Instrumentation instrumentation) throws AssertionError { + Debug.println("Boot-Classpath: " + System.getProperty("sun.boot.class.path")); Debug.println("Classpath: " + System.getProperty("java.class.path")); boolean addToBoot = true; String[] jarPaths = jars.split(":"); diff -r 189fa2a6b1f5 -r 95d4e43f484f vm-profiler/jvm-agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/jvm/ProfilerInstrumentor.java --- a/vm-profiler/jvm-agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/jvm/ProfilerInstrumentor.java Mon Aug 29 14:50:28 2016 -0400 +++ b/vm-profiler/jvm-agent/src/main/java/com/redhat/thermostat/vm/profiler/agent/jvm/ProfilerInstrumentor.java Mon Aug 29 14:51:15 2016 -0400 @@ -57,9 +57,8 @@ // this class ignorePackageRegexps.add(Pattern.compile("com\\.redhat\\.thermostat\\.vm\\.profiler\\.agent\\.jvm\\..*")); - - // our dependencies - ignorePackageRegexps.add(Pattern.compile("org\\.objectweb\\.asm\\..*")); + // our dependencies: shaded asm + ignorePackageRegexps.add(Pattern.compile("com\\.redhat\\.thermostat\\.vm\\.profiler\\.agent\\.asm\\..*")); } @Override @@ -68,6 +67,12 @@ ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { + if (!loader.equals(classBeingRedefined.getClassLoader())) { + String message = "ERROR: classloader " + loader + " didn't load " + className; + Debug.println(message); + throw new AssertionError(message); + } + className = className.replace('/', '.'); if (!shouldInstrument(className)) { return null;