Last active
August 29, 2015 14:01
-
-
Save trask/d47133aef3b662b6548b to your computer and use it in GitHub Desktop.
ClassFileTransformer.transform() can be passed null protectionDomain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.instrument.Instrumentation; | |
public class Agent { | |
public static void premain(String agentArgs, Instrumentation instrumentation) { | |
instrumentation.addTransformer(new Transformer()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Premain-Class: Agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java/lang/invoke/MethodHandleImpl passed in with null protection domain | |
java/lang/invoke/MemberName$Factory passed in with null protection domain | |
java/lang/invoke/LambdaForm$NamedFunction passed in with null protection domain | |
java/lang/invoke/MethodType$ConcurrentWeakInternSet passed in with null protection domain | |
java/lang/invoke/MethodHandleStatics passed in with null protection domain | |
java/lang/invoke/MethodHandleStatics$1 passed in with null protection domain | |
java/lang/invoke/MethodTypeForm passed in with null protection domain | |
java/lang/invoke/Invokers passed in with null protection domain | |
java/lang/invoke/MethodType$ConcurrentWeakInternSet$WeakEntry passed in with null protection domain | |
java/lang/Void passed in with null protection domain | |
java/lang/IllegalAccessException passed in with null protection domain | |
sun/misc/PostVMInitHook passed in with null protection domain | |
java version "1.8.0_05" | |
Java(TM) SE Runtime Environment (build 1.8.0_05-b13) | |
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode) | |
java/lang/Shutdown passed in with null protection domain | |
java/lang/Shutdown$Lock passed in with null protection domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
javac Agent.java Transformer.java | |
jar cmf MANIFEST.MF agent.jar Agent.class Transformer.class | |
java -javaagent:agent.jar -version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.instrument.ClassFileTransformer; | |
import java.lang.instrument.IllegalClassFormatException; | |
import java.security.ProtectionDomain; | |
public class Transformer implements ClassFileTransformer { | |
@Override | |
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, | |
ProtectionDomain protectionDomain, byte[] classfileBuffer) | |
throws IllegalClassFormatException { | |
if (protectionDomain == null) { | |
System.out.println(className + " passed in with null protection domain"); | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment