elharo commented on code in PR #12540:
URL: https://github.com/apache/maven/pull/12540#discussion_r3650795950
##########
src/mdo/java/ImmutableCollections.java:
##########
@@ -120,6 +120,12 @@ static <K, V> Map<K, V> copy(Map<K, V> map) {
Map.Entry<K, V> entry = map.entrySet().iterator().next();
return singletonMap(entry.getKey(), entry.getValue());
default:
+ // Check if this is already an immutable JDK map (from
Map.of(), Map.copyOf(), etc.)
+ // Those throw UnsupportedOperationException on put() and
don't need copying
+ String className = map.getClass().getName();
+ if
(className.startsWith("java.util.ImmutableCollections$")) {
Review Comment:
Is this guaranteed by the JDK or could the actual class names used here
change in the future?
Is there any other way we could test this? Maybe
`addAll(Collections.emptyList())` and see if it throws or not.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]