It’s true that two modules cannot, ordinarily, define types in the same
package. Until recently, putting jsr305.jar
on the class path of a
JDK 9 build would have no effect: That JAR file defines types in the
javax.annotation
package but that package is defined in the platform’s built-in
java.xml.ws.annotation
module, and the latter takes precedence.
Owing in part to the widespread use of jsr305.jar
, however, and also to make
it easier for existing application servers to migrate to JDK 9, we changed
the default set of root modules to exclude the annotations module, among
others. Putting jsr305.jar
on the JDK 9 class path works out-of-the-box
with both JDK 9 and JDK 10; details are available in
JEP 261. It will continue
to work out-of-the-box with later releases since the annotations module, along
with all the other Java EE and CORBA modules, were removed in JDK 11
per JEP 320.