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


On Thu, 1 Oct 2020 18:11:02 GMT, Ian Graves <igraves at openjdk.org> wrote:

>> Add a cause may work but it should probably be predicted on isLinkPhase as otherwise it will leak through to usages of
>> the ModuleFinder API.
>
> So after some thought and discussion offline, I've pushed a pretty different change that slims all of this down to
> simply printing an exception stack trace to the log/stdout when a FindException is thrown. This isn't the same way as
> the other error, but I believe for reasons given elsewhere that this is okay.  This exception is thrown when we're
> looking into module that is newer than the current runtime's supported module versions. This should never be supported
> and is unique from the existing case where we don't link modules that are older versions than the runtime's supported
> version. This leaves that code path alone.  Since the FindException is a broad exception and can be thrown for a
> variety of reasons, printing the stack trace should provide visibility into what the problem is while keeping any kind
> of coupling in jlink to that exception to a minimum.

New error message:

Error: Error 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

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

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


More information about the core-libs-dev mailing list