On 04/06/12 16:33, Diego Belfer wrote:
Hi Alan,

I've already sent the signed OCA. Will  you sponsor the patch ?

I don't yet see you listed on the OCA Signatories List [1]. It may just take a little time to process your agreement.

-Chris.

[1] http://www.oracle.com/technetwork/community/oca-486395.html


Best,
Diego

On Mon, May 28, 2012 at 11:37 PM, Diego Belfer<dbel...@gmail.com>  wrote:

Hi Alan,

Thanks for your reply. I am attaching a new patch and it contains the test
case now.

I have read the contents of the link you sent me and I believe the OCA
signature is the only thing that is pending. I will send a signed copy of
the OCA tomorrow so my change can be applied to the repository once it gets
approved.

Let me know if I'm missing something.

Best,
Diego



# HG changeset patch
# User muralx
# Date 1338257674 10800
# Node ID f61b94fd7aca738353177fcf3cc3972ddf36cf36

# Parent  9b8c96f96a0f9a5801b55530a387fefbe50482a3
PATCH 7164256 : EnumMap.clone does not clear the instance field entrySet

diff --git a/src/share/classes/java/util/EnumMap.java
b/src/share/classes/java/util/EnumMap.java
--- a/src/share/classes/java/util/EnumMap.java
+++ b/src/share/classes/java/util/EnumMap.java
@@ -721,6 +721,7 @@
              throw new AssertionError();
          }
          result.vals = result.vals.clone();
+        result.entrySet = null;
          return result;
      }

diff --git a/test/java/util/EnumMap/ProperEntrySetOnClone.java
b/test/java/util/EnumMap/ProperEntrySetOnClone.java
new file mode 100644
--- /dev/null
+++ b/test/java/util/EnumMap/ProperEntrySetOnClone.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but
WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     7164256
+ * @summary EnumMap.entrySet() returns an entrySet referencing to the
cloned instance
+ * @author  Diego Belfer
+ */
+
+import java.util.EnumMap;
+
+public class ProperEntrySetOnClone {
+    public enum Test {
+        ONE, TWO
+    }
+
+    public static void main(String[] args) {
+        EnumMap<Test, String>  map1 = new EnumMap<Test,
String>(Test.class);
+        map1.put(Test.ONE, "1");
+        map1.put(Test.TWO, "2");
+
+        // We need to force creation of the map1.entrySet
+        int size = map1.entrySet().size();
+        if (size != 2) {
+            throw new RuntimeException(
+                    "Invalid size in original map. Expected: 2 was: " +
size);
+        }
+
+        EnumMap<Test, String>  map2 = map1.clone();
+        map2.remove(Test.ONE);
+        size = map2.entrySet().size();
+        if (size != 1) {
+            throw new RuntimeException(
+                    "Invalid size in cloned instance. Expected: 1 was: "
+ size);
+        }
+    }
+}



On Mon, May 28, 2012 at 5:02 PM, Alan Bateman<alan.bate...@oracle.com>wrote:

On 28/05/2012 20:31, Diego Belfer wrote:

Hi,

The patch seems to have been removed by the mailer. I am adding it
inline.

Best,
Diego Belfer
[muralx]

  Thanks for the bug report and patch. I think mailman is configured to
drop certain types of attachments which would explain why it was missing
from your first mail.

As you are contributing a fix then I would suggesting going through this
page first:

http://openjdk.java.net/**contribute/<http://openjdk.java.net/contribute/>

This explains how to be a contributor. Also note in section 3 that a unit
or regression tests should be included where practical. I realize this will
be more work than the fix itself but that is often the case. You can find
some examples of tests for this area in jdk/test/java/util/EnumMap.

-Alan.



Reply via email to