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

Mandy Chung mchung at openjdk.java.net
Wed Sep 30 21:50:54 UTC 2020


On Wed, 30 Sep 2020 10:56:46 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> 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:
>> 
>> `Error: jlink encountered a java.base jmod with unsupported module descriptor version 60.0`
>
> This impacts the java.lang.module API. I think I'd prefer to drop all changes to jdk.internal.module from this patch
> and instead focus on a jlink specific change.

Maybe `ModulePath` can provide a method to open an input stream of the `module-info.class` of the named module found on
the module path.  jlink can then parse the class file to check if the major and minor version is supported class file
version.

Or a simpler solution is to concatenate the `FindException` message with the exception message of the cause.  This will
also cover other error cases besides unsupported class file version.

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

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


More information about the core-libs-dev mailing list