Mercurial > hg > icedtea8-forest > hotspot
changeset 10578:8b80409d5840 jdk8u242-b07
8138978: Examine usages of sun.misc.IOUtils
Reviewed-by: mbalao
author | andrew |
---|---|
date | Mon, 13 Jan 2020 02:15:57 +0000 |
parents | f37db4bd396c |
children | 7c9f6b5f8d11 |
files | test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java test/runtime/8003720/VictimClassLoader.java |
diffstat | 2 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java Tue Oct 08 10:26:17 2019 -0400 +++ b/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java Mon Jan 13 02:15:57 2020 +0000 @@ -22,9 +22,10 @@ */ import sun.hotspot.WhiteBox; +import sun.misc.IOUtils; 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; @@ -108,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 = 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
--- a/test/runtime/8003720/VictimClassLoader.java Tue Oct 08 10:26:17 2019 -0400 +++ b/test/runtime/8003720/VictimClassLoader.java Mon Jan 13 02:15:57 2020 +0000 @@ -22,6 +22,8 @@ * */ +import sun.misc.IOUtils; + public class VictimClassLoader extends ClassLoader { public static long counter = 0; @@ -72,8 +74,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 = IOUtils.readAllBytes(in); + if (len != -1 && b.length != len) + throw new java.io.IOException("Expected:" + len + ", actual:" + b.length); + return b; } public void finalize() {