RFR(S): 8240734: ModuleHashes attribute not reproducible between builds

Yangfei (Felix) felix.yang at huawei.com
Thu Mar 12 07:32:48 UTC 2020

Hi Alan,

> -----Original Message-----
> From: Alan Bateman [mailto:Alan.Bateman at oracle.com]
> Sent: Wednesday, March 11, 2020 3:03 PM
> To: Yangfei (Felix) <felix.yang at huawei.com>; core-libs-dev at openjdk.java.net
> Subject: Re: RFR(S): 8240734: ModuleHashes attribute not reproducible
> between builds
> On 11/03/2020 01:11, Yangfei (Felix) wrote:
> > Thanks for reviewing this.  Pushed.
> Okay but I think we need to add a test for this. Can you look at
> JLinkReproducibleTest and see if it can be extended to use
> --keep-packaged-modules so that you have the JMOD files in the run-time
> image.

I looked into the JLinkReproducibleTest.
There are only two modules contained in lib/modules of the image: main and java.base. 
I changed the test specifying --keep-packaged-modules: 
diff -r 8c5697ed51b2 test/jdk/tools/jlink/JLinkReproducibleTest.java
--- a/test/jdk/tools/jlink/JLinkReproducibleTest.java   Wed Mar 11 08:34:14 2020 +0100
+++ b/test/jdk/tools/jlink/JLinkReproducibleTest.java   Thu Mar 12 15:30:45 2020 +0800
@@ -49,6 +49,8 @@
             "--module-path", JMODS_DIR.toString() + File.pathSeparator + CLASS_DIR.toString(),
             "--add-modules", "main",
+            "--keep-packaged-modules",
+            image.resolve("jmods").toString(),
             "--output", image.toString()

One extra java.base.jmod file will be emitted for each image created: 

These jmod files are the same with the one located in the JDK install directory.  
The ModuleHashes attribute is written in java.base.jmod file when building JDK.  
So the java.base.jmod will always be the same for each run of the JLinkReproducibleTest.  
Maybe I missed something? Could you please say something more on how extending the test?  


More information about the core-libs-dev mailing list