1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. The Android Open Source 7 * Project designates this particular file as subject to the "Classpath" 8 * exception as provided by The Android Open Source Project in the LICENSE 9 * file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 */ 21 22 package sun.nio.ch; 23 24 import java.io.FileDescriptor; 25 import java.io.IOException; 26 import java.io.InputStream; 27 import java.io.OutputStream; 28 import java.net.InetAddress; 29 import java.net.Socket; 30 import java.net.SocketAddress; 31 import java.net.SocketException; 32 import java.net.SocketImpl; 33 34 /** 35 * This class is only used for {@link SocketAdaptor} to be backward-compatible 36 * with older Android versions which always set the {@code impl} field of 37 * {@link Socket}. As such none of the methods in this class are implemented 38 * since {@link SocketAdaptor} should override everything in {@link Socket} 39 * which may access the {@code impl} field. 40 */ 41 class FileDescriptorHolderSocketImpl extends SocketImpl { FileDescriptorHolderSocketImpl(FileDescriptor fd)42 public FileDescriptorHolderSocketImpl(FileDescriptor fd) { 43 this.fd = fd; 44 } 45 46 @Override setOption(int optID, Object value)47 public void setOption(int optID, Object value) throws SocketException { 48 throw new UnsupportedOperationException(); 49 } 50 51 @Override getOption(int optID)52 public Object getOption(int optID) throws SocketException { 53 throw new UnsupportedOperationException(); 54 } 55 56 @Override create(boolean stream)57 protected void create(boolean stream) throws IOException { 58 throw new UnsupportedOperationException(); 59 } 60 61 @Override connect(String host, int port)62 protected void connect(String host, int port) throws IOException { 63 throw new UnsupportedOperationException(); 64 } 65 66 @Override connect(InetAddress address, int port)67 protected void connect(InetAddress address, int port) throws IOException { 68 throw new UnsupportedOperationException(); 69 } 70 71 @Override connect(SocketAddress address, int timeout)72 protected void connect(SocketAddress address, int timeout) throws IOException { 73 throw new UnsupportedOperationException(); 74 } 75 76 @Override bind(InetAddress host, int port)77 protected void bind(InetAddress host, int port) throws IOException { 78 throw new UnsupportedOperationException(); 79 } 80 81 @Override listen(int backlog)82 protected void listen(int backlog) throws IOException { 83 throw new UnsupportedOperationException(); 84 } 85 86 @Override accept(SocketImpl s)87 protected void accept(SocketImpl s) throws IOException { 88 throw new UnsupportedOperationException(); 89 } 90 91 @Override getInputStream()92 protected InputStream getInputStream() throws IOException { 93 throw new UnsupportedOperationException(); 94 } 95 96 @Override getOutputStream()97 protected OutputStream getOutputStream() throws IOException { 98 throw new UnsupportedOperationException(); 99 } 100 101 @Override available()102 protected int available() throws IOException { 103 throw new UnsupportedOperationException(); 104 } 105 106 @Override close()107 protected void close() throws IOException { 108 throw new UnsupportedOperationException(); 109 } 110 111 @Override sendUrgentData(int data)112 protected void sendUrgentData(int data) throws IOException { 113 throw new UnsupportedOperationException(); 114 } 115 } 116