Reputation: 1279
I have a very simple Java class
public class TestAnnotation {
public static void main(String[] args) {
System.out.println(javax.annotation.Generated.class.getName());
}
}
As expected, this does not compile using JDK 9
"c:\Program Files\Java\jdk-9.0.1\bin\javac.exe" TestAnnotation.java
TestAnnotation.java:3: error: package javax.annotation is not visible
System.out.println(javax.annotation.Generated.class.getName());
^
(package javax.annotation is declared in module java.xml.ws.annotation, which is not in the module graph)
1 error
Ignoring the error message (and using java.xml.ws instead of the suggested java.xml.ws.annotation), I can get it to compile using
"c:\Program Files\Java\jdk-9.0.1\bin\javac.exe" --add-modules java.xml.ws TestAnnotation.java
However, looking at the module graph module java.xml.ws does not depend on module java.xml.ws.annotation, which exports the javax.annotation package.
How is it possible this does compile (and run, btw)?
Upvotes: 3
Views: 3846
Reputation: 39536
java.xml.ws
does depend on java.xml.ws.annotation
: http://hg.openjdk.java.net/jdk/jdk/file/68c6f57c40d4/src/java.xml.ws/share/classes/module-info.java#l46
module java.xml.ws {
requires java.desktop;
requires java.logging;
requires java.management;
requires java.xml.ws.annotation;
...
I have no idea why this dependency is missing in that picture. Probably they wanted to show only the key links.
Upvotes: 3