RFR: 8333560: -Xlint:restricted does not work with --release

Jorn Vernee jvernee at openjdk.org
Wed Jun 5 09:11:30 UTC 2024


Currently, `-Xlint:restricted` can be used to print out lint warnings when restricted methods are used in source code compiled by javac. However, this option doesn't work as intended when used in combination with `--release`, and instead no warnings are printed at all.

Javac relies on the internal `jdk.internal.javac.Restricted` annotation being present on a method in order to determine if a method is restricted. This annotation is however currently being stripped out when generating shim class files that are used by javac to get release-specific symbol information.

There are already some annotations that are exempt from being stripped away, such as `jdk.internal.javac.PreviewFeature`. The proposed fix is to add `jdk.internal.javac.Restricted` to the list of exempted annotations as well.

Testing: tier 1-3 (ongoing)

-------------

Commit messages:
 - fix -Xlint:restricted when using --release

Changes: https://git.openjdk.org/jdk/pull/19548/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19548&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8333560
  Stats: 9 lines in 3 files changed: 4 ins; 0 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/19548.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19548/head:pull/19548

PR: https://git.openjdk.org/jdk/pull/19548


More information about the compiler-dev mailing list