On Fri, 7 Nov 2025 00:46:44 GMT, Henry Jen <[email protected]> wrote:

>> This PR include build changes from @magicus and jlink change to verify the 
>> build signature.
>> 
>> Tested with local builds for MacOS and Linux as below shows that cross 
>> linking with same build is working while linking with different build failed 
>> with error message.
>> 
>> ❯ export 
>> JAVA_HOME=./build/macosx-x86_64-server-fastdebug/images/jdk-bundle/jdk-26.jdk/Contents/Home
>>                                                                              
>>                                                                              
>>        
>> ❯ java --version
>> openjdk 26-internal 2026-03-17
>> OpenJDK Runtime Environment (fastdebug build 
>> 26-internal-adhoc.hjen.JDK-8347831)
>> OpenJDK 64-Bit Server VM (fastdebug build 
>> 26-internal-adhoc.hjen.JDK-8347831, mixed mode, sharing)
>>                                                                              
>>                                                                              
>>        
>> ❯ jlink --version                                                            
>>            
>> 26-internal
>>                                                                              
>>                                                                              
>>        
>> ❯ jlink --module-path ./build/linux-x86_64-server-release/images/jdk/jmods 
>> --add-modules java.base --output linux                                       
>>                                                                              
>>                     
>>                                                                              
>>                                                                              
>>        
>> ❯ jlink --add-modules java.base --output macos
>>                                                             
>> ❯ jlink --module-path ~/linux/jdk-25.0.1/jmods --add-modules java.base 
>> --output linux25    
>> Error: jlink build N/A-26-internal-adhoc.hjen.JDK-8347831-2026-03-17 does 
>> not match target java.base build N/A
>>                                                                              
>>                                                                              
>>        
>> ❯ jlink --module-path 
>> /Library/Java/JavaVirtualMachines/jdk-25.jdk/Contents/Home/jmods 
>> --add-modules java.base --output macos25 
>> Error: jlink build N/A-26-internal-adhoc.hjen.JDK-8347831-2026-03-17 does 
>> not match target java.base build N/A
>
> Henry Jen has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Use release.txt from java.base module in current and target for comparison

The updated version is much simpler, thank you. Just a few small comments on 
the jlink changes.

> This PR include build changes from @magicus and jlink change to verify the 
> build signature.

In that case, you'll need to list Magnus (`/contributor` command).

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java line 245:

> 243:     public static final String OPTIONS_RESOURCE = 
> "jdk/tools/jlink/internal/options";
> 244:     // Release information as in the java.base module for target image
> 245:     public static final String JDK_RELEASE_RESOURCE = 
> "jdk/internal/jmod/resources/release.txt";

I assume this can be private.

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java line 256:

> 254:         }
> 255: 
> 256:         try (var r = new BufferedReader(new 
> InputStreamReader(in.get()))) {

It's not immediately obvious that `in` is an `Optional<InputStream>` , so maybe 
rename and/or avoid var for this case.

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java line 600:

> 598:             ModuleReference target = finder.find("java.base").get();
> 599:             String currentRelease = 
> getReleaseInfo(current).orElseThrow(() ->
> 600:                 new IllegalArgumentException("Cannot find release.txt"));

I assume this is an err.jlink.version.mismatch case too. The packaged version 
of java.base on the module path is missing the resource file so it must be an 
older version, hence a mismatch.

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java line 603:

> 601:             String targetRelease = getReleaseInfo(target).orElse("N/A");
> 602:             if (! currentRelease.equals(targetRelease)) {
> 603:                 // jlink version and java.base version do not match.

The comment could be clearer. It's a version mismatch between the current 
runtime and the target runtime image.

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java line 610:

> 608:             }
> 609:         } catch (NoSuchElementException e) {
> 610:             assert false : "Should have found java.base module";

I think you can drop the catching of NoSuchElementException, jlink should just 
fail if this were to happen.

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

PR Review: https://git.openjdk.org/jdk/pull/28155#pullrequestreview-3432931919
PR Comment: https://git.openjdk.org/jdk/pull/28155#issuecomment-3501891672
PR Review Comment: https://git.openjdk.org/jdk/pull/28155#discussion_r2502816169
PR Review Comment: https://git.openjdk.org/jdk/pull/28155#discussion_r2502693905
PR Review Comment: https://git.openjdk.org/jdk/pull/28155#discussion_r2502804031
PR Review Comment: https://git.openjdk.org/jdk/pull/28155#discussion_r2502808353
PR Review Comment: https://git.openjdk.org/jdk/pull/28155#discussion_r2502682900

Reply via email to