< prev index next >

src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java

Print this page
rev 14210 : 8154231: Simplify access to System properties from JDK code
Reviewed-by: rriggs


  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.net;
  26 
  27 import java.io.FileDescriptor;
  28 import java.io.IOException;
  29 import java.security.AccessController;
  30 import sun.net.ResourceManager;
  31 import java.util.Set;
  32 import java.util.HashSet;
  33 import java.util.Collections;

  34 
  35 /**
  36  * Abstract datagram and multicast socket implementation base class.
  37  * Note: This is not a public class, so that applets cannot call
  38  * into the implementation directly and hence cannot bypass the
  39  * security checks present in the DatagramSocket and MulticastSocket
  40  * classes.
  41  *
  42  * @author Pavani Diwanji
  43  */
  44 
  45 abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
  46 {
  47     /* timeout value for receive() */
  48     int timeout = 0;
  49     boolean connected = false;
  50     private int trafficClass = 0;
  51     protected InetAddress connectedAddress = null;
  52     private int connectedPort = -1;
  53 
  54     private static final String os = AccessController.doPrivileged(
  55         new sun.security.action.GetPropertyAction("os.name")
  56     );
  57 
  58     /**
  59      * flag set if the native connect() call not to be used
  60      */
  61     private static final boolean connectDisabled = os.contains("OS X");
  62 
  63     /**
  64      * Load net library into runtime.
  65      */
  66     static {
  67         java.security.AccessController.doPrivileged(
  68             new java.security.PrivilegedAction<>() {
  69                 public Void run() {
  70                     System.loadLibrary("net");
  71                     return null;
  72                 }
  73             });
  74     }
  75 
  76     private static volatile boolean checkedReusePort;




  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package java.net;
  26 
  27 import java.io.FileDescriptor;
  28 import java.io.IOException;
  29 import java.security.AccessController;
  30 import sun.net.ResourceManager;
  31 import java.util.Set;
  32 import java.util.HashSet;
  33 import java.util.Collections;
  34 import sun.security.action.GetPropertyAction;
  35 
  36 /**
  37  * Abstract datagram and multicast socket implementation base class.
  38  * Note: This is not a public class, so that applets cannot call
  39  * into the implementation directly and hence cannot bypass the
  40  * security checks present in the DatagramSocket and MulticastSocket
  41  * classes.
  42  *
  43  * @author Pavani Diwanji
  44  */
  45 
  46 abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
  47 {
  48     /* timeout value for receive() */
  49     int timeout = 0;
  50     boolean connected = false;
  51     private int trafficClass = 0;
  52     protected InetAddress connectedAddress = null;
  53     private int connectedPort = -1;
  54 
  55     private static final String os = GetPropertyAction.getProperty("os.name");


  56 
  57     /**
  58      * flag set if the native connect() call not to be used
  59      */
  60     private static final boolean connectDisabled = os.contains("OS X");
  61 
  62     /**
  63      * Load net library into runtime.
  64      */
  65     static {
  66         java.security.AccessController.doPrivileged(
  67             new java.security.PrivilegedAction<>() {
  68                 public Void run() {
  69                     System.loadLibrary("net");
  70                     return null;
  71                 }
  72             });
  73     }
  74 
  75     private static volatile boolean checkedReusePort;


< prev index next >