more bugfixes

This commit is contained in:
Joel Dice
2007-08-14 07:27:10 -06:00
parent 587dbeb163
commit 71c7013808
6 changed files with 27 additions and 10 deletions

View File

@ -58,7 +58,7 @@ doOpen(JNIEnv* e, const char* path, int mask)
{ {
int fd = OPEN(path, mask | OPEN_MASK, S_IRUSR | S_IWUSR); int fd = OPEN(path, mask | OPEN_MASK, S_IRUSR | S_IWUSR);
if (fd == -1) { if (fd == -1) {
throwNew(e, "java/lang/IOException", strerror(errno)); throwNew(e, "java/io/IOException", strerror(errno));
} }
return fd; return fd;
} }
@ -68,7 +68,7 @@ doClose(JNIEnv* e, jint fd)
{ {
int r = CLOSE(fd); int r = CLOSE(fd);
if (r == -1) { if (r == -1) {
throwNew(e, "java/lang/IOException", strerror(errno)); throwNew(e, "java/io/IOException", strerror(errno));
} }
} }
@ -81,7 +81,7 @@ doRead(JNIEnv* e, jint fd, jbyte* data, jint length)
} else if (r == 0) { } else if (r == 0) {
return -1; return -1;
} else { } else {
throwNew(e, "java/lang/IOException", strerror(errno)); throwNew(e, "java/io/IOException", strerror(errno));
return 0; return 0;
} }
} }
@ -91,7 +91,7 @@ doWrite(JNIEnv* e, jint fd, const jbyte* data, jint length)
{ {
int r = WRITE(fd, data, length); int r = WRITE(fd, data, length);
if (r != length) { if (r != length) {
throwNew(e, "java/lang/IOException", strerror(errno)); throwNew(e, "java/io/IOException", strerror(errno));
} }
} }
@ -128,7 +128,7 @@ Java_java_io_File_mkdir(JNIEnv* e, jclass, jstring path)
if (not exists(chars)) { if (not exists(chars)) {
int r = ::MKDIR(chars, 0700); int r = ::MKDIR(chars, 0700);
if (r != 0) { if (r != 0) {
throwNew(e, "java/lang/IOException", strerror(errno)); throwNew(e, "java/io/IOException", strerror(errno));
} }
} }
e->ReleaseStringUTFChars(path, chars); e->ReleaseStringUTFChars(path, chars);
@ -143,7 +143,7 @@ Java_java_io_File_createNewFile(JNIEnv* e, jclass, jstring path)
if (not exists(chars)) { if (not exists(chars)) {
int fd = CREAT(chars, 0600); int fd = CREAT(chars, 0600);
if (fd == -1) { if (fd == -1) {
throwNew(e, "java/lang/IOException", strerror(errno)); throwNew(e, "java/io/IOException", strerror(errno));
} else { } else {
doClose(e, fd); doClose(e, fd);
} }

View File

@ -16,6 +16,7 @@ public class StringReader extends Reader {
} }
} }
in.getChars(position, length, b, offset); in.getChars(position, length, b, offset);
position += length;
return length; return length;
} }

View File

@ -35,6 +35,10 @@ public class Throwable {
return message; return message;
} }
public String toString() {
return getClass().getName() + ": " + message;
}
private static native Object trace(int skipCount); private static native Object trace(int skipCount);
private static native StackTraceElement[] resolveTrace(Object trace); private static native StackTraceElement[] resolveTrace(Object trace);

View File

@ -95,6 +95,12 @@ ThrowNew(Thread* t, jclass c, const char* message)
return 0; return 0;
} }
void
DeleteLocalRef(Thread*, jobject)
{
// do nothing
}
jboolean jboolean
ExceptionCheck(Thread* t) ExceptionCheck(Thread* t)
{ {
@ -119,6 +125,7 @@ populateJNITable(JNIEnvVTable* table)
table->FindClass = ::FindClass; table->FindClass = ::FindClass;
table->ThrowNew = ::ThrowNew; table->ThrowNew = ::ThrowNew;
table->ExceptionCheck = ::ExceptionCheck; table->ExceptionCheck = ::ExceptionCheck;
table->DeleteLocalRef = ::DeleteLocalRef;
} }
} // namespace vm } // namespace vm

View File

@ -1033,7 +1033,9 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
set(t, classMethodTable(t, class_), methodTable); set(t, classMethodTable(t, class_), methodTable);
} }
if (declaredVirtualCount == 0) { if (declaredVirtualCount == 0
and (classFlags(t, class_) & ACC_INTERFACE) == 0)
{
// inherit interface table and virtual table from superclass // inherit interface table and virtual table from superclass
set(t, classInterfaceTable(t, class_), set(t, classInterfaceTable(t, class_),

View File

@ -208,11 +208,14 @@ resolve(Thread* t, object pool, unsigned index,
object class_ = resolveClass(t, o, referenceClass); object class_ = resolveClass(t, o, referenceClass);
if (UNLIKELY(t->exception)) return 0; if (UNLIKELY(t->exception)) return 0;
o = 0;
if (classFlags(t, class_) & ACC_INTERFACE) { if (classFlags(t, class_) & ACC_INTERFACE) {
if (classVirtualTable(t, class_)) {
o = ::find(t, classVirtualTable(t, class_), arrayBody(t, pool, index), o = ::find(t, classVirtualTable(t, class_), arrayBody(t, pool, index),
methodName, methodSpec); methodName, methodSpec);
}
} else { } else {
for (o = 0; o == 0 and class_; class_ = classSuper(t, class_)) { for (; o == 0 and class_; class_ = classSuper(t, class_)) {
o = find(t, class_, arrayBody(t, pool, index)); o = find(t, class_, arrayBody(t, pool, index));
} }
} }