# HG changeset patch # User iignatyev # Date 1495147885 25200 # Node ID 636b3e3f9976bf20ea5b2119fbd48480844c1b23 # Parent 5c2ed400440ab57bb940fa6208a9a3b1085a7e5c 8180397: remove jdk.testlibrary.IOUtils Reviewed-by: alanb diff -r 5c2ed400440a -r 636b3e3f9976 jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeRuntimeAssumptionTest.java --- a/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeRuntimeAssumptionTest.java Thu May 18 15:43:44 2017 -0700 +++ b/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeRuntimeAssumptionTest.java Thu May 18 15:51:25 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. 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 @@ -25,8 +25,6 @@ * @test * @summary Test consistent parsing of ex-RUNTIME annotations that * were changed and separately compiled to have CLASS retention - * @library /lib/testlibrary - * @build jdk.testlibrary.IOUtils * @run main AnnotationTypeRuntimeAssumptionTest */ @@ -35,8 +33,6 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import jdk.testlibrary.IOUtils; - import static java.lang.annotation.RetentionPolicy.CLASS; import static java.lang.annotation.RetentionPolicy.RUNTIME; @@ -140,7 +136,7 @@ String altPath = altName.replace('.', '/').concat(".class"); try (InputStream is = getResourceAsStream(altPath)) { if (is != null) { - byte[] bytes = IOUtils.readFully(is); + byte[] bytes = is.readAllBytes(); // patch class bytes to contain original name for (int i = 0; i < bytes.length - 2; i++) { if (bytes[i] == '_' && @@ -163,7 +159,7 @@ String path = name.replace('.', '/').concat(".class"); try (InputStream is = getResourceAsStream(path)) { if (is != null) { - byte[] bytes = IOUtils.readFully(is); + byte[] bytes = is.readAllBytes(); return defineClass(name, bytes, 0, bytes.length); } else { diff -r 5c2ed400440a -r 636b3e3f9976 jdk/test/java/lang/invoke/lambda/LambdaClassLoaderSerialization.java --- a/jdk/test/java/lang/invoke/lambda/LambdaClassLoaderSerialization.java Thu May 18 15:43:44 2017 -0700 +++ b/jdk/test/java/lang/invoke/lambda/LambdaClassLoaderSerialization.java Thu May 18 15:51:25 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. 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 @@ -25,8 +25,6 @@ * @test * @bug 8004970 * @summary Lambda serialization in the presence of class loaders - * @library /lib/testlibrary - * @build jdk.testlibrary.IOUtils * @run main LambdaClassLoaderSerialization * @author Peter Levart */ @@ -38,9 +36,6 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; -import java.util.Arrays; - -import jdk.testlibrary.IOUtils; public class LambdaClassLoaderSerialization { @@ -130,7 +125,7 @@ String path = name.replace('.', '/').concat(".class"); try (InputStream is = getResourceAsStream(path)) { if (is != null) { - byte[] bytes = IOUtils.readFully(is); + byte[] bytes = is.readAllBytes(); return defineClass(name, bytes, 0, bytes.length); } else { throw new ClassNotFoundException(name); diff -r 5c2ed400440a -r 636b3e3f9976 jdk/test/java/lang/reflect/Method/InterfaceStatic/StaticInterfaceMethodInWayOfDefault.java --- a/jdk/test/java/lang/reflect/Method/InterfaceStatic/StaticInterfaceMethodInWayOfDefault.java Thu May 18 15:43:44 2017 -0700 +++ b/jdk/test/java/lang/reflect/Method/InterfaceStatic/StaticInterfaceMethodInWayOfDefault.java Thu May 18 15:51:25 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. 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 @@ -27,19 +27,14 @@ * @summary Test that a static method on an interface doesn't hide a default * method with the same name and signature in a separate compilation * scenario. - * @library /lib/testlibrary - * @build jdk.testlibrary.IOUtils * @run main StaticInterfaceMethodInWayOfDefault */ import java.io.IOException; import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.concurrent.Callable; -import jdk.testlibrary.IOUtils; - public class StaticInterfaceMethodInWayOfDefault { public interface A_v1 { } @@ -147,7 +142,7 @@ String altPath = altName.replace('.', '/').concat(".class"); try (InputStream is = getResourceAsStream(altPath)) { if (is != null) { - byte[] bytes = IOUtils.readFully(is); + byte[] bytes = is.readAllBytes(); // patch class bytes to contain original name for (int i = 0; i < bytes.length - 2; i++) { if (bytes[i] == '_' && @@ -170,7 +165,7 @@ String path = name.replace('.', '/').concat(".class"); try (InputStream is = getResourceAsStream(path)) { if (is != null) { - byte[] bytes = IOUtils.readFully(is); + byte[] bytes = is.readAllBytes(); return defineClass(name, bytes, 0, bytes.length); } else { diff -r 5c2ed400440a -r 636b3e3f9976 jdk/test/lib/testlibrary/jdk/testlibrary/IOUtils.java --- a/jdk/test/lib/testlibrary/jdk/testlibrary/IOUtils.java Thu May 18 15:43:44 2017 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2014, Oracle and/or its affiliates. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.testlibrary; - -/** - * Defines useful I/O methods. - */ -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; - -public final class IOUtils { - - /* - * Prevent instantiation. - */ - private IOUtils() {} - - /** - * Read all bytes from in - * until EOF is detected. - * @param in input stream, must not be null - * @return bytes read - * @throws IOException Any IO error. - */ - public static byte[] readFully(InputStream is) throws IOException { - byte[] output = {}; - int pos = 0; - while (true) { - int bytesToRead; - if (pos >= output.length) { // Only expand when there's no room - bytesToRead = output.length + 1024; - if (output.length < pos + bytesToRead) { - output = Arrays.copyOf(output, pos + bytesToRead); - } - } else { - bytesToRead = output.length - pos; - } - int cc = is.read(output, pos, bytesToRead); - if (cc < 0) { - if (output.length != pos) { - output = Arrays.copyOf(output, pos); - } - break; - } - pos += cc; - } - return output; - } -} diff -r 5c2ed400440a -r 636b3e3f9976 jdk/test/sun/security/tools/jarsigner/EntriesOrder.java --- a/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java Thu May 18 15:43:44 2017 -0700 +++ b/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java Thu May 18 15:51:25 2017 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. 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 @@ -25,11 +25,9 @@ * @test * @bug 8031572 * @summary jarsigner -verify exits with 0 when a jar file is not properly signed - * @library /lib/testlibrary * @modules java.base/sun.security.tools.keytool * jdk.jartool/sun.security.tools.jarsigner * jdk.jartool/sun.tools.jar - * @build jdk.testlibrary.IOUtils * @run main EntriesOrder */ @@ -45,8 +43,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import jdk.testlibrary.IOUtils; - public class EntriesOrder { public static void main(String[] args) throws Exception { @@ -114,7 +110,7 @@ Enumeration jes = jf.entries(); while (jes.hasMoreElements()) { JarEntry je = jes.nextElement(); - IOUtils.readFully(jf.getInputStream(je)); + jf.getInputStream(je).readAllBytes(); Certificate[] certs = je.getCertificates(); if (certs != null && certs.length > 0) { cc++; @@ -146,7 +142,7 @@ while (true) { JarEntry je = jis.getNextJarEntry(); if (je == null) break; - IOUtils.readFully(jis); + jis.readAllBytes(); Certificate[] certs = je.getCertificates(); if (certs != null && certs.length > 0) { cc++;