RFR: JDK-8160601: unexpected error compiling @Deprecated package
Jan Lahoda
jan.lahoda at oracle.com
Wed Sep 2 15:46:51 UTC 2020
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