-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
None
ADDITIONAL SYSTEM INFORMATION :
Microsoft Windows [Version 10.0.26100.6725]
(c) Microsoft Corporation. All rights reserved.
C:\Users\hwaite>%JAVA_HOME%\bin\java -version
openjdk version "25" 2025-09-16
OpenJDK Runtime Environment (build 25+36-3489)
OpenJDK 64-Bit Server VM (build 25+36-3489, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
The 'Map.of' methods currently return a Map. These methods would be more convenient if they returned SequencedMap instead (or at least a regular Map that happens to maintain order). This overloaded method accepts a maximum of 10 key/value pairs. As such, the performance implications of retaining order are insignificant. However, when a developer needs to preserve ordering, there's a significant verbosity penalty. One needs to declare a LinkedHashMap and wrap it in an unmodifiable map.
There should be minimal backwards compatibility issues, since SequencedMap is a subinterface of Map. This proposal is an alternative to adding 'SequencedMap.of' methods (JDK-8323729).
Microsoft Windows [Version 10.0.26100.6725]
(c) Microsoft Corporation. All rights reserved.
C:\Users\hwaite>%JAVA_HOME%\bin\java -version
openjdk version "25" 2025-09-16
OpenJDK Runtime Environment (build 25+36-3489)
OpenJDK 64-Bit Server VM (build 25+36-3489, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
The 'Map.of' methods currently return a Map. These methods would be more convenient if they returned SequencedMap instead (or at least a regular Map that happens to maintain order). This overloaded method accepts a maximum of 10 key/value pairs. As such, the performance implications of retaining order are insignificant. However, when a developer needs to preserve ordering, there's a significant verbosity penalty. One needs to declare a LinkedHashMap and wrap it in an unmodifiable map.
There should be minimal backwards compatibility issues, since SequencedMap is a subinterface of Map. This proposal is an alternative to adding 'SequencedMap.of' methods (
- relates to
-
JDK-8156081 add unmodifiable set and map with defined encounter order
-
- Open
-