diff options
author | andrew <unknown> | 2020-01-13 02:15:57 +0000 |
---|---|---|
committer | bell-sw <liberica@bell-sw.com> | 2020-01-19 09:12:38 +0300 |
commit | 27f0d020b3179cebf96e982e45205f770cade6fe (patch) | |
tree | f6143721af5aa5eca76741ebcc502f84bc31cbd6 | |
parent | 7614eb54977b9865371c0edbc7f19ad3c9b28d84 (diff) | |
download | jdk8u_hotspot-27f0d020b3179cebf96e982e45205f770cade6fe.tar.gz |
8138978: Examine usages of sun.misc.IOUtils
Reviewed-by: mbalao
-rw-r--r-- | test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java | 11 | ||||
-rw-r--r-- | test/runtime/8003720/VictimClassLoader.java | 8 |
2 files changed, 15 insertions, 4 deletions
diff --git a/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java b/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java index 6fbaf9cef..9ff45492f 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 3505f7832..e219fd60f 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() { |