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 unnecessary use of reflection #401

Merged
merged 1 commit into from
Nov 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 1 addition & 13 deletions src/main/java/org/jenkinsci/maven/plugins/hpi/RunMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
Expand Down Expand Up @@ -704,7 +703,7 @@ public void finishConfigurationBeforeStart() throws Exception {
try {
// for Jenkins modules, swap the component from jenkins.war by target/classes
// via classloader magic
WebAppClassLoader wacl = new WebAppClassLoader(new JettyAndServletApiOnlyClassLoader(getPlatformClassLoader(),getClass().getClassLoader()),wac) {
WebAppClassLoader wacl = new WebAppClassLoader(new JettyAndServletApiOnlyClassLoader(ClassLoader.getPlatformClassLoader(),getClass().getClassLoader()),wac) {
private final Pattern exclusionPattern;
{
if (getProject().getPackaging().equals("jenkins-module")) {
Expand Down Expand Up @@ -747,17 +746,6 @@ public void addJars(org.eclipse.jetty.util.resource.Resource lib) {
}
}

private ClassLoader getPlatformClassLoader() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
if (isPostJava8()) {
return (ClassLoader) ClassLoader.class.getMethod("getPlatformClassLoader").invoke(null);
}
return null;
}

private boolean isPostJava8() {
return !System.getProperty("java.version").startsWith("1.");
}

@Override
public void startJetty() throws MojoExecutionException {
if (httpConnector == null && (defaultPort != 0 || (defaultHost != null && !defaultHost.isEmpty()))) {
Expand Down