RFR: 8354216: Small cleanups relating to Log.DiagnosticHandler [v2]

Archie Cobbs acobbs at openjdk.org
Thu Apr 10 14:31:10 UTC 2025


> This is split off as a sub-task of [JDK-8224228](https://bugs.openjdk.org/browse/JDK-8224228), which seeks to add `@SuppressWarnings` support for lexical features. 
> 
> There are a few of small refactoring cleanups possible relating to the nested class `Log.DiagnosticHandler`.
> 
> First, this class is currently declared as a static inner class with an explicit field reference to its outer class (`Log`) instance. Although protected and non final, this field really should never be changed. Therefore, there is no reason not to just make `DiagnosticHandler` a non-static inner class. This will slightly simplify the code and eliminate an obscure corner case by which a bug could possibly occur someday.
> 
> Secondly, the deferred diagnostics are currently stored in a linked list, and in cases where they must be sorted before being reported, they have to be copied into an array first. A simpler and more space efficient approach would be to just use an `ArrayList`. Then the sorting variant of the method can just sort the list in place and delegate directly to the non-sorting variant.
> 
> Finally, the code can be simplified by replacing a null `filter` predicate with an always true predicate at construction time instead of at filter time.

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

  Add comment per review suggestion.

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/24553/files
  - new: https://git.openjdk.org/jdk/pull/24553/files/2e68d7a3..dc3b98c2

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

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

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


More information about the compiler-dev mailing list