Java, runtime class reloading -


i looking way reload class java @ runtime. motivation make debugging more efficient. application typical client/server design synchronously processes requests. "handler" object instantiated each request. class intend dynamically replace. since each request deals fresh instance, reloading class won't have side-effects. in short, not want restart entire application every time there change module.

in design, java process becomes aware .class file has been updated in classpath in between requests. when happens, "handler" class unloaded , new 1 loaded.

i know can use classloader interface load in new class. seem having trouble finding proper way of "unloading".

classes unloaded , garbage collected other object, if there no remaining reference them. means there must no reachable instance of class (as loaded particular classloader instance) , classloader instance must eligible garbage collection well.

so basically, have create new classloader instance load new version of class, , make sure no references instances of old version remain.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -