Skip to content

Commit

Permalink
[JENKINS-46724] - Remove obsolete ClassloadingLock reflection in Remo…
Browse files Browse the repository at this point in the history
…teClassloader.

Remoting now required Java 8, so this Java 6 compatibility lgic is not required at all.
  • Loading branch information
oleg-nenashev committed Nov 15, 2017
1 parent 40def98 commit 0859573
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/main/java/hudson/remoting/RemoteClassLoader.java
Expand Up @@ -29,7 +29,6 @@
import java.io.InputStream;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.MalformedURLException;
import java.net.URLClassLoader;
Expand Down Expand Up @@ -272,7 +271,7 @@ ClassReference toRef(ClassFile2 cf) {
ClassLoader cl = cr.classLoader;
if (cl instanceof RemoteClassLoader) {
RemoteClassLoader rcl = (RemoteClassLoader) cl;
synchronized (_getClassLoadingLock(rcl, name)) {
synchronized (rcl.getClassLoadingLock(name)) {
Class<?> c = rcl.findLoadedClass(name);

boolean interrupted = false;
Expand Down Expand Up @@ -333,28 +332,6 @@ ClassReference toRef(ClassFile2 cf) {
}
}

private static Method gCLL;
static {
try {
gCLL = ClassLoader.class.getDeclaredMethod("getClassLoadingLock", String.class);
gCLL.setAccessible(true);
} catch (NoSuchMethodException x) {
// OK, Java 6
} catch (Exception x) {
LOGGER.log(WARNING, null, x);
}
}
private static Object _getClassLoadingLock(RemoteClassLoader rcl, String name) {
// Java 7: return rcl.getClassLoadingLock(name);
if (gCLL != null) {
try {
return gCLL.invoke(rcl, name);
} catch (Exception x) {
LOGGER.log(WARNING, null, x);
}
}
return rcl;
}
/**
* Intercept {@link RemoteClassLoader#findClass(String)} to allow unittests to be written.
*
Expand Down

0 comments on commit 0859573

Please sign in to comment.