RFR: 8204256: improve jlink error message to report unsupported class file format [v2]

Ian Graves igraves at openjdk.java.net
Thu Oct 1 19:19:18 UTC 2020


> This pull request contains a change to facilitate better error messages in jlink for when jlink creates an image from
> jmod files that are unsupported by the runtime by being _too new_. The existing behavior supports modules that are too
> old via an error about a mismatched version.  The solution to this problem is constrained by jlink's use of some
> specified behavior by java.lang.module.ModuleFinder. The solution in this PR is to subclass some existing exceptions
> internally as to signal to jlink more specific error conditions when attempting to find and open modules.  Bug here:
> https://bugs.openjdk.java.net/browse/JDK-8204256
> New Error message example:
> 
>  reading module: /Users/igraves/dev/jdk-otro/build/macosx-x64/images/jmods/java.security.sasl.jmod
> java.lang.module.FindException: Error reading module:
> /Users/igraves/dev/jdk-otro/build/macosx-x64/images/jmods/java.security.sasl.jmod 	at
> java.base/jdk.internal.module.ModulePath.readModule(ModulePath.java:350) 	at
> java.base/jdk.internal.module.ModulePath.scanDirectory(ModulePath.java:284) 	at
> java.base/jdk.internal.module.ModulePath.scan(ModulePath.java:232) 	at
> java.base/jdk.internal.module.ModulePath.scanNextEntry(ModulePath.java:190) 	at
> java.base/jdk.internal.module.ModulePath.find(ModulePath.java:154) 	at
> jdk.jlink/jdk.tools.jlink.internal.JlinkTask.newModuleFinder(JlinkTask.java:443) 	at
> jdk.jlink/jdk.tools.jlink.internal.JlinkTask.initJlinkConfig(JlinkTask.java:374) 	at
> jdk.jlink/jdk.tools.jlink.internal.JlinkTask.run(JlinkTask.java:267) 	at
> jdk.jlink/jdk.tools.jlink.internal.Main.run(Main.java:54) 	at jdk.jlink/jdk.tools.jlink.internal.Main.main(Main.java:33)
> Caused by: java.lang.module.InvalidModuleDescriptorException: Unsupported major.minor version 60.0
> 	at java.base/jdk.internal.module.ModuleInfo.invalidModuleDescriptor(ModuleInfo.java:1088)
> 	at java.base/jdk.internal.module.ModuleInfo.doRead(ModuleInfo.java:192)
> 	at java.base/jdk.internal.module.ModuleInfo.read(ModuleInfo.java:129)
> 	at java.base/jdk.internal.module.ModulePath.readJMod(ModulePath.java:395)
> 	at java.base/jdk.internal.module.ModulePath.readModule(ModulePath.java:343)
> 	... 9 more```

Ian Graves has refreshed the contents of this pull request, and previous commits have been removed. The incremental
views will show differences compared to the previous content of the PR. The pull request contains one new commit since
the last revision:

  Print stack traces for find exceptions in JLink

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/409/files
  - new: https://git.openjdk.java.net/jdk/pull/409/files/1eb85453..bee11534

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=409&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=409&range=00-01

  Stats: 150 lines in 6 files changed: 5 ins; 120 del; 25 mod
  Patch: https://git.openjdk.java.net/jdk/pull/409.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/409/head:pull/409

PR: https://git.openjdk.java.net/jdk/pull/409


More information about the core-libs-dev mailing list