diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index a91067a3da..da95bb068a 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -163,6 +163,21 @@ Java_java_io_File_delete(JNIEnv* e, jclass, jstring path) return r == 0; } +extern "C" JNIEXPORT jboolean JNICALL +Java_java_io_File_isDirectory(JNIEnv* e, jclass, jstring path) +{ + const char* chars = e->GetStringUTFChars(path, 0); + if (chars) { + STRUCT_STAT s; + int r = STAT(chars, &s); + bool v = (r == 0 and S_ISDIR(s.st_mode)); + e->ReleaseStringUTFChars(path, chars); + return v; + } else { + return false; + } +} + extern "C" JNIEXPORT jboolean JNICALL Java_java_io_File_exists(JNIEnv* e, jclass, jstring path) { diff --git a/classpath/java/io/File.java b/classpath/java/io/File.java index 8dd379c205..d99b2fa628 100644 --- a/classpath/java/io/File.java +++ b/classpath/java/io/File.java @@ -23,6 +23,12 @@ public class File { this(parent.getPath() + FileSeparator + child); } + private static native boolean isDirectory(String path); + + public boolean isDirectory() { + return isDirectory(path); + } + public String getName() { int index = path.lastIndexOf(FileSeparator); if (index >= 0) { diff --git a/classpath/java/lang/Byte.java b/classpath/java/lang/Byte.java index 1d1f4caac2..8863b67547 100644 --- a/classpath/java/lang/Byte.java +++ b/classpath/java/lang/Byte.java @@ -37,6 +37,10 @@ public final class Byte extends Number implements Comparable { return toString(v, 10); } + public static byte parseByte(String s) { + return (byte) Integer.parseInt(s); + } + public byte byteValue() { return value; } diff --git a/classpath/java/lang/Runtime.java b/classpath/java/lang/Runtime.java index ddc657ec87..3546e388c2 100644 --- a/classpath/java/lang/Runtime.java +++ b/classpath/java/lang/Runtime.java @@ -60,6 +60,8 @@ public class Runtime { public native long freeMemory(); + public native long totalMemory(); + private static class MyProcess extends Process { private int pid; private final int in; diff --git a/src/builtin.cpp b/src/builtin.cpp index 11d645527b..a7d3801059 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -561,6 +561,13 @@ Java_java_lang_Runtime_freeMemory(Thread*, jobject) return 0; } +extern "C" JNIEXPORT jlong JNICALL +Java_java_lang_Runtime_totalMemory(Thread*, jobject) +{ + // todo + return 0; +} + extern "C" JNIEXPORT jobject JNICALL Java_java_lang_Throwable_trace(Thread* t, jclass, jint skipCount) {