Modify field in class during runtime - java -


my question is, possible inject properties or methods "classloaded" class. noticed, in java not simple add properties dynamically , says should use map (add property object dynamicly).

is there better , "cleaner" way change class during runtime. read asm, not know if visitor pattern, use asm, optimal way work with.

in case asm best thing handle problem, there documentation beside 1 provided on asm website (http://download.forge.objectweb.org/asm/asm4-guide.pdf)

once class has been loaded jvm, not possible modify it.

your best bet modify class, load fresh copy ... in different classloader. end 2 versions of class (with different runtime types!). instances of first version of class not have new fields, methods etcetera.

my advice ... don't it. think of way implement trying here. or if modifying classes on fly fundamental application, consider using more dynamic language.


Comments

Popular posts from this blog

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -