1 5 package org.exoplatform.container.monitor.jvm.v15; 6 7 import java.lang.instrument.ClassFileTransformer ; 8 import java.lang.instrument.IllegalClassFormatException ; 9 import java.lang.instrument.Instrumentation ; 10 17 public class ExoInstrument { 18 static private Instrumentation ins_ ; 19 20 public static void main(String args[] ) { 21 System.out.println("Hello World" ); 22 } 23 24 public static void premain(String options, Instrumentation ins) { 25 ins_ = ins ; 27 System.out.println("==========================> call premain") ; 28 } 29 30 public static Instrumentation getInstrumentation() { return ins_ ; } 31 32 public void printObjectSize(Object object) { 33 System.out.println("size of " + object.getClass().getName() + " = "+ ins_.getObjectSize(object)) ; 34 } 35 36 37 public static class Logger implements ClassFileTransformer { 38 public byte[] transform(java.lang.ClassLoader loader, 39 java.lang.String className, 40 java.lang.Class classBeingRedefined, 41 java.security.ProtectionDomain protectionDomain, 42 byte[] classfileBuffer) throws IllegalClassFormatException { 43 System.out.println(className ); 44 return null; 45 } 46 } 47 } | Popular Tags |