# HG changeset patch # User redestad # Date 1562874602 -7200 # Thu Jul 11 21:50:02 2019 +0200 # Node ID f12485d67273225967eb639eed82e5d8eaa4ae5b # Parent 1346086863a360db9361be10603e47e6155e156e 8227587: Add internal privileged System.loadLibrary Reviewed-by: rriggs diff --git a/src/java.base/aix/classes/sun/nio/fs/AixNativeDispatcher.java b/src/java.base/aix/classes/sun/nio/fs/AixNativeDispatcher.java --- a/src/java.base/aix/classes/sun/nio/fs/AixNativeDispatcher.java +++ b/src/java.base/aix/classes/sun/nio/fs/AixNativeDispatcher.java @@ -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() { - public Void run() { - System.loadLibrary("nio"); - return null; - }}); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); init(); } } diff --git a/src/java.base/linux/classes/sun/nio/fs/LinuxNativeDispatcher.java b/src/java.base/linux/classes/sun/nio/fs/LinuxNativeDispatcher.java --- a/src/java.base/linux/classes/sun/nio/fs/LinuxNativeDispatcher.java +++ b/src/java.base/linux/classes/sun/nio/fs/LinuxNativeDispatcher.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); init(); } } diff --git a/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java b/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java --- a/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java +++ b/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); } } diff --git a/src/java.base/macosx/classes/apple/security/KeychainStore.java b/src/java.base/macosx/classes/apple/security/KeychainStore.java --- a/src/java.base/macosx/classes/apple/security/KeychainStore.java +++ b/src/java.base/macosx/classes/apple/security/KeychainStore.java @@ -105,13 +105,7 @@ private static final Debug debug = Debug.getInstance("keystore"); static { - AccessController.doPrivileged( - new PrivilegedAction() { - public Void run() { - System.loadLibrary("osxsecurity"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("osxsecurity"); try { PKCS8ShroudedKeyBag_OID = new ObjectIdentifier(keyBag); pbeWithSHAAnd3KeyTripleDESCBC_OID = new ObjectIdentifier(pbeWithSHAAnd3KeyTripleDESCBC); diff --git a/src/java.base/macosx/classes/sun/nio/fs/UTIFileTypeDetector.java b/src/java.base/macosx/classes/sun/nio/fs/UTIFileTypeDetector.java --- a/src/java.base/macosx/classes/sun/nio/fs/UTIFileTypeDetector.java +++ b/src/java.base/macosx/classes/sun/nio/fs/UTIFileTypeDetector.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); } } diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -2274,6 +2274,23 @@ public void setCause(Throwable t, Throwable cause) { t.setCause(cause); } + + @CallerSensitive + public void loadLibrary(String library) { + Class klass = Reflection.getCallerClass(); + assert(library.indexOf(File.separatorChar) < 0, "library name must not contain directory separators"); + if (System.getSecurityManager() == null) { + ClassLoader.loadLibrary(klass, library, false); + } else { + AccessController.doPrivileged( + new java.security.PrivilegedAction<>() { + public Void run() { + ClassLoader.loadLibrary(klass, library, false); + return null; + } + }); + } + } }); } } diff --git a/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java b/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java --- a/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java +++ b/src/java.base/share/classes/java/net/AbstractPlainDatagramSocketImpl.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); } private static volatile boolean checkedReusePort; diff --git a/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java b/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java --- a/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java +++ b/src/java.base/share/classes/java/net/AbstractPlainSocketImpl.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); } private static volatile boolean checkedReusePort; diff --git a/src/java.base/share/classes/java/net/DatagramPacket.java b/src/java.base/share/classes/java/net/DatagramPacket.java --- a/src/java.base/share/classes/java/net/DatagramPacket.java +++ b/src/java.base/share/classes/java/net/DatagramPacket.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); init(); } diff --git a/src/java.base/share/classes/java/net/InetAddress.java b/src/java.base/share/classes/java/net/InetAddress.java --- a/src/java.base/share/classes/java/net/InetAddress.java +++ b/src/java.base/share/classes/java/net/InetAddress.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); SharedSecrets.setJavaNetInetAddressAccess( new JavaNetInetAddressAccess() { public String getOriginalHostName(InetAddress ia) { diff --git a/src/java.base/share/classes/java/net/NetworkInterface.java b/src/java.base/share/classes/java/net/NetworkInterface.java --- a/src/java.base/share/classes/java/net/NetworkInterface.java +++ b/src/java.base/share/classes/java/net/NetworkInterface.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); init(); defaultInterface = DefaultInterface.getDefault(); diff --git a/src/java.base/share/classes/java/util/zip/ZipUtils.java b/src/java.base/share/classes/java/util/zip/ZipUtils.java --- a/src/java.base/share/classes/java/util/zip/ZipUtils.java +++ b/src/java.base/share/classes/java/util/zip/ZipUtils.java @@ -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 pa = () -> { System.loadLibrary("zip"); return null; }; - AccessController.doPrivileged(pa); - } + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("zip"); } private static final Unsafe unsafe = Unsafe.getUnsafe(); diff --git a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java --- a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java +++ b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java @@ -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,10 @@ * @param cause set t's cause to new value */ void setCause(Throwable t, Throwable cause); + + /** + * Privileged System.loadLibrary + * @param library name of the library to load + */ + void loadLibrary(String library); } diff --git a/src/java.base/share/classes/sun/net/sdp/SdpSupport.java b/src/java.base/share/classes/sun/net/sdp/SdpSupport.java --- a/src/java.base/share/classes/sun/net/sdp/SdpSupport.java +++ b/src/java.base/share/classes/sun/net/sdp/SdpSupport.java @@ -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() { - public Void run() { - System.loadLibrary("net"); - return null; - } - }); + SharedSecrets.getJavaLangAccess().loadLibrary("net"); } } diff --git a/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java b/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java --- a/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java +++ b/src/java.base/share/classes/sun/net/spi/DefaultProxySelector.java @@ -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() { - public Void run() { - System.loadLibrary("net"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); hasSystemProxies = init(); } } diff --git a/src/java.base/share/classes/sun/nio/ch/IOUtil.java b/src/java.base/share/classes/sun/nio/ch/IOUtil.java --- a/src/java.base/share/classes/sun/nio/ch/IOUtil.java +++ b/src/java.base/share/classes/sun/nio/ch/IOUtil.java @@ -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() { - public Void run() { - System.loadLibrary("net"); - System.loadLibrary("nio"); - return null; - } - }); - + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); initIDs(); IOV_MAX = iovMax(); diff --git a/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java b/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java --- a/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java +++ b/src/java.base/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java @@ -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() { - public Void run() { - System.loadLibrary("nio"); - return null; - }}); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); init(); } } diff --git a/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java b/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java --- a/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java +++ b/src/java.base/solaris/classes/sun/nio/fs/SolarisWatchService.java @@ -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() { - public Void run() { - System.loadLibrary("nio"); - return null; - }}); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); init(); } } diff --git a/src/java.base/unix/classes/sun/net/PortConfig.java b/src/java.base/unix/classes/sun/net/PortConfig.java --- a/src/java.base/unix/classes/sun/net/PortConfig.java +++ b/src/java.base/unix/classes/sun/net/PortConfig.java @@ -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.access.SharedSecrets.getJavaLangAccess().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) { diff --git a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java --- a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java +++ b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); } } diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java b/src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java --- a/src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java +++ b/src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); } } diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java b/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java --- a/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java +++ b/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java @@ -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.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); capabilities = init(); } } diff --git a/src/java.base/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java b/src/java.base/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java --- a/src/java.base/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java +++ b/src/java.base/windows/classes/sun/nio/fs/RegistryFileTypeDetector.java @@ -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() { - @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.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); } } diff --git a/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java b/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java --- a/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java @@ -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() { - 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.access.SharedSecrets.getJavaLangAccess().loadLibrary("net"); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("nio"); initIDs(); } diff --git a/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java b/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java --- a/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java +++ b/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -55,13 +55,7 @@ */ public class FileManager { static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("osx"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("osx"); } /** diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -57,13 +57,7 @@ static final int kLSItemInfoExtensionIsHidden = 0x00100000; /* Item has a hidden extension*/ static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("osxui"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("osxui"); } // TODO: Un-comment this out when the native version exists diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaLookAndFeel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -132,12 +132,7 @@ * @see UIManager#setLookAndFeel */ public void initialize() { - java.security.AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - System.loadLibrary("osxui"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("osxui"); java.security.AccessController.doPrivileged(new PrivilegedAction(){ @Override diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaMenuBarUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -39,11 +39,7 @@ public class AquaMenuBarUI extends BasicMenuBarUI implements ScreenMenuBarProvider { static { - java.security.AccessController.doPrivileged( - (java.security.PrivilegedAction) () -> { - System.loadLibrary("osxui"); - return null; - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("osxui"); } // Utilities diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaNativeResources.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -34,13 +34,7 @@ public class AquaNativeResources { static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("osxui"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("osxui"); } // TODO: removing CColorPaint for now diff --git a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenu.java b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenu.java --- a/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenu.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/ScreenMenu.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -42,13 +42,7 @@ ScreenMenuPropertyHandler { static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); } // screen menu stuff diff --git a/src/java.desktop/macosx/classes/sun/awt/PlatformGraphicsInfo.java b/src/java.desktop/macosx/classes/sun/awt/PlatformGraphicsInfo.java --- a/src/java.desktop/macosx/classes/sun/awt/PlatformGraphicsInfo.java +++ b/src/java.desktop/macosx/classes/sun/awt/PlatformGraphicsInfo.java @@ -27,16 +27,11 @@ import java.awt.GraphicsEnvironment; import java.awt.Toolkit; -import java.security.AccessController; -import java.security.PrivilegedAction; public class PlatformGraphicsInfo { static { - AccessController.doPrivileged((PrivilegedAction) () -> { - System.loadLibrary("awt"); - return null; - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); } public static GraphicsEnvironment createGE() { diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java @@ -67,13 +67,7 @@ static { // Need to load the native library for this code. - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); } static CAccessibility sAccessibility; diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java @@ -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 @@ -86,13 +86,7 @@ private int numImages = 0; static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("javajpeg"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("javajpeg"); initReaderIDs(ImageInputStream.class, JPEGQTable.class, JPEGHuffmanTable.class); diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageWriter.java @@ -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 @@ -174,13 +174,7 @@ ///////// static initializer static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("javajpeg"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("javajpeg"); initWriterIDs(JPEGQTable.class, JPEGHuffmanTable.class); } diff --git a/src/java.desktop/share/classes/com/sun/media/sound/Platform.java b/src/java.desktop/share/classes/com/sun/media/sound/Platform.java --- a/src/java.desktop/share/classes/com/sun/media/sound/Platform.java +++ b/src/java.desktop/share/classes/com/sun/media/sound/Platform.java @@ -25,8 +25,6 @@ package com.sun.media.sound; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.StringTokenizer; /** @@ -78,10 +76,7 @@ // load the native library isNativeLibLoaded = true; try { - AccessController.doPrivileged((PrivilegedAction) () -> { - System.loadLibrary(libName); - return null; - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary(libName); } catch (Throwable t) { if (Printer.err) Printer.err("Couldn't load library "+libName+": "+t.toString()); isNativeLibLoaded = false; diff --git a/src/java.desktop/share/classes/java/awt/SplashScreen.java b/src/java.desktop/share/classes/java/awt/SplashScreen.java --- a/src/java.desktop/share/classes/java/awt/SplashScreen.java +++ b/src/java.desktop/share/classes/java/awt/SplashScreen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -128,13 +128,7 @@ } // SplashScreen class is now a singleton if (!wasClosed && theInstance == null) { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("splashscreen"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("splashscreen"); long ptr = _getInstance(); if (ptr != 0 && _isVisible(ptr)) { theInstance = new SplashScreen(ptr); diff --git a/src/java.desktop/share/classes/java/awt/Toolkit.java b/src/java.desktop/share/classes/java/awt/Toolkit.java --- a/src/java.desktop/share/classes/java/awt/Toolkit.java +++ b/src/java.desktop/share/classes/java/awt/Toolkit.java @@ -1374,13 +1374,7 @@ private static boolean loaded = false; static void loadLibraries() { if (!loaded) { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); loaded = true; } } diff --git a/src/java.desktop/share/classes/java/awt/image/ColorModel.java b/src/java.desktop/share/classes/java/awt/image/ColorModel.java --- a/src/java.desktop/share/classes/java/awt/image/ColorModel.java +++ b/src/java.desktop/share/classes/java/awt/image/ColorModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -203,13 +203,7 @@ private static boolean loaded = false; static void loadLibraries() { if (!loaded) { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); loaded = true; } } diff --git a/src/java.desktop/share/classes/sun/awt/NativeLibLoader.java b/src/java.desktop/share/classes/sun/awt/NativeLibLoader.java --- a/src/java.desktop/share/classes/sun/awt/NativeLibLoader.java +++ b/src/java.desktop/share/classes/sun/awt/NativeLibLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -53,12 +53,6 @@ * that the name of the library is "awt". -br. */ static void loadLibraries() { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); } } diff --git a/src/java.desktop/share/classes/sun/awt/image/JPEGImageDecoder.java b/src/java.desktop/share/classes/sun/awt/image/JPEGImageDecoder.java --- a/src/java.desktop/share/classes/sun/awt/image/JPEGImageDecoder.java +++ b/src/java.desktop/share/classes/sun/awt/image/JPEGImageDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -53,13 +53,7 @@ private ColorModel colormodel; static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("javajpeg"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("javajpeg"); initIDs(InputStreamClass); RGBcolormodel = new DirectColorModel(24, 0xff0000, 0xff00, 0xff); ARGBcolormodel = ColorModel.getRGBdefault(); diff --git a/src/java.desktop/share/classes/sun/java2d/Disposer.java b/src/java.desktop/share/classes/sun/java2d/Disposer.java --- a/src/java.desktop/share/classes/sun/java2d/Disposer.java +++ b/src/java.desktop/share/classes/sun/java2d/Disposer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, 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 @@ -61,13 +61,7 @@ public static int refType = PHANTOM; static { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); initIDs(); String type = java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction("sun.java2d.reftype")); diff --git a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java --- a/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java +++ b/src/java.desktop/share/classes/sun/java2d/cmm/lcms/LCMS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -163,7 +163,7 @@ int outFormatter, boolean isOutIntPacked, Object disposerRef); - /** + /** * Constructs ColorTransform object corresponding to an ICC_profile */ public ColorTransform createTransform(ICC_Profile profile, @@ -199,17 +199,11 @@ return theLcms; } - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Object run() { - /* We need to load awt here because of usage trace and - * disposer frameworks - */ - System.loadLibrary("awt"); - System.loadLibrary("lcms"); - return null; - } - }); + /* We need to load awt here because of usage trace and + * disposer frameworks + */ + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("lcms"); initLCMS(LCMSTransform.class, LCMSImageLayout.class, ICC_Profile.class); diff --git a/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java b/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java --- a/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java +++ b/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java @@ -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 @@ -81,13 +81,7 @@ static { // load awt library to access native code - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); libFound = initIDs(); if (libFound) { cupsServer = getCupsServer(); diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java --- a/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -111,14 +111,7 @@ private static boolean loaded = false; public static void loadLibraries() { if (!loaded) { - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - @Override - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); loaded = true; } } diff --git a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java --- a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java +++ b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java @@ -84,13 +84,7 @@ } } - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Void run() { - System.loadLibrary("awt"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("awt"); } /* The singleton win32 print lookup service. diff --git a/src/jdk.net/linux/classes/jdk/net/LinuxSocketOptions.java b/src/jdk.net/linux/classes/jdk/net/LinuxSocketOptions.java --- a/src/jdk.net/linux/classes/jdk/net/LinuxSocketOptions.java +++ b/src/jdk.net/linux/classes/jdk/net/LinuxSocketOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -95,9 +95,6 @@ private static native boolean keepAliveOptionsSupported0(); private static native boolean quickAckSupported0(); static { - AccessController.doPrivileged((PrivilegedAction) () -> { - System.loadLibrary("extnet"); - return null; - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("extnet"); } -} \ No newline at end of file +} diff --git a/src/jdk.net/macosx/classes/jdk/net/MacOSXSocketOptions.java b/src/jdk.net/macosx/classes/jdk/net/MacOSXSocketOptions.java --- a/src/jdk.net/macosx/classes/jdk/net/MacOSXSocketOptions.java +++ b/src/jdk.net/macosx/classes/jdk/net/MacOSXSocketOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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,8 +25,6 @@ package jdk.net; import java.net.SocketException; -import java.security.AccessController; -import java.security.PrivilegedAction; import jdk.net.ExtendedSocketOptions.PlatformSocketOptions; class MacOSXSocketOptions extends PlatformSocketOptions { @@ -77,9 +75,6 @@ private static native int getTcpKeepAliveIntvl0(int fd) throws SocketException; private static native boolean keepAliveOptionsSupported0(); static { - AccessController.doPrivileged((PrivilegedAction) () -> { - System.loadLibrary("extnet"); - return null; - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("extnet"); } } diff --git a/src/jdk.net/solaris/classes/jdk/net/SolarisSocketOptions.java b/src/jdk.net/solaris/classes/jdk/net/SolarisSocketOptions.java --- a/src/jdk.net/solaris/classes/jdk/net/SolarisSocketOptions.java +++ b/src/jdk.net/solaris/classes/jdk/net/SolarisSocketOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 jdk.net; import java.net.SocketException; -import java.security.AccessController; -import java.security.PrivilegedAction; import jdk.net.ExtendedSocketOptions.PlatformSocketOptions; class SolarisSocketOptions extends PlatformSocketOptions { @@ -45,12 +43,7 @@ private static native void init(); static { - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - System.loadLibrary("extnet"); - return null; - } - }); + jdk.internal.access.SharedSecrets.getJavaLangAccess().loadLibrary("extnet"); init(); } }