org.zeroturnaround.javarebel.integration.sap.SapSystemURLStreamHandlerFactoryCBP Maven / Gradle / Ivy
The newest version!
package org.zeroturnaround.javarebel.integration.sap;
import org.zeroturnaround.bundled.javassist.ClassPool;
import org.zeroturnaround.bundled.javassist.CtClass;
import org.zeroturnaround.bundled.javassist.CtMethod;
import org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor;
public class SapSystemURLStreamHandlerFactoryCBP extends
JavassistClassBytecodeProcessor {
public void process(ClassPool cp, ClassLoader cl, CtClass ctClass)
throws Exception {
cp.importPackage("java.util");
cp.importPackage("java.lang.ref");
cp.importPackage("java.lang");
CtMethod m = ctClass.getDeclaredMethod("loadClass");
m.setBody("{" +
"List wr = new ArrayList(weakReferences); " +
"for (Iterator i = wr.iterator(); i.hasNext(); ) {\n" +
" WeakReference ref = (WeakReference) i.next();\n" +
" ClassLoader loader = (ClassLoader)ref.get();\n" +
" if (loader == null) {\n" +
" weakReferences.remove(ref);\n" +
" } else {\n" +
" return loader.loadClass($1);\n" +
" }\n" +
" }" +
" return null;" +
"}");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy