mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8294399: (ch) Refactor some methods out of sun.nio.ch.UnixFileDispatcherImpl
Reviewed-by: alanb
This commit is contained in:
parent
628820f47e
commit
d6678952a6
9 changed files with 171 additions and 73 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2022, 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
|
||||
|
@ -33,7 +33,7 @@ import java.io.IOException;
|
|||
* for read and write operations.
|
||||
*/
|
||||
|
||||
class DatagramDispatcher extends NativeDispatcher {
|
||||
class DatagramDispatcher extends UnixDispatcher {
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
|
@ -56,15 +56,15 @@ class DatagramDispatcher extends NativeDispatcher {
|
|||
}
|
||||
|
||||
void close(FileDescriptor fd) throws IOException {
|
||||
FileDispatcherImpl.close0(fd);
|
||||
close0(fd);
|
||||
}
|
||||
|
||||
void preClose(FileDescriptor fd) throws IOException {
|
||||
FileDispatcherImpl.preClose0(fd);
|
||||
preClose0(fd);
|
||||
}
|
||||
|
||||
void dup(FileDescriptor fd1, FileDescriptor fd2) throws IOException {
|
||||
FileDispatcherImpl.dup0(fd1, fd2);
|
||||
dup0(fd1, fd2);
|
||||
}
|
||||
|
||||
static native int read0(FileDescriptor fd, long address, int len)
|
||||
|
@ -78,4 +78,7 @@ class DatagramDispatcher extends NativeDispatcher {
|
|||
|
||||
static native long writev0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native void dup0(FileDescriptor fd1, FileDescriptor fd2)
|
||||
throws IOException;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2022, 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
|
||||
|
@ -33,7 +33,7 @@ import java.io.IOException;
|
|||
* for read and write operations.
|
||||
*/
|
||||
|
||||
class SocketDispatcher extends NativeDispatcher {
|
||||
class SocketDispatcher extends UnixDispatcher {
|
||||
SocketDispatcher() { }
|
||||
|
||||
/**
|
||||
|
@ -59,19 +59,19 @@ class SocketDispatcher extends NativeDispatcher {
|
|||
}
|
||||
|
||||
int write(FileDescriptor fd, long address, int len) throws IOException {
|
||||
return FileDispatcherImpl.write0(fd, address, len);
|
||||
return write0(fd, address, len);
|
||||
}
|
||||
|
||||
long writev(FileDescriptor fd, long address, int len) throws IOException {
|
||||
return FileDispatcherImpl.writev0(fd, address, len);
|
||||
return writev0(fd, address, len);
|
||||
}
|
||||
|
||||
void close(FileDescriptor fd) throws IOException {
|
||||
FileDispatcherImpl.close0(fd);
|
||||
close0(fd);
|
||||
}
|
||||
|
||||
void preClose(FileDescriptor fd) throws IOException {
|
||||
FileDispatcherImpl.preClose0(fd);
|
||||
preClose0(fd);
|
||||
}
|
||||
|
||||
// -- Native methods --
|
||||
|
@ -82,6 +82,12 @@ class SocketDispatcher extends NativeDispatcher {
|
|||
private static native long readv0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native int write0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static native long writev0(FileDescriptor fd, long address, int len)
|
||||
throws IOException;
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
}
|
||||
|
|
51
src/java.base/unix/classes/sun/nio/ch/UnixDispatcher.java
Normal file
51
src/java.base/unix/classes/sun/nio/ch/UnixDispatcher.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2022, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.nio.ch;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.IOException;
|
||||
|
||||
abstract class UnixDispatcher extends NativeDispatcher {
|
||||
|
||||
void close(FileDescriptor fd) throws IOException {
|
||||
close0(fd);
|
||||
}
|
||||
|
||||
void preClose(FileDescriptor fd) throws IOException {
|
||||
preClose0(fd);
|
||||
}
|
||||
|
||||
static native void close0(FileDescriptor fd) throws IOException;
|
||||
|
||||
static native void preClose0(FileDescriptor fd) throws IOException;
|
||||
|
||||
static native void init();
|
||||
|
||||
static {
|
||||
IOUtil.load();
|
||||
init();
|
||||
}
|
||||
}
|
|
@ -39,7 +39,6 @@ class UnixFileDispatcherImpl extends FileDispatcher {
|
|||
|
||||
static {
|
||||
IOUtil.load();
|
||||
init();
|
||||
}
|
||||
|
||||
private static final JavaIOFileDescriptorAccess fdAccess =
|
||||
|
@ -108,14 +107,6 @@ class UnixFileDispatcherImpl extends FileDispatcher {
|
|||
fdAccess.close(fd);
|
||||
}
|
||||
|
||||
void preClose(FileDescriptor fd) throws IOException {
|
||||
preClose0(fd);
|
||||
}
|
||||
|
||||
void dup(FileDescriptor fd1, FileDescriptor fd2) throws IOException {
|
||||
dup0(fd1, fd2);
|
||||
}
|
||||
|
||||
FileDescriptor duplicateForMapping(FileDescriptor fd) {
|
||||
// file descriptor not required for mapping operations; okay
|
||||
// to return invalid file descriptor.
|
||||
|
@ -211,14 +202,6 @@ class UnixFileDispatcherImpl 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;
|
||||
|
||||
static native void dup0(FileDescriptor fd1, FileDescriptor fd2) throws IOException;
|
||||
|
||||
static native void closeIntFD(int fd) throws IOException;
|
||||
|
||||
static native long allocationGranularity0();
|
||||
|
@ -230,6 +213,4 @@ class UnixFileDispatcherImpl extends FileDispatcher {
|
|||
static native int unmap0(long address, long length);
|
||||
|
||||
static native int setDirect0(FileDescriptor fd) throws IOException;
|
||||
|
||||
static native void init();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue