JDK-8350212 : Track source end positions of declarations that support @SuppressWarnings
  • Type: Sub-task
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 25
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2025-02-17
  • Updated: 2025-06-19
  • Resolved: 2025-06-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 26
26 b02Fixed
Description
This is split off as a sub-task of JDK-8224228, which seeks to add @SuppressWarnings support for lexical features.

In order for @SuppressWarnings to work for source code bits that are handled by the parser (for example, new lexical features subject to preview warnings), these bits need to be located within the innermost enclosing @SuppressWarnings-supporting declaration, i.e., module, package, class, method, or variable declaration. Since these are lexical bits, not Java members or symbols with "owners", etc., this requires we know the starting and ending positions of such enclosing declarations.

The parser does not normally store lexical end positions in an EndPositionTable unless this is requested explicitly. So we can't rely on that, and we don't want to make the EndPositionTable mandatory for performance reasons.

Instead, we can just add a new "int endPos" field to the five corresponding AST node classes: JCModuleDecl, JCPackageDecl, JCClassDecl, JCMethodDecl, and JCVariableDecl. This field can be populated as part of the normal parsing of these node types, which already supports the (optional) tracking of end positions.
Comments
Changeset: c793de98 Branch: master Author: Archie Cobbs <acobbs@openjdk.org> Date: 2025-06-05 21:57:33 +0000 URL: https://git.openjdk.org/jdk/commit/c793de989facdb532021e1d5ddd01eb0e089b8e6
05-06-2025

After further review, this change is now on the table again; reopening this ticket.
04-04-2025

We decided not to go this route. Closing issue.
28-02-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/23669 Date: 2025-02-18 02:39:37 +0000
18-02-2025