test/hotspot/jtreg/runtime/appcds/jigsaw/overridetests/OverrideTests.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Cdiff test/hotspot/jtreg/runtime/appcds/jigsaw/overridetests/OverrideTests.java

test/hotspot/jtreg/runtime/appcds/jigsaw/overridetests/OverrideTests.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2015, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2015, 2018, 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.
*** 65,84 **** private static final String TEST_SRC = System.getProperty("test.src"); private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); private static final Path MODS_DIR = Paths.get("mods"); // the module that is upgraded ! private static final String[] UPGRADED_MODULES = {"jdk.compiler", "java.activation"}; private static final Path[] UPGRADEDMODS_DIR = {Paths.get("upgradedmod1"), Paths.get("upgradedmod2")}; // the test module private static final String TEST_MODULE = "test"; private static final String MAIN_CLASS = "jdk.test.Main"; // test classes to archive. These are both in UPGRADED_MODULES private static final String APP_ARCHIVE_CLASS = "com/sun/tools/javac/Main"; ! private static final String PLATFORM_ARCHIVE_CLASS = "javax/activation/UnsupportedDataTypeException"; private static final String[] ARCHIVE_CLASSES = {APP_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS}; private static String testArchiveName; public static void main(String[] args) throws Exception { --- 65,84 ---- private static final String TEST_SRC = System.getProperty("test.src"); private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); private static final Path MODS_DIR = Paths.get("mods"); // the module that is upgraded ! private static final String[] UPGRADED_MODULES = {"jdk.compiler", "java.net.http"}; private static final Path[] UPGRADEDMODS_DIR = {Paths.get("upgradedmod1"), Paths.get("upgradedmod2")}; // the test module private static final String TEST_MODULE = "test"; private static final String MAIN_CLASS = "jdk.test.Main"; // test classes to archive. These are both in UPGRADED_MODULES private static final String APP_ARCHIVE_CLASS = "com/sun/tools/javac/Main"; ! private static final String PLATFORM_ARCHIVE_CLASS = "java/net/http/HttpTimeoutException"; private static final String[] ARCHIVE_CLASSES = {APP_ARCHIVE_CLASS, PLATFORM_ARCHIVE_CLASS}; private static String testArchiveName; public static void main(String[] args) throws Exception {
*** 92,105 **** boolean compiled; // javac -d upgradedmods/$upgradedMod src/$upgradedMod/** int i = 0; for (String upgradedMod : UPGRADED_MODULES) { compiled = CompilerUtils.compile( ! SRC_DIR.resolve(upgradedMod), ! UPGRADEDMODS_DIR[i].resolve(upgradedMod) ); ! Asserts.assertTrue(compiled, upgradedMod + " did not compile"); i++; } // javac -d mods/test --upgrade-module-path upgradedmods ... compiled = CompilerUtils.compile( --- 92,105 ---- boolean compiled; // javac -d upgradedmods/$upgradedMod src/$upgradedMod/** int i = 0; for (String upgradedMod : UPGRADED_MODULES) { compiled = CompilerUtils.compile( ! SRC_DIR.resolve(UPGRADED_MODULES[i]), ! UPGRADEDMODS_DIR[i].resolve(UPGRADED_MODULES[i]) ); ! Asserts.assertTrue(compiled, UPGRADED_MODULES[i] + " did not compile"); i++; } // javac -d mods/test --upgrade-module-path upgradedmods ... compiled = CompilerUtils.compile(
*** 108,133 **** "--upgrade-module-path", UPGRADEDMODS_DIR[0].toString() + System.getProperty("path.separator") + UPGRADEDMODS_DIR[1].toString() ); Asserts.assertTrue(compiled, TEST_MODULE + " did not compile"); ! // the java.activation module is not defined by default; --add-modules is required. ! // dumping without "--add-modules java.activation" ! // the class in the javax.activation package cannot be found ! OutputAnalyzer output1 = TestCommon.dump(null /* appJar*/, TestCommon.list(ARCHIVE_CLASSES)); ! TestCommon.checkDump(output1); ! output1.shouldContain( ! "Preload Warning: Cannot find javax/activation/UnsupportedDataTypeException"); ! ! // dump the archive with jdk.comiler and java.activation classes in the class list ! // with "--add-modules java.activation" ! output1 = TestCommon.dump(null /* appJar*/, TestCommon.list(ARCHIVE_CLASSES), ! "--add-modules", "java.activation"); ! TestCommon.checkDump(output1); // Make sure all the classes where successfully archived. for (String archiveClass : ARCHIVE_CLASSES) { ! output1.shouldNotContain("Preload Warning: Cannot find " + archiveClass); } testArchiveName = TestCommon.getCurrentArchiveName(); } --- 108,124 ---- "--upgrade-module-path", UPGRADEDMODS_DIR[0].toString() + System.getProperty("path.separator") + UPGRADEDMODS_DIR[1].toString() ); Asserts.assertTrue(compiled, TEST_MODULE + " did not compile"); ! // dump the archive with jdk.comiler and jdk.incubator.httpclient classes in the class list ! // with "--add-modules jdk.incubator.httpclient" ! OutputAnalyzer output = TestCommon.dump(null /* appJar*/, TestCommon.list(ARCHIVE_CLASSES)); ! TestCommon.checkDump(output); // Make sure all the classes where successfully archived. for (String archiveClass : ARCHIVE_CLASSES) { ! output.shouldNotContain("Preload Warning: Cannot find " + archiveClass); } testArchiveName = TestCommon.getCurrentArchiveName(); }
*** 145,159 **** } /** * PLATFORM Class Overriding Tests * ! * Archive PLATFORM class javax.activation.UnsupportedDataTypeException from module jdk.activation. ! * -At run time, upgrade module jdk.activation using --upgrade-module-path. ! * Class.forname(UnsupportedDataTypeException) MUST NOT load the archived UnsupportedDataTypeException. ! * -At run time, module jdk.activation also exists in --module-path. ! * Class.forname(UnsupportedDataTypeException) MUST load the archived UnsupportedDataTypeException. */ public void testPlatformClassOverriding() throws Exception { testClassOverriding(PLATFORM_ARCHIVE_CLASS, "platform"); } --- 136,150 ---- } /** * PLATFORM Class Overriding Tests * ! * Archive PLATFORM class java.net.http.HttpTimeoutException from module java.net.http. ! * -At run time, upgrade module java.net.http using --upgrade-module-path. ! * Class.forname(HttpTimeoutException) MUST NOT load the archived HttpTimeoutException. ! * -At run time, module java.net.http also exists in --module-path. ! * Class.forname(HttpTimeoutException) MUST load the archived HttpTimeoutException. */ public void testPlatformClassOverriding() throws Exception { testClassOverriding(PLATFORM_ARCHIVE_CLASS, "platform"); }
*** 171,199 **** String expectedException = "java.lang.module.FindException: Unable to compute the hash"; String prefix[] = new String[4]; prefix[0] = "-cp"; prefix[1] = "\"\""; prefix[2] = "--add-modules"; ! prefix[3] = "java.activation"; // Run the test with --upgrade-module-path set to alternate location of archiveClass // The alternate version of archiveClass SHOULD be found. ! output = TestCommon.execModule( prefix, UPGRADEDMODS_DIR[upgradeModIdx].toString(), MODS_DIR.toString(), mid, archiveClass, loaderName, "true"); // last 3 args passed to test ! if (isAppLoader) { try { output.shouldContain(expectedException); } catch (Exception e) { TestCommon.checkCommonExecExceptions(output, e); } - } else { - TestCommon.checkExec(output); - } // Now run this same test again, but this time without AppCDS. Behavior should be the same. CDSOptions opts = (new CDSOptions()) .addPrefix(prefix) .setArchiveName(testArchiveName).setUseVersion(false) --- 162,188 ---- String expectedException = "java.lang.module.FindException: Unable to compute the hash"; String prefix[] = new String[4]; prefix[0] = "-cp"; prefix[1] = "\"\""; prefix[2] = "--add-modules"; ! prefix[3] = "java.net.http"; // Run the test with --upgrade-module-path set to alternate location of archiveClass // The alternate version of archiveClass SHOULD be found. ! CDSTestUtils.Result res = TestCommon.runWithModules( prefix, UPGRADEDMODS_DIR[upgradeModIdx].toString(), MODS_DIR.toString(), mid, archiveClass, loaderName, "true"); // last 3 args passed to test ! ! output = res.getOutput(); try { output.shouldContain(expectedException); } catch (Exception e) { TestCommon.checkCommonExecExceptions(output, e); } // Now run this same test again, but this time without AppCDS. Behavior should be the same. CDSOptions opts = (new CDSOptions()) .addPrefix(prefix) .setArchiveName(testArchiveName).setUseVersion(false)
*** 201,230 **** "-p", MODS_DIR.toString(), "-m", mid) .addSuffix(archiveClass, loaderName, "true"); output = CDSTestUtils.runWithArchive(opts); - if (isAppLoader) { try { output.shouldContain(expectedException); } catch (Exception e) { TestCommon.checkCommonExecExceptions(output, e); } - } else { - if (!CDSTestUtils.isUnableToMap(output)) - output.shouldHaveExitValue(0); - } // Run the test with -p set to alternate location of archiveClass. // The alternate version of archiveClass SHOULD NOT be found. ! output = TestCommon.execModule( prefix, null, UPGRADEDMODS_DIR[upgradeModIdx].toString() + java.io.File.pathSeparator + MODS_DIR.toString(), mid, archiveClass, loaderName, "false"); // last 3 args passed to test ! TestCommon.checkExec(output); // Now run this same test again, but this time without AppCDS. Behavior should be the same. opts = (new CDSOptions()) .addPrefix(prefix) .setArchiveName(testArchiveName).setUseVersion(false) --- 190,214 ---- "-p", MODS_DIR.toString(), "-m", mid) .addSuffix(archiveClass, loaderName, "true"); output = CDSTestUtils.runWithArchive(opts); try { output.shouldContain(expectedException); } catch (Exception e) { TestCommon.checkCommonExecExceptions(output, e); } // Run the test with -p set to alternate location of archiveClass. // The alternate version of archiveClass SHOULD NOT be found. ! res = TestCommon.runWithModules( prefix, null, UPGRADEDMODS_DIR[upgradeModIdx].toString() + java.io.File.pathSeparator + MODS_DIR.toString(), mid, archiveClass, loaderName, "false"); // last 3 args passed to test ! TestCommon.checkExec(res.getOutput()); // Now run this same test again, but this time without AppCDS. Behavior should be the same. opts = (new CDSOptions()) .addPrefix(prefix) .setArchiveName(testArchiveName).setUseVersion(false)
test/hotspot/jtreg/runtime/appcds/jigsaw/overridetests/OverrideTests.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File