Beispiel #1
0
 static void load() {
   synchronized (Util.class) {
     if (loaded) return;
     loaded = true;
     java.security.AccessController.doPrivileged(new sun.security.action.LoadLibraryAction("net"));
     java.security.AccessController.doPrivileged(new sun.security.action.LoadLibraryAction("nio"));
     // IOUtil must be initialized; Its native methods are called from
     // other places in native nio code so they must be set up.
     IOUtil.initIDs();
   }
 }
Beispiel #2
0
 /**
  * Returns the max size allowed for a cached temp buffers, in bytes. It defaults to
  * Long.MAX_VALUE. It can be set with the jdk.nio.maxCachedBufferSize property. Even though
  * ByteBuffer.capacity() returns an int, we're using a long here for potential future-proofing.
  */
 private static long getMaxCachedBufferSize() {
   String s =
       java.security.AccessController.doPrivileged(
           new PrivilegedAction<String>() {
             @Override
             public String run() {
               return System.getProperty("jdk.nio.maxCachedBufferSize");
             }
           });
   if (s != null) {
     try {
       long m = Long.parseLong(s);
       if (m >= 0) {
         return m;
       } else {
         // if it's negative, ignore the system property
       }
     } catch (NumberFormatException e) {
       // if the string is not well formed, ignore the system property
     }
   }
   return Long.MAX_VALUE;
 }