8080225: FileInput/OutputStream/FileChannel cleanup should be improved

Reviewed-by: mchung, plevart, bpb
This commit is contained in:
Roger Riggs 2017-12-01 16:40:08 -05:00
parent b93586c51e
commit f29e21abb1
23 changed files with 1104 additions and 261 deletions

View file

@ -57,7 +57,7 @@ Java_java_io_FileDescriptor_initIDs(JNIEnv *env, jclass fdClass) {
}
JNIEXPORT jlong JNICALL
Java_java_io_FileDescriptor_set(JNIEnv *env, jclass fdClass, jint fd) {
Java_java_io_FileDescriptor_getHandle(JNIEnv *env, jclass fdClass, jint fd) {
SET_HANDLE(fd);
}
@ -73,8 +73,17 @@ Java_java_io_FileDescriptor_sync(JNIEnv *env, jobject this) {
}
}
JNIEXPORT void JNICALL
Java_java_io_FileDescriptor_cleanupClose0(JNIEnv *env, jclass fdClass, jlong handle) {
if (handle != -1) {
if (CloseHandle((HANDLE)handle) == -1) {
JNU_ThrowIOExceptionWithLastError(env, "close failed");
}
}
}
// instance method close0 for FileDescriptor
JNIEXPORT void JNICALL
Java_java_io_FileDescriptor_close(JNIEnv *env, jobject this) {
Java_java_io_FileDescriptor_close0(JNIEnv *env, jobject this) {
fileDescriptorClose(env, this);
}