RFR: 8344148: Add an explicit compiler phase for warning generation

Archie Cobbs acobbs at openjdk.org
Thu Nov 21 17:36:19 UTC 2024


On Thu, 21 Nov 2024 16:53:32 GMT, Vicente Romero <vromero at openjdk.org> wrote:

>> Please review this patch which does some minor refactoring to the compiler:
>> * Create a new `WARN` phase which can be a dedicated home for (new) lint/warning logic
>> * Create a new `WarningAnalyzer` singleton whose job is to invoke such lint/warning logic
>> * Move `ThisEscapeAnalyzer` out of `Flow` (where it doesn't belong) and into `WarningAnalyzer`
>> * Refactor `ThisEscapeAnalyzer` to be a context singleton like all other such classes
>> 
>> See [JDK-8344148](https://bugs.openjdk.org/browse/JDK-8344148) for details.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ThisEscapeAnalyzer.java line 267:
> 
>> 265:     }
>> 266: 
>> 267:     private void doAnalyzeTree(Env<AttrContext> env) {
> 
> the doAnalyzeTree method doesn't seems to add much value

This class is being refactored to be a singleton, so now it's crucial that it cleans itself up after each execution, and that required adding the new try/finally structure to ensure this.

It seemed cleaner to have two separate methods, because that more clearly separates the clean up step from the analysis step (also this avoids generating 200 lines of whitespace indention diffs).

But of course this is just a style thing - so I'm happy to inline `doAnalyzeTree()` if you think that's more consistent with the compiler style.

Thanks for taking a look.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/22088#discussion_r1852581567


More information about the compiler-dev mailing list