java.lang.reflect.InvocationTargetException gets thrown when bytecode instrumentation is finished with asm. -


i wanted instrument methods/classes in java. purpose wrote java agent instruments few classes choose.

i use following code loaded classes , filter of them:

 instrumentation.addtransformer(mytransformer,true);   class[] loadedclasses=instrumentation.getallloadedclasses();   class[] modifiableclasses=modifiableclasses(loadedclasses,instrumentation);  class[] filteredclasses=filterclasses(modifiableclasses);  if(instrumentation.isretransformclassessupported()){         system.out.println("retransformation supported");         instrumentation.retransformclasses(filteredclasses);      } 

this should not create problem filterclasses returns classes want instrumented want instrument these classes:

  • ljava/nio/buffer;
  • ljava/util/hashmap$entry;
  • ljava/nio/heapcharbuffer;
  • ljava/nio/charbuffer;
  • ljava/lang/classloader;
  • ljava/lang/class;
  • ljava/util/hashmap;
  • ljava/nio/bytebuffer;
  • ljava/lang/system;
  • ljava/io/bufferedwriter;
  • ljava/lang/string;
  • ljava/io/outputstreamwriter;
  • ljava/io/bufferedoutputstream;
  • ljava/nio/charset/coderresult;
  • ljava/io/writer;
  • ljava/util/hashset;
  • ljava/nio/charset/charsetencoder;
  • ljava/io/fileoutputstream;
  • ljava/io/printstream;

everything works fine print instrumented , unistrumented classes in specific folders debug. use asm coreapi add instructions @ beginning , end of methods dont instrument constructors,native methods, abstract methods , static variables. when instrument new classes being loaded works fine. guess dont understand classloader or specific here on console:

    exception in thread "main" java.lang.reflect.invocationtargetexception     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source)     @ java.lang.reflect.method.invoke(unknown source)     @ sun.instrument.instrumentationimpl.loadclassandstartagent(unknown source)     @ sun.instrument.instrumentationimpl.loadclassandcallpremain(unknown source)      caused by: java.lang.internalerror     @ sun.instrument.instrumentationimpl.retransformclasses0(native method)     @ sun.instrument.instrumentationimpl.retransformclasses(unknown source)     @ my.agent.watcher.premain(watcher.java:88)     ... 6 more     fatal error in native method: processing of -javaagent failed 

i thankful can link or hint in right direction.

sorry guys mistake after looking more precisely in instrumented classes found errors have solve, if want work. admin/mod can close thread .


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -