RFR: 8355753: @SuppressWarnings("this-escape") not respected for indirect leak via field [v3]

Archie Cobbs acobbs at openjdk.org
Fri May 30 13:27:29 UTC 2025


> This PR corrects a bug in the logic for handling `@SuppressWarnings("this-escape")` when the leak is from a field initializer.
> 
> The `ThisEscapeAnalyzer` has to do some custom handling for `@SuppressWarnings("this-escape")` because when a constructor executes, the actual path of execution can jump around between multiple constructors, field initializers, and initialization blocks. The previous logic was somewhat ad hoc and contained at least one bug (this one), so this PR refactors it to fix the bug and also make the code clearer.
> 
> Now we "execute" field initializers and initialization blocks when we encounter `super()` invocations, just like the actual JVM does, and we move the logics for (a) applying suppression and (b) the "at most one warning per constructor or initializer" rule until after the analysis, so they are part of the existing warning filtering and de-duplication step.

Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision:

  Remove extraneous semicolons.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/24932/files
  - new: https://git.openjdk.org/jdk/pull/24932/files/65e2679e..f79e35f8

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24932&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24932&range=01-02

  Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod
  Patch: https://git.openjdk.org/jdk/pull/24932.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24932/head:pull/24932

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


More information about the compiler-dev mailing list