4

I ran the followings commands, but I got the same errors:

$ jdeps --generate-module-info . --multi-release 9 libs/log4j-core-2.11.1.jar
Error: log4j-core-2.11.1.jar is a multi-release jar file but --multi-release option is not set

$ jdeps --generate-module-info . --multi-release 10 libs/log4j-core-2.11.1.jar
Error: log4j-core-2.11.1.jar is a multi-release jar file but --multi-release option is not set

$ jdeps --generate-module-info . --multi-release 11 libs/log4j-core-2.11.1.jar
Error: log4j-core-2.11.1.jar is a multi-release jar file but --multi-release option is not set

$ jdeps --generate-module-info . libs/log4j-core-2.11.1.jar
Error: log4j-core-2.11.1.jar is a multi-release jar file but --multi-release option is not set

What's the problem with the above commands?

Follow others commands about my environment:

$ java --version
openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)

$ javac --version
javac 10.0.2

$ jdeps --version
10.0.2

Same error with the java-11-oracle.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
Fabrício Pereira
  • 1,521
  • 1
  • 12
  • 20
  • 1
    The question also is why do you want to `generate-module-info` for a jar which already has its own explicit `module-info.java` class packaged in the jar? It's a [tag:multi-release-jar] after all. – Naman Dec 02 '18 at 18:20
  • This 'module' doesn't have a module-info because is a automatic module. But I want building a launcher with jlink and include it (core) too, besides the api module from log4j. – Fabrício Pereira Dec 02 '18 at 21:50
  • 1
    1. Being a multi-release-jar it must be having a module-info.java under either of the `META-INF/versions` directory since they MRJAR has been introduced along with module descriptor in Java9. 2. Why are you using it as an automatic module and not an explicit module given (1) ? – Naman Dec 02 '18 at 21:57
  • Because despite having included the statements `requires org.apache.logging.log4j; requires org.apache.logging.log4j.core;`, I got a error about automatic module with `jlink` (`Error: automatic module cannot be used with jlink: org.apache.logging.log4j.core from file:///PATH_PROJECT/libs/log4j-core-2.11.1.jar`. And only with statement `requires org.apache.logging.log4j;` the `jlink` works. But when running the launcher I got the error `ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...`. – Fabrício Pereira Dec 02 '18 at 22:35
  • That is, `jlink` did not include this automatic module, and the launcher requires that I include a classpath with `log4j-core-2.11.1.jar` when running it. There isn't any problem with the module in **log4j-api-2.11.1.jar**, only with the automatic module in **log4j-core-2.11.1.jar**. – Fabrício Pereira Dec 02 '18 at 22:36

2 Answers2

7

There's a bug with --multi-release option to work with modules

jdeps fails when executing on a non multi release jar and the --class-path contains multi release jars. The opposite is also true. jdeps fails when executing on a multi release jar with the appropriate --multi-release flag is set and the --class-path contains non multi release jars.

Which summarizes the issue:

This basically makes multi-release jars unusable with modules.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233
1

JDK-8229396 fixes jdeps --generate-module-info option to properly use the version specified to --multi-release option to parse the given multi-release JAR. This has been fixed in 14. Please try out the EA build in coming weeks.