mirror of
https://github.com/corda/corda.git
synced 2024-12-28 00:38:55 +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)) {
|
||||
object n = *nameString;
|
||||
char name[stringLength(t, n) + 1];
|
||||
memcpy(name,
|
||||
&byteArrayBody(t, stringBytes(t, n), stringOffset(t, n)),
|
||||
stringLength(t, n));
|
||||
name[stringLength(t, n)] = 0;
|
||||
stringChars(t, n, name);
|
||||
|
||||
System::Library* lib;
|
||||
if (LIKELY(t->vm->system->success
|
||||
|
@ -19,12 +19,7 @@ GetStringUTFChars(Thread* t, jstring s, jboolean* isCopy)
|
||||
|
||||
char* chars = static_cast<char*>
|
||||
(t->vm->system->allocate(stringLength(t, *s) + 1));
|
||||
|
||||
memcpy(chars,
|
||||
&byteArrayBody(t, stringBytes(t, *s), stringOffset(t, *s)),
|
||||
stringLength(t, *s));
|
||||
|
||||
chars[stringLength(t, *s)] = 0;
|
||||
stringChars(t, *s, chars);
|
||||
|
||||
if (isCopy) *isCopy = true;
|
||||
return chars;
|
||||
|
@ -331,6 +331,7 @@ collect(Thread* t, Heap::CollectionType type)
|
||||
void
|
||||
removeMonitor(Thread* t, object o)
|
||||
{
|
||||
abort(t);
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
hashMapFindNode(Thread* t, object map, object key,
|
||||
uint32_t (*hash)(Thread*, object),
|
||||
|
@ -1397,6 +1397,9 @@ makeByteArray(Thread* t, const char* format, ...);
|
||||
object
|
||||
makeString(Thread* t, const char* format, ...);
|
||||
|
||||
void
|
||||
stringChars(Thread* t, object string, char* chars);
|
||||
|
||||
inline void
|
||||
pushObject(Thread* t, object o)
|
||||
{
|
||||
|
85
src/run.cpp
85
src/run.cpp
@ -226,6 +226,9 @@ findInterfaceMethod(Thread* t, object method, object o)
|
||||
abort(t);
|
||||
}
|
||||
|
||||
object
|
||||
resolveClass(Thread*, object);
|
||||
|
||||
inline object
|
||||
findMethod(Thread* t, object method, object class_)
|
||||
{
|
||||
@ -233,12 +236,6 @@ findMethod(Thread* t, object method, object class_)
|
||||
methodOffset(t, method));
|
||||
}
|
||||
|
||||
inline object
|
||||
findVirtualMethod(Thread* t, object method, object o)
|
||||
{
|
||||
return findMethod(t, method, objectClass(t, o));
|
||||
}
|
||||
|
||||
bool
|
||||
isSuperclass(Thread* t, object class_, object base)
|
||||
{
|
||||
@ -451,9 +448,6 @@ addInterfaces(Thread* t, object class_, object map)
|
||||
}
|
||||
}
|
||||
|
||||
object
|
||||
resolveClass(Thread*, object);
|
||||
|
||||
void
|
||||
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
|
||||
(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) {
|
||||
fprintf(stderr, "parsing %s\n", &byteArrayBody
|
||||
(t, spec, 0));
|
||||
@ -1232,18 +1229,13 @@ resolveClass(Thread* t, object spec)
|
||||
}
|
||||
|
||||
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_) {
|
||||
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))) {
|
||||
object class_ = methodClass(t, frameMethod(t, frame));
|
||||
if (isSpecialMethod(t, method, class_)) {
|
||||
code = findMethod(t, method, classSuper(t, class_));
|
||||
if (UNLIKELY(exception)) goto throw_;
|
||||
class_ = classSuper(t, class_);
|
||||
|
||||
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 {
|
||||
code = method;
|
||||
}
|
||||
@ -2425,10 +2433,24 @@ run(Thread* t)
|
||||
|
||||
unsigned parameterFootprint = methodParameterFootprint(t, method);
|
||||
if (LIKELY(peekObject(t, sp - parameterFootprint))) {
|
||||
code = findVirtualMethod
|
||||
(t, method, peekObject(t, sp - parameterFootprint));
|
||||
if (UNLIKELY(exception)) goto throw_;
|
||||
|
||||
object class_ = objectClass(t, peekObject(t, sp - parameterFootprint));
|
||||
|
||||
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;
|
||||
} else {
|
||||
exception = makeNullPointerException(t);
|
||||
@ -2635,6 +2657,8 @@ run(Thread* t)
|
||||
== arrayBody(t, t->vm->types, Machine::FloatType))
|
||||
{
|
||||
pushInt(t, floatValue(t, v));
|
||||
} else {
|
||||
abort(t);
|
||||
}
|
||||
} goto loop;
|
||||
|
||||
@ -2650,6 +2674,8 @@ run(Thread* t)
|
||||
== arrayBody(t, t->vm->types, Machine::DoubleType))
|
||||
{
|
||||
pushLong(t, doubleValue(t, v));
|
||||
} else {
|
||||
abort(t);
|
||||
}
|
||||
} goto loop;
|
||||
|
||||
@ -3139,6 +3165,8 @@ run(Thread* t)
|
||||
} goto loop;
|
||||
|
||||
throw_:
|
||||
fprintf(stderr, "throw\n");
|
||||
pokeInt(t, t->frame + FrameIpOffset, t->ip);
|
||||
for (; frame >= 0; frame = frameNext(t, frame)) {
|
||||
if (methodFlags(t, frameMethod(t, frame)) & ACC_NATIVE) {
|
||||
return 0;
|
||||
@ -3149,8 +3177,8 @@ run(Thread* t)
|
||||
if (eht) {
|
||||
for (unsigned i = 0; i < exceptionHandlerTableLength(t, eht); ++i) {
|
||||
ExceptionHandler* eh = exceptionHandlerTableBody(t, eht, i);
|
||||
if (frameIp(t, frame) >= exceptionHandlerStart(eh)
|
||||
and frameIp(t, frame) >= exceptionHandlerEnd(eh))
|
||||
if (frameIp(t, frame) - 1 >= exceptionHandlerStart(eh)
|
||||
and frameIp(t, frame) - 1 < exceptionHandlerEnd(eh))
|
||||
{
|
||||
object catchType = 0;
|
||||
if (exceptionHandlerCatchType(eh)) {
|
||||
@ -3187,10 +3215,7 @@ run(Thread* t)
|
||||
if (throwableMessage(t, exception)) {
|
||||
object m = throwableMessage(t, exception);
|
||||
char message[stringLength(t, m) + 1];
|
||||
memcpy(message,
|
||||
&byteArrayBody(t, stringBytes(t, m), stringOffset(t, m)),
|
||||
stringLength(t, m));
|
||||
message[stringLength(t, m)] = 0;
|
||||
stringChars(t, m, message);
|
||||
fprintf(stderr, ": %s\n", message);
|
||||
} else {
|
||||
fprintf(stderr, "\n");
|
||||
|
@ -110,7 +110,7 @@
|
||||
|
||||
(type string java/lang/String
|
||||
(extends jobject)
|
||||
(object bytes)
|
||||
(object data)
|
||||
(int32_t offset)
|
||||
(int32_t length)
|
||||
(int32_t hash))
|
||||
@ -169,9 +169,12 @@
|
||||
(type noSuchMethodError java/lang/NoSuchMethodError
|
||||
(extends error))
|
||||
|
||||
(type unsatisfiedLinkError java/lang/UnsatisifiedLinkError
|
||||
(type linkageError java/lang/LinkageError
|
||||
(extends error))
|
||||
|
||||
(type unsatisfiedLinkError java/lang/UnsatisifiedLinkError
|
||||
(extends linkageError))
|
||||
|
||||
(type byte java/lang/Byte
|
||||
(extends jobject)
|
||||
(int8_t value))
|
||||
|
Loading…
Reference in New Issue
Block a user