Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Bytecode Compatibility Transformer #5526

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,6 @@ THE SOFTWARE.
<artifactId>args4j</artifactId>
<version>2.33</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>bytecode-compatibility-transformer</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>task-reactor</artifactId>
Expand Down
4 changes: 0 additions & 4 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ THE SOFTWARE.
<groupId>org.jenkins-ci</groupId>
<artifactId>annotation-indexer</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>bytecode-compatibility-transformer</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>task-reactor</artifactId>
Expand Down
22 changes: 1 addition & 21 deletions core/src/main/java/hudson/ClassicPluginStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@
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;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FilenameFilter;
Expand Down Expand Up @@ -304,7 +302,7 @@ protected ClassLoader createClassLoader(List<File> paths, ClassLoader parent, At
}
}

AntClassLoader2 classLoader = new AntClassLoader2(parent);
AntWithFindResourceClassLoader classLoader = new AntWithFindResourceClassLoader(parent, true);
classLoader.addPathFiles(paths);
return classLoader;
}
Expand Down Expand Up @@ -708,25 +706,7 @@ protected URL findResource(String name) {
}
}

/**
* {@link AntClassLoader} with a few methods exposed, {@link Closeable} support, and {@link Transformer} 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 {
if (!DISABLE_TRANSFORMER)
classData = pluginManager.getCompatibilityTransformer().transform(classname, classData, this);
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");
@SuppressFBWarnings("MS_SHOULD_BE_FINAL")
public static boolean DISABLE_TRANSFORMER = SystemProperties.getBoolean(ClassicPluginStrategy.class.getName()+".noBytecodeTransformer");
}
21 changes: 0 additions & 21 deletions core/src/main/java/hudson/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -334,8 +333,6 @@ PluginManager doCreate(@NonNull Class<? extends PluginManager> 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
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -521,13 +507,6 @@ protected void reactOnCycle(PluginWrapper q, List<PluginWrapper> 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.
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/hudson/model/AbstractProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -231,7 +230,6 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
/**
* List of all {@link Trigger}s for this project.
*/
@AdaptField(was=List.class)
protected volatile DescribableList<Trigger<?>,TriggerDescriptor> triggers = new DescribableList<>(this);
private static final AtomicReferenceFieldUpdater<AbstractProject,DescribableList> triggersUpdater
= AtomicReferenceFieldUpdater.newUpdater(AbstractProject.class,DescribableList.class,"triggers");
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/hudson/model/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2108,7 +2107,6 @@ public long getId() {
return id;
}

@AdaptField(was=int.class, name="id")
@Deprecated
public int getIdLegacy() {
if (id > Integer.MAX_VALUE) {
Expand Down