Class ClassLoaderDefineClassPatcher
- java.lang.Object
-
- org.hotswap.agent.util.classloader.ClassLoaderDefineClassPatcher
-
public class ClassLoaderDefineClassPatcher extends Object
Classloader patch which will redefine each patch via Javassist in the target classloader. Note that the class will typically be already accessible by parent classloader, but if it is loaded from parent classloader, it does not have access to other child classloader classes. Redefine will work only if the class was not loaded by the child classloader. This may not be used for Plugin class itself, because some target library classes may be enhanced by plugin reference (e.g. to set some initialized property). Although the class resides in parent classloader it cannot be redefined in child classloader with other definition - the classloader already knows about this class. This is the reason, why plugin class cannot be executed in child classloader.- Author:
- Jiri Bubnik
-
-
Constructor Summary
Constructors Constructor Description ClassLoaderDefineClassPatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisPatchAvailable(ClassLoader classLoader)Check if the classloader can be patched.voidpatch(ClassLoader classLoaderFrom, String pluginPath, ClassLoader classLoaderTo, ProtectionDomain protectionDomain)Patch the classloader.
-
-
-
Method Detail
-
patch
public void patch(ClassLoader classLoaderFrom, String pluginPath, ClassLoader classLoaderTo, ProtectionDomain protectionDomain)
Patch the classloader.- Parameters:
classLoaderFrom- classloader to load classes frompluginPath- path to copyclassLoaderTo- classloader to copy classes toprotectionDomain- required protection in target classloader
-
isPatchAvailable
public boolean isPatchAvailable(ClassLoader classLoader)
Check if the classloader can be patched. Typically skip synthetic classloaders.- Parameters:
classLoader- classloader to check- Returns:
- if true, call patch()
-
-