# HG changeset patch # User chegar # Date 1444396893 -3600 # Node ID 89da05adaa00ccbce875d3d79949c3c13378cb67 # Parent 8392405ab038b22e69a3728e17dbdd9e3d3a22ed 8138978: Examine usages of sun.misc.IOUtils Reviewed-by: alanb, mullan, psandoz, rriggs, weijun diff -r 8392405ab038 -r 89da05adaa00 hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java --- a/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java Wed Jul 05 20:52:37 2017 +0200 +++ b/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java Fri Oct 09 14:21:33 2015 +0100 @@ -23,8 +23,8 @@ import sun.hotspot.WhiteBox; import sun.misc.Unsafe; -import sun.misc.IOUtils; +import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLConnection; @@ -109,7 +109,13 @@ // (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 = connection.getInputStream().readAllBytes(); + 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 -r 8392405ab038 -r 89da05adaa00 hotspot/test/runtime/8003720/VictimClassLoader.java --- a/hotspot/test/runtime/8003720/VictimClassLoader.java Wed Jul 05 20:52:37 2017 +0200 +++ b/hotspot/test/runtime/8003720/VictimClassLoader.java Fri Oct 09 14:21:33 2015 +0100 @@ -72,8 +72,10 @@ } 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 = in.readAllBytes(); + if (len != -1 && b.length != len) + throw new java.io.IOException("Expected:" + len + ", actual:" + b.length); + return b; } public void finalize() {