Skip to content
Browse files

fix element spec calculation for multidimensional primitive arrays

The element class for e.g. [[[I should be [[I, not [I.
  • Loading branch information...
1 parent 023787d commit 8995db69d279b240d104bfd2d21398266cb25984 @dicej dicej committed Apr 22, 2013
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/machine.cpp
View
11 src/machine.cpp
@@ -2510,10 +2510,13 @@ makeArrayClass(Thread* t, object loader, object spec, bool throw_,
default:
if (dimensions > 1) {
char c = *s;
- elementSpec = makeByteArray(t, 3);
- byteArrayBody(t, elementSpec, 0) = '[';
- byteArrayBody(t, elementSpec, 1) = c;
- byteArrayBody(t, elementSpec, 2) = 0;
+ elementSpec = makeByteArray(t, dimensions + 1);
+ unsigned i;
+ for (i = 0; i < dimensions - 1; ++i) {
+ byteArrayBody(t, elementSpec, i) = '[';
+ }
+ byteArrayBody(t, elementSpec, i++) = c;
+ byteArrayBody(t, elementSpec, i) = 0;
-- dimensions;
} else {
abort(t);

0 comments on commit 8995db6

Please sign in to comment.
Something went wrong with that request. Please try again.