< prev index next >

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

Print this page
rev 55657 : 8227587: Add internal privileged System.loadLibrary
Reviewed-by: rriggs


  50 {
  51     /* timeout value for receive() */
  52     int timeout = 0;
  53     boolean connected = false;
  54     private int trafficClass = 0;
  55     protected InetAddress connectedAddress = null;
  56     private int connectedPort = -1;
  57 
  58     private static final String os =
  59             GetPropertyAction.privilegedGetProperty("os.name");
  60 
  61     /**
  62      * flag set if the native connect() call not to be used
  63      */
  64     private static final boolean connectDisabled = os.contains("OS X");
  65 
  66     /**
  67      * Load net library into runtime.
  68      */
  69     static {
  70         java.security.AccessController.doPrivileged(
  71             new java.security.PrivilegedAction<>() {
  72                 public Void run() {
  73                     System.loadLibrary("net");
  74                     return null;
  75                 }
  76             });
  77     }
  78 
  79     private static volatile boolean checkedReusePort;
  80     private static volatile boolean isReusePortAvailable;
  81 
  82     /**
  83      * Tells whether SO_REUSEPORT is supported.
  84      */
  85     static boolean isReusePortAvailable() {
  86         if (!checkedReusePort) {
  87             isReusePortAvailable = isReusePortAvailable0();
  88             checkedReusePort = true;
  89         }
  90         return isReusePortAvailable;
  91     }
  92 
  93     /**
  94      * Creates a datagram socket
  95      */
  96     protected synchronized void create() throws SocketException {




  50 {
  51     /* timeout value for receive() */
  52     int timeout = 0;
  53     boolean connected = false;
  54     private int trafficClass = 0;
  55     protected InetAddress connectedAddress = null;
  56     private int connectedPort = -1;
  57 
  58     private static final String os =
  59             GetPropertyAction.privilegedGetProperty("os.name");
  60 
  61     /**
  62      * flag set if the native connect() call not to be used
  63      */
  64     private static final boolean connectDisabled = os.contains("OS X");
  65 
  66     /**
  67      * Load net library into runtime.
  68      */
  69     static {
  70         jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("net");






  71     }
  72 
  73     private static volatile boolean checkedReusePort;
  74     private static volatile boolean isReusePortAvailable;
  75 
  76     /**
  77      * Tells whether SO_REUSEPORT is supported.
  78      */
  79     static boolean isReusePortAvailable() {
  80         if (!checkedReusePort) {
  81             isReusePortAvailable = isReusePortAvailable0();
  82             checkedReusePort = true;
  83         }
  84         return isReusePortAvailable;
  85     }
  86 
  87     /**
  88      * Creates a datagram socket
  89      */
  90     protected synchronized void create() throws SocketException {


< prev index next >