RFR: 8355065: ConcurrentModificationException in RichDiagnosticFormatter [v2]
Chen Liang
liach at openjdk.org
Mon Apr 21 17:53:45 UTC 2025
On Mon, 21 Apr 2025 17:42:11 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:
>> Hi, please consider this fix for [JDK-8355065](https://bugs.openjdk.org/browse/JDK-8355065). RichDiagnosticFormatter is comparing type variables by their `toString` representation, and in this example the comparison fails due to type annotations. Replacing a call to `stripMetadataIfNeeded` with `stripMetadata` allows the comparison to succeed, and is consistent with the approach used in other parts of RichDiagnosticFormatter (e.g. for [the fix for JDK-8144580](https://github.com/openjdk/jdk/commit/570883e4dc5f769e17b3fcd8f2bbeb369dfe3a5d)).
>
> Liam Miller-Cushon has updated the pull request incrementally with one additional commit since the last revision:
>
> Detect recursion in RichDiagnosticFormatter#format
>
> The class is not designed to be re-entered, and will produce incorrect
> results if that happens.
src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java line 90:
> 88:
> 89: WhereClauses() {
> 90: Map<WhereClauseKind, Map<Type, JCDiagnostic>> whereClauses = new LinkedHashMap<>();
Looks like a great candidate for `EnumMap`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24769#discussion_r2052774435
More information about the compiler-dev
mailing list