test/jdk/java/net/ServerSocket/NullConstructor.java
author phedlin
Fri, 15 Nov 2019 16:39:08 +0100
changeset 59291 54cf02d52c1b
parent 54743 ba74d2de9a01
permissions -rw-r--r--
8220376: C2: Int >0 not recognized as !=0 for div by 0 check Reviewed-by: neliasso, vlivanov, mdoerr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
54743
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
     1
/*
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
     4
 *
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
     8
 *
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    13
 * accompanied this code).
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    14
 *
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    18
 *
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    21
 * questions.
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    22
 */
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    23
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    24
/**
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    25
 * @test
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    26
 * @bug 8223457
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    27
 * @run main NullConstructor
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    28
 * @summary java.net.ServerSocket protected constructor should throw NPE if impl null
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    29
 */
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    30
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    31
import java.net.ServerSocket;
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    32
import java.net.SocketImpl;
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    33
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    34
public class NullConstructor {
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    35
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    36
    public static void main(String args[]) throws Exception {
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    37
        try {
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    38
            ServerSocket server = new ServerSocket((SocketImpl)null) {};
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    39
            throw new RuntimeException("Test failed");
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    40
        } catch (NullPointerException ee) {}
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    41
    }
ba74d2de9a01 8223457: java.net.ServerSocket protected constructor should throw NPE if impl null
michaelm
parents:
diff changeset
    42
}