Discussion:
Moving to Java 9 - module-info.class not found for <module-name> module
Rahman USTA
2017-09-01 20:21:16 UTC
Permalink
Hi,

I migrate TerminalFX <https://github.com/rahmanusta/TerminalFX> project to
Java 9. To run the project on Java 9 I'm following the steps:

mvn clean install dependency:copy-dependencies
java --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx -m terminalfx/com.terminalfx.AppStarter

It works normally. Then, I want to generate a jlink image with the
following script

jlink --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx --launcher terminalfx=terminalfx/com.terminalfx.AppStarter
--output target/release

However it gives me the following error;

Error: module-info.class not found for jackson.databind module

My module-info.java is:

module terminalfx {

requires jackson.annotations;
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
requires javafx.web;
requires jackson.core;
requires pty4j;
requires jackson.databind;
requires jna;
requires jdk.jsobject;

exports com.terminalfx;
exports com.terminalfx.config to jackson.databind;

}


and the project is located here in *java9* branch
https://github.com/rahmanusta/TerminalFX

How can I solve this issue?

Thanks.
--
Rahman USTA
Istanbul JUG
Alex Buckley
2017-09-01 21:06:16 UTC
Permalink
Post by Rahman USTA
java --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx -m terminalfx/com.terminalfx.AppStarter
(You shouldn't need the --add-modules, since terminalfx is already the
main module.)
Post by Rahman USTA
It works normally. Then, I want to generate a jlink image with the
following script
jlink --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx --launcher terminalfx=terminalfx/com.terminalfx.AppStarter
--output target/release
However it gives me the following error;
Error: module-info.class not found for jackson.databind module
I suspect jackson.databind is an automatic module. jlink does not
support linking of automatic modules because they can rely on the
arbitrary content of the classpath, which goes against the idea of a
self-contained Java runtime.

Alex
Remi Forax
2017-09-01 21:59:18 UTC
Permalink
As Alex said,
jackson.databind is not an explicit module.

You should report that issue to their bugtracker.

cheers,
Rémi

----- Mail original -----
Envoyé: Vendredi 1 Septembre 2017 23:06:16
Objet: Re: Moving to Java 9 - module-info.class not found for <module-name> module
Post by Rahman USTA
java --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx -m terminalfx/com.terminalfx.AppStarter
(You shouldn't need the --add-modules, since terminalfx is already the
main module.)
Post by Rahman USTA
It works normally. Then, I want to generate a jlink image with the
following script
jlink --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx --launcher terminalfx=terminalfx/com.terminalfx.AppStarter
--output target/release
However it gives me the following error;
Error: module-info.class not found for jackson.databind module
I suspect jackson.databind is an automatic module. jlink does not
support linking of automatic modules because they can rely on the
arbitrary content of the classpath, which goes against the idea of a
self-contained Java runtime.
Alex
Rahman USTA
2017-09-02 11:30:24 UTC
Permalink
Thank you, Remi and Alex.

I think automatic modules can be supported by jlink. It could be a
transition feature like --illegal-access imho.

Kind regards.
Post by Remi Forax
As Alex said,
jackson.databind is not an explicit module.
You should report that issue to their bugtracker.
cheers,
Rémi
----- Mail original -----
Envoyé: Vendredi 1 Septembre 2017 23:06:16
Objet: Re: Moving to Java 9 - module-info.class not found for
<module-name> module
Post by Rahman USTA
java --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx -m terminalfx/com.terminalfx.AppStarter
(You shouldn't need the --add-modules, since terminalfx is already the
main module.)
Post by Rahman USTA
It works normally. Then, I want to generate a jlink image with the
following script
jlink --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx --launcher terminalfx=terminalfx/com.terminalfx.AppStarter
--output target/release
However it gives me the following error;
Error: module-info.class not found for jackson.databind module
I suspect jackson.databind is an automatic module. jlink does not
support linking of automatic modules because they can rely on the
arbitrary content of the classpath, which goes against the idea of a
self-contained Java runtime.
Alex
--
Rahman USTA
Istanbul JUG
https://github.com/rahmanusta
f***@univ-mlv.fr
2017-09-02 11:43:19 UTC
Permalink
Envoyé: Samedi 2 Septembre 2017 13:30:24
Objet: Re: Moving to Java 9 - module-info.class not found for <module-name> module
Thank you, Remi and Alex.
I think automatic modules can be supported by jlink. It could be a transition
feature like --illegal-access imho.
The whole idea of jlink is that unlike classical Java it works under the assumption that the world is closed i.e. all the bytecodes that will be loaded is known, so it can do "whole world" optimizations like i know all the lambda forms that will be used by the string concatenation because i know all the call sites that does string concatenation so i can pre-generate them.
If you have an automatic module, it can have dependencies on jars from the classpath, the close world assumption does not hold.

If you are in a hacky mood, there is a simple solution to transform an automatic module to an explicit one, create a module-info.java, compile it and update the jar of the automatic module with the module-info.class or better ask the maintainer of the jar to do the work for you :)
Kind regards.
regards,
Rémi
Post by Remi Forax
As Alex said,
jackson.databind is not an explicit module.
You should report that issue to their bugtracker.
cheers,
Rémi
----- Mail original -----
] >
Envoyé: Vendredi 1 Septembre 2017 23:06:16
Objet: Re: Moving to Java 9 - module-info.class not found for <module-name> module
Post by Rahman USTA
java --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx -m terminalfx/com.terminalfx.AppStarter
(You shouldn't need the --add-modules, since terminalfx is already the
main module.)
Post by Rahman USTA
It works normally. Then, I want to generate a jlink image with the
following script
jlink --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency --add-modules
terminalfx --launcher terminalfx=terminalfx/com.terminalfx.AppStarter
--output target/release
However it gives me the following error;
Error: module-info.class not found for jackson.databind module
I suspect jackson.databind is an automatic module. jlink does not
support linking of automatic modules because they can rely on the
arbitrary content of the classpath, which goes against the idea of a
self-contained Java runtime.
Alex
--
Rahman USTA
Istanbul JUG
[ https://github.com/rahmanusta | https://github.com/rahmanusta ]
Gunnar Morling
2017-09-21 20:04:01 UTC
Permalink
Post by f***@univ-mlv.fr
If you are in a hacky mood, there is a simple solution to transform an
automatic module to an explicit one,
Post by f***@univ-mlv.fr
create a module-info.java, compile it and update the jar of the automatic
module with the module-info.class

I'm working on a Maven plug-in, ModiTect, which largely automates that
task. E.g. here is an example which adds the required descriptors to
Undertow (a web server) as well as its dependencies and then creates a
runtime image from that:


https://github.com/moditect/moditect/blob/master/integrationtest/undertow/pom.xml

Needless to say, that having the upstream project provide explicit modules
is the favourable approach.
Post by f***@univ-mlv.fr
Envoyé: Samedi 2 Septembre 2017 13:30:24
Objet: Re: Moving to Java 9 - module-info.class not found for
<module-name>
module
Thank you, Remi and Alex.
I think automatic modules can be supported by jlink. It could be a
transition
feature like --illegal-access imho.
The whole idea of jlink is that unlike classical Java it works under the
assumption that the world is closed i.e. all the bytecodes that will be
loaded is known, so it can do "whole world" optimizations like i know all
the lambda forms that will be used by the string concatenation because i
know all the call sites that does string concatenation so i can
pre-generate them.
If you have an automatic module, it can have dependencies on jars from the
classpath, the close world assumption does not hold.
If you are in a hacky mood, there is a simple solution to transform an
automatic module to an explicit one, create a module-info.java, compile it
and update the jar of the automatic module with the module-info.class or
better ask the maintainer of the jar to do the work for you :)
Kind regards.
regards,
Rémi
Post by Remi Forax
As Alex said,
jackson.databind is not an explicit module.
You should report that issue to their bugtracker.
cheers,
Rémi
----- Mail original -----
] >
Envoyé: Vendredi 1 Septembre 2017 23:06:16
Objet: Re: Moving to Java 9 - module-info.class not found for
<module-name>
Post by Remi Forax
module
Post by Rahman USTA
java --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency
--add-modules
Post by Remi Forax
Post by Rahman USTA
terminalfx -m terminalfx/com.terminalfx.AppStarter
(You shouldn't need the --add-modules, since terminalfx is already the
main module.)
Post by Rahman USTA
It works normally. Then, I want to generate a jlink image with the
following script
jlink --module-path
%JAVA_HOME%/jmods;target\terminalfx.jar;target\dependency
--add-modules
Post by Remi Forax
Post by Rahman USTA
terminalfx --launcher terminalfx=terminalfx/com.
terminalfx.AppStarter
Post by Remi Forax
Post by Rahman USTA
--output target/release
However it gives me the following error;
Error: module-info.class not found for jackson.databind module
I suspect jackson.databind is an automatic module. jlink does not
support linking of automatic modules because they can rely on the
arbitrary content of the classpath, which goes against the idea of a
self-contained Java runtime.
Alex
--
Rahman USTA
Istanbul JUG
[ https://github.com/rahmanusta | https://github.com/rahmanusta ]
Loading...