提交 25657da5 编写于 作者: M mchung

7164376: Replace use of sun.security.action.LoadLibraryAction with System.loadLibrary

Reviewed-by: alanb, mullan, prr
上级 c7160959
...@@ -27,7 +27,6 @@ package apple.launcher; ...@@ -27,7 +27,6 @@ package apple.launcher;
import java.io.*; import java.io.*;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.security.PrivilegedAction;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.*; import java.util.*;
import java.util.jar.*; import java.util.jar.*;
...@@ -36,7 +35,13 @@ import javax.swing.*; ...@@ -36,7 +35,13 @@ import javax.swing.*;
class JavaAppLauncher implements Runnable { class JavaAppLauncher implements Runnable {
static { static {
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("osx")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("osx");
return null;
}
});
} }
private static native <T> T nativeConvertAndRelease(final long ptr); private static native <T> T nativeConvertAndRelease(final long ptr);
......
...@@ -103,7 +103,13 @@ public final class KeychainStore extends KeyStoreSpi { ...@@ -103,7 +103,13 @@ public final class KeychainStore extends KeyStoreSpi {
private static final int SALT_LEN = 20; private static final int SALT_LEN = 20;
static { static {
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("osx")); AccessController.doPrivileged(
new PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("osx");
return null;
}
});
try { try {
PKCS8ShroudedKeyBag_OID = new ObjectIdentifier(keyBag); PKCS8ShroudedKeyBag_OID = new ObjectIdentifier(keyBag);
pbeWithSHAAnd3KeyTripleDESCBC_OID = new ObjectIdentifier(pbeWithSHAAnd3KeyTripleDESCBC); pbeWithSHAAnd3KeyTripleDESCBC_OID = new ObjectIdentifier(pbeWithSHAAnd3KeyTripleDESCBC);
......
...@@ -27,7 +27,13 @@ package com.apple.concurrent; ...@@ -27,7 +27,13 @@ package com.apple.concurrent;
final class LibDispatchNative { final class LibDispatchNative {
static { static {
java.security.AccessController.doPrivileged((java.security.PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("osx")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("osx");
return null;
}
});
} }
static native boolean nativeIsDispatchSupported(); static native boolean nativeIsDispatchSupported();
......
...@@ -28,7 +28,6 @@ package com.apple.eawt; ...@@ -28,7 +28,6 @@ package com.apple.eawt;
import java.awt.*; import java.awt.*;
import java.awt.peer.*; import java.awt.peer.*;
import java.beans.Beans; import java.beans.Beans;
import java.security.PrivilegedAction;
import javax.swing.JMenuBar; import javax.swing.JMenuBar;
...@@ -59,7 +58,13 @@ public class Application { ...@@ -59,7 +58,13 @@ public class Application {
static Application sApplication = null; static Application sApplication = null;
static { static {
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("awt")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
checkSecurity(); checkSecurity();
if (!Beans.isDesignTime()) { if (!Beans.isDesignTime()) {
......
...@@ -55,7 +55,13 @@ import java.io.*; ...@@ -55,7 +55,13 @@ import java.io.*;
*/ */
public class FileManager { public class FileManager {
static { static {
java.security.AccessController.doPrivileged((java.security.PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("osx")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("osx");
return null;
}
});
} }
/** /**
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
package com.apple.laf; package com.apple.laf;
import java.io.*; import java.io.*;
import java.security.PrivilegedAction;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
...@@ -57,7 +56,13 @@ class AquaFileView extends FileView { ...@@ -57,7 +56,13 @@ class AquaFileView extends FileView {
static final int kLSItemInfoExtensionIsHidden = 0x00100000; /* Item has a hidden extension*/ static final int kLSItemInfoExtensionIsHidden = 0x00100000; /* Item has a hidden extension*/
static { static {
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("osxui")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("osxui");
return null;
}
});
} }
// TODO: Un-comment this out when the native version exists // TODO: Un-comment this out when the native version exists
......
...@@ -134,10 +134,16 @@ public class AquaLookAndFeel extends BasicLookAndFeel { ...@@ -134,10 +134,16 @@ public class AquaLookAndFeel extends BasicLookAndFeel {
* @see UIManager#setLookAndFeel * @see UIManager#setLookAndFeel
*/ */
public void initialize() { public void initialize() {
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("osxui")); java.security.AccessController.doPrivileged(new PrivilegedAction<Void>() {
java.security.AccessController.doPrivileged(new PrivilegedAction<Object>(){ public Void run() {
System.loadLibrary("osxui");
return null;
}
});
java.security.AccessController.doPrivileged(new PrivilegedAction<Void>(){
@Override @Override
public Object run() { public Void run() {
JRSUIControl.initJRSUI(); JRSUIControl.initJRSUI();
return null; return null;
} }
......
...@@ -27,7 +27,6 @@ package com.apple.laf; ...@@ -27,7 +27,6 @@ package com.apple.laf;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.security.PrivilegedAction;
import javax.swing.plaf.UIResource; import javax.swing.plaf.UIResource;
...@@ -35,7 +34,13 @@ import com.apple.laf.AquaUtils.RecyclableSingleton; ...@@ -35,7 +34,13 @@ import com.apple.laf.AquaUtils.RecyclableSingleton;
public class AquaNativeResources { public class AquaNativeResources {
static { static {
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("osxui")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("osxui");
return null;
}
});
} }
// TODO: removing CColorPaint for now // TODO: removing CColorPaint for now
......
...@@ -28,7 +28,6 @@ package com.apple.laf; ...@@ -28,7 +28,6 @@ package com.apple.laf;
import java.awt.*; import java.awt.*;
import java.awt.event.*; import java.awt.event.*;
import java.awt.peer.MenuComponentPeer; import java.awt.peer.MenuComponentPeer;
import java.security.PrivilegedAction;
import java.util.Hashtable; import java.util.Hashtable;
import javax.swing.*; import javax.swing.*;
...@@ -38,7 +37,13 @@ import sun.lwawt.macosx.*; ...@@ -38,7 +37,13 @@ import sun.lwawt.macosx.*;
class ScreenMenu extends Menu implements ContainerListener, ComponentListener, ScreenMenuPropertyHandler { class ScreenMenu extends Menu implements ContainerListener, ComponentListener, ScreenMenuPropertyHandler {
static { static {
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("awt")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
} }
// screen menu stuff // screen menu stuff
......
...@@ -26,15 +26,19 @@ ...@@ -26,15 +26,19 @@
package com.apple.laf; package com.apple.laf;
import java.awt.*; import java.awt.*;
import java.security.PrivilegedAction;
import javax.swing.*; import javax.swing.*;
import sun.lwawt.macosx.CPlatformWindow; import sun.lwawt.macosx.CPlatformWindow;
class ScreenPopupFactory extends PopupFactory { class ScreenPopupFactory extends PopupFactory {
static { static {
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("osxui")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("osxui");
return null;
}
});
} }
static final Float TRANSLUCENT = new Float(248f/255f); static final Float TRANSLUCENT = new Float(248f/255f);
......
...@@ -79,7 +79,13 @@ import java.lang.ref.WeakReference; ...@@ -79,7 +79,13 @@ import java.lang.ref.WeakReference;
class MacOSXPreferencesFile { class MacOSXPreferencesFile {
static { static {
java.security.AccessController.doPrivileged(new sun.security.action.LoadLibraryAction("osx")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("osx");
return null;
}
});
} }
private class FlushTask extends TimerTask { private class FlushTask extends TimerTask {
......
...@@ -58,9 +58,15 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment { ...@@ -58,9 +58,15 @@ public class CGraphicsEnvironment extends SunGraphicsEnvironment {
public static void init() { } public static void init() { }
static { static {
java.security.AccessController.doPrivileged(new sun.security.action.LoadLibraryAction("awt")); java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() {
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Object>() { public Void run() {
public Object run() { System.loadLibrary("awt");
return null;
}
});
java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Void>() {
public Void run() {
if (isHeadless()) return null; if (isHeadless()) return null;
initCocoa(); initCocoa();
return null; return null;
......
...@@ -29,7 +29,6 @@ import java.awt.*; ...@@ -29,7 +29,6 @@ import java.awt.*;
import java.beans.*; import java.beans.*;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.security.PrivilegedAction;
import java.util.*; import java.util.*;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
...@@ -41,7 +40,13 @@ class CAccessibility implements PropertyChangeListener { ...@@ -41,7 +40,13 @@ class CAccessibility implements PropertyChangeListener {
static { static {
// Need to load the native library for this code. // Need to load the native library for this code.
java.security.AccessController.doPrivileged((PrivilegedAction<?>)new sun.security.action.LoadLibraryAction("awt")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
} }
static CAccessibility sAccessibility; static CAccessibility sAccessibility;
......
...@@ -87,7 +87,12 @@ public class JPEGImageReader extends ImageReader { ...@@ -87,7 +87,12 @@ public class JPEGImageReader extends ImageReader {
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("jpeg")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("jpeg");
return null;
}
});
initReaderIDs(ImageInputStream.class, initReaderIDs(ImageInputStream.class,
JPEGQTable.class, JPEGQTable.class,
JPEGHuffmanTable.class); JPEGHuffmanTable.class);
......
...@@ -177,7 +177,12 @@ public class JPEGImageWriter extends ImageWriter { ...@@ -177,7 +177,12 @@ public class JPEGImageWriter extends ImageWriter {
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("jpeg")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("jpeg");
return null;
}
});
initWriterIDs(ImageOutputStream.class, initWriterIDs(ImageOutputStream.class,
JPEGQTable.class, JPEGQTable.class,
JPEGHuffmanTable.class); JPEGHuffmanTable.class);
......
...@@ -87,7 +87,12 @@ class NativeUnpack { ...@@ -87,7 +87,12 @@ class NativeUnpack {
// If loading from stand alone build uncomment this. // If loading from stand alone build uncomment this.
// System.loadLibrary("unpack"); // System.loadLibrary("unpack");
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("unpack")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("unpack");
return null;
}
});
initIDs(); initIDs();
} }
......
...@@ -119,7 +119,12 @@ public final class SplashScreen { ...@@ -119,7 +119,12 @@ public final class SplashScreen {
// SplashScreen class is now a singleton // SplashScreen class is now a singleton
if (!wasClosed && theInstance == null) { if (!wasClosed && theInstance == null) {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("splashscreen")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("splashscreen");
return null;
}
});
long ptr = _getInstance(); long ptr = _getInstance();
if (ptr != 0 && _isVisible(ptr)) { if (ptr != 0 && _isVisible(ptr)) {
theInstance = new SplashScreen(ptr); theInstance = new SplashScreen(ptr);
......
...@@ -1646,7 +1646,12 @@ public abstract class Toolkit { ...@@ -1646,7 +1646,12 @@ public abstract class Toolkit {
static void loadLibraries() { static void loadLibraries() {
if (!loaded) { if (!loaded) {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("awt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
loaded = true; loaded = true;
} }
} }
......
...@@ -54,6 +54,11 @@ class NativeLibLoader { ...@@ -54,6 +54,11 @@ class NativeLibLoader {
*/ */
static void loadLibraries() { static void loadLibraries() {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("awt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
} }
} }
...@@ -204,7 +204,12 @@ public abstract class ColorModel implements Transparency{ ...@@ -204,7 +204,12 @@ public abstract class ColorModel implements Transparency{
static void loadLibraries() { static void loadLibraries() {
if (!loaded) { if (!loaded) {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("awt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
loaded = true; loaded = true;
} }
} }
......
...@@ -67,7 +67,12 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl ...@@ -67,7 +67,12 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
*/ */
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("net")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
} }
/** /**
......
...@@ -78,7 +78,12 @@ abstract class AbstractPlainSocketImpl extends SocketImpl ...@@ -78,7 +78,12 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
*/ */
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("net")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
} }
/** /**
......
...@@ -47,7 +47,12 @@ class DatagramPacket { ...@@ -47,7 +47,12 @@ class DatagramPacket {
*/ */
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("net")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
init(); init();
} }
......
...@@ -234,7 +234,13 @@ class InetAddress implements java.io.Serializable { ...@@ -234,7 +234,13 @@ class InetAddress implements java.io.Serializable {
static { static {
preferIPv6Address = java.security.AccessController.doPrivileged( preferIPv6Address = java.security.AccessController.doPrivileged(
new GetBooleanAction("java.net.preferIPv6Addresses")).booleanValue(); new GetBooleanAction("java.net.preferIPv6Addresses")).booleanValue();
AccessController.doPrivileged(new LoadLibraryAction("net")); AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
init(); init();
} }
......
...@@ -53,7 +53,14 @@ public final class NetworkInterface { ...@@ -53,7 +53,14 @@ public final class NetworkInterface {
private static final int defaultIndex; /* index of defaultInterface */ private static final int defaultIndex; /* index of defaultInterface */
static { static {
AccessController.doPrivileged(new LoadLibraryAction("net")); AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
init(); init();
defaultInterface = DefaultInterface.getDefault(); defaultInterface = DefaultInterface.getDefault();
if (defaultInterface != null) { if (defaultInterface != null) {
......
...@@ -54,6 +54,11 @@ class NativeLibLoader { ...@@ -54,6 +54,11 @@ class NativeLibLoader {
*/ */
static void loadLibraries() { static void loadLibraries() {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("awt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
} }
} }
...@@ -54,7 +54,12 @@ public class JPEGImageDecoder extends ImageDecoder { ...@@ -54,7 +54,12 @@ public class JPEGImageDecoder extends ImageDecoder {
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("jpeg")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("jpeg");
return null;
}
});
initIDs(InputStreamClass); initIDs(InputStreamClass);
RGBcolormodel = new DirectColorModel(24, 0xff0000, 0xff00, 0xff); RGBcolormodel = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
ARGBcolormodel = ColorModel.getRGBdefault(); ARGBcolormodel = ColorModel.getRGBdefault();
......
...@@ -53,7 +53,12 @@ class NativeLibLoader { ...@@ -53,7 +53,12 @@ class NativeLibLoader {
* that the name of the library is "awt". -br. * that the name of the library is "awt". -br.
*/ */
static void loadLibraries() { static void loadLibraries() {
java.security.AccessController.doPrivileged java.security.AccessController.doPrivileged(
(new sun.security.action.LoadLibraryAction("awt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
} }
} }
...@@ -57,7 +57,12 @@ public class Disposer implements Runnable { ...@@ -57,7 +57,12 @@ public class Disposer implements Runnable {
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("awt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
initIDs(); initIDs();
String type = (String) java.security.AccessController.doPrivileged( String type = (String) java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("sun.java2d.reftype")); new sun.security.action.GetPropertyAction("sun.java2d.reftype"));
......
...@@ -37,7 +37,6 @@ import javax.management.RuntimeOperationsException; ...@@ -37,7 +37,6 @@ import javax.management.RuntimeOperationsException;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedActionException; import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction; import java.security.PrivilegedExceptionAction;
import sun.security.action.LoadLibraryAction;
import sun.util.logging.LoggingSupport; import sun.util.logging.LoggingSupport;
...@@ -422,7 +421,13 @@ public class ManagementFactoryHelper { ...@@ -422,7 +421,13 @@ public class ManagementFactoryHelper {
} }
static { static {
AccessController.doPrivileged(new LoadLibraryAction("management")); AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("management");
return null;
}
});
jvm = new VMManagementImpl(); jvm = new VMManagementImpl();
} }
......
...@@ -76,6 +76,11 @@ public final class SdpSupport { ...@@ -76,6 +76,11 @@ public final class SdpSupport {
static { static {
AccessController.doPrivileged( AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("net")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
} }
} }
...@@ -95,7 +95,12 @@ public class DefaultProxySelector extends ProxySelector { ...@@ -95,7 +95,12 @@ public class DefaultProxySelector extends ProxySelector {
}}); }});
if (b != null && b.booleanValue()) { if (b != null && b.booleanValue()) {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("net")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
hasSystemProxies = init(); hasSystemProxies = init();
} }
} }
......
...@@ -472,10 +472,15 @@ public class Util { ...@@ -472,10 +472,15 @@ public class Util {
if (loaded) if (loaded)
return; return;
loaded = true; loaded = true;
java.security.AccessController java.security.AccessController.doPrivileged(
.doPrivileged(new sun.security.action.LoadLibraryAction("net")); new java.security.PrivilegedAction<Void>() {
java.security.AccessController public Void run() {
.doPrivileged(new sun.security.action.LoadLibraryAction("nio")); System.loadLibrary("net");
System.loadLibrary("nio");
return null;
}
});
// IOUtil must be initialized; Its native methods are called from // IOUtil must be initialized; Its native methods are called from
// other places in native nio code so they must be set up. // other places in native nio code so they must be set up.
IOUtil.initIDs(); IOUtil.initIDs();
......
/*
* Copyright (c) 1998, 2006, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.security.action;
/**
* A convenience class for loading a system library as a privileged action.
*
* <p>An instance of this class can be used as the argument of
* <code>AccessController.doPrivileged</code>.
*
* <p>The following code attempts to load the system library named
* <code>"lib"</code> as a privileged action: <p>
*
* <pre>
* java.security.AccessController.doPrivileged(new LoadLibraryAction("lib"));
* </pre>
*
* @author Roland Schemers
* @see java.security.PrivilegedAction
* @see java.security.AccessController
* @since 1.2
*/
public class LoadLibraryAction implements java.security.PrivilegedAction<Void> {
private String theLib;
/**
* Constructor that takes the name of the system library that needs to be
* loaded.
*
* <p>The manner in which a library name is mapped to the
* actual system library is system dependent.
*
* @param theLib the name of the library.
*/
public LoadLibraryAction(String theLib) {
this.theLib = theLib;
}
/**
* Loads the system library whose name was specified in the constructor.
*/
public Void run() {
System.loadLibrary(theLib);
return null;
}
}
...@@ -36,7 +36,13 @@ public class SCDynamicStoreConfig { ...@@ -36,7 +36,13 @@ public class SCDynamicStoreConfig {
private static native Hashtable<String, Object> getKerberosConfig(); private static native Hashtable<String, Object> getKerberosConfig();
static { static {
java.security.AccessController.doPrivileged(new sun.security.action.LoadLibraryAction("osx")); java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("osx");
return null;
}
});
installNotificationCallback(); installNotificationCallback();
} }
......
...@@ -27,8 +27,6 @@ package sun.security.smartcardio; ...@@ -27,8 +27,6 @@ package sun.security.smartcardio;
import java.security.AccessController; import java.security.AccessController;
import sun.security.action.LoadLibraryAction;
/** /**
* Access to native PC/SC functions and definition of PC/SC constants. * Access to native PC/SC functions and definition of PC/SC constants.
* Initialization and platform specific PC/SC constants are handled in * Initialization and platform specific PC/SC constants are handled in
......
...@@ -36,7 +36,12 @@ class JVM { ...@@ -36,7 +36,12 @@ class JVM {
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("jsdt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("jsdt");
return null;
}
});
} }
static long activate(String moduleName, DTraceProvider[] providers) { static long activate(String moduleName, DTraceProvider[] providers) {
......
...@@ -48,7 +48,12 @@ public class FileSystemImpl extends FileSystem { ...@@ -48,7 +48,12 @@ public class FileSystemImpl extends FileSystem {
// Initialization // Initialization
static { static {
java.security.AccessController java.security.AccessController.doPrivileged(
.doPrivileged(new sun.security.action.LoadLibraryAction("management")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("management");
return null;
}
});
} }
} }
...@@ -251,7 +251,12 @@ public class ResolverConfigurationImpl ...@@ -251,7 +251,12 @@ public class ResolverConfigurationImpl
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("net")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
} }
} }
......
...@@ -1100,7 +1100,12 @@ public class SctpChannelImpl extends SctpChannel ...@@ -1100,7 +1100,12 @@ public class SctpChannelImpl extends SctpChannel
static { static {
Util.load(); /* loads nio & net native libraries */ Util.load(); /* loads nio & net native libraries */
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("sctp")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("sctp");
return null;
}
});
initIDs(); initIDs();
} }
} }
...@@ -989,6 +989,11 @@ public class SctpMultiChannelImpl extends SctpMultiChannel ...@@ -989,6 +989,11 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
static { static {
Util.load(); /* loads nio & net native libraries */ Util.load(); /* loads nio & net native libraries */
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("sctp")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("sctp");
return null;
}
});
} }
} }
...@@ -428,7 +428,12 @@ public class SctpServerChannelImpl extends SctpServerChannel ...@@ -428,7 +428,12 @@ public class SctpServerChannelImpl extends SctpServerChannel
static { static {
Util.load(); // loads nio & net native libraries Util.load(); // loads nio & net native libraries
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("sctp")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("sctp");
return null;
}
});
initIDs(); initIDs();
} }
} }
...@@ -77,7 +77,12 @@ public class CUPSPrinter { ...@@ -77,7 +77,12 @@ public class CUPSPrinter {
static { static {
// load awt library to access native code // load awt library to access native code
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("awt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
libFound = initIDs(); libFound = initIDs();
if (libFound) { if (libFound) {
cupsServer = getCupsServer(); cupsServer = getCupsServer();
......
...@@ -37,8 +37,6 @@ import java.util.*; ...@@ -37,8 +37,6 @@ import java.util.*;
import java.util.List; import java.util.List;
import java.util.concurrent.*; import java.util.concurrent.*;
import sun.security.action.LoadLibraryAction;
import static sun.awt.shell.Win32ShellFolder2.*; import static sun.awt.shell.Win32ShellFolder2.*;
import sun.awt.OSInfo; import sun.awt.OSInfo;
...@@ -56,7 +54,13 @@ public class Win32ShellFolderManager2 extends ShellFolderManager { ...@@ -56,7 +54,13 @@ public class Win32ShellFolderManager2 extends ShellFolderManager {
static { static {
// Load library here // Load library here
AccessController.doPrivileged(new LoadLibraryAction("awt")); AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
} }
public ShellFolder createShellFolder(File file) throws FileNotFoundException { public ShellFolder createShellFolder(File file) throws FileNotFoundException {
......
...@@ -94,7 +94,12 @@ public class WToolkit extends SunToolkit implements Runnable { ...@@ -94,7 +94,12 @@ public class WToolkit extends SunToolkit implements Runnable {
public static void loadLibraries() { public static void loadLibraries() {
if (!loaded) { if (!loaded) {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("awt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
loaded = true; loaded = true;
} }
} }
......
...@@ -56,8 +56,13 @@ public class FileSystemImpl extends FileSystem { ...@@ -56,8 +56,13 @@ public class FileSystemImpl extends FileSystem {
// Initialization // Initialization
static { static {
java.security.AccessController java.security.AccessController.doPrivileged(
.doPrivileged(new sun.security.action.LoadLibraryAction("management")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("management");
return null;
}
});
init0(); init0();
} }
} }
...@@ -161,7 +161,12 @@ public class ResolverConfigurationImpl ...@@ -161,7 +161,12 @@ public class ResolverConfigurationImpl
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("net")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("net");
return null;
}
});
init0(); init0();
// start the address listener thread // start the address listener thread
......
...@@ -56,7 +56,12 @@ public class Win32PrintServiceLookup extends PrintServiceLookup { ...@@ -56,7 +56,12 @@ public class Win32PrintServiceLookup extends PrintServiceLookup {
static { static {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.LoadLibraryAction("awt")); new java.security.PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("awt");
return null;
}
});
} }
/* The singleton win32 print lookup service. /* The singleton win32 print lookup service.
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
package sun.security.smartcardio; package sun.security.smartcardio;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.action.LoadLibraryAction;
// Platform specific code and constants // Platform specific code and constants
class PlatformPCSC { class PlatformPCSC {
...@@ -44,7 +43,12 @@ class PlatformPCSC { ...@@ -44,7 +43,12 @@ class PlatformPCSC {
private static Throwable loadLibrary() { private static Throwable loadLibrary() {
try { try {
AccessController.doPrivileged(new LoadLibraryAction("j2pcsc")); AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
System.loadLibrary("j2pcsc");
return null;
}
});
return null; return null;
} catch (Throwable e) { } catch (Throwable e) {
return e; return e;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册