[FIXED JENKINS-18677]

Integrated bytecode-compatibility-transformer that allows core to
do signature changes on properties that plugins might depend on.

The library performs necessary bytecode transformation to achieve this.

The first use of this is to fix plugins that looks for List
AbstractProject.triggers, thereby resolving JENKINS-18677.

For the time being, I'm not loading such compatibility annotations from
plugins, but I did code that in PluginManager. Let's see how this
feature work out for a while in the core, and if it looks stable and
solid, we'll open it up to plugins at that point.
This commit is contained in:
Kohsuke Kawaguchi committed 2013-08-02 22:29:21 -07:00
1 parent e7b9143067
commit 47de54d070
6 files changed
+46 -16

No files matched your search

@@ -59,7 +59,6 @@ import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -223,19 +222,10 @@ public class ClassicPluginStrategy implements PluginStrategy {
return classLoader;
}
}
if(useAntClassLoader && !Closeable.class.isAssignableFrom(URLClassLoader.class)) {
// using AntClassLoader with Closeable so that we can predictably release jar files opened by URLClassLoader
AntClassLoader2 classLoader = new AntClassLoader2(parent);
classLoader.addPathFiles(paths);
return classLoader;
} else {
// Tom reported that AntClassLoader has a performance issue when Hudson keeps trying to load a class that doesn't exist,
// so providing a legacy URLClassLoader support, too
List<URL> urls = new ArrayList<URL>();
for (File path : paths)
urls.add(path.toURI().toURL());
return new URLClassLoader(urls.toArray(new URL[urls.size()]),parent);
}
AntClassLoader2 classLoader = new AntClassLoader2(parent);
classLoader.addPathFiles(paths);
return classLoader;
}
/**
@@ -652,7 +642,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
* {@link AntClassLoader} with a few methods exposed and {@link Closeable} support.
* Deprecated as of Java 7, retained only for Java 5/6.
*/
private static final class AntClassLoader2 extends AntClassLoader implements Closeable {
private final class AntClassLoader2 extends AntClassLoader implements Closeable {
private final Vector pathComponents;
private AntClassLoader2(ClassLoader parent) {
@@ -669,6 +659,7 @@ public class ClassicPluginStrategy implements PluginStrategy {
}
}
public void addPathFiles(Collection<File> paths) throws IOException {
for (File f : paths)
addPathFile(f);
@@ -699,6 +690,11 @@ public class ClassicPluginStrategy implements PluginStrategy {
return url;
}
@Override
protected Class defineClassFromData(File container, byte[] classData, String classname) throws IOException {
return super.defineClassFromData(container, pluginManager.getCompatibilityTransformer().transform(classname,classData), classname);
}
}
public static boolean useAntClassLoader = Boolean.getBoolean(ClassicPluginStrategy.class.getName()+".useAntClassLoader");