RFR: 8349155: The "log" parameter to Lint.logIfEnabled() is not needed

Archie Cobbs acobbs at openjdk.org
Fri Jan 31 18:17:19 UTC 2025


In [JDK-8345263](https://bugs.openjdk.org/browse/JDK-8345263), a new method `Lint.logIfEnabled(Log log, DiagnosticPosition pos, LintWarning warning)` was added. It was decided at the time to pass a `log` parameter explicitly instead of having `Lint` keep its own reference to the `Log` singleton. This was done to keep a conservative approach with the refactoring and to avoid possible initialization ordering issues.

After other recent changes ([JDK-8344079](https://bugs.openjdk.org/browse/JDK-8344079), [JDK-8347474](https://bugs.openjdk.org/browse/JDK-8347474)) the initialization ordering issues have been alleviated. It's also the case that there is only ever one `Log` instance per compiler `Context`. So the `log` parameter can be removed and `Lint` can just keep its own reference, as is the normal custom in the compiler code. This results in a minor code cleanup.

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

Commit messages:
 - Refactor to remove the "log" parameter from Lint.logIfEnabled().

Changes: https://git.openjdk.org/jdk/pull/23400/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23400&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8349155
  Stats: 49 lines in 8 files changed: 3 ins; 2 del; 44 mod
  Patch: https://git.openjdk.org/jdk/pull/23400.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23400/head:pull/23400

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


More information about the compiler-dev mailing list