From 0ca8601777be0beca7bbcdfe5f7b9228541bf112 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 25 Oct 2013 13:23:03 -0500 Subject: [PATCH] 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#toArray(Class[][]) from working properly. Signed-off-by: Johannes Schindelin --- src/machine.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/machine.cpp b/src/machine.cpp index e8d60ce2fc..3bf59a6fe9 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -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),