From c6ac66e45ad9a08f6de48047ee9c57d406e86f98 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 27 Feb 2012 18:16:01 -0700 Subject: [PATCH] fix bug in isAssignableFrom such that primitive array types were considered to be subclasses of the Object array type --- src/machine.cpp | 7 +++++-- src/machine.h | 2 ++ test/Misc.java | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index 33d1599f20..f05ba92d39 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -869,9 +869,10 @@ parsePoolEntry(Thread* t, Stream& s, uint32_t* index, object pool, unsigned i) parsePoolEntry(t, s, index, pool, ci); parsePoolEntry(t, s, index, pool, nti); - + object class_ = referenceName(t, singletonObject(t, pool, ci)); object nameAndType = singletonObject(t, pool, nti); + object value = makeReference (t, class_, pairFirst(t, nameAndType), pairSecond(t, nameAndType)); set(t, pool, SingletonBody + (i * BytesPerWord), value); @@ -3228,7 +3229,9 @@ isAssignableFrom(Thread* t, object a, object b) return isAssignableFrom (t, classStaticTable(t, a), classStaticTable(t, b)); } - } else { + } else if ((classVmFlags(t, a) & PrimitiveFlag) + == (classVmFlags(t, b) & PrimitiveFlag)) + { for (; b; b = classSuper(t, b)) { if (b == a) { return true; diff --git a/src/machine.h b/src/machine.h index 96c853624f..83ea2577a4 100644 --- a/src/machine.h +++ b/src/machine.h @@ -2164,6 +2164,8 @@ hashTaken(Thread*, object o) inline unsigned baseSize(Thread* t, object o, object class_) { + assert(t, classFixedSize(t, class_) >= BytesPerWord); + return ceiling(classFixedSize(t, class_), BytesPerWord) + ceiling(classArrayElementSize(t, class_) * cast(o, classFixedSize(t, class_) - BytesPerWord), diff --git a/test/Misc.java b/test/Misc.java index 7ff2f25378..450f23d2b0 100644 --- a/test/Misc.java +++ b/test/Misc.java @@ -235,5 +235,7 @@ public class Misc { System.out.println(75.62); System.out.println(75.62d); System.out.println(new char[] { 'h', 'i' }); + + expect(! (((Object) new int[0]) instanceof Object[])); } }