DistinctEntrySetElements.java revision 3977
97a9a944b5887e91042b019776c41d5dd74557aferikabele * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
97a9a944b5887e91042b019776c41d5dd74557aferikabele * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c3ff7979929443ce8cbc881239f6cf130b4e256aslive * This code is free software; you can redistribute it and/or modify it
c3ff7979929443ce8cbc881239f6cf130b4e256aslive * under the terms of the GNU General Public License version 2 only, as
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * published by the Free Software Foundation.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * This code is distributed in the hope that it will be useful, but WITHOUT
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * version 2 for more details (a copy is included in the LICENSE file that
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * accompanied this code).
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * You should have received a copy of the GNU General Public License version
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * 2 along with this work; if not, write to the Free Software Foundation,
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * or visit www.oracle.com if you need additional information or have any
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * questions.
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * Portions Copyright (c) 2011 IBM Corporation
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * @bug 6312706
0c4abc32c00611fe1d52c9661f5cc79a3f74c6d4nd * @summary Sets from Map.entrySet() return distinct objects for each Entry
46fb146a4ec8c97d8dccb8c0c96a6cfddfc5442cnd * @author Neil Richards <neil.richards@ngmr.net>, <neil_richards@uk.ibm.com>
c3ff7979929443ce8cbc881239f6cf130b4e256aslive public static void main(String[] args) throws Exception {
c3ff7979929443ce8cbc881239f6cf130b4e256aslive final ConcurrentHashMap<String, String> concurrentHashMap =
46fb146a4ec8c97d8dccb8c0c96a6cfddfc5442cnd Set<Map.Entry<String, String>> entrySet = concurrentHashMap.entrySet();
20189240503ef2c8f5dc6e2248b57faab4b23b5and HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet);
46fb146a4ec8c97d8dccb8c0c96a6cfddfc5442cnd throw new RuntimeException("Test FAILED: Sets are not equal.");
46fb146a4ec8c97d8dccb8c0c96a6cfddfc5442cnd throw new RuntimeException("Test FAILED: Set's hashcodes are not equal.");