All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zeroturnaround.javarebel.integration.confluence.JarClassLoaderCBP Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package org.zeroturnaround.javarebel.integration.confluence;

import org.zeroturnaround.bundled.javassist.ClassPool;
import org.zeroturnaround.bundled.javassist.CtClass;
import org.zeroturnaround.bundled.javassist.CtConstructor;
import org.zeroturnaround.bundled.javassist.CtMethod;
import org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor;

public class JarClassLoaderCBP extends
    JavassistClassBytecodeProcessor {
  
  public void process(ClassPool cp, ClassLoader cl, CtClass ctClass) throws Exception {
    CtConstructor[] constructors = ctClass.getConstructors();
    for (int i = 0; i < constructors.length; i++) {
      CtConstructor constructor = constructors[i];
      constructor.insertAfter(
          "org.zeroturnaround.javarebel.IntegrationFactory.getInstance()" +
          "  .registerClassLoader($0, " +
          "    new org.zeroturnaround.javarebel.integration.jira.JiraClassResourceSource($0));");
    }
    
    CtMethod m = ctClass.getMethod("findClass", "(Ljava/lang/String;)Ljava/lang/Class;");
    m.insertBefore(
        "{   synchronized ($0) {" + 
        "      Class result =" + 
        "        findLoadedClass($1);" + 
        "      if (result != null)" + 
        "        return result;" + 
        "      result = " + 
        "        org.zeroturnaround.javarebel.IntegrationFactory.getInstance()" + 
        "          .findReloadableClass($0, $1);" + 
        "      if (result != null)" + 
        "        return result;" + 
        "    }}");
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy