API for determining the hash of a module

Ethan McCue ethan at mccue.dev
Mon Dec 16 02:12:05 UTC 2024


I am experimenting with making a package repository where modules are the
artifacts (bundled as JMODs) and not jars. In this context we lack
information about what version a particular module requires or what
provider to get that module from. What I *can* do is say "if you use this
java.base, you must use this java.xml" and so on, but given a two java.xml
modules I can't say without those hashes which one you are allowed to use
when constructing a "module set".

This is relevant also if someone uploads some of their own modules where
the hashes don't line up.

On Sat, Dec 14, 2024 at 12:20 AM Alan Bateman <alan.bateman at oracle.com>
wrote:

> On 14/12/2024 08:02, Ethan McCue wrote:
> > 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.
>
> The hashes you found are a JDK-specific feature so you there isn't a
> standard API exposed. Hashes are used to detect accidental mixing of
> tightly coupled modules from different builds, mostly at link time (as
> in the jlink tool). The jar tool can generate hashes too so it is
> possible to have hashes for tightly coupled modules that are packaged as
> modular JAR files, and have the hashes checked at runtime.
>
> I wouldn't expect programs to interact with modules hashes so I'm
> curious what you are doing.
>
> -Alan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20241215/bbd2134a/attachment-0001.htm>


More information about the core-libs-dev mailing list