graal icon indicating copy to clipboard operation
graal copied to clipboard

Too heavyweight org.graalvm.shadowed.icu4j

Open JaroslavTulach opened this issue 9 months ago • 2 comments

Describe GraalVM and your environment :

  • GraalVM version or commit id if built from source: 21.0.2+13.1
  • CE or EE: CE
  • JDK version: JDK21.0.2
  • OS and OS Version: Ubuntu
  • Architecture: amd64
  • The output of java -Xinternalversion:
OpenJDK 64-Bit Server VM (21.0.2+13-jvmci-23.1-b30) for linux-amd64 JRE (21.0.2+13-jvmci-23.1-b30),
built on 2024-01-06T13:12:14Z by "buildslave" with gcc 11.2.0

Have you verified this issue still happens when using the latest snapshot?

Confirmed by a discussion on slack

Describe the issue

I am trying to find a minimal JDK to execute Enso programming language and environment on, I am using jlink. I am trying to get things down as much as I can, but Graal.js seems to need java.desktop! (via a transitive dependency thru regex):

java.lang.module.FindException: Module java.desktop not found, required by org.graalvm.shadowed.icu4j
$ rm ./built-distribution/enso-engine-0.0.0-dev-linux-amd64/enso-0.0.0-dev/component/icu4j-24.0.0.jar 
java.lang.module.FindException: Module org.graalvm.shadowed.icu4j not found, required by com.oracle.truffle.regex
$ rm ./built-distribution/enso-engine-0.0.0-dev-linux-amd64/enso-0.0.0-dev/component/regex-24.0.0.jar 
java.lang.module.FindException: Module com.oracle.truffle.regex not found, required by org.graalvm.js

E.g. org.graalvm.js needs com.oracle.truffle.regex and that one needs org.graalvm.shadowed.icu4j and that one needs java.desktop.

I assume the java.desktop dependency isn't necessary - maybe it can be made optional... can such a change be made in your build?

Steps to reproduce the issue

I am generating the minimal JDK as:

$ /graalvm/bin/jlink --output jdk --add-modules java.net.http,jdk.unsupported,java.sql,jdk.management,jdk.jfr
$ ./jdk/bin/java --list-modules
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

and then I'd like to invoke Graal.js and its components on the generated JVM. It fails with java.lang.module.FindException as shown above.

Expected behavior

java.desktop is a huge module and it shouldn't be needed for running Graal.js - having that fixed would allow using Graal.js & co. in headless JDKs without java.desktop & co. modules.

Additional context

I have discovered this problem while working on:

JaroslavTulach avatar May 08 '24 05:05 JaroslavTulach

I assume the java.desktop dependency isn't necessary - maybe it can be made optional... can such a change be made in your build?

A quick investigation shows it is only needed for one method in ICU4J: Bidi.setPara(AttributedCharacterIterator) (due to java.awt.font.TextAttribute and java.awt.font.NumericShaper), which I believe we don't use anywhere. So I think we could easily make the dependency on java.desktop optional (using requires static, or if that does not work for some reason, patch out the method).

Do you need this to be backported to 23.1.x, or is it enough to do this for 24.1 only?

woess avatar May 08 '24 13:05 woess

Suggested fix: https://github.com/oracle/graal/pull/8908. Let me know if you want to test this before merging @JaroslavTulach.

woess avatar May 10 '24 17:05 woess

Hello Andreas. Thanks for the #8908 fix, it looks good.

A quick investigation shows it is only needed for one method in ICU4J: Bidi.setPara(AttributedCharacterIterator) (due to java.awt.font.TextAttribute and java.awt.font.NumericShaper), which I believe we don't use anywhere. So I think we could easily make the dependency on java.desktop optional (using requires static, or if that does not work for some reason, patch out the method).

Yup, requires static in suite.py seems like the right fix.

Do you need this to be backported to 23.1.x, or is it enough to do this for 24.1 only?

We are trying to stay with the latest Truffle (but LTS JDK - e.g. 21), so having the fix in latest Truffle release is good enough for Enso.

JaroslavTulach avatar May 13 '24 03:05 JaroslavTulach

ok, so I assume this does not need to be backported, since you can use the latest version on LTS JDK. good.

woess avatar May 13 '24 16:05 woess