|
1 /* |
|
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE 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 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package sun.nio.ch; |
|
27 |
|
28 import java.io.InputStream; |
|
29 import java.io.OutputStream; |
|
30 import java.net.InetAddress; |
|
31 import java.net.SocketAddress; |
|
32 import java.net.SocketImpl; |
|
33 import java.net.SocketOption; |
|
34 import java.security.AccessController; |
|
35 import java.security.PrivilegedAction; |
|
36 import java.util.Set; |
|
37 |
|
38 /** |
|
39 * Dummy SocketImpl for use by the socket adaptors. All methods are overridden |
|
40 * to throw an error. |
|
41 */ |
|
42 |
|
43 class DummySocketImpl extends SocketImpl { |
|
44 private static final PrivilegedAction<SocketImpl> NEW = DummySocketImpl::new; |
|
45 |
|
46 private DummySocketImpl() { } |
|
47 |
|
48 static SocketImpl create() { |
|
49 return AccessController.doPrivileged(NEW); |
|
50 } |
|
51 |
|
52 private static <T> T shouldNotGetHere() { |
|
53 throw new InternalError("Should not get here"); |
|
54 } |
|
55 |
|
56 @Override |
|
57 protected void create(boolean stream) { |
|
58 shouldNotGetHere(); |
|
59 } |
|
60 |
|
61 @Override |
|
62 protected void connect(SocketAddress remote, int millis) { |
|
63 shouldNotGetHere(); |
|
64 } |
|
65 |
|
66 @Override |
|
67 protected void connect(String host, int port) { |
|
68 shouldNotGetHere(); |
|
69 } |
|
70 |
|
71 @Override |
|
72 protected void connect(InetAddress address, int port) { |
|
73 shouldNotGetHere(); |
|
74 } |
|
75 |
|
76 @Override |
|
77 protected void bind(InetAddress host, int port) { |
|
78 shouldNotGetHere(); |
|
79 } |
|
80 |
|
81 @Override |
|
82 protected void listen(int backlog) { |
|
83 shouldNotGetHere(); |
|
84 } |
|
85 |
|
86 @Override |
|
87 protected void accept(SocketImpl si) { |
|
88 shouldNotGetHere(); |
|
89 } |
|
90 |
|
91 @Override |
|
92 protected InputStream getInputStream() { |
|
93 return shouldNotGetHere(); |
|
94 } |
|
95 @Override |
|
96 protected OutputStream getOutputStream() { |
|
97 return shouldNotGetHere(); |
|
98 } |
|
99 @Override |
|
100 protected int available() { |
|
101 return shouldNotGetHere(); |
|
102 } |
|
103 |
|
104 @Override |
|
105 protected void close() { |
|
106 shouldNotGetHere(); |
|
107 } |
|
108 |
|
109 @Override |
|
110 protected Set<SocketOption<?>> supportedOptions() { |
|
111 return shouldNotGetHere(); |
|
112 } |
|
113 |
|
114 @Override |
|
115 protected <T> void setOption(SocketOption<T> opt, T value) { |
|
116 shouldNotGetHere(); |
|
117 } |
|
118 |
|
119 @Override |
|
120 protected <T> T getOption(SocketOption<T> opt) { |
|
121 return shouldNotGetHere(); |
|
122 } |
|
123 |
|
124 @Override |
|
125 public void setOption(int opt, Object value) { |
|
126 shouldNotGetHere(); |
|
127 } |
|
128 |
|
129 @Override |
|
130 public Object getOption(int opt) { |
|
131 return shouldNotGetHere(); |
|
132 } |
|
133 |
|
134 @Override |
|
135 protected void shutdownInput() { |
|
136 shouldNotGetHere(); |
|
137 } |
|
138 |
|
139 @Override |
|
140 protected void shutdownOutput() { |
|
141 shouldNotGetHere(); |
|
142 } |
|
143 |
|
144 @Override |
|
145 protected boolean supportsUrgentData() { |
|
146 return shouldNotGetHere(); |
|
147 } |
|
148 |
|
149 @Override |
|
150 protected void sendUrgentData(int data) { |
|
151 shouldNotGetHere(); |
|
152 } |
|
153 } |