[External] : Re: Trying to build j-extract on Linux throws "java.lang.module.FindException: Module jdk.compiler not found"

Sundararajan Athijegannathan sundararajan.athijegannathan at oracle.com
Fri Sep 23 08:46:21 UTC 2022


Hi,

java command listing a module just means that module is linked in that jdk and you can use classes from that module from your java code.

For example, if I use "java" launcher from jextract image, I get the following:


./java --list-modules

java.base at 19

java.compiler at 19

jdk.compiler at 19

jdk.zipfs at 19

org.openjdk.jextract at 19


But this does not mean that the .jmod files of above modules are available in that jdk. For example, in jextract jdk image, there are no .jmod files.

jlink uses those jmod files of the modules being linked.  jlink tries to find the jmods needed from either --module-path passed or from the underlying jdk from which you're running jlink tool.

You may want to check out $JAVA_HOME/jmods/ folder where JAVA_HOME is the jdk from which you are running jlink tool. That folder should contain jdk.compiler.jmod, jdk.zipfs.jmod and so on.

Hope this helps,
-Sundar
________________________________
From: Gavin Ray <ray.gavin97 at gmail.com>
Sent: 22 September 2022 22:58
To: Sundararajan Athijegannathan <sundararajan.athijegannathan at oracle.com>
Cc: panama-dev at openjdk.org <panama-dev at openjdk.org>
Subject: Re: [External] : Re: Trying to build j-extract on Linux throws "java.lang.module.FindException: Module jdk.compiler not found"

I used Gradle 8.0 nightly to get around the classfile issue, though the error unfortunately wasn't from the gradle build
but instead directly from running jlink in JDK20 =(

I run "jdk20/jdk/bin/jlink" with the same commands as the gradle build does manually and I get this
Should I file an issue somewhere about jlink?

[user at MSI ]$ jdk-20-panama/jdk/bin/jlink \
  --module-path=~/projects/jextract-panama-upstream/build/jmods \
  --add-modules=org.openjdk.jextract,jdk.compiler,jdk.zipfs \
  --output=~/projects/jextract-panama-upstream/build/jextract \
  --launcher=jextract=org.openjdk.jextract/org.openjdk.jextract.JextractTool \
  --add-options '"--enable-native-access=org.openjdk.jextract" "--enable-preview"'

java.lang.module.FindException: Module jdk.compiler not found
        at java.base/java.lang.module.Resolver.findFail(Resolver.java:892)
        at...

[user at MSI ]$ jdk-20-panama/jdk/bin/java --list-modules | grep jdk.compiler
jdk.compiler file:///home/user/downloads/jdk-20-panama-sourcebuilt/jdk/modules/jdk.compiler/

On Wed, Sep 21, 2022 at 10:45 PM Sundararajan Athijegannathan <sundararajan.athijegannathan at oracle.com<mailto:sundararajan.athijegannathan at oracle.com>> wrote:
Gradle 7.5.1 supports only up to jdk 18.


  1.  You may need to set JAVA_HOME to point to the latest version of java supported by Gradle version that you use.

   2.  Pass -Pjdk19_home to be jdk 19 installation from https://jdk.java.net/19/<https://urldefense.com/v3/__https://jdk.java.net/19/__;!!ACWV5N9M2RV99hQ!K-OgL0LfEuRDdjsxMViprRj1Z86KNdDBH6Ex_fvCJL11ONtDXD8G-0aQwx0qpd7ZHRrzIBdzCd7ffh8R2mVuflYVPHByST5Myw$> to build it.


  *

If you want to build jextract that works with the latest panama API from panama repo, then

   1. Set JAVA_HOME to point to your Gradle compatible java
      2. build jdk from panama-foreign repo's

  foreign-memaccess+abi branch.

   3. In jextract repo, check out "panama" branch.

   4. Pass -Pjdk20_home to gradle build (pointing to  panama build)



Hope this helps,

-Sundar


________________________________
From: Gavin Ray <ray.gavin97 at gmail.com<mailto:ray.gavin97 at gmail.com>>
Sent: 21 September 2022 22:08
To: Sundararajan Athijegannathan <sundararajan.athijegannathan at oracle.com<mailto:sundararajan.athijegannathan at oracle.com>>
Cc: panama-dev at openjdk.org<mailto:panama-dev at openjdk.org> <panama-dev at openjdk.org<mailto:panama-dev at openjdk.org>>
Subject: [External] : Re: Trying to build j-extract on Linux throws "java.lang.module.FindException: Module jdk.compiler not found"

Well the above worked for JDK 19, though now I am trying to build from the "panama" branch which includes API changes from JDK 20

I built Panama OpenJDK from source, and got the same issue. It's very strange:

[user at MSI ]$ /home/user/downloads/jdk-20-panama-sourcebuilt/jdk/bin/jlink \
  --module-path=/home/user/projects/jextract-panama-upstream/build/jmods \
  --add-modules=org.openjdk.jextract,jdk.compiler,jdk.zipfs \
  --output=/home/user/projects/jextract-panama-upstream/build/jextract \
  --launcher=jextract=org.openjdk.jextract/org.openjdk.jextract.JextractTool \
  --add-options '"--enable-native-access=org.openjdk.jextract" "--enable-preview"'
Error: Module jdk.compiler not found

java.lang.module.FindException: Module jdk.compiler not found
        at java.base/java.lang.module.Resolver.findFail(Resolver.java:892)
        at...

[user at MSI ]$ /home/user/downloads/jdk-20-panama-sourcebuilt/jdk/bin/java --list-modules | grep jdk.compiler
jdk.compiler file:///home/user/downloads/jdk-20-panama-sourcebuilt/jdk/modules/jdk.compiler/

On Tue, Sep 20, 2022 at 11:53 PM Gavin Ray <ray.gavin97 at gmail.com<mailto:ray.gavin97 at gmail.com>> wrote:
Thanks for the swift reply Sundararajan,

Running this seems to produce one output, it looks like something is there:

[user at MSI] $ /usr/lib/jvm/java-19-openjdk-19.0.0.0.36-2.rolling.fc38.x86_64/bin/java --list-modules | grep jdk.compiler
jdk.compiler at 19

Where the output line is "jdk.compiler at 19"

[image.png]

It's not so much a big deal, I installed JDK 17 and used that as the Gradle compiler and it worked
Probably it is something I am doing wrong and not worth investing time into

I have written a Dockerfile that builds jextract from source and allows you to use it without installing anything
It is late here so I haven't had time to test it yet, but I will double-check it tomorrow and submit it as a PR to repo so folks can use this if they want:

https://gist.github.com/GavinRay97/45365bf3b7d49ae335c525ffd51605c4<https://urldefense.com/v3/__https://gist.github.com/GavinRay97/45365bf3b7d49ae335c525ffd51605c4__;!!ACWV5N9M2RV99hQ!NB6BSgz6WT2DrbrHX1HyXvOyFBIy6Nexl3Y93Kv2K03HKb1mF22uDXLR7g_AmKCvU-1vS1UAuuD6SfflaMamAXQ7IQIAfpjSiw$>

Then anyone can run jextract like:
docker run --rm -it jextract:v0.x <flags>

=)


On Tue, Sep 20, 2022 at 11:36 PM Sundararajan Athijegannathan <sundararajan.athijegannathan at oracle.com<mailto:sundararajan.athijegannathan at oracle.com>> wrote:
Hi,

I just checked with Oracle jdk19 installation + jextract repo's master branch. Build/verify worked as expected on mac.

From the error message you posted, it seems "jdk.compiler" module is missing in your jdk19 installation. jextract needs jdk.compiler module to compile the extracted Java sources to produce .class files.

Will you please check if the following command prints "jdk.compiler"?

/usr/lib/jvm/java-19-openjdk-19.0.0.0.36-2.rolling.fc38.x86_64/bin/java --list-modules | grep jdk.compiler

For example, in my case


$ /Library/Java/JavaVirtualMachines/jdk-19.jdk/Contents/Home/bin/java \

>   --list-modules | grep jdk.compiler

jdk.compiler at 19


If not, that installation may be missing compiler module (perhaps generated by jlink invocation). Solution is to install a full JDK 19.


Hope this helps,

-Sundar




________________________________
From: panama-dev <panama-dev-retn at openjdk.org<mailto:panama-dev-retn at openjdk.org>> on behalf of Gavin Ray <ray.gavin97 at gmail.com<mailto:ray.gavin97 at gmail.com>>
Sent: 21 September 2022 07:35
To: panama-dev at openjdk.org<mailto:panama-dev at openjdk.org> <panama-dev at openjdk.org<mailto:panama-dev at openjdk.org>>
Subject: Trying to build j-extract on Linux throws "java.lang.module.FindException: Module jdk.compiler not found"

Hello all,

I'm trying to generate jextract types for io_uring (I didn't find any non-JNI/JNA libraries to use it from JVM)
Unfortunately, following the instructions I've hit a snag.

Building it with JDK 19, I get:
=============================================
[user at MSI jextract]$ sh ./gradlew \
-Pjdk19_home=/usr/lib/jvm/java-19-openjdk-19.0.0.0.36-2.rolling.fc38.x86_64 \
-Pllvm_home=/home/user/downloads/clang+llvm-15.0.0-aarch64-linux-gnu clean verify

> Task :compileJava
Note: Some input files use preview features of Java SE 19.
Note: Recompile with -Xlint:preview for details.

> Task :createJextractImage FAILED
Error: Module jdk.compiler not found
java.lang.module.FindException: Module jdk.compiler not found
        at java.base/java.lang.module.Resolver.findFail(Resolver.java:892)
        at java.base/java.lang.module.Resolver.resolve(Resolver.java:129)
        at java.base/java.lang.module.Configuration.resolve(Configuration.java:420)
        at java.base/java.lang.module.Configuration.resolve(Configuration.java:254)
        at jdk.jlink/jdk.tools.jlink.internal.Jlink$JlinkConfiguration.resolve(Jlink.java:217)
        at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImageProvider(JlinkTask.java:536)
        at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.createImage(JlinkTask.java:424)
        at jdk.jlink/jdk.tools.jlink.internal.JlinkTask.run(JlinkTask.java:276)
        at jdk.jlink/jdk.tools.jlink.internal.Main.run(Main.java:56)
        at jdk.jlink/jdk.tools.jlink.internal.Main.main(Main.java:34)
=============================================

Would it make sense to add a Dockerfile for Linux to the repo that can reliably build the latest version?
That way folks don't have to mess around with finding and installing LLVM and whatnot.

I'm happy to submit a PR for this if someone can tell me why the regular build command is failing, ha.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20220923/2544c4d1/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 83028 bytes
Desc: image.png
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20220923/2544c4d1/image-0001.png>


More information about the panama-dev mailing list