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