RFR: 8354216: Small cleanups relating to Log.DiagnosticHandler

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Apr 10 14:09:46 UTC 2025


On Wed, 9 Apr 2025 17:38:10 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/util/Log.java line 184:
>> 
>>> 182:         /** Report all deferred diagnostics in the specified order. */
>>> 183:         public void reportDeferredDiagnostics(Comparator<JCDiagnostic> order) {
>>> 184:             deferred.sort(order);
>> 
>> So, here there would seem to be a difference in behavior, in that `sort` has a permanent side-effect on `deferred`. But I think this is fine, because at the end of this method we end up setting `deferred = null` anyway, right?
>
> Yes, that's my thought too - we are indeed changing the list, but who cares because we're about to discard it. Of course the discarding is done indirectly by `reportDeferredDiagnostics()`, not by this method.

As usual -- maybe add comments to capture this

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24553#discussion_r2037512331


More information about the compiler-dev mailing list