RFR JDK-8022442: Fix unchecked warnings in HashMap

Dan Smith daniel.smith at oracle.com
Tue Aug 6 22:23:14 UTC 2013

On Aug 6, 2013, at 2:43 PM, Remi Forax <forax at univ-mlv.fr> wrote:

> On 08/06/2013 11:11 PM, Dan Smith wrote:
>> Please review this warnings cleanup.
>> Bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8022442 (not yet visible)
>> Webrev: http://cr.openjdk.java.net/~dlsmith/8022442/webrev.00/
>> —Dan
> Hi Dan,
> I've seen that you have introduce a common super interface for entry and tree node,
> I suppose that  you check that there is no performance regression.
> I wonder if an abstract class is not better than an interface because as far as I know
> CHA implemented in hotspot doesn't work on interface
> (but I may be wrong, there is perhaps a special optimization for arrays).

To make sure I understand: your concern is that an aastore will be more expensive when assigning to a KeyValueData[] than to an Object[] (or even to SomeOtherClass[])?

For what it's worth, all assignments to table[i] are statically known to be safe.  E.g.:

Entry<K,V> next = (Entry<K,V>) e.next;
table[i] = next;

So surely a smart VM only does the check once?

Here are some other things that might be concerns, but don't apply here:
- interface method invocations: there are no methods in the interface to invoke
- checkcast to an interface: all the casts are to concrete classes (Entry, TreeBin, TreeNode)

(There are some unchecked casts from KeyValueData to KeyValueData with different type parameters, but I assume these don't cause any checkcasts.)


More information about the core-libs-dev mailing list