Skip to content
Permalink
Browse files

[JENKINS-46724] - Remove obsolete ClassloadingLock reflection in Remo…

…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 085957317e4819aca3a9b66e927fe3aa641591a2
Showing with 1 addition and 24 deletions.
  1. +1 −24 src/main/java/hudson/remoting/RemoteClassLoader.java
@@ -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;
@@ -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;
@@ -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.
*

0 comments on commit 0859573

Please sign in to comment.
You can’t perform that action at this time.