Hi Alan,

> -----Original Message-----
> From: Alan Bateman [mailto:alan.bate...@oracle.com]
> Sent: Wednesday, March 11, 2020 3:03 PM
> To: Yangfei (Felix) <felix.y...@huawei.com>; core-libs-dev@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 @@
         cmd.addAll(List.of(
             "--module-path", JMODS_DIR.toString() + File.pathSeparator + 
CLASS_DIR.toString(),
             "--add-modules", "main",
+            "--keep-packaged-modules",
+            image.resolve("jmods").toString(),
             "--compress=2",
             "--output", image.toString()
         ));

One extra java.base.jmod file will be emitted for each image created: 
  image-second/jmods/java.base.jmod
  image-fourth/jmods/java.base.jmod
  image-third/jmods/java.base.jmod
  image-first/jmods/java.base.jmod

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?  

Thanks,
Felix

Reply via email to