RFR: JDK-8160601: unexpected error compiling @Deprecated package

Jim Laskey james.laskey at oracle.com
Wed Sep 2 15:50:02 UTC 2020


LGTM

> On Sep 2, 2020, at 12:46 PM, Jan Lahoda <jan.lahoda at oracle.com> wrote:
> 
> Hi,
> 
> Having a package-info.java like this:
> /**
> * @deprecated This is a deprecated package.
> */
> @Deprecated
> package com.example.foobar;
> 
> javac reports:
> $ javac package-info.java
> package-info.java:5: error: modifier deprecated not allowed here
> package com.example.foobar;
> ^
> 1 error
> 
> This is because the @deprecated tag is internally in the parser viewed as a modifier, and packages cannot have modifiers. The tag is wrong on a package, of course, but it is in a comment, so javac should not report a compile-time error.
> 
> The proposed fix is to simply ignore the deprecated internal flag when verifying the package does not have modifiers. There is already a similar code for modules.
> 
> Proposed webrev:
> http://cr.openjdk.java.net/~jlahoda/8160601/webrev.00/
> 
> JBS:
> https://bugs.openjdk.java.net/browse/JDK-8160601
> 
> How does this look?
> 
> Thanks,
>   Jan



More information about the compiler-dev mailing list