6996807: FieldReflectorKey hash code computation can be improved
Reviewed-by: rriggs
This commit is contained in:
parent
32d78c46dc
commit
d76c772d2f
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -2275,7 +2275,7 @@ public class ObjectStreamClass implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private static class FieldReflectorKey extends WeakReference<Class<?>> {
|
private static class FieldReflectorKey extends WeakReference<Class<?>> {
|
||||||
|
|
||||||
private final String sigs;
|
private final String[] sigs;
|
||||||
private final int hash;
|
private final int hash;
|
||||||
private final boolean nullClass;
|
private final boolean nullClass;
|
||||||
|
|
||||||
@ -2284,13 +2284,13 @@ public class ObjectStreamClass implements Serializable {
|
|||||||
{
|
{
|
||||||
super(cl, queue);
|
super(cl, queue);
|
||||||
nullClass = (cl == null);
|
nullClass = (cl == null);
|
||||||
StringBuilder sbuf = new StringBuilder();
|
sigs = new String[2 * fields.length];
|
||||||
for (int i = 0; i < fields.length; i++) {
|
for (int i = 0, j = 0; i < fields.length; i++) {
|
||||||
ObjectStreamField f = fields[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) + Arrays.hashCode(sigs);
|
||||||
hash = System.identityHashCode(cl) + sigs.hashCode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
@ -2308,7 +2308,7 @@ public class ObjectStreamClass implements Serializable {
|
|||||||
return (nullClass ? other.nullClass
|
return (nullClass ? other.nullClass
|
||||||
: ((referent = get()) != null) &&
|
: ((referent = get()) != null) &&
|
||||||
(referent == other.get())) &&
|
(referent == other.get())) &&
|
||||||
sigs.equals(other.sigs);
|
Arrays.equals(sigs, other.sigs);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user