Unexpected ClassnotFoundException on reflective Class#getMethod
Alan Bateman
Alan.Bateman at oracle.com
Thu Apr 7 10:55:13 UTC 2016
On 07/04/2016 11:26, Dawid Weiss wrote:
> Ok, got it to work by patching the default module this package comes from:
>
> -Xpatch:java.annotations.common=mods\javax.annotation.priority at 1.0.jar
I'm curious what the following lists for you:
java
-Xpatch:java.annotations.common=mods/javax.annotation.priority at 1.0.jar
-listmods:java.annotations.common
The EE version of this API has additional package such as
javax.annotation.security and javax.annotation.sql. If your JAR file has
those then they will not be exported by default and so you might also
need to run with -XaddExports.
In any case, the right way to deploy with the upgraded version is:
-upgrademodulepath mods/javax.annotation at 1.2.jar
where the JAR file has a compiled module declaration to declare the
module, its dependences, and exports.
>
> The name of the module was kind of misleading (different than packages
> inside).
The naming is unfortunate but that is what JSR-250 claims to be be.
> I kept trying to patch javax.annotation... also, I couldn't
> get it to work with upgrademodulepath, no matter how hard I tried
> (copied java.annotations.common.jmod verbatim, created a modular jar
> out of it). Everything falls to pieces with:
>
>> java -upgrademodulepath mods -cp . Test
> Error occurred during initialization of VM
> java.lang.module.ResolutionException: Unable to compute the hash of
> module java.base
> at java.lang.module.Resolver.fail(java.base at 9-ea/Resolver.java:796)
> at java.lang.module.Resolver.checkHashes(java.base at 9-ea/Resolver.java:457)
> at java.lang.module.Resolver.finish(java.base at 9-ea/Resolver.java:274)
> at java.lang.module.Configuration.<init>(java.base at 9-ea/Configuration.java:187)
> at java.lang.module.Configuration.resolveRequiresAndUses(java.base at 9-ea/Configuration.java:346)
> at jdk.internal.module.ModuleBootstrap.boot(java.base at 9-ea/ModuleBootstrap.java:217)
> at java.lang.System.initPhase2(java.base at 9-ea/System.java:1916)
>
Hacking the packaged modules will fall foul of integrity checks. This
suggests to me that you didn't actually create or compile a
module-info.java.
-Alan
More information about the jigsaw-dev
mailing list