use of org.hotswap.agent.javassist.ClassPool 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.ClassPool in project HotswapAgent by HotswapProjects.
the class ProxyTransformationUtils method getClassPool.
/**
* Creates one ClassPool per ClassLoader and caches it
*
* @param classLoader
* @return
*/
public static ClassPool getClassPool(ClassLoader classLoader) {
ClassPool classPool = classPoolMap.get(classLoader);
if (classPool == null) {
synchronized (classPoolMap) {
classPool = classPoolMap.get(classLoader);
if (classPool == null) {
classPool = createClassPool(classLoader);
classPoolMap.put(classLoader, classPool);
}
}
}
return classPool;
}
use of org.hotswap.agent.javassist.ClassPool 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.ClassPool in project HotswapAgent by HotswapProjects.
the class Analyzer method buildExceptionInfo.
private ExceptionInfo[] buildExceptionInfo(MethodInfo method) {
ConstPool constPool = method.getConstPool();
ClassPool classes = clazz.getClassPool();
ExceptionTable table = method.getCodeAttribute().getExceptionTable();
ExceptionInfo[] exceptions = new ExceptionInfo[table.size()];
for (int i = 0; i < table.size(); i++) {
int index = table.catchType(i);
Type type;
try {
type = index == 0 ? Type.THROWABLE : Type.get(classes.get(constPool.getClassInfo(index)));
} catch (NotFoundException e) {
throw new IllegalStateException(e.getMessage());
}
exceptions[i] = new ExceptionInfo(table.startPc(i), table.endPc(i), table.handlerPc(i), type);
}
return exceptions;
}
use of org.hotswap.agent.javassist.ClassPool 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)));
}
Aggregations