There is actually a comment in the code about this (ObjectArrayList):
- The actual value in this field is always <code>Object</code>, regardless of the
- generic type used. The JDK is inconsistent here too –
- internal <code>Object</code> buffer, but
declares an array of
- generic type objects like we do. The tradeoff is probably minimal, but you should
- be aware of additional casts generated by <code>javac</code>
- when <code>buffer</code> is directly accessed - these casts may result in exceptions
- at runtime. A workaround is to cast directly to <code>Object</code> before
- accessing the buffer's elements.
but this can't stay this way indeed, it's weird. I'll look for a workaround.