diff --git a/classpath/avian/Continuations.java b/classpath/avian/Continuations.java
index ecec10b348..42565830d4 100644
--- a/classpath/avian/Continuations.java
+++ b/classpath/avian/Continuations.java
@@ -128,7 +128,7 @@ public class Continuations {
* receiver.receive(Callback)
, propagate the exception
* thrown by that method, return the result passed to the
* handleResult(T) method of the continuation, or throw the
- * exception passed to the handleException(Throwable) of the
+ * exception passed to the handleException(Throwable) method of the
* continuation.
*/
public static native T callWithCurrentContinuation
diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp
index 134045bdd2..f134d6dc0c 100644
--- a/classpath/java-io.cpp
+++ b/classpath/java-io.cpp
@@ -25,6 +25,7 @@
# include
# include
+# define ACCESS _waccess
# define CLOSE _close
# define READ _read
# define WRITE _write
@@ -56,6 +57,7 @@ typedef wchar_t char_t;
# include
# include "sys/mman.h"
+# define ACCESS access
# define OPEN open
# define CLOSE close
# define READ read
@@ -377,6 +379,31 @@ Java_java_io_File_delete(JNIEnv* e, jclass, jstring path)
}
}
+extern "C" JNIEXPORT jboolean JNICALL
+Java_java_io_File_canRead(JNIEnv* e, jclass, jstring path)
+{
+ string_t chars = getChars(e, path);
+ if (chars) {
+ int r = ACCESS(chars, R_OK);
+ releaseChars(e, path, chars);
+ return (r == 0);
+ }
+ return false;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL
+Java_java_io_File_canWrite(JNIEnv* e, jclass, jstring path)
+{
+ string_t chars = getChars(e, path);
+ if (chars) {
+ int r = ACCESS(chars, W_OK);
+ releaseChars(e, path, chars);
+ return (r == 0);
+ }
+ return false;
+}
+
+
extern "C" JNIEXPORT jboolean JNICALL
Java_java_io_File_rename(JNIEnv* e, jclass, jstring old, jstring new_)
{
diff --git a/classpath/java-lang.cpp b/classpath/java-lang.cpp
index 8303e3e4e1..ea37b2f275 100644
--- a/classpath/java-lang.cpp
+++ b/classpath/java-lang.cpp
@@ -36,9 +36,6 @@
# define isnan _isnan
# define isfinite _finite
# define strtof strtod
-# define FTIME _ftime_s
-# else
-# define FTIME _ftime
# endif
#else // not PLATFORM_WINDOWS
@@ -234,7 +231,8 @@ extern "C" JNIEXPORT void JNICALL
Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
jobjectArray command, jlongArray process)
{
- char** argv = static_cast(malloc((e->GetArrayLength(command) + 1) * sizeof(char*)));
+ char** argv = static_cast
+ (malloc((e->GetArrayLength(command) + 1) * sizeof(char*)));
int i;
for(i = 0; i < e->GetArrayLength(command); i++){
jstring element = (jstring) e->GetObjectArrayElement(command, i);
@@ -255,11 +253,11 @@ Java_java_lang_Runtime_exec(JNIEnv* e, jclass,
makePipe(e, out);
if(e->ExceptionCheck()) return;
jlong outDescriptor = static_cast(out[1]);
- e->SetLongArrayRegion(process, 1, 1, &outDescriptor);
+ e->SetLongArrayRegion(process, 2, 1, &outDescriptor);
makePipe(e, err);
if(e->ExceptionCheck()) return;
jlong errDescriptor = static_cast(err[0]);
- e->SetLongArrayRegion(process, 1, 1, &errDescriptor);
+ e->SetLongArrayRegion(process, 3, 1, &errDescriptor);
makePipe(e, msg);
if(e->ExceptionCheck()) return;
if(fcntl(msg[1], F_SETFD, FD_CLOEXEC) != 0) {
@@ -468,9 +466,13 @@ extern "C" JNIEXPORT jlong JNICALL
Java_java_lang_System_currentTimeMillis(JNIEnv*, jclass)
{
#ifdef PLATFORM_WINDOWS
- _timeb tb;
- FTIME(&tb);
- return (static_cast(tb.time) * 1000) + static_cast(tb.millitm);
+ // We used to use _ftime here, but that only gives us 1-second
+ // resolution on Windows 7. _ftime_s might work better, but MinGW
+ // doesn't have it as of this writing. So we use this mess instead:
+ FILETIME time;
+ GetSystemTimeAsFileTime(&time);
+ return (((static_cast(time.dwHighDateTime) << 32)
+ | time.dwLowDateTime) / 10000) - 11644473600000LL;
#else
timeval tv = { 0, 0 };
gettimeofday(&tv, 0);
diff --git a/classpath/java/io/File.java b/classpath/java/io/File.java
index c3fa42932f..86ef77c6a3 100644
--- a/classpath/java/io/File.java
+++ b/classpath/java/io/File.java
@@ -60,7 +60,19 @@ public class File {
public boolean isFile() {
return isFile(path);
}
+
+ private static native boolean canRead(String path);
+
+ public boolean canRead() {
+ return canRead(path);
+ }
+ private static native boolean canWrite(String path);
+
+ public boolean canWrite() {
+ return canWrite(path);
+ }
+
public String getName() {
int index = path.lastIndexOf(FileSeparator);
if (index >= 0) {
diff --git a/classpath/java/io/ObjectInputStream.java b/classpath/java/io/ObjectInputStream.java
index 001a192a73..8447e10efa 100644
--- a/classpath/java/io/ObjectInputStream.java
+++ b/classpath/java/io/ObjectInputStream.java
@@ -79,6 +79,10 @@ public class ObjectInputStream extends InputStream {
read('d');
return readDoubleToken();
}
+
+ public void defaultReadObject() throws IOException {
+ throw new UnsupportedOperationException();
+ }
private void skipSpace() throws IOException {
int c;
diff --git a/classpath/java/io/ObjectOutputStream.java b/classpath/java/io/ObjectOutputStream.java
index 42d080f676..90743a5b32 100644
--- a/classpath/java/io/ObjectOutputStream.java
+++ b/classpath/java/io/ObjectOutputStream.java
@@ -82,6 +82,10 @@ public class ObjectOutputStream extends OutputStream {
out.print(v);
}
+ public void defaultWriteObject() throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
private void writeObject(Object o, IdentityHashMap