diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index 740d5199c6..3c4ec00544 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -331,7 +331,7 @@ Java_java_io_File_length(JNIEnv* e, jclass, jstring path) } } - return -1; + return 0; } extern "C" JNIEXPORT void JNICALL diff --git a/test/FileOutput.java b/test/FileOutput.java index fa2cc0965e..6fffc0f8a7 100644 --- a/test/FileOutput.java +++ b/test/FileOutput.java @@ -4,6 +4,10 @@ import java.io.File; import java.io.IOException; public class FileOutput { + private static void expect(boolean v) { + if (! v) throw new RuntimeException(); + } + private static void test(boolean appendFirst) throws IOException { try { FileOutputStream f = new FileOutputStream("test.txt", appendFirst); @@ -33,6 +37,8 @@ public class FileOutput { } public static void main(String[] args) throws IOException { + expect(new File("nonexistent-file").length() == 0); + test(false); test(true); }