Package org.hotswap.agent.javassist

Examples of org.hotswap.agent.javassist.ClassPool.appendClassPath()


    public AnonymousClassInfo getAnonymousCtClassInfo() throws NotFoundException, ClassNotFoundException, IOException, CannotCompileException {
        Class clazz = getClass().getClassLoader().loadClass(AnonymousTestClass1.class.getName() + "$1");

        ClassPool classPool = new ClassPool();
        classPool.appendClassPath(new LoaderClassPath(getClass().getClassLoader()));
        return new AnonymousClassInfo(classPool.get(clazz.getName()));
    }
}
View Full Code Here


     * @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)));
    }
}
View Full Code Here

     * @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());
    }
View Full Code Here

     * @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());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.