From fcfdd6be3ac73ec211718cdec69cef825c7b382a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 13 May 2013 13:12:58 -0600 Subject: [PATCH] initialize the class if necessary when the "new" operator is invoked This is one of the conditions specified in http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.4.1, which I had forgotten about. --- src/compile.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/compile.cpp b/src/compile.cpp index 24737d8344..649e55fb5f 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -3252,22 +3252,35 @@ instanceOfFromReference(Thread* t, object pair, object o) uint64_t makeNewGeneral64(Thread* t, object class_) { + PROTECT(t, class_); + + initClass(t, class_); + return reinterpret_cast(makeNewGeneral(t, class_)); } uint64_t makeNew64(Thread* t, object class_) { + PROTECT(t, class_); + + initClass(t, class_); + return reinterpret_cast(makeNew(t, class_)); } uint64_t makeNewFromReference(Thread* t, object pair) { - return makeNewGeneral64 - (t, resolveClass - (t, classLoader(t, methodClass(t, pairFirst(t, pair))), - referenceName(t, pairSecond(t, pair)))); + object class_ = resolveClass + (t, classLoader(t, methodClass(t, pairFirst(t, pair))), + referenceName(t, pairSecond(t, pair))); + + PROTECT(t, class_); + + initClass(t, class_); + + return makeNewGeneral64(t, class_); } uint64_t