Created
April 2, 2016 12:27
-
-
Save heipacker/4be207245fc34938891966083d773c3c to your computer and use it in GitHub Desktop.
addCode
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
private static void addCode(Instrumentation instrumentation) { | |
Class[] allLoadedClasses = instrumentation.getAllLoadedClasses(); | |
System.out.println("all load classes length:" + allLoadedClasses.length); | |
System.out.println("object size:" + instrumentation.getObjectSize(new Object())); | |
instrumentation.addTransformer(new ClassFileTransformer() { | |
@Override | |
public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws IllegalClassFormatException { | |
if (classBeingRedefined != null) return null; | |
System.out.println("class transform " + className); | |
return classfileBuffer; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment