Hi! I'm currently trying to perform some bytecode modifications on a class while 
loading this class in the JVM:

Usually, Javassist users are likely to inject source code into a CtClass but my 
concern is to inject code from a compiled class A into compiled class B. Plus I'd like 
to do so while loading Class B into the JVM (Class A doesn't require to be loaded into 
the JVM) through a ClassLoader of mine.

My first idea was to modify the findClass(..) method of my ClassLoader: I would 
intercept the moment class B is loaded and I could get its methods as CtMethods...Then 
I would use the Javassist Bytecode level API to obtain a ClassFile describing Class A. 
Thus I could use a CodeIterator to get some compiled code from Class A to finally 
inject it into some CtMethods of Class B. Eventually Class B would be loaded into the 
JVM and would behave with some code that belonged to A.

Unfortunately I don't know how to inject the byte[] obtained from Class A bytecode 
into any CtMethod of Class B. Maybe we just can't?!

I would really appreciate if you could tell me how to do such a thing and/or showing a 
piece of code would be great. If my approach is wrong, could you tell me how to proceed

Thank you very much!

-Fabien

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3837989#3837989

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3837989


-------------------------------------------------------
This SF.Net email is sponsored by: GNOME Foundation
Hackers Unite!  GUADEC: The world's #1 Open Source Desktop Event.
GNOME Users and Developers European Conference, 28-30th June in Norway
http://2004/guadec.org
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to