Hermetic Java (static image packaging/formatting) investigation and proposal
Florian Weimer
fweimer at redhat.com
Mon Feb 13 09:58:43 UTC 2023
* Jiangli Zhou:
> 1. The executable image (see slide #10 ofa [1]) consists of three
> sections: the ELF executable section (see slide #14), the JDK runtime
> section (see slide #20, #21) and the JAR section (see slide #22).
These sections are not ELF sections, right?
> 2. The Java launcher executable is statically linked with Hotspot/JDK
> natives and application JNI natives (see slide #15 - #18).
Doesn't this make the resulting executable non-distributable in almost
all cases, for licensing reasons? (Hotspot is under the GPL, version 2,
most open-source Java libraries use the Apache license, version 2.0, and
those two are generally considered incompatible.) At least for those
developers who do not have special licensing arrangements with Oracle
and thus receive OpenJDK under the default terms (including the assembly
exception, but it doesn't seem to help here because it only extends to
OpenJDK components).
[from further down the thread]
> Yeah, the loadLibrary and friends need to be able look up built-in
> libraries in the executable (within the image ELF section). The
> existing JDK code is already able to handle built-in libraries
> (partially). Please see more details for built-in native support in
> earlier comments.
I believe that will require a custom glibc patch that has not been
upstreamed. I think Google's approach is here:
<https://sourceware.org/git/?p=glibc.git;a=blob;f=dlfcn/dlopen.c;h=faf7a48ea71df186b3581235bffcc7a3692f1325;hb=refs/heads/google/grte/v5-2.27/master#l95>
The offset argument is then threaded through the entire code, e.g.:
<https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/dl-open.c;h=178270ca1554c1a81db794fb110a962693839887;hb=refs/heads/google/grte/v5-2.27/master#l539>
There is a different proposed glibc interface for this:
[PATCH v2 2/2] dlfcn,elf: implement dlmem() function [BZ #11767]
<https://sourceware.org/pipermail/libc-alpha/2023-February/145476.html>
Maybe you could check if that interface could serve your needs as well?
Thanks,
Florian
More information about the leyden-dev
mailing list