RFR: 8347755: Support static library in jmod [v6]

Jiangli Zhou jiangli at openjdk.org
Fri Apr 18 00:37:49 UTC 2025


On Fri, 18 Apr 2025 00:09:14 GMT, Henry Jen <henryjen at openjdk.org> wrote:

> > The default Java launcher `main.o` (and packaged as `liblauncher` static library) is produced by https://github.com/openjdk/jdk/blob/ad7c475fb1e23f583a33d58f0bd73ea0fb56740c/make/modules/java.base/Launcher.gmk#L39:
> > ```
> > $(eval $(call SetupBuildLauncher, java, \
> >     ENABLE_ARG_FILES := true, \
> >     EXPAND_CLASSPATH_WILDCARDS := true, \
> >     EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \
> >     VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
> >     OPTIMIZATION := HIGH, \
> > ))
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > That should be used to link the launcher executable when jlink creates the final image, if no custom launcher is used.
> > With the https://github.com/openjdk/leyden/blob/hermetic-java-runtime/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/LinkHermeticImagePlugin.java prototype, we could pass additional linking flags to to form the complete native linking command (when integrating with the static .jmod support). With with that, I think we can pass the default `liblauncher.a` as part of the extra linking flags. Then, that may help simplify things for us by not having to include `liblauncher` in `java.base` static .jmod and not have to deal with optionally using the default `liblauncher` from the .jmod for linking. We could go with that.
> > The default launcher and custom launcher would be handled similarly then, by passing via the extra linking flag.
> 
> Yes, that's just for the `java` launcher. If that's the only executable for java.base static mod targeted for. `javaw` would be another executable in java.base, so we will need another one for that. 

`javaw` is Windows only, right? It would only need to be included for Windows build. 

> Regard to other executable, this approach would expect they would need to build a separate lib in their own corresponding static jmod to link with.

Yes. Or they could just directly pass the user supplied static libraries or .o files to jlink via the extra linking flag.

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

PR Comment: https://git.openjdk.org/leyden/pull/46#issuecomment-2814259013


More information about the leyden-dev mailing list