src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java
Print this page
@@ -23,14 +23,14 @@
* questions.
*/
package sun.invoke.anon;
+import java.io.EOFException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import sun.misc.IOUtils;
/**
* Anonymous class loader. Will load any valid classfile, producing
* a {@link Class} metaobject, without installing that class in the
* system dictionary. Therefore, {@link Class#forName(String)} will never
@@ -223,8 +223,12 @@
java.net.URLConnection connection = url.openConnection();
int contentLength = connection.getContentLength();
if (contentLength < 0)
throw new IOException("invalid content length "+contentLength);
- return IOUtils.readFully(connection.getInputStream(), contentLength, true);
+ byte[] b = connection.getInputStream().readAllBytes();
+ if (b.length != contentLength)
+ throw new EOFException("Expected:" + contentLength + ", read:" + b.length);
+
+ return b;
}
}