Add new method Log.clear().

This commit is contained in:
Archie L. Cobbs 2025-04-04 16:55:20 -05:00
parent ba28119642
commit e9931f6df2
2 changed files with 17 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -267,7 +267,7 @@ public class JavacTaskPool {
if (ht.get(Log.logKey) instanceof ReusableLog) {
//log already inited - not first round
((ReusableLog)Log.instance(this)).clear();
Log.instance(this).clear();
Enter.instance(this).newRound();
((ReusableJavaCompiler)ReusableJavaCompiler.instance(this)).clear();
Types.instance(this).newRound();
@ -395,11 +395,9 @@ public class JavacTaskPool {
this.context = context;
}
void clear() {
recorded.clear();
sourceMap.clear();
nerrors = 0;
nwarnings = 0;
@Override
public void clear() {
super.clear();
//Set a fake listener that will lazily lookup the context for the 'real' listener. Since
//this field is never updated when a new task is created, we cannot simply reset the field
//or keep old value. This is a hack to workaround the limitations in the current infrastructure.

View File

@ -689,6 +689,18 @@ public class Log extends AbstractLog {
diagnosticHandler.report(diagnostic);
}
/**
* Reset the state of this instance.
*/
public void clear() {
recorded.clear();
sourceMap.clear();
nerrors = 0;
nwarnings = 0;
nsuppressederrors = 0;
nsuppressedwarns = 0;
}
/**
* Common diagnostic handling.
* The diagnostic is counted, and depending on the options and how many diagnostics have been