8236850: Operations on constant List/Set.of(element) instances does not consistently constant fold

Reviewed-by: smarks, jrose, rriggs, psandoz
This commit is contained in:
Claes Redestad 2020-01-14 23:40:42 +01:00
parent 631b4d2694
commit de96aeddf5
6 changed files with 219 additions and 100 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -1288,7 +1288,7 @@ public interface Map<K, V> {
*/
@SuppressWarnings("unchecked")
static <K, V> Map<K, V> of() {
return (Map<K,V>) ImmutableCollections.MapN.EMPTY_MAP;
return (Map<K,V>) ImmutableCollections.EMPTY_MAP;
}
/**
@ -1606,7 +1606,7 @@ public interface Map<K, V> {
static <K, V> Map<K, V> ofEntries(Entry<? extends K, ? extends V>... entries) {
if (entries.length == 0) { // implicit null check of entries array
@SuppressWarnings("unchecked")
var map = (Map<K,V>) ImmutableCollections.MapN.EMPTY_MAP;
var map = (Map<K,V>) ImmutableCollections.EMPTY_MAP;
return map;
} else if (entries.length == 1) {
// implicit null check of the array slot