--- a/jdk/src/share/classes/sun/applet/AppletClassLoader.java Thu Aug 13 15:12:32 2009 -0700
+++ b/jdk/src/share/classes/sun/applet/AppletClassLoader.java Tue Aug 18 12:10:12 2009 +0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,7 @@
import java.security.PermissionCollection;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
+import sun.misc.IOUtils;
import sun.net.www.ParseUtil;
import sun.security.util.SecurityConstants;
@@ -331,36 +332,7 @@
byte[] b;
try {
- if (len != -1) {
- // Read exactly len bytes from the input stream
- b = new byte[len];
- while (len > 0) {
- int n = in.read(b, b.length - len, len);
- if (n == -1) {
- throw new IOException("unexpected EOF");
- }
- len -= n;
- }
- } else {
- // Read until end of stream is reached - use 8K buffer
- // to speed up performance [stanleyh]
- b = new byte[8192];
- int total = 0;
- while ((len = in.read(b, total, b.length - total)) != -1) {
- total += len;
- if (total >= b.length) {
- byte[] tmp = new byte[total * 2];
- System.arraycopy(b, 0, tmp, 0, total);
- b = tmp;
- }
- }
- // Trim array to correct size, if necessary
- if (total != b.length) {
- byte[] tmp = new byte[total];
- System.arraycopy(b, 0, tmp, 0, total);
- b = tmp;
- }
- }
+ b = IOUtils.readFully(in, len, true);
} finally {
in.close();
}