diff --git a/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java b/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java index 6fbaf9cef72e8f46269a9e56fecc922cac9490a6..9ff45492f468b0674619600fb99bbe4ba614d670 100644 --- a/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java +++ b/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java @@ -22,9 +22,10 @@ */ import sun.hotspot.WhiteBox; -import sun.misc.Unsafe; import sun.misc.IOUtils; +import sun.misc.Unsafe; +import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLConnection; @@ -108,7 +109,13 @@ public class TestAnonymousClassUnloading { // (1) Load an anonymous version of this class using the corresponding Unsafe method URL classUrl = TestAnonymousClassUnloading.class.getResource("TestAnonymousClassUnloading.class"); URLConnection connection = classUrl.openConnection(); - byte[] classBytes = IOUtils.readFully(connection.getInputStream(), connection.getContentLength(), true); + + int length = connection.getContentLength(); + byte[] classBytes = IOUtils.readAllBytes(connection.getInputStream()); + if (length != -1 && classBytes.length != length) { + throw new IOException("Expected:" + length + ", actual: " + classBytes.length); + } + Class anonymousClass = UNSAFE.defineAnonymousClass(TestAnonymousClassUnloading.class, classBytes, null); // (2) Make sure all paths of doWork are profiled and compiled diff --git a/test/runtime/8003720/VictimClassLoader.java b/test/runtime/8003720/VictimClassLoader.java index 3505f7832f39b6dafa41354a630e43a674252ac7..e219fd60f9edb6fec7c97b76567e489c16f8a7e9 100644 --- a/test/runtime/8003720/VictimClassLoader.java +++ b/test/runtime/8003720/VictimClassLoader.java @@ -22,6 +22,8 @@ * */ +import sun.misc.IOUtils; + public class VictimClassLoader extends ClassLoader { public static long counter = 0; @@ -72,8 +74,10 @@ public class VictimClassLoader extends ClassLoader { } static byte[] readFully(java.io.InputStream in, int len) throws java.io.IOException { - // Warning here: - return sun.misc.IOUtils.readFully(in, len, true); + byte[] b = IOUtils.readAllBytes(in); + if (len != -1 && b.length != len) + throw new java.io.IOException("Expected:" + len + ", actual:" + b.length); + return b; } public void finalize() {