JImage missing in ToolProvider registration
Joerg Michelberger
j.michelberger at gmail.com
Mon Oct 20 19:48:58 UTC 2025
Hi there,
this is Jörg, the one who met Stuart Marks at Devoxx BE 2025.
We talked at Devoxx Antwerp about a flaw with the programmatic
accessibility of jimage in JDK21.
While it was with source/target 8 possible to compile and access the Main
of jlink/jimage/jmod, encapsulation with source/target 11 it is not. But
the intended new ToolProvider API which should make the three accessible in
a controlled way, lacks the Tool Registration of jimage.
Registration for jmod can be seen here:
https://github.com/openjdk/jdk/blob/master/src/jdk.jlink/share/classes/jdk/tools/jmod/Main.java#L53,
same for jlink. But jimage seems to be forgotten:
https://github.com/openjdk/jdk/blob/master/src/jdk.jlink/share/classes/jdk/tools/jimage/Main.java
.
IMHO it is trivial to add registration for the jimage in code and module
definition and it seems that it also could be almost riskless to be
backported to JDK25/17/11.
This would make me as the "nobody use that" user happy, because it feels so
bad to access this via ProcessBuilder and external process call.
Withdrawn ticket in OpenJDK is here:
https://bugs.openjdk.org/browse/JDK-8359429.
I already cloned the OpenJdk Github repo to provide a pull request to
provide the fix, but it seems I am not familiar enough with the
contribution process and so on.
As Stuart mentioned the question in the JDK-8359429 issue comment, I tried
the Chuck Norris --add-opens and also accessing JImageTask instead of its
Main class, but with no success.
And here is a hint for the question in the issue comment for Alan Bateman.
I have a somewhat unusual deployment process and have several checks in
place to ensure that there are all classes for the deployment target on
board and are deployed for a certain installation.
The check scans among other things all META-INF/services if service
interface and service implementations are part of the deployed classes in
jars and modules. To do that, the jimage list command with the module file
of the with the app deployed target JRE is used to gather the list of the
JRE classes.
Thanks a lot.
Regards.
Jörg Michelberger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jigsaw-dev/attachments/20251020/fb6978a9/attachment.htm>
More information about the jigsaw-dev
mailing list