On Tue, 29 Oct 2024 20:43:16 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:
> 
>   Fix bug in filtering out -Wl,--exclude-libs,ALL

I finally noticed that you are testing a precompiled HelloWorld class, and I 
have been running with a source file argument to have java compile it on the 
fly.

When I try using a pre-compiled HelloWorld, the linux port works for me too.

@jianglizhou Can you please verify if you can run this with a .java file 
directly? To be clear: this works fine on my mac with this PR, and (as I said), 
I'm pretty certain it used to work at least at some point during development on 
this PR.


ihse@sthihse:/localhome/git/jdk-ALT$ cat > HelloWorld.java
public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, world!");
  }
}
ihse@sthihse:/localhome/git/jdk-ALT$ javac HelloWorld.java 
ihse@sthihse:/localhome/git/jdk-ALT$ 
./build/linux-x64/images/static-jdk/bin/java HelloWorld 
Hello, world!
ihse@sthihse:/localhome/git/jdk-ALT$ 
./build/linux-x64/images/static-jdk/bin/java HelloWorld.java
Error: Unable to load main class com.sun.tools.javac.launcher.SourceLauncher in 
module jdk.compiler
Caused by: java.lang.UnsatisfiedLinkError: no jimage in system library path: 
/localhome/git/jdk-ALT/build/linux-x64/images/static-jdk/bin
Runtime.exit(1) logging failed: Could not initialize class 
jdk.internal.module.SystemModuleFinders$SystemImage
ihse@sthihse:/localhome/git/jdk-ALT$

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

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

Reply via email to