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

@ -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
@ -28,6 +28,9 @@ package sun.nio.ch;
import java.io.FileDescriptor;
import java.io.IOException;
import jdk.internal.misc.JavaIOFileDescriptorAccess;
import jdk.internal.misc.SharedSecrets;
class FileDispatcherImpl extends FileDispatcher {
static {
@ -35,6 +38,9 @@ class FileDispatcherImpl extends FileDispatcher {
init();
}
private static final JavaIOFileDescriptorAccess fdAccess =
SharedSecrets.getJavaIOFileDescriptorAccess();
FileDispatcherImpl() {
}
@ -95,7 +101,7 @@ class FileDispatcherImpl extends FileDispatcher {
}
void close(FileDescriptor fd) throws IOException {
close0(fd);
fdAccess.close(fd);
}
void preClose(FileDescriptor fd) throws IOException {
@ -153,6 +159,8 @@ class FileDispatcherImpl extends FileDispatcher {
static native void release0(FileDescriptor fd, long pos, long size)
throws IOException;
// Shared with SocketDispatcher and DatagramDispatcher but
// NOT used by FileDispatcherImpl
static native void close0(FileDescriptor fd) throws IOException;
static native void preClose0(FileDescriptor fd) throws IOException;