RFR: 8353757: Log class should have a proper clear() method [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Apr 7 09:03:58 UTC 2025
On Fri, 4 Apr 2025 22:20:28 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:
>> This is a simple refactoring to add a method `Log.clear()`, move `ReusableLog.clear()`'s clearing operations into it and invoke `super.clear()` instead, and add two more fields that should be included in the clear operation but were not because they were added to `Log` after `ReusableLog.clear()` was added and were missed.
>>
>> A natural question: Are there any other fields in `Log` that should be cleared in `Log.clear()`? The two I've added (`nsuppressederrors` and `nsuppressedwarns`) are the only two that weren't there when `ReusableLog` as added, so presumably not, but it's possible.
>
> Archie Cobbs has updated the pull request incrementally with one additional commit since the last revision:
>
> Invoke Log.useSource() before recursing into attribution.
src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java line 696:
> 694: */
> 695: public void clear() {
> 696: recorded.clear();
I think the list here is good. There is more state in Log -- but that state seems to be set at creation (e.g. diag listener, writers), while the goal here is to clear up state that "accumulates" from a compilation task.
The thing I'm unsure about is the `diagnosticHandler` field. I suppose we always call "clear" from a context where we already have popped all the installed alternate handlers -- but if not we should reset that too?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24460#discussion_r2030783042
More information about the compiler-dev
mailing list