How to make Java agent and reflection work together? -


i have project (https://github.com/zhihan/janala2-gradle) uses java-agent online instrumentation. tried have annotation class runtime reflection. program crashes noclassdeffounderror

exception in thread "main" java.lang.noclassdeffounderror: janala/logger/djvm @ com.sun.proxy.$proxy0.<clinit>(unknown source) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:62) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:408) @ java.lang.reflect.proxy.newproxyinstance(proxy.java:739) @ sun.reflect.annotation.annotationparser$1.run(annotationparser.java:305) @ sun.reflect.annotation.annotationparser$1.run(annotationparser.java:303) @ java.security.accesscontroller.doprivileged(native method) @ sun.reflect.annotation.annotationparser.annotationformap(annotationparser.java:303) @ sun.reflect.annotation.annotationparser.parseannotation2(annotationparser.java:293) @ sun.reflect.annotation.annotationparser.parseannotations2(annotationparser.java:120) @ sun.reflect.annotation.annotationparser.parseselectannotations(annotationparser.java:101) @ sun.reflect.annotation.annotationtype.<init>(annotationtype.java:139) @ sun.reflect.annotation.annotationtype.getinstance(annotationtype.java:85) @ sun.reflect.annotation.annotationparser.parseannotation2(annotationparser.java:266) @ sun.reflect.annotation.annotationparser.parseannotations2(annotationparser.java:120) @ sun.reflect.annotation.annotationparser.parseannotations(annotationparser.java:72) @ java.lang.reflect.executable.declaredannotations(executable.java:546) @ java.lang.reflect.executable.getannotation(executable.java:520) @ java.lang.reflect.method.getannotation(method.java:607) @ janala.utils.classrunner.run(classrunner.java:20) @ janala.utils.classrunner.main(classrunner.java:33) 

the call site of error simply

test annotation = method.getannotation(test.class); 

if change program first instrument class, write instrumented class .class file , run program same classpath. runs fine.

the annotation declared as

public class annotations {     /**    * catg test.    */   @retention(retentionpolicy.runtime)   @target(elementtype.method)   public @interface test {} } 

and use of annotation like

  @test   public void testand() { 

well, turns out reason in stack trace

at com.sun.proxy.$proxy0.<clinit>(unknown source) 

the proxy class automatically generated jvm part of reflection support. , instrumenter default instrument everything. filtering package solves problem.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -