Remove AntClassLoader (#7846)

This commit is contained in:
Basil Crow authored and GitHub committed 2023-04-25 09:39:41 +02:00
1 parent cb2c48bb57
commit 9ce1ff4e7c
7 files changed
+11 -274

No files matched your search

@@ -59,8 +59,6 @@ import java.util.logging.Logger;
import jenkins.ClassLoaderReflectionToolkit;
import jenkins.ExtensionFilter;
import jenkins.plugins.DetachedPluginsUtil;
import jenkins.util.AntClassLoader;
import jenkins.util.SystemProperties;
import jenkins.util.URLClassLoader2;
import org.apache.commons.io.output.NullOutputStream;
import org.apache.tools.ant.BuildException;
@@ -290,30 +288,17 @@ public class ClassicPluginStrategy implements PluginStrategy {
boolean usePluginFirstClassLoader =
atts != null && Boolean.parseBoolean(atts.getValue("PluginFirstClassLoader"));
if (useAntClassLoader) {
AntClassLoader classLoader;
if (usePluginFirstClassLoader) {
classLoader = new PluginFirstClassLoader();
classLoader.setParentFirst(false);
classLoader.setParent(parent);
} else {
classLoader = new AntClassLoader(parent, true);
}
classLoader.addPathFiles(paths);
return classLoader;
} else {
List<URL> urls = new ArrayList<>();
for (File path : paths) {
urls.add(path.toURI().toURL());
}
URLClassLoader2 classLoader;
if (usePluginFirstClassLoader) {
classLoader = new PluginFirstClassLoader2(urls.toArray(new URL[0]), parent);
} else {
classLoader = new URLClassLoader2(urls.toArray(new URL[0]), parent);
}
return classLoader;
List<URL> urls = new ArrayList<>();
for (File path : paths) {
urls.add(path.toURI().toURL());
}
URLClassLoader2 classLoader;
if (usePluginFirstClassLoader) {
classLoader = new PluginFirstClassLoader2(urls.toArray(new URL[0]), parent);
} else {
classLoader = new URLClassLoader2(urls.toArray(new URL[0]), parent);
}
return classLoader;
}
/**
@@ -432,17 +417,6 @@ public class ClassicPluginStrategy implements PluginStrategy {
if (classLoader instanceof DependencyClassLoader) {
return (DependencyClassLoader) classLoader;
}
if (classLoader instanceof AntClassLoader) {
// AntClassLoaders hold parents not only as AntClassLoader#getParent()
// but also as AntClassLoader#getConfiguredParent()
DependencyClassLoader ret = findAncestorDependencyClassLoader(
((AntClassLoader) classLoader).getConfiguredParent()
);
if (ret != null) {
return ret;
}
}
}
return null;
}
@@ -716,7 +690,4 @@ public class ClassicPluginStrategy implements PluginStrategy {
return null;
}
}
@SuppressFBWarnings(value = "MS_SHOULD_BE_FINAL", justification = "Accessible via System Groovy Scripts")
public static /* not final */ boolean useAntClassLoader = SystemProperties.getBoolean(ClassicPluginStrategy.class.getName() + ".useAntClassLoader");
}