0 Replies Latest reply on Feb 21, 2013 8:53 AM by Mike Stoddart

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

    Mike Stoddart Newbie

      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

       

      I should point out that no other classes reference or inherit this class. I simply store instances of this class in a hash map and list.

       

      Is this at all possible? Thanks