4625N/A/*
4625N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4625N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4625N/A *
4625N/A * This code is free software; you can redistribute it and/or modify it
4625N/A * under the terms of the GNU General Public License version 2 only, as
4625N/A * published by the Free Software Foundation.
4625N/A *
4625N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4625N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4625N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4625N/A * version 2 for more details (a copy is included in the LICENSE file that
4625N/A * accompanied this code).
4625N/A *
4625N/A * You should have received a copy of the GNU General Public License version
4625N/A * 2 along with this work; if not, write to the Free Software Foundation,
4625N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4625N/A *
4625N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4625N/A * or visit www.oracle.com if you need additional information or have any
4625N/A * questions.
4625N/A */
4625N/A
4625N/A/*
4625N/A * Portions Copyright (c) 2012, IBM Corporation
4625N/A */
4625N/A
4625N/A/*
4625N/A * @test
4625N/A * @bug 7123229
4625N/A * @summary (coll) EnumMap.containsValue(null) returns true
4625N/A * @author ngmr
4625N/A */
4625N/A
4625N/Aimport java.util.EnumMap;
4625N/Aimport java.util.Map;
4625N/A
4625N/Apublic class UniqueNullValue {
4625N/A static enum TestEnum { e00, e01 }
4625N/A
4625N/A public static void main(String[] args) {
4625N/A Map<TestEnum, Integer> map = new EnumMap<>(TestEnum.class);
4625N/A
4625N/A map.put(TestEnum.e00, 0);
4625N/A if (false == map.containsValue(0)) {
4625N/A throw new RuntimeException("EnumMap unexpectedly missing 0 value");
4625N/A }
4625N/A if (map.containsValue(null)) {
4625N/A throw new RuntimeException("EnumMap unexpectedly holds null value");
4625N/A }
4625N/A
4625N/A map.put(TestEnum.e00, null);
4625N/A if (map.containsValue(0)) {
4625N/A throw new RuntimeException("EnumMap unexpectedly holds 0 value");
4625N/A }
4625N/A if (false == map.containsValue(null)) {
4625N/A throw new RuntimeException("EnumMap unexpectedly missing null value");
4625N/A }
4625N/A }
4625N/A}