< prev index next >

src/java.base/share/classes/java/lang/invoke/VarHandle.java

Print this page
rev 52981 : 8215300: additional changes to constants API

@@ -1862,10 +1862,20 @@
             this.type = type;
             this.mode = mode;
         }
     }
 
+    /**
+     * Compare this {@linkplain VarHandle} with another object for equality.
+     * Two {@linkplain VarHandle}s are considered equal if they both describe the
+     * same instance field, both describe the same static field, both describe
+     * array elements for arrays with the same component type, or both describe
+     * the same component of an off-heap structure.
+     *
+     * @param o the other object
+     * @return Whether this {@linkplain VarHandle} is equal to the other object
+     */
     @Override
     public final boolean equals(Object o) {
         if (this == o) return true;
         if (o == null || getClass() != o.getClass()) return false;
 

@@ -1881,10 +1891,16 @@
         return 31 * accessModeType(AccessMode.GET).hashCode() + internalHashCode();
     }
 
     abstract int internalHashCode();
 
+    /**
+     * Returns a compact textual description of this {@linkplain VarHandle},
+     * including the type of variable described, and a description of its coordinates.
+     *
+     * @return A compact textual description of this {@linkplain VarHandle}
+     */
     @Override
     public final String toString() {
         return String.format("VarHandle[varType=%s, coord=%s]",
                              varType().getName(),
                              coordinateTypes());

@@ -2270,10 +2286,18 @@
                 default:
                     throw new InternalError("Cannot reach here");
             }
         }
 
+        /**
+         * Returns a compact textual description of this constant description.
+         * For a field {@linkplain VarHandle}, includes the owner, name, and type
+         * of the field, and whether it is static; for an array {@linkplain VarHandle},
+         * the name of the component type.
+         *
+         * @return A compact textual description of this descriptor
+         */
         @Override
         public String toString() {
             switch (kind) {
                 case FIELD:
                 case STATIC_FIELD:
< prev index next >