Skip to content
Permalink
Browse files

Merge pull request #223 from oleg-nenashev/bug/JENKINS-46724-reflecti…

…ve-operation

[JENKINS-46724] - Remove obsolete ClassloadingLock reflection in RemoteClassloader.
  • Loading branch information...
oleg-nenashev committed Nov 16, 2017
2 parents 0b79eae + 0859573 commit 7efdd3f9c0ba5766346a62b988c8dc421e99d338
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 7efdd3f

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