[jboss-user] [Javassist] - Any way to reload or rebuild a class with different methods/member data?

Mike Stoddart do-not-reply at jboss.com
Thu Feb 21 08:49:26 EST 2013


Mike Stoddart [https://community.jboss.org/people/stodge] created the discussion

"Any way to reload or rebuild a class with different methods/member data?"

To view the discussion, visit: https://community.jboss.org/message/798833#798833

--------------------------------------------------------------
I can successfully create class definitions at runtime using Javassist, but I also need the ability to rebuild the definitions to add/remove/change member data and their getters/setters. Is this at all possible? I'm using a custom class loader for the classes that I generate. I was hoping I could do something like this:

- create class definition in custom class pool ( http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/html/javassist/ClassPool.html#ClassPool(javassist.ClassPool) ClassPool( http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/html/javassist/ClassPool.html ClassPool parent))
- add to custom class loader

Then later:

- retrieve CtClass instance and detach it from the pool
- remove from custom class loader
- create new class definition with the same class path
- add to same custom class loader

Or alternatively:

- retrieve CtClass instance and detach it from the pool
- remove all fields and methods
- create new fields and methods

Is this at all possible? Thanks
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/798833#798833]

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/20130221/376fc5c2/attachment-0001.html 


More information about the jboss-user mailing list