[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,6 +59,7 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.logging.LogFactory;
import org.jenkinsci.bytecode.Transformer;
import org.jvnet.hudson.reactor.Executable;
import org.jvnet.hudson.reactor.Reactor;
import org.jvnet.hudson.reactor.ReactorException;
@@ -151,6 +152,8 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
// and load plugin-contributed classes.
public final ClassLoader uberClassLoader = new UberClassLoader();
private final Transformer compatibilityTransformer = new Transformer();
/**
* Once plugin is uploaded, this flag becomes true.
* This is used to report a message that Jenkins needs to be restarted
@@ -179,6 +182,17 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
rootDir.mkdirs();
strategy = createPluginStrategy();
// load up rules for the core first
try {
compatibilityTransformer.loadRules(getClass().getClassLoader());
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to load compatibility rewrite rules",e);
}
}
public Transformer getCompatibilityTransformer() {
return compatibilityTransformer;
}
public Api getApi() {
@@ -301,6 +315,13 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas
}
});
// Let's see for a while until we open this functionality up to plugins
// g.followedBy().attains(PLUGINS_LISTED).add("Load compatibility rules", new Executable() {
// public void run(Reactor reactor) throws Exception {
// compatibilityTransformer.loadRules(uberClassLoader);
// }
// });
session.addAll(g.discoverTasks(session));
pluginListed = true; // technically speaking this is still too early, as at this point tasks are merely scheduled, not necessarily executed.