Path: blob/master/src/java.base/share/classes/sun/nio/ch/DummySocketImpl.java
41159 views
/*1* Copyright (c) 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.InputStream;28import java.io.OutputStream;29import java.net.InetAddress;30import java.net.SocketAddress;31import java.net.SocketImpl;32import java.net.SocketOption;33import java.util.Set;3435/**36* Dummy SocketImpl for use by the socket adaptors. All methods are overridden37* to throw an error.38*/3940class DummySocketImpl extends SocketImpl {41private DummySocketImpl() { }4243static SocketImpl create() {44return new DummySocketImpl();45}4647private static <T> T shouldNotGetHere() {48throw new InternalError("Should not get here");49}5051@Override52protected void create(boolean stream) {53shouldNotGetHere();54}5556@Override57protected void connect(SocketAddress remote, int millis) {58shouldNotGetHere();59}6061@Override62protected void connect(String host, int port) {63shouldNotGetHere();64}6566@Override67protected void connect(InetAddress address, int port) {68shouldNotGetHere();69}7071@Override72protected void bind(InetAddress host, int port) {73shouldNotGetHere();74}7576@Override77protected void listen(int backlog) {78shouldNotGetHere();79}8081@Override82protected void accept(SocketImpl si) {83shouldNotGetHere();84}8586@Override87protected InputStream getInputStream() {88return shouldNotGetHere();89}90@Override91protected OutputStream getOutputStream() {92return shouldNotGetHere();93}94@Override95protected int available() {96return shouldNotGetHere();97}9899@Override100protected void close() {101shouldNotGetHere();102}103104@Override105protected Set<SocketOption<?>> supportedOptions() {106return shouldNotGetHere();107}108109@Override110protected <T> void setOption(SocketOption<T> opt, T value) {111shouldNotGetHere();112}113114@Override115protected <T> T getOption(SocketOption<T> opt) {116return shouldNotGetHere();117}118119@Override120public void setOption(int opt, Object value) {121shouldNotGetHere();122}123124@Override125public Object getOption(int opt) {126return shouldNotGetHere();127}128129@Override130protected void shutdownInput() {131shouldNotGetHere();132}133134@Override135protected void shutdownOutput() {136shouldNotGetHere();137}138139@Override140protected boolean supportsUrgentData() {141return shouldNotGetHere();142}143144@Override145protected void sendUrgentData(int data) {146shouldNotGetHere();147}148}149150151