use of org.hotswap.agent.javassist.LoaderClassPath in project HotswapAgent by HotswapProjects.
the class EnhancerProxyCreater method getCp.
private ClassPool getCp(ClassLoader loader) {
ClassPool cp = new ClassPool();
cp.appendSystemPath();
cp.appendClassPath(new LoaderClassPath(loader));
return cp;
}
use of org.hotswap.agent.javassist.LoaderClassPath in project HotswapAgent by HotswapProjects.
the class ProxyTransformationUtils method createClassPool.
/**
* Creates a ClassPool with supplied ClassLoader
*
* @param classLoader
* @return
*/
public static ClassPool createClassPool(final ClassLoader classLoader) {
ClassPool cp = new ClassPool() {
@Override
public ClassLoader getClassLoader() {
return classLoader;
}
};
cp.appendSystemPath();
if (classLoader != null) {
LOGGER.trace("Adding loader classpath " + classLoader);
cp.appendClassPath(new LoaderClassPath(classLoader));
}
return cp;
}
use of org.hotswap.agent.javassist.LoaderClassPath in project HotswapAgent by HotswapProjects.
the class WatchEventCommand method createCtClass.
/**
* Creats javaassist CtClass for bytecode manipulation. Add default classloader.
*
* @param uri uri
* @param classLoader loader
* @return created class
* @throws org.hotswap.agent.javassist.NotFoundException
*/
private CtClass createCtClass(URI uri, ClassLoader classLoader) throws NotFoundException, IOException {
ClassPool cp = new ClassPool();
cp.appendClassPath(new LoaderClassPath(classLoader));
return cp.makeClass(new ByteArrayInputStream(IOUtils.toByteArray(uri)));
}
use of org.hotswap.agent.javassist.LoaderClassPath in project HotswapAgent by HotswapProjects.
the class HotSwapperJpda method swapClasses.
/**
* Swap class definition from another class file.
* <p/>
* This is mainly useful for unit testing - declare multiple version of a class and then
* hotswap definition and do the tests.
*
* @param original original class currently in use
* @param swap fully qualified class name of class to swap
* @throws Exception swap exception
*/
public void swapClasses(Class original, String swap) throws Exception {
// need to recreate classpool on each swap to avoid stale class definition
ClassPool classPool = new ClassPool();
classPool.appendClassPath(new LoaderClassPath(original.getClassLoader()));
CtClass ctClass = classPool.getAndRename(swap, original.getName());
reload(original.getName(), ctClass.toBytecode());
}
use of org.hotswap.agent.javassist.LoaderClassPath in project HotswapAgent by HotswapProjects.
the class HotSwapper method swapClasses.
/**
* Swap class definition from another class file.
* <p/>
* This is mainly useful for unit testing - declare multiple version of a class and then
* hotswap definition and do the tests.
*
* @param original original class currently in use
* @param swap fully qualified class name of class to swap
* @throws Exception swap exception
*/
public static void swapClasses(Class original, String swap) throws Exception {
// need to recreate classpool on each swap to avoid stale class definition
ClassPool classPool = new ClassPool();
classPool.appendClassPath(new LoaderClassPath(original.getClassLoader()));
CtClass ctClass = classPool.getAndRename(swap, original.getName());
reload(original, ctClass.toBytecode());
}
Aggregations