Mercurial > hg > truffle
changeset 18382:322d928a373e
fixed findbug's issue
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 15 Nov 2014 23:19:58 +0100 |
parents | 53bd20792127 |
children | 1518c3296cc8 |
files | graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/LinkedIdentityHashMap.java |
diffstat | 1 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/LinkedIdentityHashMap.java Sat Nov 15 16:39:23 2014 +0100 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/remote/LinkedIdentityHashMap.java Sat Nov 15 23:19:58 2014 +0100 @@ -52,7 +52,7 @@ * Wrapper for an object that gives uses the object's identity for the purpose of equality * comparisons and computing a hash code. */ - public static class Id<T> { + static final class Id<T> { final T object; public Id(T object) { @@ -63,7 +63,7 @@ @SuppressWarnings("unchecked") @Override public boolean equals(Object obj) { - return ((Id<T>) obj).object == object; + return obj instanceof Id && ((Id<T>) obj).object == object; } @Override @@ -110,7 +110,10 @@ @SuppressWarnings("unchecked") public void putAll(Map<? extends K, ? extends V> m) { - if (m != null && m.getClass() == getClass()) { + if (m == null) { + throw new NullPointerException(); + } + if (m.getClass() == getClass()) { LinkedIdentityHashMap<K, V> that = (LinkedIdentityHashMap<K, V>) m; map.putAll(that.map);