Merged branch subtype-trunk into default.
[cacao.git] / src / vm / linker.cpp
index a29ffaa86bdaa1704985bbba61c339c41c2a11dd..b1bd60a427ca66815990cf6269939f03395e75be 100644 (file)
 
 #include "vm/types.h"
 
-#include "mm/memory.h"
+#include "mm/memory.hpp"
 
 #include "native/native.hpp"
 
 #include "threads/lock.hpp"
 #include "threads/mutex.hpp"
 
-#include "toolbox/logging.h"
+#include "toolbox/logging.hpp"
 
 #include "vm/access.hpp"
 #include "vm/array.hpp"
@@ -531,7 +531,7 @@ static bool linker_overwrite_method(methodinfo *mg,
 
 *******************************************************************************/
 
-static void build_display(classinfo *c)
+static classinfo *build_display(classinfo *c)
 {
        int depth, i;
        int depth_fixed;
@@ -558,7 +558,8 @@ static void build_display(classinfo *c)
                super = c->super;
        } while (false);
        if (super) {
-               build_display(super);
+               if (!link_class(super))
+                       return NULL;
                depth = super->vftbl->subtype_depth + 1;
        } else
                /* java.lang.Object doesn't have a super class. */
@@ -586,6 +587,8 @@ static void build_display(classinfo *c)
                c->vftbl->subtype_display[i] = NULL;
        c->vftbl->subtype_offset = OFFSET(vftbl_t, subtype_display[0]) + sizeof(vftbl_t*) * depth_fixed;
        c->vftbl->subtype_depth = depth;
+
+       return c;
 }
 #endif
 
@@ -995,7 +998,8 @@ static classinfo *link_class_intern(classinfo *c)
        RT_TIMING_GET_TIME(time_subclasses);
 
 #if USES_NEW_SUBTYPE
-       build_display(c);
+       if (!build_display(c))
+               return NULL;
 #endif
 
        /* revert the linking state and class is linked */
@@ -1104,8 +1108,8 @@ static arraydescriptor *link_array(classinfo *c)
                        desc->elementvftbl = compvftbl->arraydesc->elementvftbl;
 
                        if (compvftbl->arraydesc->dimension >= 255) {
-                               log_text("Creating array of dimension >255");
-                               assert(0);
+                               exceptions_throw_illegalargumentexception();
+                               return NULL;
                        }
 
                        desc->dimension = compvftbl->arraydesc->dimension + 1;