8227587: Add internal privileged System.loadLibrary
authorredestad
Wed, 17 Jul 2019 12:35:46 +0200
changeset 55693 9a97b1393e72
parent 55692 64330bbb9be5
child 55717 2b4e14968afd
8227587: Add internal privileged System.loadLibrary Reviewed-by: rriggs, mchung, chegar
src/java.base/aix/classes/sun/nio/fs/AixNativeDispatcher.java
src/java.base/linux/classes/sun/nio/fs/LinuxNativeDispatcher.java
src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java
src/java.base/macosx/classes/apple/security/KeychainStore.java
src/java.base/macosx/classes/sun/nio/fs/UTIFileTypeDetector.java
src/java.base/share/classes/java/lang/System.java
src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java
src/java.base/share/classes/java/net/DatagramPacket.java
src/java.base/share/classes/java/net/InetAddress.java
src/java.base/share/classes/java/net/NetworkInterface.java
src/java.base/share/classes/java/util/zip/ZipUtils.java
src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java
src/java.base/share/classes/jdk/internal/loader/BootLoader.java
src/java.base/share/classes/sun/net/sdp/SdpSupport.java
src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java
src/java.base/share/classes/sun/nio/ch/IOUtil.java
src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java
src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java
src/java.base/unix/classes/sun/net/PortConfig.java
src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java
src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java
src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java
src/java.base/windows/classes/sun/net/dns/ResolverConfigurationImpl.java
src/java.base/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java
src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java
--- a/src/java.base/aix/classes/sun/nio/fs/AixNativeDispatcher.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/aix/classes/sun/nio/fs/AixNativeDispatcher.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2013 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -26,9 +26,6 @@
 
 package sun.nio.fs;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
 /**
  * AIX specific system calls.
  */
@@ -46,11 +43,7 @@
     private static native void init();
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-        }});
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
         init();
     }
 }
--- a/src/java.base/linux/classes/sun/nio/fs/LinuxNativeDispatcher.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/linux/classes/sun/nio/fs/LinuxNativeDispatcher.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,6 @@
 
 package sun.nio.fs;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
 /**
  * Linux specific system calls.
  */
@@ -121,11 +118,7 @@
     private static native void init();
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction<>() {
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-        }});
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
         init();
     }
 }
--- a/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,6 @@
 package sun.nio.fs;
 
 import java.nio.file.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.*;
 import java.io.IOException;
 import jdk.internal.misc.Unsafe;
@@ -459,10 +457,6 @@
     private static native int poll(int fd1, int fd2) throws UnixException;
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction<>() {
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-        }});
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
     }
 }
--- a/src/java.base/macosx/classes/apple/security/KeychainStore.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/macosx/classes/apple/security/KeychainStore.java	Wed Jul 17 12:35:46 2019 +0200
@@ -105,13 +105,7 @@
     private static final Debug debug = Debug.getInstance("keystore");
 
     static {
-        AccessController.doPrivileged(
-            new PrivilegedAction<Void>() {
-                public Void run() {
-                    System.loadLibrary("osxsecurity");
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("osxsecurity");
         try {
             PKCS8ShroudedKeyBag_OID = new ObjectIdentifier(keyBag);
             pbeWithSHAAnd3KeyTripleDESCBC_OID = new ObjectIdentifier(pbeWithSHAAnd3KeyTripleDESCBC);
--- a/src/java.base/macosx/classes/sun/nio/fs/UTIFileTypeDetector.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/macosx/classes/sun/nio/fs/UTIFileTypeDetector.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,6 @@
 
 import java.io.IOException;
 import java.nio.file.Path;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 
 /**
  * File type detector that uses a file extension to look up its MIME type
@@ -55,12 +53,6 @@
     }
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction<>() {
-            @Override
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-            }
-        });
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
     }
 }
--- a/src/java.base/share/classes/java/lang/System.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/java/lang/System.java	Wed Jul 17 12:35:46 2019 +0200
@@ -2274,6 +2274,11 @@
             public void setCause(Throwable t, Throwable cause) {
                 t.setCause(cause);
             }
+
+            public void loadLibrary(Class<?> caller, String library) {
+                assert library.indexOf(java.io.File.separatorChar) < 0;
+                ClassLoader.loadLibrary(caller, library, false);
+            }
         });
     }
 }
--- a/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java	Wed Jul 17 12:35:46 2019 +0200
@@ -67,13 +67,7 @@
      * Load net library into runtime.
      */
     static {
-        java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<>() {
-                public Void run() {
-                    System.loadLibrary("net");
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("net");
     }
 
     private static volatile boolean checkedReusePort;
--- a/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java	Wed Jul 17 12:35:46 2019 +0200
@@ -94,13 +94,7 @@
      * Load net library into runtime.
      */
     static {
-        java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<>() {
-                public Void run() {
-                    System.loadLibrary("net");
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("net");
     }
 
     private static volatile boolean checkedReusePort;
--- a/src/java.base/share/classes/java/net/DatagramPacket.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/java/net/DatagramPacket.java	Wed Jul 17 12:35:46 2019 +0200
@@ -46,13 +46,7 @@
      * Perform class initialization
      */
     static {
-        java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<>() {
-                public Void run() {
-                    System.loadLibrary("net");
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("net");
         init();
     }
 
--- a/src/java.base/share/classes/java/net/InetAddress.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/java/net/InetAddress.java	Wed Jul 17 12:35:46 2019 +0200
@@ -317,13 +317,7 @@
         } else {
             preferIPv6Address = PREFER_IPV4_VALUE;
         }
-        AccessController.doPrivileged(
-            new java.security.PrivilegedAction<>() {
-                public Void run() {
-                    System.loadLibrary("net");
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("net");
         SharedSecrets.setJavaNetInetAddressAccess(
                 new JavaNetInetAddressAccess() {
                     public String getOriginalHostName(InetAddress ia) {
--- a/src/java.base/share/classes/java/net/NetworkInterface.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/java/net/NetworkInterface.java	Wed Jul 17 12:35:46 2019 +0200
@@ -28,7 +28,6 @@
 import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.NoSuchElementException;
-import java.security.AccessController;
 import java.util.Spliterator;
 import java.util.Spliterators;
 import java.util.stream.Stream;
@@ -57,13 +56,7 @@
     private static final int defaultIndex; /* index of defaultInterface */
 
     static {
-        AccessController.doPrivileged(
-            new java.security.PrivilegedAction<>() {
-                public Void run() {
-                    System.loadLibrary("net");
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("net");
 
         init();
         defaultInterface = DefaultInterface.getDefault();
--- a/src/java.base/share/classes/java/util/zip/ZipUtils.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/java/util/zip/ZipUtils.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,6 @@
 
 import java.nio.ByteBuffer;
 import java.nio.file.attribute.FileTime;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.time.DateTimeException;
 import java.time.Instant;
 import java.time.LocalDateTime;
@@ -278,13 +276,7 @@
      * Loads zip native library, if not already laoded
      */
     static void loadLibrary() {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm == null) {
-            System.loadLibrary("zip");
-        } else {
-            PrivilegedAction<Void> pa = () -> { System.loadLibrary("zip"); return null; };
-            AccessController.doPrivileged(pa);
-        }
+        jdk.internal.loader.BootLoader.loadLibrary("zip");
     }
 
     private static final Unsafe unsafe = Unsafe.getUnsafe();
--- a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -311,4 +311,12 @@
      * @param cause set t's cause to new value
      */
     void setCause(Throwable t, Throwable cause);
+
+    /**
+     * Privileged System.loadLibrary
+     *
+     * @param caller on behalf of which the library is being loaded
+     * @param library name of the library to load
+     */
+    void loadLibrary(Class<?> caller, String library);
 }
--- a/src/java.base/share/classes/jdk/internal/loader/BootLoader.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/jdk/internal/loader/BootLoader.java	Wed Jul 17 12:35:46 2019 +0200
@@ -129,6 +129,23 @@
     }
 
     /**
+     * Loads a library from the system path.
+     */
+    public static void loadLibrary(String library) {
+        if (System.getSecurityManager() == null) {
+            SharedSecrets.getJavaLangAccess().loadLibrary(BootLoader.class, library);
+        } else {
+            AccessController.doPrivileged(
+                new java.security.PrivilegedAction<>() {
+                    public Void run() {
+                        SharedSecrets.getJavaLangAccess().loadLibrary(BootLoader.class, library);
+                        return null;
+                    }
+                });
+        }
+    }
+
+    /**
      * Returns a URL to a resource in a module defined to the boot loader.
      */
     public static URL findResource(String mn, String name) throws IOException {
--- a/src/java.base/share/classes/sun/net/sdp/SdpSupport.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/sun/net/sdp/SdpSupport.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
 
 import java.io.IOException;
 import java.io.FileDescriptor;
-import java.security.AccessController;
 
 import jdk.internal.access.SharedSecrets;
 import jdk.internal.access.JavaIOFileDescriptorAccess;
@@ -75,12 +74,6 @@
     private static native void convert0(int fd) throws IOException;
 
     static {
-        AccessController.doPrivileged(
-            new java.security.PrivilegedAction<Void>() {
-                public Void run() {
-                    System.loadLibrary("net");
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("net");
     }
 }
--- a/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -98,13 +98,7 @@
                     return NetProperties.getBoolean(key);
                 }});
         if (b != null && b.booleanValue()) {
-            java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<Void>() {
-                    public Void run() {
-                        System.loadLibrary("net");
-                        return null;
-                    }
-                });
+            jdk.internal.loader.BootLoader.loadLibrary("net");
             hasSystemProxies = init();
         }
     }
--- a/src/java.base/share/classes/sun/nio/ch/IOUtil.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/share/classes/sun/nio/ch/IOUtil.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -432,15 +432,8 @@
     public static void load() { }
 
     static {
-        java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<Void>() {
-                    public Void run() {
-                        System.loadLibrary("net");
-                        System.loadLibrary("nio");
-                        return null;
-                    }
-                });
-
+        jdk.internal.loader.BootLoader.loadLibrary("net");
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
         initIDs();
 
         IOV_MAX = iovMax();
--- a/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,6 @@
 
 package sun.nio.fs;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
 /**
  * Solaris specific system calls.
  */
@@ -52,11 +49,7 @@
     private static native void init();
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-        }});
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
         init();
     }
 }
--- a/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,6 @@
 package sun.nio.fs;
 
 import java.nio.file.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.*;
 import java.io.IOException;
 import jdk.internal.misc.Unsafe;
@@ -817,11 +815,7 @@
         throws UnixException;
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-        }});
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
         init();
     }
 }
--- a/src/java.base/unix/classes/sun/net/PortConfig.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/unix/classes/sun/net/PortConfig.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 package sun.net;
 
-import java.security.AccessController;
+import sun.security.action.GetPropertyAction;
 
 /**
  * Determines the ephemeral port range in use on this system.
@@ -41,35 +41,29 @@
     private PortConfig() {}
 
     static {
-        AccessController.doPrivileged(
-            new java.security.PrivilegedAction<>() {
-                public Void run() {
-                    System.loadLibrary("net");
-                    String os = System.getProperty("os.name");
-                    if (os.startsWith("Linux")) {
-                        defaultLower = 32768;
-                        defaultUpper = 61000;
-                    } else if (os.startsWith("SunOS")) {
-                        defaultLower = 32768;
-                        defaultUpper = 65535;
-                    } else if (os.contains("OS X")) {
-                        defaultLower = 49152;
-                        defaultUpper = 65535;
-                    } else if (os.startsWith("AIX")) {
-                        // The ephemeral port is OS version dependent on AIX:
-                        // http://publib.boulder.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.rsct315.admin/bl503_ephport.htm
-                        // However, on AIX 5.3 / 6.1 / 7.1 we always see the
-                        // settings below by using:
-                        // /usr/sbin/no -a | fgrep ephemeral
-                        defaultLower = 32768;
-                        defaultUpper = 65535;
-                    } else {
-                        throw new InternalError(
-                            "sun.net.PortConfig: unknown OS");
-                    }
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("net");
+        String os = GetPropertyAction.privilegedGetProperty("os.name");
+        if (os.startsWith("Linux")) {
+            defaultLower = 32768;
+            defaultUpper = 61000;
+        } else if (os.startsWith("SunOS")) {
+            defaultLower = 32768;
+            defaultUpper = 65535;
+        } else if (os.contains("OS X")) {
+            defaultLower = 49152;
+            defaultUpper = 65535;
+        } else if (os.startsWith("AIX")) {
+            // The ephemeral port is OS version dependent on AIX:
+            // http://publib.boulder.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.rsct315.admin/bl503_ephport.htm
+            // However, on AIX 5.3 / 6.1 / 7.1 we always see the
+            // settings below by using:
+            // /usr/sbin/no -a | fgrep ephemeral
+            defaultLower = 32768;
+            defaultUpper = 65535;
+        } else {
+            throw new InternalError(
+                "sun.net.PortConfig: unknown OS");
+        }
 
         int v = getLower0();
         if (v == -1) {
--- a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -259,13 +259,7 @@
     static native String fallbackDomain0();
 
     static {
-        java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<>() {
-                public Void run() {
-                    System.loadLibrary("net");
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("net");
     }
 
 }
--- a/src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,8 +33,6 @@
 import java.nio.file.LinkOption;
 import java.nio.file.LinkPermission;
 import java.nio.file.StandardCopyOption;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 
@@ -628,12 +626,7 @@
         throws UnixException;
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction<>() {
-            @Override
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-            }});
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
     }
 
 }
--- a/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java	Wed Jul 17 12:35:46 2019 +0200
@@ -25,9 +25,6 @@
 
 package sun.nio.fs;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
 /**
  * Unix system and library calls.
  */
@@ -630,11 +627,7 @@
 
     private static native int init();
     static {
-        AccessController.doPrivileged(new PrivilegedAction<>() {
-            public Void run() {
-                System.loadLibrary("nio");
-                return null;
-        }});
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
         capabilities = init();
     }
 }
--- a/src/java.base/windows/classes/sun/net/dns/ResolverConfigurationImpl.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/windows/classes/sun/net/dns/ResolverConfigurationImpl.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -160,13 +160,7 @@
     static native int notifyAddrChange0();
 
     static {
-        java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<Void>() {
-                public Void run() {
-                    System.loadLibrary("net");
-                    return null;
-                }
-            });
+        jdk.internal.loader.BootLoader.loadLibrary("net");
         init0();
 
         // start the address listener thread
--- a/src/java.base/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java	Wed Jul 17 12:35:46 2019 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,8 +27,6 @@
 
 import java.nio.file.*;
 import java.io.IOException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 
 /**
  * File type detector that does lookup of file extension using Windows Registry.
@@ -70,13 +68,8 @@
     private static native String queryStringValue(long subKey, long name);
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            @Override
-            public Void run() {
-                // nio.dll has dependency on net.dll
-                System.loadLibrary("net");
-                System.loadLibrary("nio");
-                return null;
-        }});
+        // nio.dll has dependency on net.dll
+        jdk.internal.loader.BootLoader.loadLibrary("net");
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
     }
 }
--- a/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java	Wed Jul 17 11:43:38 2019 +0200
+++ b/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java	Wed Jul 17 12:35:46 2019 +0200
@@ -25,8 +25,6 @@
 
 package sun.nio.fs;
 
-import java.security.AccessController;
-import java.security.PrivilegedAction;
 import jdk.internal.misc.Unsafe;
 
 import static sun.nio.fs.WindowsConstants.*;
@@ -1153,13 +1151,9 @@
     private static native void initIDs();
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction<Void>() {
-            public Void run() {
-                // nio.dll has dependency on net.dll
-                System.loadLibrary("net");
-                System.loadLibrary("nio");
-                return null;
-        }});
+        // nio.dll has dependency on net.dll
+        jdk.internal.loader.BootLoader.loadLibrary("net");
+        jdk.internal.loader.BootLoader.loadLibrary("nio");
         initIDs();
     }