RFR: 8355753: @SuppressWarnings("this-escape") not respected for indirect leak via field [v3]
Archie Cobbs
acobbs at openjdk.org
Fri May 30 14:44:56 UTC 2025
On Fri, 30 May 2025 13:27:29 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:
>> 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.
Thanks for the review!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/24932#issuecomment-2922589138
More information about the compiler-dev
mailing list