-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8322657: CDS filemap fastdebug assert while loading Graal CE Polyglot…
… in isolated classloader Reviewed-by: dholmes Backport-of: 841ab487f83d7e3639d352e796dc7131310c2390
- Loading branch information
1 parent
60c68a1
commit f9f7a27
Showing
6 changed files
with
188 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/ModularJarWithNonExistentJar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Copyright (c) 2024, 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. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
/** | ||
* @test | ||
* @bug 8322657 | ||
* @summary This test defines an application module using the DefineModuleApp. | ||
* When performing dynamic dump, the modular jar containing the module | ||
* is in the -cp. The jar listed in the "Class-Path" attribute of the modular | ||
* jar doesn't exist. VM should not crash during dynamic dump under this scenario. | ||
* @requires vm.cds | ||
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds | ||
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes | ||
* @build jdk.test.whitebox.WhiteBox DefineModuleApp | ||
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox | ||
* @run driver jdk.test.lib.helpers.ClassFileInstaller -jar define_module_app.jar DefineModuleApp | ||
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. ModularJarWithNonExistentJar | ||
*/ | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import jdk.test.lib.cds.CDSTestUtils; | ||
import jdk.test.lib.helpers.ClassFileInstaller; | ||
|
||
public class ModularJarWithNonExistentJar extends DynamicArchiveTestBase { | ||
private static final Path USER_DIR = Paths.get(CDSTestUtils.getOutputDir()); | ||
|
||
private static final String TEST_SRC = System.getProperty("test.src"); | ||
|
||
private static final Path SRC_DIR = Paths.get(TEST_SRC, "../jigsaw/modulepath/src"); | ||
private static final Path MODS_DIR = Paths.get("mods"); | ||
private static final Path MANIFEST_PATH = Paths.get(TEST_SRC, "test-classes/manifest-with-non-existent-jar.txt"); | ||
|
||
// the module name of the test module | ||
private static final String TEST_MODULE = "com.simple"; | ||
|
||
// the module main class | ||
private static final String MAIN_CLASS = "com.simple.Main"; | ||
|
||
private static Path moduleDir = null; | ||
private static Path modularJar = null; | ||
|
||
public static void buildTestModule() throws Exception { | ||
|
||
// javac -d mods/$TESTMODULE --module-path MOD_DIR src/$TESTMODULE/** | ||
JarBuilder.compileModule(SRC_DIR.resolve(TEST_MODULE), | ||
MODS_DIR.resolve(TEST_MODULE), | ||
MODS_DIR.toString()); | ||
|
||
|
||
moduleDir = Files.createTempDirectory(USER_DIR, "mlib"); | ||
|
||
modularJar = moduleDir.resolve(TEST_MODULE + ".jar"); | ||
String classes = MODS_DIR.resolve(TEST_MODULE).toString(); | ||
JarBuilder.createModularJarWithManifest(modularJar.toString(), classes, | ||
MAIN_CLASS, MANIFEST_PATH.toString()); | ||
} | ||
|
||
public static void main(String... args) throws Exception { | ||
runTest(ModularJarWithNonExistentJar::testDefaultBase); | ||
} | ||
|
||
static void testDefaultBase() throws Exception { | ||
String topArchiveName = getNewArchiveName("top"); | ||
doTest(topArchiveName); | ||
} | ||
|
||
private static void doTest(String topArchiveName) throws Exception { | ||
// compile the module and create the modular jar file | ||
buildTestModule(); | ||
String appJar = ClassFileInstaller.getJarPath("define_module_app.jar"); | ||
dump(topArchiveName, | ||
"-Xlog:cds,class+path=info", | ||
"-Xlog:cds+dynamic=debug", | ||
"-cp", appJar + File.pathSeparator + modularJar.toString(), | ||
"DefineModuleApp", moduleDir.toString(), TEST_MODULE) | ||
.assertNormalExit(output -> { | ||
output.shouldContain("Written dynamic archive 0x"); | ||
}); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/DefineModuleApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (c) 2024, 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. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
/** | ||
* This app defines a module using the ModuleLayer.defineModulesWithOneLoader API | ||
* which calls the JVM_DefineModule. | ||
**/ | ||
|
||
import java.nio.file.Path; | ||
import java.lang.ModuleLayer.Controller; | ||
import java.lang.module.*; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class DefineModuleApp { | ||
public static void main(String[] args) throws Throwable { | ||
if (args.length != 2) { | ||
throw new RuntimeException("DefineModuleApp expects 2 args but saw " + args.length); | ||
} | ||
final Path MODS = Path.of(args[0]); | ||
final String MODULE_NAME = args[1]; | ||
Configuration cf = ModuleLayer.boot() | ||
.configuration() | ||
.resolve(ModuleFinder.of(), ModuleFinder.of(MODS), Set.of(MODULE_NAME)); | ||
ResolvedModule m = cf.findModule(MODULE_NAME).orElseThrow(); | ||
ModuleLayer bootLayer = ModuleLayer.boot(); | ||
ClassLoader scl = ClassLoader.getSystemClassLoader(); | ||
Controller controller = ModuleLayer.defineModulesWithOneLoader(cf, List.of(bootLayer), scl); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...t/jtreg/runtime/cds/appcds/dynamicArchive/test-classes/manifest-with-non-existent-jar.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Manifest-Version: 1.0 | ||
Class-Path: NonExistent.jar | ||
Created-By: 23-internal (Oracle Corporation) |