javac accepts enums, annotations and final classes being referenced by 'uses' statement

Georgiy Rakov georgiy.rakov at oracle.com
Wed Mar 30 11:18:30 UTC 2016


Hello,

currently JDK9b111 javac successfully compiles following code:

    a/module-info.java:
    module a {
         uses pkg.FinalClassST;
         uses pkg.EnumST;
         uses pkg.AnnotationST;
    }

    a/pkg/AnnotationST.java:
    package pkg;
    public @interface AnnotationST{}

    a/pkg/EnumST.java:
    package pkg;
    public enum EnumST {A,B}

    a/pkg/FinalClassST.java:
    package pkg;
    public final class FinalClassST{}


Could you please tell if this is javac, spec or both issue that type 
being referenced by 'uses' statement is not checked at compile-time for 
ability to be a service interface.

The minimized testcase is attached; in order to run it please:
1. unzip attached archive on Windows machine;
2. rename test9\test_bat to test9\test.bat;
3. modify test.bat by changing JDK_HOME variable to point to your JDK 
installation;
4. run test.bat.

BTW: provided the type name references non existing type javac does 
produce compile error.

Thanks,
Georgiy.


More information about the jigsaw-dev mailing list