Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8231805

Specify what exceptions SocketPermission constructor can throw

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 14
    • core-libs
    • None
    • behavioral
    • minimal
    • Java API
    • SE

      Summary

      The specification of the constructor java.net.SocketPermission(String, String) has to be updated to specify that it can throw NullPointerException or IllegalArgumentException.

      Problem

      Currently, the throws section of the constructor is completely omitted. On the other hand, constructors of other subclasses of java.security.Permission (for example, java.io.FilePermission, javax.smartcardio.CardPermission, java.net.URLPermission) do specify what exceptions they can throw.

      Solution

      The constructor SocketPermission(String, String) will be specified to throw IllegalArgumentException if format of the argument host is invalid or if the argument action is empty, malformed or contains unexpected values. It will also be specified that NullPointerException is thrown if any arguments are null.

      Specification

      +     *
      +     * @throws NullPointerException if any parameters are null
      +     * @throws IllegalArgumentException if the format of {@code host} is
      +     *         invalid, or if the {@code action} string is empty, malformed, or
      +     *         contains an action other than the specified possible actions
            */
           public SocketPermission(String host, String action) {

            igerasim Ivan Gerasimov
            igerasim Ivan Gerasimov
            Chris Hegarty
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: