-
Notifications
You must be signed in to change notification settings - Fork 327
Handle --jvm
flag in process with JNI instantiated JVM
#12843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
--jvm
flag in process with JNI instantiated JVM
aa4dae1
to
1efcc8f
Compare
Now the problem is in executing Generic_JDBC_Tests - e.g. the switch to JVM mode isn't yet working correctly:
Unsatisfied link problem on Linux (update on May 7, 2025: got it working after removing java.desktop module from native image). We have linkage problem on Windows:
Update on May 2, 2025: the Windows version works on GraalVM for JDK21, but not on any newer version! |
LinuxTrying to isolate the
looks like the set of enabled modules is the cause of the problem! With: diff --git build.sbt build.sbt
diff --git build.sbt build.sbt
index bbdeef42ce..00f114fa64 100644
$ git diff
diff --git build.sbt build.sbt
diff --git build.sbt build.sbt
index bbdeef42ce..764f9bf079 100644
--- build.sbt
+++ build.sbt
@@ -3912,7 +3912,7 @@ lazy val `engine-runner` = project
val NI_MODULES =
"org.graalvm.nativeimage,org.graalvm.nativeimage.builder,org.graalvm.nativeimage.base,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto,com.oracle.graal.graal_enterprise,com.oracle.svm.svm_enterprise"
val JDK_MODULES =
- "java.desktop,java.naming,java.net.http,jdk.charsets,jdk.crypto.ec,jdk.localedata,jdk.httpserver,java.rmi"
+ "java.naming,java.net.http,jdk.charsets,jdk.crypto.ec,jdk.localedata,jdk.httpserver,java.rmi"
val DEBUG_MODULES = "jdk.jdwp.agent"
val PYTHON_MODULES = "jdk.security.auth,java.naming" it is possible to execute enso$ ./built-distribution/enso-engine-*/enso-*/bin/enso --jvm --run test/Base_Tests after building native image executable with |
…al, not JNA anymore
|
||
@Override | ||
public List<String> getLibraries() { | ||
return List.of("jvm"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This may be the core cause of [Native Image] Dynamic loading of
jvm.dll
doesn't link - regression since GraalVM21? oracle/graal#11152 - the
jvm.lib
orjvm.obj
then appears multiple times in the linkage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Let's see if it works in da05d8d!?
- Use the generated executable JaroslavTulach/LaunchJdkViaJni#3 indicates it could work
), | ||
assemblyMergeStrategy := { case _ => | ||
MergeStrategy.preferProject | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the commit 967e2ce starts with following idea
- define
poi-wrapper
fat JAR - use that
poi-wrapper
instd-table
instead of direct dependecy on poi - make sure the
poi-wrapper
contains the necessary patches to avoid dependency onjava.desktop
- I was hoping to find inspiration at Updating snakeyaml and removing no longer needed patches #11207 - but it doesn't define reusable fat JAR either!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- done by @Akirathan at 179aff3
- thank you - it's a complicated change - I could never do it myself
- but the CI is green!
- finally we can move pass this JNI struggle...
private static Map<Integer, HSSFColor> indexHash; | ||
private static Map<HSSFColorPredefined, HSSFColor> enumList; | ||
|
||
private final int index; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Patches to avoid dependency on
java.desktop
by Apache POI - proposal sent to upstream project
- once it is integrated
- let's switch to new POI version and remove this copy of
HSSFColor
!
…ar, not other poi jars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I understand it correctly, all the Standard Library Tests (jvm) use the new launch-in-the-same-process technique?
lib/java/os-environment/src/main/java/org/enso/os/environment/jni/JVM.java
Outdated
Show resolved
Hide resolved
lib/java/os-environment/src/main/java/org/enso/os/environment/jni/JVM.java
Outdated
Show resolved
Hide resolved
lib/java/os-environment/src/main/java/org/enso/os/environment/jni/JVM.java
Outdated
Show resolved
Hide resolved
lib/java/os-environment/src/main/java/org/enso/os/environment/jni/PosixJVM.java
Outdated
Show resolved
Hide resolved
lib/java/os-environment/src/main/java/org/enso/os/environment/jni/WindowsJVM.java
Outdated
Show resolved
Hide resolved
This change is already present in this Nightly Release:
These values should be smaller, because we removed |
Decreasing the maximum expected NI size of Linux by 30 MB. The new sizes (as reported in #12843 (comment)): - [Linux](https://github.com/enso-org/enso/actions/runs/14951454883/job/42001442578#step:10:3067) **404MB** - [MacOSX Arm](https://github.com/enso-org/enso/actions/runs/14951454883/job/42001442393#step:10:3076) **392MB** - [MacOSX Intel](https://github.com/enso-org/enso/actions/runs/14951454883/job/42001442260#step:10:2883) **377MB** - [Windows](https://github.com/enso-org/enso/actions/runs/14951454883/job/42001442715#step:10:3129) **390MB**
Fixes #12842 by designing a _JNI OS environment_, providing its implementations for supported platforms and using it to handle `--jvm` flag. All the _Standard Library Tests (jvm)_ use this new launch-in-the-same-process technique.
Decreasing the maximum expected NI size of Linux by 30 MB. The new sizes (as reported in #12843 (comment)): - [Linux](https://github.com/enso-org/enso/actions/runs/14951454883/job/42001442578#step:10:3067) **404MB** - [MacOSX Arm](https://github.com/enso-org/enso/actions/runs/14951454883/job/42001442393#step:10:3076) **392MB** - [MacOSX Intel](https://github.com/enso-org/enso/actions/runs/14951454883/job/42001442260#step:10:2883) **377MB** - [Windows](https://github.com/enso-org/enso/actions/runs/14951454883/job/42001442715#step:10:3129) **390MB**
Pull Request Description
Fixes #12842 by designing a JNI OS environment, providing its implementations for supported platforms and using it to handle
--jvm
flag. All the Standard Library Tests (jvm) use this new launch-in-the-same-process technique.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,