javac accepts enums, annotations and final classes being referenced by 'uses' statement
Jonathan Gibbons
jonathan.gibbons at oracle.com
Thu Mar 31 15:10:21 UTC 2016
Georgiy,
Please file this as an issue against javac, and we'll take it from
there. The case of the final class has previously been considered and
considered "silly but not wrong", but the other two have not been
explicitly considered.
Alex has previously said in this forum that 'uses' and 'provides' are
just a convenient front-end for the ServiceLoader API, so I would expect
that to be taken into account when considering what should be accepted
as legal here.
-- Jon
On 03/30/2016 04:18 AM, Georgiy Rakov wrote:
> 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