提交 c08633ca 编写于 作者: I igerasim

6996807: FieldReflectorKey hash code computation can be improved

Reviewed-by: rriggs
上级 eaca4f6e
/*
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2019, 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
......@@ -2371,7 +2371,7 @@ public class ObjectStreamClass implements Serializable {
*/
private static class FieldReflectorKey extends WeakReference<Class<?>> {
private final String sigs;
private final String[] sigs;
private final int hash;
private final boolean nullClass;
......@@ -2380,13 +2380,13 @@ public class ObjectStreamClass implements Serializable {
{
super(cl, queue);
nullClass = (cl == null);
StringBuilder sbuf = new StringBuilder();
for (int i = 0; i < fields.length; i++) {
sigs = new String[2 * fields.length];
for (int i = 0, j = 0; i < fields.length; i++) {
ObjectStreamField f = fields[i];
sbuf.append(f.getName()).append(f.getSignature());
sigs[j++] = f.getName();
sigs[j++] = f.getSignature();
}
sigs = sbuf.toString();
hash = System.identityHashCode(cl) + sigs.hashCode();
hash = System.identityHashCode(cl) + Arrays.hashCode(sigs);
}
public int hashCode() {
......@@ -2404,7 +2404,7 @@ public class ObjectStreamClass implements Serializable {
return (nullClass ? other.nullClass
: ((referent = get()) != null) &&
(referent == other.get())) &&
sigs.equals(other.sigs);
Arrays.equals(sigs, other.sigs);
} else {
return false;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册