8187631: Refactor FileDescriptor close implementation

Reviewed-by: bpb, alanb
This commit is contained in:
Roger Riggs 2017-09-21 11:41:12 -04:00
parent 8088bd6350
commit 5e55e5e2ee
20 changed files with 184 additions and 305 deletions

View file

@ -341,7 +341,7 @@ class FileInputStream extends InputStream
fd.closeAll(new Closeable() {
public void close() throws IOException {
close0();
fd.close();
}
});
}
@ -403,7 +403,6 @@ class FileInputStream extends InputStream
private static native void initIDs();
private native void close0() throws IOException;
static {
initIDs();

View file

@ -365,7 +365,7 @@ class FileOutputStream extends OutputStream
fd.closeAll(new Closeable() {
public void close() throws IOException {
close0();
fd.close();
}
});
}
@ -458,8 +458,6 @@ class FileOutputStream extends OutputStream
}
}
private native void close0() throws IOException;
private static native void initIDs();
static {

View file

@ -648,7 +648,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
fd.closeAll(new Closeable() {
public void close() throws IOException {
close0();
fd.close();
}
});
}
@ -1177,8 +1177,6 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
private static native void initIDs();
private native void close0() throws IOException;
static {
initIDs();
SharedSecrets.setJavaIORandomAccessFileAccess(new JavaIORandomAccessFileAccess()

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -31,12 +31,13 @@ import java.io.FileDescriptor;
*/
public interface JavaIOFileDescriptorAccess {
public void set(FileDescriptor obj, int fd);
public int get(FileDescriptor fd);
public void setAppend(FileDescriptor obj, boolean append);
public boolean getAppend(FileDescriptor obj);
public void set(FileDescriptor fdo, int fd);
public int get(FileDescriptor fdo);
public void setAppend(FileDescriptor fdo, boolean append);
public boolean getAppend(FileDescriptor fdo);
public void close(FileDescriptor fdo);
// Only valid on Windows
public void setHandle(FileDescriptor obj, long handle);
public long getHandle(FileDescriptor obj);
public void setHandle(FileDescriptor fdo, long handle);
public long getHandle(FileDescriptor fdo);
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -144,7 +144,7 @@ public class FileChannelImpl
//
((java.io.Closeable)parent).close();
} else {
nd.close(fd);
fdAccess.close(fd);
}
}