On Tue, 15 Oct 2024 20:22:52 GMT, Magnus Ihse Bursie <i...@openjdk.org> wrote:

>> As a prerequisite for Hermetic Java, we need a statically linked `java` 
>> launcher. It should behave like the normal, dynamically linked `java` 
>> launcher, except that all JDK native libraries should be statically, not 
>> dynamically, linked.
>> 
>> This patch is the first step towards this goal. It will generate a 
>> `static-jdk` image with a statically linked launcher. This launcher is 
>> missing several native libs, however, and does therefore not behave like a 
>> proper dynamic java. One of the reasons for this is that local symbol hiding 
>> in static libraries are not implemented yet, which causes symbol clashes 
>> when linking all static libraries together. This will be addressed in an 
>> upcoming patch. 
>> 
>> All changes in the `src` directory are copied from, or inspired by, changes 
>> made in [the hermetic-java-runtime branch in Project 
>> Leyden](https://github.com/openjdk/leyden/tree/hermetic-java-runtime).
>
> Magnus Ihse Bursie has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Don't hardcode server variant

I tried to build/run this on Linux as well (since I'm using parts of this PR in 
https://github.com/openjdk/mobile/pull/30) and I noticed that the executable 
doesn't start (even with --version):

images/static-jdk/bin/java --version
Error: Failed , because images/static-jdk/bin/java: undefined symbol: 
JNI_CreateJavaVM

The `JNI_CreateJavaVM` symbol seems to be local only:

nm images/static-jdk/bin/java |grep JNI_CreateJ
0000000000e22430 t JNI_CreateJavaVM

Hence calling it with `dlsym` won't work. And indeed, that is how it is called 
from `./java.base/unix/native/libjli/java_md.c ` `(LoadJavaVM)`

dlsym(libjvm, "JNI_CreateJavaVM");

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20837#issuecomment-2431273631

Reply via email to