On 22/03/2016 22:29, Richard Opalka wrote:
Hi,

   I'm experiencing the same problem locally.
When trying to build Oracle provided maven artifact from sources, namely

http://search.maven.org/#artifactdetails|javax.annotation|javax.annotation-api|1.2|jar

the build fails on JDK9 (with Jigsaw) with message:

./src/javax/annotation/Priority.java:42: error: package exists in another module: java.annotations.common
package javax.annotation;
^
1 error

How is Jigsaw javac going to deal with such compilation scenarios?
I've changed the subject line as this issue seems to be about how to compile with, and make use of, the EE versions of the so-called "Common Annotations".

The JSR 250 defined Common Annotations is one of a small number of APIs that is shared between Java SE and Java EE. Java SE defines a subset, where Java EE defines the full API (or the full set of annotations in this case). With JDK 8 and older then Java EE or app servers needed to deploy an EE version to override the Java SE version. The only supported way of doing this was via the endorsed standards override mechanism (that mechanism was documented for both endorsed standards and standalone technologies with JSR 250 one of the standalone technologies).

As things currently stand, the replacement to the endorsed standards override mechanism is upgradeable modules. In JEP 261 you will see the option -upgrademodulepath that can be used to deploy modules that upgrade/override modules in the JDK.

So what you need here is the Java EE version of the java.annotations.common module and deploy it via -upgrademodulepath to upgrade/override the module in the JDK.

Unfortunately there isn't an EE version of this module yet so you have to create it yourself. Not hard, you just need to compile the following module-info.java and put it in the top-level directory of the JAR file to make it a modular JAR.

module java.annotations.common {
    exports javax.annotation;
    exports javax.annotation.security;
    exports javax.annotation.sql;
}

Note that the Java SE/JDK version exports one package, the Java EE version exports three packages.

You can check that the EE version is observable with the following common:

  java -upgrademodulepath libs/javax.annotation-api.jar -listmods

or -listmods:java.annotations.common to have the module definition printed so that you can checks the exports.

-Alan



Reply via email to