Skip to content

Commit

Permalink
Remove unnecessary use of reflection (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil committed Nov 30, 2022
1 parent 6718f32 commit 47d8584
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions src/main/java/org/jenkinsci/maven/plugins/hpi/RunMojo.java
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

0 comments on commit 47d8584

Please sign in to comment.