8016576: Overrides warnings in jdi and jconsole
authorkhazra
Wed, 19 Jun 2013 14:02:38 -0700
changeset 18292 3d40978f5ff8
parent 18291 18803e8ff87c
child 18293 5d768c1bf246
8016576: Overrides warnings in jdi and jconsole Summary: Implement hashCode() in classes emitting warnings Reviewed-by: alanb, chegar
jdk/src/share/classes/com/sun/tools/jdi/SDE.java
jdk/src/share/classes/sun/tools/jconsole/inspector/XObject.java
--- a/jdk/src/share/classes/com/sun/tools/jdi/SDE.java	Wed Jun 19 13:00:53 2013 -0700
+++ b/jdk/src/share/classes/com/sun/tools/jdi/SDE.java	Wed Jun 19 14:02:38 2013 -0700
@@ -171,7 +171,7 @@
         }
 
         public boolean equals(Object obj) {
-            if ((obj != null) && (obj instanceof LineStratum)) {
+            if (obj instanceof LineStratum) {
                 LineStratum other = (LineStratum)obj;
                 return (lti == other.lti) &&
                        (sti == other.sti) &&
@@ -182,6 +182,11 @@
             }
         }
 
+        @Override
+        public int hashCode() {
+            return (lineNumber() * 17) ^ refType.hashCode();
+        }
+
         int lineNumber() {
             return stiLineNumber(sti, lti, jplsLine);
         }
--- a/jdk/src/share/classes/sun/tools/jconsole/inspector/XObject.java	Wed Jun 19 13:00:53 2013 -0700
+++ b/jdk/src/share/classes/sun/tools/jconsole/inspector/XObject.java	Wed Jun 19 14:02:38 2013 -0700
@@ -27,6 +27,7 @@
 
 // java import
 import javax.swing.*;
+import java.util.Objects;
 
 /**
  * This provides a wrapper to the Object class to allow it to be
@@ -48,18 +49,17 @@
     }
 
     public boolean equals(Object o) {
-        try {
-            if (o instanceof XObject) {
-                return object.equals(((XObject)o).getObject());
-            }
-        }
-        catch (Throwable t) {
-            System.out.println("Error comparing XObjects"+
-                               t.getMessage());
+        if (o instanceof XObject) {
+            return Objects.equals(object, ((XObject)o).getObject());
         }
         return false;
     }
 
+    @Override
+    public int hashCode() {
+        return object.hashCode();
+    }
+
 
     public Object getObject() {
         return object;