src/share/classes/java/util/Collections.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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.  Oracle designates this

@@ -1487,10 +1487,12 @@
                 public V setValue(V value) {
                     throw new UnsupportedOperationException();
                 }
                 public int hashCode()    {return e.hashCode();}
                 public boolean equals(Object o) {
+                    if (this == o)
+                        return true;
                     if (!(o instanceof Map.Entry))
                         return false;
                     Map.Entry t = (Map.Entry)o;
                     return eq(e.getKey(),   t.getKey()) &&
                            eq(e.getValue(), t.getValue());

@@ -1707,10 +1709,12 @@
         SynchronizedSet(Set<E> s, Object mutex) {
             super(s, mutex);
         }
 
         public boolean equals(Object o) {
+            if (this == o)
+                return true;
             synchronized (mutex) {return c.equals(o);}
         }
         public int hashCode() {
             synchronized (mutex) {return c.hashCode();}
         }

@@ -1861,10 +1865,12 @@
             super(list, mutex);
             this.list = list;
         }
 
         public boolean equals(Object o) {
+            if (this == o) 
+                return true;
             synchronized (mutex) {return list.equals(o);}
         }
         public int hashCode() {
             synchronized (mutex) {return list.hashCode();}
         }

@@ -2071,10 +2077,12 @@
                 return values;
             }
         }
 
         public boolean equals(Object o) {
+            if (this == o)
+                return true;
             synchronized (mutex) {return m.equals(o);}
         }
         public int hashCode() {
             synchronized (mutex) {return m.hashCode();}
         }