mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
snapshot; known bug: finalizers and weak references don't work correctly wrt tenured objects
This commit is contained in:
parent
f71c77298c
commit
a77693fb29
11
classpath/java/lang/LinkageError.java
Normal file
11
classpath/java/lang/LinkageError.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class LinkageError extends Error {
|
||||||
|
public LinkageError(String message) {
|
||||||
|
super(message, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkageError() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
}
|
11
classpath/java/lang/UnsatisfiedLinkError.java
Normal file
11
classpath/java/lang/UnsatisfiedLinkError.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class UnsatisfiedLinkError extends LinkageError {
|
||||||
|
public UnsatisfiedLinkError(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnsatisfiedLinkError() {
|
||||||
|
this(null);
|
||||||
|
}
|
||||||
|
}
|
@ -40,10 +40,7 @@ loadLibrary(Thread* t, jstring nameString)
|
|||||||
if (LIKELY(nameString)) {
|
if (LIKELY(nameString)) {
|
||||||
object n = *nameString;
|
object n = *nameString;
|
||||||
char name[stringLength(t, n) + 1];
|
char name[stringLength(t, n) + 1];
|
||||||
memcpy(name,
|
stringChars(t, n, name);
|
||||||
&byteArrayBody(t, stringBytes(t, n), stringOffset(t, n)),
|
|
||||||
stringLength(t, n));
|
|
||||||
name[stringLength(t, n)] = 0;
|
|
||||||
|
|
||||||
System::Library* lib;
|
System::Library* lib;
|
||||||
if (LIKELY(t->vm->system->success
|
if (LIKELY(t->vm->system->success
|
||||||
|
@ -19,12 +19,7 @@ GetStringUTFChars(Thread* t, jstring s, jboolean* isCopy)
|
|||||||
|
|
||||||
char* chars = static_cast<char*>
|
char* chars = static_cast<char*>
|
||||||
(t->vm->system->allocate(stringLength(t, *s) + 1));
|
(t->vm->system->allocate(stringLength(t, *s) + 1));
|
||||||
|
stringChars(t, *s, chars);
|
||||||
memcpy(chars,
|
|
||||||
&byteArrayBody(t, stringBytes(t, *s), stringOffset(t, *s)),
|
|
||||||
stringLength(t, *s));
|
|
||||||
|
|
||||||
chars[stringLength(t, *s)] = 0;
|
|
||||||
|
|
||||||
if (isCopy) *isCopy = true;
|
if (isCopy) *isCopy = true;
|
||||||
return chars;
|
return chars;
|
||||||
|
@ -331,6 +331,7 @@ collect(Thread* t, Heap::CollectionType type)
|
|||||||
void
|
void
|
||||||
removeMonitor(Thread* t, object o)
|
removeMonitor(Thread* t, object o)
|
||||||
{
|
{
|
||||||
|
abort(t);
|
||||||
hashMapRemove(t, t->vm->monitorMap, o, objectHash, referenceEqual);
|
hashMapRemove(t, t->vm->monitorMap, o, objectHash, referenceEqual);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,6 +671,24 @@ makeString(Thread* t, const char* format, ...)
|
|||||||
return makeString(t, s, 0, byteArrayLength(t, s), 0);
|
return makeString(t, s, 0, byteArrayLength(t, s), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
stringChars(Thread* t, object string, char* chars)
|
||||||
|
{
|
||||||
|
object data = stringData(t, string);
|
||||||
|
if (objectClass(t, data)
|
||||||
|
== arrayBody(t, t->vm->types, Machine::ByteArrayType))
|
||||||
|
{
|
||||||
|
memcpy(chars,
|
||||||
|
&byteArrayBody(t, data, stringOffset(t, string)),
|
||||||
|
stringLength(t, string));
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < stringLength(t, string); ++i) {
|
||||||
|
chars[i] = charArrayBody(t, data, stringOffset(t, string) + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
chars[stringLength(t, string)] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
object
|
object
|
||||||
hashMapFindNode(Thread* t, object map, object key,
|
hashMapFindNode(Thread* t, object map, object key,
|
||||||
uint32_t (*hash)(Thread*, object),
|
uint32_t (*hash)(Thread*, object),
|
||||||
|
@ -1397,6 +1397,9 @@ makeByteArray(Thread* t, const char* format, ...);
|
|||||||
object
|
object
|
||||||
makeString(Thread* t, const char* format, ...);
|
makeString(Thread* t, const char* format, ...);
|
||||||
|
|
||||||
|
void
|
||||||
|
stringChars(Thread* t, object string, char* chars);
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
pushObject(Thread* t, object o)
|
pushObject(Thread* t, object o)
|
||||||
{
|
{
|
||||||
|
83
src/run.cpp
83
src/run.cpp
@ -226,6 +226,9 @@ findInterfaceMethod(Thread* t, object method, object o)
|
|||||||
abort(t);
|
abort(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object
|
||||||
|
resolveClass(Thread*, object);
|
||||||
|
|
||||||
inline object
|
inline object
|
||||||
findMethod(Thread* t, object method, object class_)
|
findMethod(Thread* t, object method, object class_)
|
||||||
{
|
{
|
||||||
@ -233,12 +236,6 @@ findMethod(Thread* t, object method, object class_)
|
|||||||
methodOffset(t, method));
|
methodOffset(t, method));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline object
|
|
||||||
findVirtualMethod(Thread* t, object method, object o)
|
|
||||||
{
|
|
||||||
return findMethod(t, method, objectClass(t, o));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isSuperclass(Thread* t, object class_, object base)
|
isSuperclass(Thread* t, object class_, object base)
|
||||||
{
|
{
|
||||||
@ -451,9 +448,6 @@ addInterfaces(Thread* t, object class_, object map)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object
|
|
||||||
resolveClass(Thread*, object);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
parseInterfaceTable(Thread* t, Stream& s, object class_, object pool)
|
parseInterfaceTable(Thread* t, Stream& s, object class_, object pool)
|
||||||
{
|
{
|
||||||
@ -1204,7 +1198,10 @@ resolveClass(Thread* t, object spec)
|
|||||||
ClassFinder::Data* data = t->vm->classFinder->find
|
ClassFinder::Data* data = t->vm->classFinder->find
|
||||||
(reinterpret_cast<const char*>(&byteArrayBody(t, spec, 0)));
|
(reinterpret_cast<const char*>(&byteArrayBody(t, spec, 0)));
|
||||||
|
|
||||||
if (data) {
|
if (byteArrayBody(t, spec, 0) == '[') {
|
||||||
|
class_ = hashMapFind
|
||||||
|
(t, t->vm->bootstrapClassMap, spec, byteArrayHash, byteArrayEqual);
|
||||||
|
} else if (data) {
|
||||||
if (Verbose) {
|
if (Verbose) {
|
||||||
fprintf(stderr, "parsing %s\n", &byteArrayBody
|
fprintf(stderr, "parsing %s\n", &byteArrayBody
|
||||||
(t, spec, 0));
|
(t, spec, 0));
|
||||||
@ -1232,18 +1229,13 @@ resolveClass(Thread* t, object spec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
hashMapInsert(t, t->vm->classMap, spec, class_, byteArrayHash);
|
hashMapInsert(t, t->vm->classMap, spec, class_, byteArrayHash);
|
||||||
} else {
|
|
||||||
class_ = hashMapFind
|
|
||||||
(t, t->vm->bootstrapClassMap, spec, byteArrayHash, byteArrayEqual);
|
|
||||||
|
|
||||||
if (class_ == 0) {
|
|
||||||
object message = makeString(t, "%s", &byteArrayBody(t, spec, 0));
|
|
||||||
t->exception = makeClassNotFoundException(t, message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_) {
|
if (class_) {
|
||||||
hashMapInsert(t, t->vm->classMap, spec, class_, byteArrayHash);
|
hashMapInsert(t, t->vm->classMap, spec, class_, byteArrayHash);
|
||||||
|
} else {
|
||||||
|
object message = makeString(t, "%s", &byteArrayBody(t, spec, 0));
|
||||||
|
t->exception = makeClassNotFoundException(t, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2383,8 +2375,24 @@ run(Thread* t)
|
|||||||
if (LIKELY(peekObject(t, sp - parameterFootprint))) {
|
if (LIKELY(peekObject(t, sp - parameterFootprint))) {
|
||||||
object class_ = methodClass(t, frameMethod(t, frame));
|
object class_ = methodClass(t, frameMethod(t, frame));
|
||||||
if (isSpecialMethod(t, method, class_)) {
|
if (isSpecialMethod(t, method, class_)) {
|
||||||
code = findMethod(t, method, classSuper(t, class_));
|
class_ = classSuper(t, class_);
|
||||||
if (UNLIKELY(exception)) goto throw_;
|
|
||||||
|
if (UNLIKELY(classVirtualTable(t, class_) == 0)) {
|
||||||
|
PROTECT(t, class_);
|
||||||
|
|
||||||
|
resolveClass(t, className(t, class_));
|
||||||
|
if (UNLIKELY(exception)) goto throw_;
|
||||||
|
|
||||||
|
object clinit = classInitializer(t, class_);
|
||||||
|
if (clinit) {
|
||||||
|
set(t, classInitializer(t, methodClass(t, method)), 0);
|
||||||
|
code = clinit;
|
||||||
|
ip -= 3;
|
||||||
|
goto invoke;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = findMethod(t, method, class_);
|
||||||
} else {
|
} else {
|
||||||
code = method;
|
code = method;
|
||||||
}
|
}
|
||||||
@ -2425,10 +2433,24 @@ run(Thread* t)
|
|||||||
|
|
||||||
unsigned parameterFootprint = methodParameterFootprint(t, method);
|
unsigned parameterFootprint = methodParameterFootprint(t, method);
|
||||||
if (LIKELY(peekObject(t, sp - parameterFootprint))) {
|
if (LIKELY(peekObject(t, sp - parameterFootprint))) {
|
||||||
code = findVirtualMethod
|
object class_ = objectClass(t, peekObject(t, sp - parameterFootprint));
|
||||||
(t, method, peekObject(t, sp - parameterFootprint));
|
|
||||||
if (UNLIKELY(exception)) goto throw_;
|
|
||||||
|
|
||||||
|
if (UNLIKELY(classVirtualTable(t, class_) == 0)) {
|
||||||
|
PROTECT(t, class_);
|
||||||
|
|
||||||
|
resolveClass(t, className(t, class_));
|
||||||
|
if (UNLIKELY(exception)) goto throw_;
|
||||||
|
|
||||||
|
object clinit = classInitializer(t, class_);
|
||||||
|
if (clinit) {
|
||||||
|
set(t, classInitializer(t, methodClass(t, method)), 0);
|
||||||
|
code = clinit;
|
||||||
|
ip -= 3;
|
||||||
|
goto invoke;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
code = findMethod(t, method, class_);
|
||||||
goto invoke;
|
goto invoke;
|
||||||
} else {
|
} else {
|
||||||
exception = makeNullPointerException(t);
|
exception = makeNullPointerException(t);
|
||||||
@ -2635,6 +2657,8 @@ run(Thread* t)
|
|||||||
== arrayBody(t, t->vm->types, Machine::FloatType))
|
== arrayBody(t, t->vm->types, Machine::FloatType))
|
||||||
{
|
{
|
||||||
pushInt(t, floatValue(t, v));
|
pushInt(t, floatValue(t, v));
|
||||||
|
} else {
|
||||||
|
abort(t);
|
||||||
}
|
}
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
@ -2650,6 +2674,8 @@ run(Thread* t)
|
|||||||
== arrayBody(t, t->vm->types, Machine::DoubleType))
|
== arrayBody(t, t->vm->types, Machine::DoubleType))
|
||||||
{
|
{
|
||||||
pushLong(t, doubleValue(t, v));
|
pushLong(t, doubleValue(t, v));
|
||||||
|
} else {
|
||||||
|
abort(t);
|
||||||
}
|
}
|
||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
@ -3139,6 +3165,8 @@ run(Thread* t)
|
|||||||
} goto loop;
|
} goto loop;
|
||||||
|
|
||||||
throw_:
|
throw_:
|
||||||
|
fprintf(stderr, "throw\n");
|
||||||
|
pokeInt(t, t->frame + FrameIpOffset, t->ip);
|
||||||
for (; frame >= 0; frame = frameNext(t, frame)) {
|
for (; frame >= 0; frame = frameNext(t, frame)) {
|
||||||
if (methodFlags(t, frameMethod(t, frame)) & ACC_NATIVE) {
|
if (methodFlags(t, frameMethod(t, frame)) & ACC_NATIVE) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -3149,8 +3177,8 @@ run(Thread* t)
|
|||||||
if (eht) {
|
if (eht) {
|
||||||
for (unsigned i = 0; i < exceptionHandlerTableLength(t, eht); ++i) {
|
for (unsigned i = 0; i < exceptionHandlerTableLength(t, eht); ++i) {
|
||||||
ExceptionHandler* eh = exceptionHandlerTableBody(t, eht, i);
|
ExceptionHandler* eh = exceptionHandlerTableBody(t, eht, i);
|
||||||
if (frameIp(t, frame) >= exceptionHandlerStart(eh)
|
if (frameIp(t, frame) - 1 >= exceptionHandlerStart(eh)
|
||||||
and frameIp(t, frame) >= exceptionHandlerEnd(eh))
|
and frameIp(t, frame) - 1 < exceptionHandlerEnd(eh))
|
||||||
{
|
{
|
||||||
object catchType = 0;
|
object catchType = 0;
|
||||||
if (exceptionHandlerCatchType(eh)) {
|
if (exceptionHandlerCatchType(eh)) {
|
||||||
@ -3187,10 +3215,7 @@ run(Thread* t)
|
|||||||
if (throwableMessage(t, exception)) {
|
if (throwableMessage(t, exception)) {
|
||||||
object m = throwableMessage(t, exception);
|
object m = throwableMessage(t, exception);
|
||||||
char message[stringLength(t, m) + 1];
|
char message[stringLength(t, m) + 1];
|
||||||
memcpy(message,
|
stringChars(t, m, message);
|
||||||
&byteArrayBody(t, stringBytes(t, m), stringOffset(t, m)),
|
|
||||||
stringLength(t, m));
|
|
||||||
message[stringLength(t, m)] = 0;
|
|
||||||
fprintf(stderr, ": %s\n", message);
|
fprintf(stderr, ": %s\n", message);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
|
|
||||||
(type string java/lang/String
|
(type string java/lang/String
|
||||||
(extends jobject)
|
(extends jobject)
|
||||||
(object bytes)
|
(object data)
|
||||||
(int32_t offset)
|
(int32_t offset)
|
||||||
(int32_t length)
|
(int32_t length)
|
||||||
(int32_t hash))
|
(int32_t hash))
|
||||||
@ -169,9 +169,12 @@
|
|||||||
(type noSuchMethodError java/lang/NoSuchMethodError
|
(type noSuchMethodError java/lang/NoSuchMethodError
|
||||||
(extends error))
|
(extends error))
|
||||||
|
|
||||||
(type unsatisfiedLinkError java/lang/UnsatisifiedLinkError
|
(type linkageError java/lang/LinkageError
|
||||||
(extends error))
|
(extends error))
|
||||||
|
|
||||||
|
(type unsatisfiedLinkError java/lang/UnsatisifiedLinkError
|
||||||
|
(extends linkageError))
|
||||||
|
|
||||||
(type byte java/lang/Byte
|
(type byte java/lang/Byte
|
||||||
(extends jobject)
|
(extends jobject)
|
||||||
(int8_t value))
|
(int8_t value))
|
||||||
|
Loading…
Reference in New Issue
Block a user