< 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()
  71                 .loadLibrary(AbstractPlainDatagramSocketImpl.class, "net");





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


< prev index next >