summaryrefslogtreecommitdiffstats
path: root/luni-kernel
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2009-09-27 14:26:34 -0700
committerElliott Hughes <enh@google.com>2009-09-30 11:40:10 -0700
commit3d478ad9fefa9c90b5c644f5e3d9437828537ed9 (patch)
treeb79762d59cdcd5e9e6435ba2015807c12a7a34a1 /luni-kernel
parent163cb7dc5a77b186cf66b00be970af7a14203b5f (diff)
downloadlibcore-3d478ad9fefa9c90b5c644f5e3d9437828537ed9.zip
libcore-3d478ad9fefa9c90b5c644f5e3d9437828537ed9.tar.gz
libcore-3d478ad9fefa9c90b5c644f5e3d9437828537ed9.tar.bz2
Throw meaningful IOException instances from native code.
The Java side of OSFileSystem was throwing IOExceptions with no detail message. If we throw from the native side instead, we can supply meaningful explanations. This turned up a couple of bugs: * read, readDirect, readv, writev, and ttyRead would only throw IOException if they returned < -1, which is impossible. (writev was probably a copy & paste from readv, and the reads were probably confused by the impedence mismatch between Unix's use of 0 to mean end of file and -1 to mean error, and Java's use of -1 for end of file.) * inconsistent checking for null byte[]s passed in. * read and write would retry on EINTR, but readDirect and writeDirect wouldn't. * we'd silently truncate seek/lock/truncate offsets that didn't fit in 32 bits; we now throw an IOException instead. It also means a few native functions become "void" because errors are now reported by throwing exceptions, and the Java functions that used to call them are no longer needed. Also change ProcessManager to use jniThrowIOException, remove the unused throwIOExceptionStr from OSNetworkSystem.cpp, and remove the KnownFailure from FileTest's test_delete, now we have a fixed version of yaffs that won't rmdir(2) non-empty directories. Bug: 1542253
Diffstat (limited to 'luni-kernel')
-rw-r--r--luni-kernel/src/main/native/java_lang_ProcessManager.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/luni-kernel/src/main/native/java_lang_ProcessManager.c b/luni-kernel/src/main/native/java_lang_ProcessManager.c
index eaefc9f..46e78f5 100644
--- a/luni-kernel/src/main/native/java_lang_ProcessManager.c
+++ b/luni-kernel/src/main/native/java_lang_ProcessManager.c
@@ -64,8 +64,7 @@ static void java_lang_ProcessManager_close(JNIEnv* env,
jclass clazz, jobject javaDescriptor) {
int fd = (*env)->GetIntField(env, javaDescriptor, descriptorField);
if (closeNow(fd) == -1) {
- jclass ioException = (*env)->FindClass(env, "java/io/IOException");
- (*env)->ThrowNew(env, ioException, strerror(errno));
+ jniThrowIOException(env, errno);
}
}