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




  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 Ensure that classes found in jimage takes precedence over classes found in -Xbootclasspath/a.
  28  * @requires vm.cds
  29  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  30  * @modules java.activation
  31  *          jdk.jartool/sun.tools.jar
  32  * @compile ../../test-classes/DummyClassHelper.java
  33  * @compile ../../test-classes/java/net/HttpCookie.jasm
  34  * @compile ../../test-classes/javax/activation/MimeType.jasm
  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     static void checkOutput(OutputAnalyzer output, String[] classNames) throws Exception {
  49         for (int i = 0; i < classNames.length; i++) {
  50             String cn = classNames[i].replace('/', '.');
  51             TestCommon.checkExec(output,
  52                 "java.lang.NoSuchMethodException: " + cn + "." +
  53                 METHOD_NAME);
  54             output.shouldNotContain(cn + ".class should be in shared space.");
  55         }
  56     }
  57 
  58     public static void main(String[] args) throws Exception {
  59         String classNames[] = { "java/net/HttpCookie",
  60                                 "javax/activation/MimeType"};
  61         JarBuilder.build("dummyClasses", classNames[0], classNames[1]);
  62 
  63         String appJar = TestCommon.getTestJar("dummyClasses.jar");
  64         OutputAnalyzer dumpOutput = TestCommon.dump(
  65             appJar, classNames, "-Xbootclasspath/a:" + appJar,
  66             "--add-modules", "java.activation");
  67         List<String> argsList = new ArrayList<String>();
  68         for (int i = 0; i < classNames.length; i++) {
  69             argsList.add(classNames[i].replace('/', '.'));
  70         }
  71         String[] arguments = new String[argsList.size()];
  72         arguments = argsList.toArray(arguments);
  73         Testcommon.run(
  74             "--add-modules", "java.activation", "-Xbootclasspath/a:" + appJar,
  75             "DummyClassHelper", arguments[0], arguments[1])
  76           .assertNormalExit(output -> checkOutput(output, classNames));
  77 
  78         JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
  79         String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
  80         String bootClassPath = "-Xbootclasspath/a:" + appJar +
  81             File.pathSeparator + whiteBoxJar;
  82         dumpOutput = TestCommon.dump(
  83             appJar, classNames, bootClassPath, "--add-modules", "java.activation");
  84         argsList.add("testWithWhiteBox");
  85         arguments = new String[argsList.size()];
  86         arguments = argsList.toArray(arguments);
  87         String[] opts = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
  88             "--add-modules", "java.activation", bootClassPath, "-Xlog:class+path=trace",
  89             "DummyClassHelper", arguments[0], arguments[1], arguments[2]};
  90         Testcommon.run(opts)
  91           .assertNormalExit(output -> checkOutput(output, classNames));
  92     }
  93 }
  94 


  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 Ensure that classes found in jimage takes precedence over classes found in -Xbootclasspath/a.
  28  * @requires vm.cds
  29  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  30  * @modules jdk.jartool/sun.tools.jar

  31  * @compile ../../test-classes/DummyClassHelper.java
  32  * @compile ../../test-classes/java/net/HttpCookie.jasm
  33  * @compile ../../../SharedArchiveFile/javax/annotation/processing/FilerException.jasm
  34  * @build sun.hotspot.WhiteBox
  35  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  36  * @run main DummyClassesInBootClassPath
  37  */
  38 
  39 import java.io.File;
  40 import java.util.List;
  41 import java.util.ArrayList;
  42 import jdk.test.lib.process.OutputAnalyzer;
  43 
  44 public class DummyClassesInBootClassPath {
  45     private static final String METHOD_NAME = "thisClassIsDummy()";
  46 
  47     static void checkOutput(OutputAnalyzer output, String[] classNames) throws Exception {
  48         for (int i = 0; i < classNames.length; i++) {
  49             String cn = classNames[i].replace('/', '.');
  50             TestCommon.checkExec(output,
  51                 "java.lang.NoSuchMethodException: " + cn + "." +
  52                 METHOD_NAME);
  53             output.shouldNotContain(cn + ".class should be in shared space.");
  54         }
  55     }
  56 
  57     public static void main(String[] args) throws Exception {
  58         String classNames[] = { "java/net/HttpCookie",
  59                                 "javax/annotation/processing/FilerException"};
  60         JarBuilder.build("dummyClasses", classNames[0], classNames[1]);
  61 
  62         String appJar = TestCommon.getTestJar("dummyClasses.jar");
  63         OutputAnalyzer dumpOutput = TestCommon.dump(
  64             appJar, classNames, "-Xbootclasspath/a:" + appJar);

  65         List<String> argsList = new ArrayList<String>();
  66         for (int i = 0; i < classNames.length; i++) {
  67             argsList.add(classNames[i].replace('/', '.'));
  68         }
  69         String[] arguments = new String[argsList.size()];
  70         arguments = argsList.toArray(arguments);
  71         TestCommon.run(
  72             "-Xbootclasspath/a:" + appJar,
  73             "DummyClassHelper", arguments[0], arguments[1])
  74           .assertNormalExit(output -> checkOutput(output, classNames));
  75 
  76         JarBuilder.build(true, "WhiteBox", "sun/hotspot/WhiteBox");
  77         String whiteBoxJar = TestCommon.getTestJar("WhiteBox.jar");
  78         String bootClassPath = "-Xbootclasspath/a:" + appJar +
  79             File.pathSeparator + whiteBoxJar;
  80         dumpOutput = TestCommon.dump(
  81             appJar, classNames, bootClassPath);
  82         argsList.add("testWithWhiteBox");
  83         arguments = new String[argsList.size()];
  84         arguments = argsList.toArray(arguments);
  85         String[] opts = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
  86             bootClassPath, "-Xlog:class+path=trace",
  87             "DummyClassHelper", arguments[0], arguments[1], arguments[2]};
  88         TestCommon.run(opts)
  89           .assertNormalExit(output -> checkOutput(output, classNames));
  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