Path: blob/master/src/java.base/share/classes/sun/nio/ch/NativeDispatcher.java
41159 views
/*1* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.nio.ch;2627import java.io.FileDescriptor;28import java.io.IOException;2930/**31* Allows different platforms to call different native methods32* for read and write operations.33*/3435abstract class NativeDispatcher {3637abstract int read(FileDescriptor fd, long address, int len)38throws IOException;3940/**41* Returns {@code true} if pread/pwrite needs to be synchronized with42* position sensitive methods.43*/44boolean needsPositionLock() {45return false;46}4748int pread(FileDescriptor fd, long address, int len, long position)49throws IOException50{51throw new IOException("Operation Unsupported");52}5354abstract long readv(FileDescriptor fd, long address, int len)55throws IOException;5657abstract int write(FileDescriptor fd, long address, int len)58throws IOException;5960int pwrite(FileDescriptor fd, long address, int len, long position)61throws IOException62{63throw new IOException("Operation Unsupported");64}6566abstract long writev(FileDescriptor fd, long address, int len)67throws IOException;6869abstract void close(FileDescriptor fd) throws IOException;7071// Prepare the given fd for closing by duping it to a known internal fd72// that's already closed. This is necessary on some operating systems73// (Solaris and Linux) to prevent fd recycling.74//75void preClose(FileDescriptor fd) throws IOException {76// Do nothing by default; this is only needed on Unix77}7879/**80* Duplicates a file descriptor.81* @param fd1 the file descriptor to duplicate82* @param fd2 the new file descriptor, the socket or file that it is connected83* to will be closed by this method84*/85void dup(FileDescriptor fd1, FileDescriptor fd2) throws IOException {86throw new UnsupportedOperationException();87}88}899091