Navgeet Agrawal [
https://community.jboss.org/people/navgeet] created the discussion
"IllegalAccessError when using an instrumented class"
To view the discussion, visit:
https://community.jboss.org/message/824470#824470
--------------------------------------------------------------
Hi all,
I am trying to instrument
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compi...
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compi...
I am using the following code:
ClassPool cp = ClassPool.getDefault();
CtClass ctClazz = cp.get("clojure.lang.Compiler");
ctClazz.addMethod(CtNewMethod.make("public String foo (){return \"foo\";
}", ctClazz));
return ctClazz.toClass();
I am calling getDeclaredMethod on the returned class and invoke on the method to call
foo() which throws:
IllegalAccessError tried to access class clojure.lang.Compiler$DefExpr$Parser from class
clojure.lang.Compiler clojure.lang.Compiler.<clinit>
(Compiler.java:102)
Javassist's docs state that it does not work with inner classes, which I suspect to be
the problem here.
Or rather it could be a ClassLoader problem. Unfortunately I know little about
classloaders.
Any pointers would be appreciated.
Thanks!
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/824470#824470]
Start a new discussion in Javassist at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]