From b498ad29bd52855cfc52e3a7ee8dc846f2689356 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Wed, 1 Feb 2017 15:07:11 +0000 Subject: [PATCH] Fix array flags --- src/machine.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index c2d43a503c..494370a130 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2940,8 +2940,15 @@ GcClass* makeArrayClass(Thread* t, GcArray* vtable = cast(t, type(t, GcJobject::Type)->virtualTable()); + // From JDK docs: for array classes the public, private, protected modifiers are the same as + // the underlying type, and the final modifier is always set. Testing on OpenJDK shows that + // ACC_ABSTRACT is also set on array classes. + int flags = elementClass->flags() & (ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED); + flags |= ACC_FINAL; + flags |= ACC_ABSTRACT; + GcClass* c = t->m->processor->makeClass(t, - 0, + flags, 0, 2 * BytesPerWord, BytesPerWord, @@ -3147,10 +3154,35 @@ void bootClass(Thread* t, mask = 0; } + int flags = 0; + switch(type) { + case Gc::JbyteType: + case Gc::JintType: + case Gc::JshortType: + case Gc::JlongType: + case Gc::JbooleanType: + case Gc::JcharType: + case Gc::JfloatType: + case Gc::JdoubleType: + + case Gc::ByteArrayType: + case Gc::IntArrayType: + case Gc::ShortArrayType: + case Gc::LongArrayType: + case Gc::BooleanArrayType: + case Gc::CharArrayType: + case Gc::FloatArrayType: + case Gc::DoubleArrayType: + // Primitive and array types are final, abstract and public. + flags = ACC_FINAL | ACC_ABSTRACT | ACC_PUBLIC; + default: + break; + } + super = (superType >= 0 ? vm::type(t, static_cast(superType)) : 0); GcClass* class_ = t->m->processor->makeClass(t, - 0, + flags, BootstrapFlag, fixedSize, arrayElementSize,