RFR: 8343418: Use HashMap instead of Hashtable for CSS.htmlAttrToCssAttrMap

Alexey Ivanov aivanov at openjdk.org
Tue Nov 5 17:50:30 UTC 2024


On Sat, 2 Nov 2024 09:08:41 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

> > I am not seeing a lot of value in this churn in completely OK code.
> 
> Can't say I see that code as "OK".
> Hashtable usage in 2024 brings eye bleeding for most of developers.
> Specifying incorrect initial size adds even more _fun_.

@prrace I tend to agree with @turbanoff, doing such clean-ups makes the code base cleaner.

It's possible that such a change may introduce regressions… yet I think this change is rather safe. Using `null` as the key into `htmlAttrToCssAttrMap` looks like a bug, and Andrey provided his analysis which proves `null` is never used. I looked at the code too, and I didn't find any other usages.

`htmlAttrToCssAttrMap` may be accessed concurrently, the text model in Swing says the document supports mutations from other threads, there's also asynchronous view implementations.

However, the map is read-only after it's initialised. @ExE-Boss's suggestion of using `Map.of` to initialise the map looks reasonable.

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

PR Comment: https://git.openjdk.org/jdk/pull/21785#issuecomment-2457814390


More information about the client-libs-dev mailing list