[Rev 01] RFR: 8208761: Update constant collections to use the new immutable collections

Kevin Rushforth kcr at openjdk.java.net
Fri Feb 21 00:15:04 UTC 2020

On Tue, 11 Feb 2020 18:10:18 GMT, Nir Lisker <nlisker at openjdk.org> wrote:

>> Resubmitting from before the transition to this repo. See linked issue for details.
> The pull request has been updated with 1 additional commit.

I took a preliminary look, and only have one high-level concern that might end up not being a problem, but will need to be checked. The docs for an Unmodifiable Set, List, or Map state that they are "value-based", meaning that the identity of the stored objects cannot be relied upon. I think `Color` is the only place where that could even possibly be an issue, since both the Color constants and the method to get a Color by looking up a string in a Map are public. In the event that `Map.get` returned an instance that was `.equals` but not `==`, an application might see a difference in behavior. I'm not sure that actually applies to the values in a `Map.entry` passed into `Map.of`, though.

I also left one minor comment inline.

modules/javafx.web/src/main/java/com/sun/javafx/webkit/KeyCodeMap.java line 217:

> 216: 
> 217:     private static Map.Entry<KeyCode, Entry> put(KeyCode keyCode, int windowsVirtualKeyCode, String keyIdentifier) {
> 218:         return Map.entry(keyCode, new Entry(windowsVirtualKeyCode, keyIdentifier));

I would rename this helper method to `entry` or similar.


PR: https://git.openjdk.java.net/jfx/pull/104

More information about the openjfx-dev mailing list