src/java.base/share/classes/sun/invoke/anon/AnonymousClassLoader.java

Print this page

        

*** 23,36 **** * questions. */ package sun.invoke.anon; 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 --- 23,36 ---- * questions. */ package sun.invoke.anon; + import java.io.EOFException; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * 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,230 **** 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); } } --- 223,234 ---- java.net.URLConnection connection = url.openConnection(); int contentLength = connection.getContentLength(); if (contentLength < 0) throw new IOException("invalid content length "+contentLength); ! byte[] b = connection.getInputStream().readAllBytes(); ! if (b.length != contentLength) ! throw new EOFException("Expected:" + contentLength + ", read:" + b.length); ! ! return b; } }