changeset 14526:7e2dc25eef6b

8141677: Improve java.lang.invoke.MemberName hashCode implementation Reviewed-by: vlivanov, psandoz, shade
author redestad
date Mon, 09 Nov 2015 17:14:05 +0100
parents bb286ec75b24
children 6cfb4df38b6d
files src/java.base/share/classes/java/lang/invoke/MemberName.java
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/invoke/MemberName.java	Mon Nov 09 11:02:07 2015 -0500
+++ b/src/java.base/share/classes/java/lang/invoke/MemberName.java	Mon Nov 09 17:14:05 2015 +0100
@@ -694,8 +694,11 @@
 
     @Override
     public int hashCode() {
-        return Objects.hash(clazz, getReferenceKind(), name, getType());
+        // Avoid autoboxing getReferenceKind(), since this is used early and will force
+        // early initialization of Byte$ByteCache
+        return Objects.hash(clazz, new Byte(getReferenceKind()), name, getType());
     }
+
     @Override
     public boolean equals(Object that) {
         return (that instanceof MemberName && this.equals((MemberName)that));