mirror of
https://github.com/corda/corda.git
synced 2024-12-28 16:58:55 +00:00
make builtin class type a bootstrap version of java/lang/Class
This commit is contained in:
parent
69eed6ba5a
commit
0099aa396b
@ -1,9 +1,23 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public final class Class <T> {
|
public final class Class <T> {
|
||||||
private Object body;
|
private short flags;
|
||||||
|
private short vmFlags;
|
||||||
|
private short fixedSize;
|
||||||
|
private short arrayElementSize;
|
||||||
|
private int[] objectMask;
|
||||||
|
private byte[] name;
|
||||||
|
private Class super_;
|
||||||
|
private Object interfaceTable;
|
||||||
|
private Object virtualTable;
|
||||||
|
private Object fieldTable;
|
||||||
|
private Object methodTable;
|
||||||
|
private Object staticTable;
|
||||||
|
private Object initializer;
|
||||||
|
|
||||||
private Class() { }
|
private Class() { }
|
||||||
|
|
||||||
public native String getName();
|
public String getName() {
|
||||||
|
return new String(name, 0, name.length, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,20 @@ public final class String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String(byte[] data, int offset, int length, boolean copy) {
|
||||||
|
if (copy) {
|
||||||
|
byte[] c = new byte[length];
|
||||||
|
System.arraycopy(data, offset, c, 0, length);
|
||||||
|
|
||||||
|
this.data = c;
|
||||||
|
this.length = length;
|
||||||
|
} else {
|
||||||
|
this.data = data;
|
||||||
|
this.offset = offset;
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int length() {
|
public int length() {
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,12 @@ toString(Thread* t, jobject this_)
|
|||||||
return pushReference(t, s);
|
return pushReference(t, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jclass
|
||||||
|
getClass(Thread* t, jobject this_)
|
||||||
|
{
|
||||||
|
return pushReference(t, objectClass(t, *this_));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
wait(Thread* t, jobject this_, jlong milliseconds)
|
wait(Thread* t, jobject this_, jlong milliseconds)
|
||||||
{
|
{
|
||||||
@ -189,6 +195,8 @@ populate(Thread* t, object map)
|
|||||||
} builtins[] = {
|
} builtins[] = {
|
||||||
{ "Java_java_lang_Object_toString",
|
{ "Java_java_lang_Object_toString",
|
||||||
reinterpret_cast<void*>(toString) },
|
reinterpret_cast<void*>(toString) },
|
||||||
|
{ "Java_java_lang_Object_getClass",
|
||||||
|
reinterpret_cast<void*>(getClass) },
|
||||||
{ "Java_java_lang_Object_wait",
|
{ "Java_java_lang_Object_wait",
|
||||||
reinterpret_cast<void*>(wait) },
|
reinterpret_cast<void*>(wait) },
|
||||||
{ "Java_java_lang_Object_notify",
|
{ "Java_java_lang_Object_notify",
|
||||||
|
@ -537,13 +537,15 @@ Thread::Thread(Machine* m, Allocator* allocator, object javaThread,
|
|||||||
object arrayClass = arrayBody(t, t->vm->types, Machine::ArrayType);
|
object arrayClass = arrayBody(t, t->vm->types, Machine::ArrayType);
|
||||||
set(t, cast<object>(t->vm->types, 0), arrayClass);
|
set(t, cast<object>(t->vm->types, 0), arrayClass);
|
||||||
|
|
||||||
|
object objectClass = arrayBody(t, m->types, Machine::JobjectType);
|
||||||
|
|
||||||
object classClass = arrayBody(t, m->types, Machine::ClassType);
|
object classClass = arrayBody(t, m->types, Machine::ClassType);
|
||||||
set(t, cast<object>(classClass, 0), classClass);
|
set(t, cast<object>(classClass, 0), classClass);
|
||||||
|
set(t, classSuper(t, classClass), objectClass);
|
||||||
|
|
||||||
object intArrayClass = arrayBody(t, m->types, Machine::IntArrayType);
|
object intArrayClass = arrayBody(t, m->types, Machine::IntArrayType);
|
||||||
set(t, cast<object>(intArrayClass, 0), classClass);
|
set(t, cast<object>(intArrayClass, 0), classClass);
|
||||||
set(t, classSuper(t, intArrayClass),
|
set(t, classSuper(t, intArrayClass), objectClass);
|
||||||
arrayBody(t, m->types, Machine::JobjectType));
|
|
||||||
|
|
||||||
m->unsafe = false;
|
m->unsafe = false;
|
||||||
|
|
||||||
|
@ -568,7 +568,7 @@ parseFieldTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
classFixedSize(t, class_) = pad(memberOffset);
|
classFixedSize(t, class_) = pad(memberOffset);
|
||||||
|
|
||||||
object mask = makeIntArray
|
object mask = makeIntArray
|
||||||
(t, divide(classFixedSize(t, class_), BitsPerWord), true);
|
(t, divide(classFixedSize(t, class_), BitsPerWord * BytesPerWord), true);
|
||||||
intArrayBody(t, mask, 0) = 1;
|
intArrayBody(t, mask, 0) = 1;
|
||||||
|
|
||||||
bool sawReferenceField = false;
|
bool sawReferenceField = false;
|
||||||
|
@ -71,14 +71,14 @@ cons(Object* car, Object* cdr)
|
|||||||
return Pair::make(car, cdr);
|
return Pair::make(car, cdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object*
|
Object*&
|
||||||
car(Object* o)
|
car(Object* o)
|
||||||
{
|
{
|
||||||
assert(o->type == Object::Pair);
|
assert(o->type == Object::Pair);
|
||||||
return static_cast<Pair*>(o)->car;
|
return static_cast<Pair*>(o)->car;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object*
|
Object*&
|
||||||
cdr(Object* o)
|
cdr(Object* o)
|
||||||
{
|
{
|
||||||
assert(o->type == Object::Pair);
|
assert(o->type == Object::Pair);
|
||||||
@ -1514,6 +1514,27 @@ typeCount(Object* declarations)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object*
|
||||||
|
reorder(Object* declarations)
|
||||||
|
{
|
||||||
|
Object* intArrayType = 0;
|
||||||
|
Object* classType = 0;
|
||||||
|
for (Object** p = &declarations; *p;) {
|
||||||
|
Object* o = car(*p);
|
||||||
|
if (o->type == Object::Type and equal(typeName(o), "intArray")) {
|
||||||
|
intArrayType = o;
|
||||||
|
*p = cdr(*p);
|
||||||
|
} else if (o->type == Object::Type and equal(typeName(o), "class")) {
|
||||||
|
classType = o;
|
||||||
|
*p = cdr(*p);
|
||||||
|
} else {
|
||||||
|
p = &cdr(*p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cons(intArrayType, cons(classType, declarations));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
writeInitializations(Output* out, Object* declarations)
|
writeInitializations(Output* out, Object* declarations)
|
||||||
{
|
{
|
||||||
@ -1530,16 +1551,11 @@ writeInitializations(Output* out, Object* declarations)
|
|||||||
out->write(count);
|
out->write(count);
|
||||||
out->write(" * sizeof(void*));\n\n");
|
out->write(" * sizeof(void*));\n\n");
|
||||||
|
|
||||||
for (Object* p = declarations; p; p = cdr(p)) {
|
declarations = reorder(declarations);
|
||||||
Object* o = car(p);
|
|
||||||
if (o->type == Object::Type and equal(typeName(o), "intArray")) {
|
|
||||||
writeInitialization(out, o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Object* p = declarations; p; p = cdr(p)) {
|
for (Object* p = declarations; p; p = cdr(p)) {
|
||||||
Object* o = car(p);
|
Object* o = car(p);
|
||||||
if (o->type == Object::Type and not equal(typeName(o), "intArray")) {
|
if (o->type == Object::Type) {
|
||||||
writeInitialization(out, o);
|
writeInitialization(out, o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
(type class
|
(type jobject java/lang/Object)
|
||||||
|
|
||||||
|
(type class java/lang/Class
|
||||||
|
(extends jobject)
|
||||||
(uint16_t flags)
|
(uint16_t flags)
|
||||||
(uint16_t vmFlags)
|
(uint16_t vmFlags)
|
||||||
(uint16_t fixedSize)
|
(uint16_t fixedSize)
|
||||||
@ -105,9 +108,6 @@
|
|||||||
(type array
|
(type array
|
||||||
(noassert array object body))
|
(noassert array object body))
|
||||||
|
|
||||||
|
|
||||||
(type jobject java/lang/Object)
|
|
||||||
|
|
||||||
(type string java/lang/String
|
(type string java/lang/String
|
||||||
(extends jobject)
|
(extends jobject)
|
||||||
(object data)
|
(object data)
|
||||||
|
Loading…
Reference in New Issue
Block a user