Search code examples
javajakarta-eejavabeans

How to dynamically add properties to class


I am developing framework for our products. I would like to add dynamically properties to a class. So if any of you have any sort of experience, kindly help me out.

Any of your suggestions are welcome.


Solution

  • I believe what you are asking for is not the right option here. Although in theory you can modify the byte code of your program to add a property dynamically as you describe, it is not a good idea at all.

    I suggest you use a HashMap that maps a property name to its value and interactively modify that map.