Bug with Multianewarray

Brendon Cahoon cahoon at meteor.cs.umass.edu
Fri Oct 9 16:12:03 PDT 1998


Fixed a problem with the MULTINEWARRAY bytecode.  It has a bug when a
dimension > 1 is specied with 0.  For example,

    Integer arr[][] = new Integer[10][0];

The problem is that arr[i] is null - it should be a reference to
another array (with 0 elements).

The two files involved are soft.c and object.c. The diffs are below
(compared to the kaffe-1.0.b2 release):

diff -u kaffe-1.0.b2/kaffe/kaffevm/object.c release/kaffe-1.0.b2//kaffe/kaffevm/object.c
--- kaffe-1.0.b2/kaffe/kaffevm/object.c Fri Oct  9 16:36:45 1998
+++ release/kaffe-1.0.b2//kaffe/kaffevm/object.c        Wed Sep 30 18:15:57 1998
@@ -113,7 +113,7 @@
        int i;
 
        obj = newArray(CLASS_ELEMENT_TYPE(clazz), dims[0]);
-       if (dims[1] >= 0) {
+       if (dims[1] > 0) {
                array = OBJARRAY_DATA(obj);
                for (i = 0; i < dims[0]; i++) {
                        array[i] = newMultiArray(CLASS_ELEMENT_TYPE(clazz), &dims[1]);

diff -u kaffe-1.0.b2/kaffe/kaffevm/soft.c release/kaffe-1.0.b2//kaffe/kaffevm/soft.c
--- kaffe-1.0.b2/kaffe/kaffevm/soft.c   Fri Oct  9 16:36:49 1998
+++ release/kaffe-1.0.b2//kaffe/kaffevm/soft.c  Wed Sep 30 15:24:13 1998
@@ -128,7 +128,7 @@
                }
                 arraydims[i] = arg;
         }
-        arraydims[i] = -1;
+        arraydims[i] = 0;
 
         /* Mmm, okay now build the array using the wonders of recursion */
         obj = newMultiArray(class, arraydims);



More information about the kaffe mailing list