RFR: 8352435: Refactor CDS test library for execution and module packaging [v2]

Calvin Cheung ccheung at openjdk.org
Wed Mar 26 17:48:17 UTC 2025


On Wed, 19 Mar 2025 23:03:51 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> In CDS/AOT testing, we have a lot of code that deal with compiling/packaging modules, as well as running various child processes for the training/assembly/production phases.
>> 
>> Currently, these operations are done in many low-level steps, so it's difficult to understand and maintain:
>> 
>> https://github.com/openjdk/jdk/blob/fcc2a24291d499f7149debad1250903ddc369d91/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/modulepath/ExportModule.java
>> 
>> This PR adds a few new classes to simplify the test cases:
>> 
>> Example: build two modular JAR files into `modulePath`
>> 
>> 
>> CDSModulePackager modulePackager = new CDSModulePackager(SRC);
>> modulePath = modulePackager.getOutputDir().toString();
>> 
>> modulePackager.createModularJar("com.foos");
>> modulePackager.createModularJar("com.needsfoosaddexport",
>>                                 "--add-exports",
>>                                 "com.foos/com.foos.internal=com.needsfoosaddexport");
>> 
>> 
>> Example: use modules in training/assembly/production phases
>> 
>> 
>> SimpleCDSAppTester.of("moduleNeedsJdkAddExport")
>>    .classpath(dummyJar)
>>    .modulepath(modulePath)
>>    .addVmArgs("--add-modules", "com.needsjdkaddexport",
>>               "--add-exports", "java.base/jdk.internal.misc=com.needsjdkaddexport", "-Xlog:cds")
>>    .appCommandLine("-m", "com.needsjdkaddexport/com.needsjdkaddexport.Main")
>>    .setAssemblyChecker((OutputAnalyzer out) -> {
>>            out.shouldContain("Full module graph = enabled");
>>         })
>>     .setProductionChecker((OutputAnalyzer out) -> {
>>             out.shouldContain("use_full_module_graph = true; java.base");
>>         })
>>     .runStaticWorkflow()
>>     .runAOTWorkflow();
>
> Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
> 
>   added comments

Found some nits. Looks good otherwise.

test/lib/jdk/test/lib/cds/CDSJarUtils.java line 224:

> 222:             }
> 223:         }
> 224:         System.out.println();

Should this be printed only if DEBUG is enabled?

test/lib/jdk/test/lib/cds/CDSModulePackager.java line 28:

> 26: 
> 27: import java.io.File;
> 28: import java.nio.file.Files;

Unused import.

test/lib/jdk/test/lib/cds/CDSModulePackager.java line 33:

> 31: import jdk.test.lib.StringArrayUtils;
> 32: import jdk.test.lib.compiler.CompilerUtils;
> 33: import jdk.test.lib.util.FileUtils;

Unused import.

test/lib/jdk/test/lib/cds/SimpleCDSAppTester.java line 29:

> 27: import jdk.test.lib.Asserts;
> 28: import jdk.test.lib.cds.CDSTestUtils;
> 29: import jdk.test.lib.process.ProcessTools;

Unused import.

test/lib/jdk/test/lib/cds/SimpleCDSAppTester.java line 33:

> 31: import jdk.test.lib.StringArrayUtils;
> 32: import jdk.test.whitebox.WhiteBox;
> 33: import jtreg.SkippedException;

Unused import.

-------------

Marked as reviewed by ccheung (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/24122#pullrequestreview-2718081398
PR Review Comment: https://git.openjdk.org/jdk/pull/24122#discussion_r2014672929
PR Review Comment: https://git.openjdk.org/jdk/pull/24122#discussion_r2014678719
PR Review Comment: https://git.openjdk.org/jdk/pull/24122#discussion_r2014683065
PR Review Comment: https://git.openjdk.org/jdk/pull/24122#discussion_r2014699055
PR Review Comment: https://git.openjdk.org/jdk/pull/24122#discussion_r2014713064


More information about the hotspot-runtime-dev mailing list