[jboss-user] [Javassist] - IllegalAccessError when using an instrumented class
Navgeet Agrawal
do-not-reply at jboss.com
Sun Jun 23 16:14:11 EDT 2013
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/Compiler.java https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java
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&containerType=14&container=2062]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130623/0fa71b66/attachment.html
More information about the jboss-user
mailing list