test/hotspot/jtreg/runtime/appcds/javaldr/ArrayTest.java
changeset 48138 78b2ecdd3c4b
child 48383 d6388b652504
equal deleted inserted replaced
48137:0afc5f9eafef 48138:78b2ecdd3c4b
       
     1 /*
       
     2  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 /*
       
    26  * @test
       
    27  * @summary test the ability to archive array classes and load them from the archive
       
    28  * AppCDS does not support uncompressed oops
       
    29  * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true)
       
    30  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
       
    31  * @modules jdk.jartool/sun.tools.jar
       
    32  * @compile ArrayTestHelper.java
       
    33  * @build sun.hotspot.WhiteBox
       
    34  * @run main ClassFileInstaller sun.hotspot.WhiteBox
       
    35  * @run main ArrayTest
       
    36  */
       
    37 
       
    38 import java.util.List;
       
    39 import java.util.ArrayList;
       
    40 import jdk.test.lib.process.OutputAnalyzer;
       
    41 
       
    42 public class ArrayTest {
       
    43 
       
    44     static String arrayClasses[] = {
       
    45         "ArrayTestHelper",
       
    46         "[Ljava/lang/Comparable;",
       
    47         "[I"
       
    48     };
       
    49 
       
    50     public static void main(String[] args) throws Exception {
       
    51         JarBuilder.build("arrayTestHelper", "ArrayTestHelper");
       
    52 
       
    53         String appJar = TestCommon.getTestJar("arrayTestHelper.jar");
       
    54         JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
       
    55         String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
       
    56         String bootClassPath = "-Xbootclasspath/a:" + whiteBoxJar;
       
    57 
       
    58         // create an archive containing array classes
       
    59         TestCommon.dump(appJar, TestCommon.list(arrayClasses), bootClassPath, "-verbose:class");
       
    60 
       
    61         List<String> argsList = new ArrayList<String>();
       
    62         argsList.add("-XX:+UnlockDiagnosticVMOptions");
       
    63         argsList.add("-XX:+WhiteBoxAPI");
       
    64         argsList.add("-cp");
       
    65         argsList.add(appJar);
       
    66         argsList.add(bootClassPath);
       
    67         argsList.add("-verbose:class");
       
    68         argsList.add("ArrayTestHelper");
       
    69         // the following are input args to the ArrayTestHelper.
       
    70         for (int i = 0; i < arrayClasses.length; i++) {
       
    71             argsList.add(arrayClasses[i]);
       
    72         }
       
    73         String[] opts = new String[argsList.size()];
       
    74         opts = argsList.toArray(opts);
       
    75         OutputAnalyzer output = TestCommon.execCommon(opts);
       
    76         TestCommon.checkExec(output);
       
    77     }
       
    78 }