RFR: 8264322: Generate CDS archive when creating custom JDK image [v2]

Mandy Chung mchung at openjdk.java.net
Fri Aug 20 02:07:25 UTC 2021


On Thu, 19 Aug 2021 23:59:32 GMT, Calvin Cheung <ccheung at openjdk.org> wrote:

>> src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/CDSPlugin.java line 121:
>> 
>>> 119:     @Override
>>> 120:     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
>>> 121:         in.transformAndCopy((file) -> {
>> 
>> This method should not be called in a post-processor.    Plugin API needs some re-thinking to support post-processor plugin.   As `Plugin::transform` is abstract method, for now this method should simply throw `UnsupportedOperationException`.
>
> It is being called. The minimal implementation is:
> 
> 
>     @Override
>     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
>         return in;
>     }
> 
> I've filed [JDK-8272734](https://bugs.openjdk.java.net/browse/JDK-8272743) to follow-up the issue.

Thanks for filing the issue.   I didn't expect `Plugin::transform` should be called.  This is a good workaround for now.

>> test/jdk/tools/jlink/plugins/CDSPluginTest.java line 80:
>> 
>>> 78:            String jlinkPath = JDKToolFinder.getJDKTool("jlink");
>>> 79:            String[] cmd = {jlinkPath, "--add-modules", "java.base,java.logging",
>>> 80:                            "-J-Dos.name=windows", "--generate-cds-archive",
>> 
>> Is there a better way of setting `os.name` system property on the command line?
>> 
>> Maybe override `ModuleTarget` attribute in module-info.class of java.base to be a different platform?
>
> I'd prefer to leave it as is for now since it's in a test case and I don't think the code is complex.

This is fragile by setting `os.name`.

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

PR: https://git.openjdk.java.net/jdk/pull/5174


More information about the hotspot-runtime-dev mailing list