test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests

test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java

Print this page


   1 /*
   2  * Copyright (c) 2015, 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  *


  35  * @build sun.hotspot.WhiteBox
  36  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  37  * @run main DummyClassesInBootClassPath
  38  */
  39 
  40 import java.io.File;
  41 import java.util.List;
  42 import java.util.ArrayList;
  43 import jdk.test.lib.process.OutputAnalyzer;
  44 
  45 public class DummyClassesInBootClassPath {
  46     private static final String METHOD_NAME = "thisClassIsDummy()";
  47 
  48     public static void main(String[] args) throws Exception {
  49         String classNames[] = { "java/net/HttpCookie",
  50                                 "javax/activation/MimeType"};
  51         JarBuilder.build("dummyClasses", classNames[0], classNames[1]);
  52 
  53         String appJar = TestCommon.getTestJar("dummyClasses.jar");
  54         OutputAnalyzer dumpOutput = TestCommon.dump(
  55             appJar, classNames, "-Xbootclasspath/a:" + appJar);
  56 
  57         List<String> argsList = new ArrayList<String>();
  58         for (int i = 0; i < classNames.length; i++) {
  59             argsList.add(classNames[i].replace('/', '.'));
  60         }
  61         String[] arguments = new String[argsList.size()];
  62         arguments = argsList.toArray(arguments);
  63         OutputAnalyzer execOutput = TestCommon.execCommon(
  64             "-cp", TestCommon.getTestDir("."), "-verbose:class",
  65             "--add-modules", "java.activation",
  66             "-Xbootclasspath/a:" + appJar, "DummyClassHelper",
  67             arguments[0], arguments[1]);
  68         for (int i = 0; i < arguments.length; i++) {
  69             TestCommon.checkExec(execOutput,
  70                 "java.lang.NoSuchMethodException: " + arguments[i] + "." +
  71                 METHOD_NAME);
  72         }
  73 
  74         JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
  75         String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
  76         String bootClassPath = "-Xbootclasspath/a:" + appJar +
  77             File.pathSeparator + whiteBoxJar;


  78         argsList.add("testWithWhiteBox");
  79         arguments = new String[argsList.size()];
  80         arguments = argsList.toArray(arguments);
  81         String[] opts = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
  82             bootClassPath, "-XX:+TraceClassPaths", "DummyClassHelper",
  83             arguments[0], arguments[1], arguments[2]};
  84         OutputAnalyzer output = TestCommon.execCommon(opts);





  85     }
  86 }
  87 
   1 /*
   2  * Copyright (c) 2015, 2018, 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  *


  35  * @build sun.hotspot.WhiteBox
  36  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  37  * @run main DummyClassesInBootClassPath
  38  */
  39 
  40 import java.io.File;
  41 import java.util.List;
  42 import java.util.ArrayList;
  43 import jdk.test.lib.process.OutputAnalyzer;
  44 
  45 public class DummyClassesInBootClassPath {
  46     private static final String METHOD_NAME = "thisClassIsDummy()";
  47 
  48     public static void main(String[] args) throws Exception {
  49         String classNames[] = { "java/net/HttpCookie",
  50                                 "javax/activation/MimeType"};
  51         JarBuilder.build("dummyClasses", classNames[0], classNames[1]);
  52 
  53         String appJar = TestCommon.getTestJar("dummyClasses.jar");
  54         OutputAnalyzer dumpOutput = TestCommon.dump(
  55             appJar, classNames, "-Xbootclasspath/a:" + appJar,
  56             "--add-modules", "java.activation");
  57         List<String> argsList = new ArrayList<String>();
  58         for (int i = 0; i < classNames.length; i++) {
  59             argsList.add(classNames[i].replace('/', '.'));
  60         }
  61         String[] arguments = new String[argsList.size()];
  62         arguments = argsList.toArray(arguments);
  63         OutputAnalyzer execOutput = TestCommon.execCommon(
  64             "--add-modules", "java.activation", "-Xbootclasspath/a:" + appJar,
  65             "DummyClassHelper", arguments[0], arguments[1]);


  66         for (int i = 0; i < arguments.length; i++) {
  67             TestCommon.checkExec(execOutput,
  68                 "java.lang.NoSuchMethodException: " + arguments[i] + "." +
  69                 METHOD_NAME);
  70         }
  71 
  72         JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
  73         String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
  74         String bootClassPath = "-Xbootclasspath/a:" + appJar +
  75             File.pathSeparator + whiteBoxJar;
  76         dumpOutput = TestCommon.dump(
  77             appJar, classNames, bootClassPath, "--add-modules", "java.activation");
  78         argsList.add("testWithWhiteBox");
  79         arguments = new String[argsList.size()];
  80         arguments = argsList.toArray(arguments);
  81         String[] opts = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
  82             "--add-modules", "java.activation", bootClassPath, "-XX:+TraceClassPaths",
  83             "DummyClassHelper", arguments[0], arguments[1], arguments[2]};
  84         execOutput = TestCommon.execCommon(opts);
  85         for (int i = 0; i < arguments.length - 1; i++) {
  86             TestCommon.checkExec(execOutput,
  87                 "java.lang.NoSuchMethodException: " + arguments[i] + "." +
  88                 METHOD_NAME);
  89         }
  90     }
  91 }
  92 
test/hotspot/jtreg/runtime/appcds/jigsaw/classpathtests/DummyClassesInBootClassPath.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File