From c16562edec969456416064491753941f26e968fa Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Mon, 24 May 2021 19:37:08 -0700 Subject: [PATCH 1/2] Remove Bytecode Compatibility Transformer --- bom/pom.xml | 5 ----- core/pom.xml | 4 ---- .../java/hudson/ClassicPluginStrategy.java | 7 +------ core/src/main/java/hudson/PluginManager.java | 21 ------------------- .../java/hudson/model/AbstractProject.java | 2 -- core/src/main/java/hudson/model/Queue.java | 2 -- 6 files changed, 1 insertion(+), 40 deletions(-) diff --git a/bom/pom.xml b/bom/pom.xml index 3ab1a2bde827..abebfd16bda3 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -208,11 +208,6 @@ THE SOFTWARE. args4j 2.33 - - org.jenkins-ci - bytecode-compatibility-transformer - 2.0-beta-2 - org.jenkins-ci task-reactor diff --git a/core/pom.xml b/core/pom.xml index f27f335ff9fc..29d294b9be3f 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -208,10 +208,6 @@ THE SOFTWARE. org.jenkins-ci annotation-indexer - - org.jenkins-ci - bytecode-compatibility-transformer - org.jenkins-ci task-reactor diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index 5b584e5de774..ab756c6e6098 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -52,7 +52,6 @@ import org.apache.tools.zip.ZipEntry; import org.apache.tools.zip.ZipExtraField; import org.apache.tools.zip.ZipOutputStream; -import org.jenkinsci.bytecode.Transformer; import edu.umd.cs.findbugs.annotations.NonNull; import java.io.Closeable; @@ -709,7 +708,7 @@ protected URL findResource(String name) { } /** - * {@link AntClassLoader} with a few methods exposed, {@link Closeable} support, and {@link Transformer} support. + * {@link AntClassLoader} with a few methods exposed and {@link Closeable} support. */ private final class AntClassLoader2 extends AntWithFindResourceClassLoader implements Closeable { private AntClassLoader2(ClassLoader parent) { @@ -718,8 +717,6 @@ private AntClassLoader2(ClassLoader parent) { @Override protected Class defineClassFromData(File container, byte[] classData, String classname) throws IOException { - if (!DISABLE_TRANSFORMER) - classData = pluginManager.getCompatibilityTransformer().transform(classname, classData, this); return super.defineClassFromData(container, classData, classname); } } @@ -727,6 +724,4 @@ protected Class defineClassFromData(File container, byte[] classData, String cla /* Unused since 1.527, see https://github.com/jenkinsci/jenkins/commit/47de54d070f67af95b4fefb6d006a72bb31a5cb8 */ @Deprecated public static boolean useAntClassLoader = SystemProperties.getBoolean(ClassicPluginStrategy.class.getName()+".useAntClassLoader"); - @SuppressFBWarnings("MS_SHOULD_BE_FINAL") - public static boolean DISABLE_TRANSFORMER = SystemProperties.getBoolean(ClassicPluginStrategy.class.getName()+".noBytecodeTransformer"); } diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index fae96692d206..2939186379da 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -79,7 +79,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.LogFactory; import org.jenkinsci.Symbol; -import org.jenkinsci.bytecode.Transformer; import org.jvnet.hudson.reactor.Executable; import org.jvnet.hudson.reactor.Reactor; import org.jvnet.hudson.reactor.TaskBuilder; @@ -334,8 +333,6 @@ PluginManager doCreate(@NonNull Class klass, // 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 @@ -366,17 +363,6 @@ public PluginManager(ServletContext context, File rootDir) { this.workDir = StringUtils.isBlank(workDir) ? null : new File(workDir); 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() { @@ -521,13 +507,6 @@ protected void reactOnCycle(PluginWrapper q, List cycle) } }); - // 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. diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 5d6eef05f6eb..ba49050a04fe 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -110,7 +110,6 @@ import jenkins.triggers.SCMTriggerItem; import jenkins.util.TimeDuration; import net.sf.json.JSONObject; -import org.jenkinsci.bytecode.AdaptField; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.DoNotUse; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -231,7 +230,6 @@ public abstract class AbstractProject

,R extends A /** * List of all {@link Trigger}s for this project. */ - @AdaptField(was=List.class) protected volatile DescribableList,TriggerDescriptor> triggers = new DescribableList<>(this); private static final AtomicReferenceFieldUpdater triggersUpdater = AtomicReferenceFieldUpdater.newUpdater(AbstractProject.class,DescribableList.class,"triggers"); diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index 3a6f7e8853c6..430cdeba7f7c 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -114,7 +114,6 @@ import jenkins.model.Jenkins; import jenkins.security.QueueItemAuthenticator; import jenkins.util.AtmostOneTaskExecutor; -import org.jenkinsci.bytecode.AdaptField; import org.jenkinsci.remoting.RoleChecker; import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.HttpResponse; @@ -2108,7 +2107,6 @@ public long getId() { return id; } - @AdaptField(was=int.class, name="id") @Deprecated public int getIdLegacy() { if (id > Integer.MAX_VALUE) { From 1103306af59a025235579ec3aa608a3dddc19235 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Tue, 25 May 2021 14:03:14 -0700 Subject: [PATCH 2/2] AntClassLoader2 is now redundant --- .../main/java/hudson/ClassicPluginStrategy.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index ab756c6e6098..19f04f016814 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -54,7 +54,6 @@ import org.apache.tools.zip.ZipOutputStream; import edu.umd.cs.findbugs.annotations.NonNull; -import java.io.Closeable; import java.io.File; import java.io.FileNotFoundException; import java.io.FilenameFilter; @@ -303,7 +302,7 @@ protected ClassLoader createClassLoader(List paths, ClassLoader parent, At } } - AntClassLoader2 classLoader = new AntClassLoader2(parent); + AntWithFindResourceClassLoader classLoader = new AntWithFindResourceClassLoader(parent, true); classLoader.addPathFiles(paths); return classLoader; } @@ -707,20 +706,6 @@ protected URL findResource(String name) { } } - /** - * {@link AntClassLoader} with a few methods exposed and {@link Closeable} support. - */ - private final class AntClassLoader2 extends AntWithFindResourceClassLoader implements Closeable { - private AntClassLoader2(ClassLoader parent) { - super(parent, true); - } - - @Override - protected Class defineClassFromData(File container, byte[] classData, String classname) throws IOException { - return super.defineClassFromData(container, classData, classname); - } - } - /* Unused since 1.527, see https://github.com/jenkinsci/jenkins/commit/47de54d070f67af95b4fefb6d006a72bb31a5cb8 */ @Deprecated public static boolean useAntClassLoader = SystemProperties.getBoolean(ClassicPluginStrategy.class.getName()+".useAntClassLoader");