4 ms·
For ArrayList, it was a huge speed regression. get(), set(), and add() were not inlineable for ten years due to an error fixable with a single line of code. T
by SeanLuke 14y ago
For ArrayList, it was a huge speed regression. get(), set(), and add() were not inlineable for ten years due to an error fixable with a single line of code. The problematic code is still there even now, but it's moot because sometime between Java 5 and 6 the Hotspot team special-cased it.
Over the years I've found that while the Hotspot team seemed pretty sharp, the monkeys writing the library code were incompetent in implementation and negligent in repair even for core stuff. I eventually gave up submitting error reports. Don't even get me started on java.util.Random. :-(
- screamers 14y agoThat's because HotSpot is written in C++, whereas the Java libraries are written in, well, Java.
- brown9-2 14y agoDo you have links available for your bug reports?
- SeanLuke 14y agoNot since Sun->Oracle totally changed the bug reporting system, sorry. It was long ago. In the ArrayList case, IIRC (it was years ago) the issue was the now-notorious RangeCheck function. For example, get(index) does this: RangeCheck(index); return elementData[index]; get() could be inlined, but because RangeCheck threw an exception if the index was >= size, RangeCheck was not inlined. But if you did this: if (index >= size) RangeCheck(index); return elementData[index]; ... you could bypass it and calls to get() would involve inlined code unless the exception was triggered. Same went for set and add. Recent versions of HotSpot have mooted this now.