--- a/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java Tue Mar 15 13:48:26 2016 -0700
+++ b/jdk/src/java.base/share/classes/sun/reflect/misc/MethodUtil.java Thu Mar 17 19:04:16 2016 +0000
@@ -25,6 +25,7 @@
package sun.reflect.misc;
+import java.lang.reflect.Module;
import java.io.EOFException;
import java.security.AllPermission;
import java.security.AccessController;
@@ -39,7 +40,6 @@
import java.net.URLConnection;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashMap;
@@ -329,24 +329,26 @@
throw new ClassNotFoundException(name);
}
String path = name.replace('.', '/').concat(".class");
- URL res = getResource(path);
- if (res != null) {
- try {
- return defineClass(name, res);
- } catch (IOException e) {
- throw new ClassNotFoundException(name, e);
+ try {
+ InputStream in = Object.class.getModule().getResourceAsStream(path);
+ if (in != null) {
+ try (in) {
+ byte[] b = in.readAllBytes();
+ return defineClass(name, b);
+ }
}
- } else {
- throw new ClassNotFoundException(name);
+ } catch (IOException e) {
+ throw new ClassNotFoundException(name, e);
}
+
+ throw new ClassNotFoundException(name);
}
/*
* Define the proxy classes
*/
- private Class<?> defineClass(String name, URL url) throws IOException {
- byte[] b = getBytes(url);
+ private Class<?> defineClass(String name, byte[] b) throws IOException {
CodeSource cs = new CodeSource(null, (java.security.cert.Certificate[])null);
if (!name.equals(TRAMPOLINE)) {
throw new IOException("MethodUtil: bad name " + name);
@@ -354,29 +356,6 @@
return defineClass(name, b, 0, b.length, cs);
}
-
- /*
- * Returns the contents of the specified URL as an array of bytes.
- */
- private static byte[] getBytes(URL url) throws IOException {
- URLConnection uc = url.openConnection();
- if (uc instanceof java.net.HttpURLConnection) {
- java.net.HttpURLConnection huc = (java.net.HttpURLConnection) uc;
- int code = huc.getResponseCode();
- if (code >= java.net.HttpURLConnection.HTTP_BAD_REQUEST) {
- throw new IOException("open HTTP connection failed.");
- }
- }
- int len = uc.getContentLength();
- try (InputStream in = new BufferedInputStream(uc.getInputStream())) {
- byte[] b = in.readAllBytes();
- if (len != -1 && b.length != len)
- throw new EOFException("Expected:" + len + ", read:" + b.length);
- return b;
- }
- }
-
-
protected PermissionCollection getPermissions(CodeSource codesource)
{
PermissionCollection perms = super.getPermissions(codesource);