author | coleenp |
Wed, 17 Jun 2015 21:44:48 +0000 | |
changeset 31362 | 8957ccbb5821 |
parent 20501 | 058de8b0a499 |
permissions | -rw-r--r-- |
20501
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
1 |
/* |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
4 |
* |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
8 |
* |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
13 |
* accompanied this code). |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
14 |
* |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
18 |
* |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
21 |
* questions. |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
22 |
*/ |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
23 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
24 |
/* |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
25 |
* @test |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
26 |
* @bug 8024952 |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
27 |
* @summary ClassCastException in PlainSocketImpl.accept() when using custom socketImpl |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
28 |
* @run main/othervm CustomSocketImplFactory |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
29 |
*/ |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
30 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
31 |
import java.net.*; |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
32 |
import java.io.*; |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
33 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
34 |
public class CustomSocketImplFactory implements SocketImplFactory { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
35 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
36 |
@Override |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
37 |
public SocketImpl createSocketImpl() { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
38 |
try { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
39 |
SocketImpl s = new CustomSocketImpl(); |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
40 |
System.out.println("Created " + s); |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
41 |
return s; |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
42 |
} catch (Exception e) { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
43 |
throw new RuntimeException(e); |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
44 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
45 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
46 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
47 |
public static void main(String[] args) throws Exception { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
48 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
49 |
Socket.setSocketImplFactory(new CustomSocketImplFactory()); |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
50 |
try (ServerSocket ss = new ServerSocket(0)) { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
51 |
ss.setSoTimeout(1); |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
52 |
ss.accept(); |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
53 |
System.out.println("PASS"); |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
54 |
} catch (SocketTimeoutException | NullPointerException e) { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
55 |
// Not a real socket impl |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
56 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
57 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
58 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
59 |
class CustomSocketImpl extends SocketImpl { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
60 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
61 |
public void create(boolean stream) throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
62 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
63 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
64 |
public void connect(String host, int port) throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
65 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
66 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
67 |
public void connect(InetAddress addr, int port) throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
68 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
69 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
70 |
public void connect(SocketAddress addr, int timeout) throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
71 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
72 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
73 |
public void bind(InetAddress host, int port) throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
74 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
75 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
76 |
public void listen(int backlog) throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
77 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
78 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
79 |
public void accept(SocketImpl s) throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
80 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
81 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
82 |
public InputStream getInputStream() throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
83 |
return null; |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
84 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
85 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
86 |
public OutputStream getOutputStream() throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
87 |
return null; |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
88 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
89 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
90 |
public int available() throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
91 |
return 0; |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
92 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
93 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
94 |
public void close() throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
95 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
96 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
97 |
public void sendUrgentData(int data) throws IOException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
98 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
99 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
100 |
public Object getOption(int i) throws SocketException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
101 |
return null; |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
102 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
103 |
|
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
104 |
public void setOption(int i, Object o) throws SocketException { |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
105 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
106 |
} |
058de8b0a499
8024952: ClassCastException in PlainSocketImpl.accept() when using custom socketImpl
coffeys
parents:
diff
changeset
|
107 |
} |