Hi all, Not sure if this is best for core-libs or langtools, but best I can tell there is no way to determine the hash of a module programmatically.
Hashes of dependent modules are recorded in JMOD files jmod describe jdks/aarch64_windows/jmods/java.base.jmod java.base@23.0.1 .... platform linux-ppc64le hashes java.datatransfer SHA-256 e9cac9cb3758d80a42e814cc0a03e5f34b511491b5f5542da1ccff6fbc4c8ac8 hashes java.desktop SHA-256 342b94944765b78932de60aaf9e47811f23d60461c7014557e84ca1d6f6c135d hashes java.instrument SHA-256 e238b7968a4a2cf233781def3a5c18e5ba828a077de47adb0524ac07d16289d4 hashes java.logging SHA-256 0702fb1772a4afc72ed95c834075ee608eff8ba8c501efc6520b457ac9ae2560 hashes java.management SHA-256 e61678895158866416322cb814b2425334374879cfb42d2201f8959a20a6568a ... But simply SHA-256ing the JMODs of these modules will not yield these hashes. Best I can gather, this functionality is only in a private API. https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/module/ModuleHashes.java#L111 If I try to replicate it with my own ModuleReferences I quickly run into "jmods cannot be used at run time" errors. https://github.com/openjdk/jdk/blob/a6277bb521e07e569cd75a4641b2a05a26f47b0a/src/java.base/share/classes/jdk/internal/module/ModulePath.java#L137-L141 Is there an API I am missing or at least documentation of how exactly these hashes are computed in a way I can replicate?