src/java.base/share/classes/sun/reflect/misc/MethodUtil.java
Print this page
@@ -23,10 +23,11 @@
* questions.
*/
package sun.reflect.misc;
+import java.io.EOFException;
import java.security.AllPermission;
import java.security.AccessController;
import java.security.PermissionCollection;
import java.security.SecureClassLoader;
import java.security.PrivilegedExceptionAction;
@@ -41,11 +42,10 @@
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
-import sun.misc.IOUtils;
class Trampoline {
static {
if (Trampoline.class.getClassLoader() == null) {
@@ -366,20 +366,17 @@
if (code >= java.net.HttpURLConnection.HTTP_BAD_REQUEST) {
throw new IOException("open HTTP connection failed.");
}
}
int len = uc.getContentLength();
- InputStream in = new BufferedInputStream(uc.getInputStream());
-
- byte[] b;
- try {
- b = IOUtils.readFully(in, len, true);
- } finally {
- in.close();
- }
+ 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);