Fix getClass().getComponentType() for higher-dimensional arrays

When creating an object array with more than two dimensions, the
component type was erroneously set to the base type, not the array
type of one less dimension.

This prevented Collection<Class[]>#toArray(Class[][]) from working
properly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2013-10-25 13:23:03 -05:00
parent 187d5dfde9
commit 0ca8601777

View File

@ -2512,7 +2512,11 @@ makeArrayClass(Thread* t, object loader, object spec, bool throw_,
++ s;
const char* elementSpecStart = s;
while (*s and *s != ';') ++ s;
if (dimensions > 1) {
elementSpecStart -= dimensions;
++ s;
}
elementSpec = makeByteArray(t, s - elementSpecStart + 1);
memcpy(&byteArrayBody(t, elementSpec, 0),
&byteArrayBody(t, spec, elementSpecStart - start),