hotspot/test/testlibrary/ClassFileInstaller.java
author erikj
Thu, 14 Apr 2016 15:13:42 +0200
changeset 37299 db3b0d4c3bda
parent 37263 08dec586ed5c
permissions -rw-r--r--
8149777: Enable enhanced failure handler for "make test" Reviewed-by: ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15793
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
     1
/*
35572
c864053d0405 8147444: compiler/jsr292/NonInlinedCall/RedefineTest.java fails with NullPointerException in ClassFileInstaller
thartmann
parents: 17373
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
15793
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
     4
 *
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
     8
 *
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    13
 * accompanied this code).
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    14
 *
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    18
 *
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    21
 * questions.
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    22
 */
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    23
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    24
import java.io.ByteArrayInputStream;
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    25
import java.io.File;
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    26
import java.io.FileInputStream;
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    27
import java.io.FileOutputStream;
35572
c864053d0405 8147444: compiler/jsr292/NonInlinedCall/RedefineTest.java fails with NullPointerException in ClassFileInstaller
thartmann
parents: 17373
diff changeset
    28
import java.io.FileNotFoundException;
15793
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    29
import java.io.InputStream;
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
    30
import java.io.ByteArrayInputStream;
15793
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    31
import java.nio.file.Files;
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    32
import java.nio.file.Path;
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    33
import java.nio.file.Paths;
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    34
import java.nio.file.StandardCopyOption;
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    35
import java.util.zip.ZipEntry;
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    36
import java.util.zip.ZipOutputStream;
15793
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    37
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    38
/**
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    39
 * Dump a class file for a class on the class path in the current directory, or
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    40
 * in the specified JAR file. This class is usually used when you build a class
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    41
 * from a test library, but want to use this class in a sub-process.
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    42
 *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    43
 * For example, to build the following library class:
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    44
 * test/lib/sun/hotspot/WhiteBox.java
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    45
 *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    46
 * You would use the following tags:
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    47
 *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    48
 * @library /test/lib
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    49
 * @build sun.hotspot.WhiteBox
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    50
 *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    51
 * JTREG would build the class file under
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    52
 * ${JTWork}/classes/test/lib/sun/hotspot/WhiteBox.class
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    53
 *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    54
 * With you run your main test class using "@run main MyMainClass", JTREG would setup the
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    55
 * -classpath to include "${JTWork}/classes/test/lib/", so MyMainClass would be able to
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    56
 * load the WhiteBox class.
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    57
 *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    58
 * However, if you run a sub process, and do not wish to use the exact same -classpath,
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    59
 * You can use ClassFileInstaller to ensure that WhiteBox is available in the current
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    60
 * directory of your test:
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    61
 *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    62
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    63
 *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    64
 * Or, you can use the -jar option to store the class in the specified JAR file. If a relative
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    65
 * path name is given, the JAR file would be relative to the current directory of
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    66
 *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    67
 * @run main ClassFileInstaller -jar myjar.jar sun.hotspot.WhiteBox
15793
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    68
 */
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    69
public class ClassFileInstaller {
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    70
    /**
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    71
     * You can enable debug tracing of ClassFileInstaller by running JTREG with
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    72
     * jtreg -DClassFileInstaller.debug=true ... <names of tests>
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    73
     */
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    74
    public static boolean DEBUG = Boolean.getBoolean("ClassFileInstaller.debug");
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    75
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    76
    /**
15793
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    77
     * @param args The names of the classes to dump
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    78
     * @throws Exception
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    79
     */
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
    80
    public static void main(String... args) throws Exception {
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    81
        if (args.length > 1 && args[0].equals("-jar")) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    82
            if (args.length < 2) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    83
                throw new RuntimeException("Usage: ClassFileInstaller <options> <classes>\n" +
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    84
                                           "where possible options include:\n" +
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    85
                                           "  -jar <path>             Write to the JAR file <path>");
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    86
            }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    87
            writeJar(args[1], null, args, 2, args.length);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    88
        } else {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    89
            if (DEBUG) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    90
                System.out.println("ClassFileInstaller: Writing to " + System.getProperty("user.dir"));
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    91
            }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    92
            for (String arg : args) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    93
                writeClassToDisk(arg);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    94
            }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    95
        }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    96
    }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    97
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    98
    public static class Manifest {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
    99
        private InputStream in;
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   100
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   101
        private Manifest(InputStream in) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   102
            this.in = in;
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   103
        }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   104
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   105
        static Manifest fromSourceFile(String fileName) throws Exception {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   106
            String pathName = System.getProperty("test.src") + File.separator + fileName;
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   107
            return new Manifest(new FileInputStream(pathName));
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   108
        }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   109
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   110
        // Example:
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   111
        //  String manifest = "Premain-Class: RedefineClassHelper\n" +
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   112
        //                "Can-Redefine-Classes: true\n";
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   113
        //  ClassFileInstaller.writeJar("redefineagent.jar",
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   114
        //    ClassFileInstaller.Manifest.fromString(manifest),
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   115
        //    "RedefineClassHelper");
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   116
        static Manifest fromString(String manifest) throws Exception {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   117
            return new Manifest(new ByteArrayInputStream(manifest.getBytes()));
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   118
        }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   119
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   120
        public InputStream getInputStream() {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   121
            return in;
15793
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
   122
        }
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
   123
    }
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   124
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   125
    private static void writeJar(String jarFile, Manifest manifest, String classes[], int from, int to) throws Exception {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   126
        if (DEBUG) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   127
            System.out.println("ClassFileInstaller: Writing to " + getJarPath(jarFile));
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   128
        }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   129
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   130
        (new File(jarFile)).delete();
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   131
        FileOutputStream fos = new FileOutputStream(jarFile);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   132
        ZipOutputStream zos = new ZipOutputStream(fos);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   133
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   134
        // The manifest must be the first or second entry. See comments in JarInputStream
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   135
        // constructor and JDK-5046178.
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   136
        if (manifest != null) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   137
            writeToDisk(zos, "META-INF/MANIFEST.MF", manifest.getInputStream());
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   138
        }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   139
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   140
        for (int i=from; i<to; i++) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   141
            writeClassToDisk(zos, classes[i]);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   142
        }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   143
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   144
        zos.close();
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   145
        fos.close();
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   146
    }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   147
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   148
    /*
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   149
     * You can call ClassFileInstaller.writeJar() from your main test class instead of
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   150
     * using "@run ClassFileInstaller -jar ...". E.g.,
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   151
     *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   152
     * String jarPath = ClassFileInstaller.getJarPath("myjar.jar", "sun.hotspot.WhiteBox")
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   153
     *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   154
     * If you call this API, make sure you build ClassFileInstaller with the following tags:
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   155
     *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   156
     * @library testlibrary
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   157
     * @build ClassFileInstaller
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   158
     */
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   159
    public static String writeJar(String jarFile, String... classes) throws Exception {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   160
        writeJar(jarFile, null, classes, 0, classes.length);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   161
        return getJarPath(jarFile);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   162
    }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   163
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   164
    public static String writeJar(String jarFile, Manifest manifest, String... classes) throws Exception {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   165
        writeJar(jarFile, manifest, classes, 0, classes.length);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   166
        return getJarPath(jarFile);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   167
    }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   168
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   169
    /**
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   170
     * This returns the absolute path to the file specified in "@ClassFileInstaller -jar myjar.jar",
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   171
     * In your test program, instead of using the JAR file name directly:
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   172
     *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   173
     * String jarPath = "myjar.jar";
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   174
     *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   175
     * you should call this function, like:
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   176
     *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   177
     * String jarPath = ClassFileInstaller.getJarPath("myjar.jar")
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   178
     *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   179
     * The reasons are:
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   180
     * (1) Using absolute path makes it easy to cut-and-paste from the JTR file and rerun your
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   181
     *     test in any directory.
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   182
     * (2) In the future, we may make the JAR file name unique to avoid clobbering
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   183
     *     during parallel JTREG execution.
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   184
     *
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   185
     */
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   186
    public static String getJarPath(String jarFileName) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   187
        return new File(jarFileName).getAbsolutePath();
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   188
    }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   189
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   190
    public static void writeClassToDisk(String className) throws Exception {
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   191
        writeClassToDisk((ZipOutputStream)null, className);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   192
    }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   193
    private static void writeClassToDisk(ZipOutputStream zos, String className) throws Exception {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   194
        writeClassToDisk(zos, className, "");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   195
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   196
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   197
    public static void writeClassToDisk(String className, String prependPath) throws Exception {
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   198
        writeClassToDisk(null, className, prependPath);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   199
    }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   200
    private static void writeClassToDisk(ZipOutputStream zos, String className, String prependPath) throws Exception {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   201
        ClassLoader cl = ClassFileInstaller.class.getClassLoader();
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   202
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   203
        // Convert dotted class name to a path to a class file
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   204
        String pathName = className.replace('.', '/').concat(".class");
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   205
        InputStream is = cl.getResourceAsStream(pathName);
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   206
        if (is == null) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   207
            throw new RuntimeException("Failed to find " + pathName);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   208
        }
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   209
        if (prependPath.length() > 0) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   210
            pathName = prependPath + "/" + pathName;
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   211
        }
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   212
        writeToDisk(zos, pathName, is);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   213
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   214
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   215
    public static void writeClassToDisk(String className, byte[] bytecode) throws Exception {
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   216
        writeClassToDisk(null, className, bytecode);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   217
    }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   218
    private static void writeClassToDisk(ZipOutputStream zos, String className, byte[] bytecode) throws Exception {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   219
        writeClassToDisk(zos, className, bytecode, "");
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   220
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   221
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   222
    public static void writeClassToDisk(String className, byte[] bytecode, String prependPath) throws Exception {
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   223
        writeClassToDisk(null, className, bytecode, prependPath);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   224
    }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   225
    private static void writeClassToDisk(ZipOutputStream zos, String className, byte[] bytecode, String prependPath) throws Exception {
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   226
        // Convert dotted class name to a path to a class file
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   227
        String pathName = className.replace('.', '/').concat(".class");
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   228
        if (prependPath.length() > 0) {
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   229
            pathName = prependPath + "/" + pathName;
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   230
        }
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   231
        writeToDisk(zos, pathName, new ByteArrayInputStream(bytecode));
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   232
    }
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   233
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   234
    private static void writeToDisk(ZipOutputStream zos, String pathName, InputStream is) throws Exception {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   235
        if (DEBUG) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   236
            System.out.println("ClassFileInstaller: Writing " + pathName);
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   237
        }
37263
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   238
        if (zos != null) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   239
            ZipEntry ze = new ZipEntry(pathName);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   240
            zos.putNextEntry(ze);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   241
            byte[] buf = new byte[1024];
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   242
            int len;
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   243
            while ((len = is.read(buf))>0){
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   244
                zos.write(buf, 0, len);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   245
            }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   246
        } else {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   247
            // Create the class file's package directory
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   248
            Path p = Paths.get(pathName);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   249
            if (pathName.contains("/")) {
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   250
                Files.createDirectories(p.getParent());
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   251
            }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   252
            // Create the class file
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   253
            Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING);
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   254
        }
08dec586ed5c 8153300: [TESTBUG] Enhance test/testlibrary/ClassFileInstaller.java to support JAR files
iklam
parents: 36508
diff changeset
   255
        is.close();
36508
5f9eee6b383b 8142968: Module System implementation
alanb
parents: 35572
diff changeset
   256
    }
15793
4867678e3517 8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
diff changeset
   257
}