diff --git a/makefile b/makefile index a8e418a08e..16f0bda40c 100644 --- a/makefile +++ b/makefile @@ -28,7 +28,7 @@ src = src classpath = classpath test = test -input = $(test-build)/Reflection.class +input = $(test-build)/Misc.class build-cxx = g++ build-cc = gcc diff --git a/src/machine.cpp b/src/machine.cpp index c4dcc1ff50..57fc157108 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -1371,6 +1371,8 @@ updateBootstrapClass(Thread* t, object bootstrapClass, object class_) and classObjectMask(t, class_) == 0) or intArrayEqual(t, classObjectMask(t, bootstrapClass), classObjectMask(t, class_))); + expect(t, arrayLength(t, classVirtualTable(t, bootstrapClass)) + == arrayLength(t, classVirtualTable(t, class_))); PROTECT(t, bootstrapClass); PROTECT(t, class_); @@ -1528,8 +1530,9 @@ bootClass(Thread* t, Machine::Type type, int superType, uint32_t objectMask, object super = (superType >= 0 ? arrayBody(t, t->m->types, superType) : 0); - object class_ = makeClass(t, 0, 0, 0, fixedSize, arrayElementSize, mask, 0, - super, 0, 0, 0, 0, 0, t->m->loader); + object class_ = makeClass + (t, 0, BootstrapFlag, 0, fixedSize, arrayElementSize, mask, 0, super, 0, 0 + , 0, 0, 0, t->m->loader); set(t, t->m->types, ArrayBody + (type * BytesPerWord), class_); } @@ -2119,9 +2122,13 @@ stringChars(Thread* t, object string, char* chars) bool isAssignableFrom(Thread* t, object a, object b) { - if (a == b) return true; + if (a == b) { + return true; + } else if (classFlags(t, a) & ACC_INTERFACE) { + if (classVmFlags(t, b) & BootstrapFlag) { + resolveClass(t, className(t, b)); + } - if (classFlags(t, a) & ACC_INTERFACE) { for (; b; b = classSuper(t, b)) { object itable = classInterfaceTable(t, b); if (itable) { diff --git a/src/machine.h b/src/machine.h index 3d4e4cf74b..37861d085c 100644 --- a/src/machine.h +++ b/src/machine.h @@ -62,6 +62,7 @@ const unsigned NeedInitFlag = 1 << 2; const unsigned InitFlag = 1 << 3; const unsigned PrimitiveFlag = 1 << 4; const unsigned SingletonFlag = 1 << 5; +const unsigned BootstrapFlag = 1 << 6; // method flags: const unsigned ClassInitFlag = 1 << 0; diff --git a/src/type-generator.cpp b/src/type-generator.cpp index 1daeae21de..928d837896 100644 --- a/src/type-generator.cpp +++ b/src/type-generator.cpp @@ -1295,6 +1295,12 @@ parseJavaClass(Object* type, Stream* s, Object* declarations) unsigned interfaceCount = s->read2(); s->skip(interfaceCount * 2); +// for (unsigned i = 0; i < interfaceCount; ++i) { +// const char* name = reinterpret_cast +// (pool[pool[s->read2() - 1] - 1]); + +// fprintf(stderr, "%s implements %s\n", typeJavaName(type), name); +// } unsigned fieldCount = s->read2(); for (unsigned i = 0; i < fieldCount; ++i) { diff --git a/test/Misc.java b/test/Misc.java index 3321647f20..2c584ce254 100644 --- a/test/Misc.java +++ b/test/Misc.java @@ -14,9 +14,11 @@ public class Misc { return s; } - public static void main(String[] args) { + public static void main(String[] args) throws Exception { boolean v = Boolean.valueOf("true"); + ClassLoader.getSystemClassLoader().toString(); + int a = 2; int b = 2; int c = a + b;