JBoss Community

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

created by Mike Stoddart in Javassist - View the full discussion

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 (ClassPool(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

Start a new discussion in Javassist at Community