Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/net/Socket/OldImpl.java
38812 views
/*1* Copyright (c) 2005, 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.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.io.*;24import java.net.*;252627/**28* @test29* @bug 508948830* @summary java.net.Socket checks for old-style impls31*/3233public class OldImpl {3435/**36* A no-op SocketImpl descendant.37*/38static class FunkySocketImpl extends SocketImpl {39protected void accept(SocketImpl impl) throws IOException {40}4142protected int available(){43return 0;44}4546protected void bind(InetAddress host, int port){47}4849protected void close(){50}5152protected void connect(InetAddress address, int port){53}5455protected void connect(String host, int port){56}5758protected void connect(SocketAddress a,int b){59}6061protected void create(boolean stream){62}6364protected InputStream getInputStream(){65return null;66}6768protected OutputStream getOutputStream(){69return null;70}7172protected void listen(int backlog){73}7475public Object getOption(int optID){76return null;77}7879public void setOption(int optID, Object value){80}8182protected void sendUrgentData(int i){83}84}8586static class FunkyWunkySocketImpl extends FunkySocketImpl {}8788/**89* A no-op Socket descendant.90*/91static class FunkySocket extends Socket {92public FunkySocket(SocketImpl impl) throws IOException {93super(impl);94}95}9697public static void main(String args[]) throws Exception {98FunkyWunkySocketImpl socketImpl = new FunkyWunkySocketImpl();99FunkySocket socko = new FunkySocket(socketImpl);100if (socko.isBound()) {101throw new RuntimeException ("socket is not really bound");102}103}104}105106107