8344061: Remove doPrivileged calls from shared implementation code in the java.desktop module : part 2
Reviewed-by: aivanov
This commit is contained in:
parent
3328b4ecf2
commit
69c9f2566e
@ -26,8 +26,6 @@
|
||||
package sun.awt;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
@ -333,17 +331,13 @@ public final class AWTAutoShutdown implements Runnable {
|
||||
* Creates and starts a new blocker thread. Doesn't return until
|
||||
* the new blocker thread starts.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private void activateBlockerThread() {
|
||||
AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
|
||||
String name = "AWT-Shutdown";
|
||||
Thread thread = new Thread(
|
||||
ThreadGroupUtils.getRootThreadGroup(), this, name, 0, false);
|
||||
Thread thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, name, 0, false);
|
||||
thread.setContextClassLoader(null);
|
||||
thread.setDaemon(false);
|
||||
blockerThread = thread;
|
||||
return thread;
|
||||
}).start();
|
||||
thread.start();
|
||||
try {
|
||||
/* Wait for the blocker thread to start. */
|
||||
mainLock.wait();
|
||||
|
@ -32,8 +32,6 @@ import java.awt.TrayIcon;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
@ -229,20 +227,13 @@ public final class AppContext {
|
||||
* @see sun.awt.SunToolkit
|
||||
* @since 1.2
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
AppContext(ThreadGroup threadGroup) {
|
||||
numAppContexts.incrementAndGet();
|
||||
|
||||
this.threadGroup = threadGroup;
|
||||
threadGroup2appContext.put(threadGroup, this);
|
||||
|
||||
this.contextClassLoader =
|
||||
AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
|
||||
public ClassLoader run() {
|
||||
return Thread.currentThread().getContextClassLoader();
|
||||
}
|
||||
});
|
||||
|
||||
this.contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
// Initialize push/pop lock and its condition to be used by all the
|
||||
// EventQueues within this AppContext
|
||||
Lock eventQueuePushPopLock = new ReentrantLock();
|
||||
@ -254,15 +245,11 @@ public final class AppContext {
|
||||
private static final ThreadLocal<AppContext> threadAppContext =
|
||||
new ThreadLocal<AppContext>();
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static void initMainAppContext() {
|
||||
// On the main Thread, we get the ThreadGroup, make a corresponding
|
||||
// AppContext, and instantiate the Java EventQueue. This way, legacy
|
||||
// code is unaffected by the move to multiple AppContext ability.
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
ThreadGroup currentThreadGroup =
|
||||
Thread.currentThread().getThreadGroup();
|
||||
ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup();
|
||||
ThreadGroup parentThreadGroup = currentThreadGroup.getParent();
|
||||
while (parentThreadGroup != null) {
|
||||
// Find the root ThreadGroup to construct our main AppContext
|
||||
@ -271,9 +258,6 @@ public final class AppContext {
|
||||
}
|
||||
|
||||
mainAppContext = SunToolkit.createNewAppContext(currentThreadGroup);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -284,7 +268,6 @@ public final class AppContext {
|
||||
* @see java.lang.ThreadGroup
|
||||
* @since 1.2
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
public static AppContext getAppContext() {
|
||||
// we are standalone app, return the main app context
|
||||
if (numAppContexts.get() == 1 && mainAppContext != null) {
|
||||
@ -294,9 +277,6 @@ public final class AppContext {
|
||||
AppContext appContext = threadAppContext.get();
|
||||
|
||||
if (null == appContext) {
|
||||
appContext = AccessController.doPrivileged(new PrivilegedAction<AppContext>()
|
||||
{
|
||||
public AppContext run() {
|
||||
// Get the current ThreadGroup, and look for it and its
|
||||
// parents in the hash from ThreadGroup to AppContext --
|
||||
// it should be found, because we use createNewContext()
|
||||
@ -326,19 +306,8 @@ public final class AppContext {
|
||||
threadGroup = threadGroup.getParent();
|
||||
if (threadGroup == null) {
|
||||
// We've got up to the root thread group and did not find an AppContext
|
||||
// Try to get it from the security manager
|
||||
SecurityManager securityManager = System.getSecurityManager();
|
||||
if (securityManager != null) {
|
||||
ThreadGroup smThreadGroup = securityManager.getThreadGroup();
|
||||
if (smThreadGroup != null) {
|
||||
/*
|
||||
* If we get this far then it's likely that
|
||||
* the ThreadGroup does not actually belong
|
||||
* to the applet, so do not cache it.
|
||||
*/
|
||||
return threadGroup2appContext.get(smThreadGroup);
|
||||
}
|
||||
}
|
||||
// We have nowhere else to look, and this is not supposed to happen.
|
||||
// return null from this whole method.
|
||||
return null;
|
||||
}
|
||||
context = threadGroup2appContext.get(threadGroup);
|
||||
@ -354,9 +323,7 @@ public final class AppContext {
|
||||
// Now we're done, so we cache the latest key/value pair.
|
||||
threadAppContext.set(context);
|
||||
|
||||
return context;
|
||||
}
|
||||
});
|
||||
appContext = context;
|
||||
}
|
||||
|
||||
return appContext;
|
||||
@ -395,7 +362,7 @@ public final class AppContext {
|
||||
* contained within this AppContext
|
||||
* @since 1.2
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "removal"})
|
||||
@SuppressWarnings("deprecation")
|
||||
public void dispose() throws IllegalThreadStateException {
|
||||
System.err.println(
|
||||
"""
|
||||
@ -439,19 +406,13 @@ public final class AppContext {
|
||||
log.finer("exception occurred while disposing app context", t);
|
||||
}
|
||||
}
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
if (!GraphicsEnvironment.isHeadless() && SystemTray.isSupported())
|
||||
{
|
||||
if (!GraphicsEnvironment.isHeadless() && SystemTray.isSupported()) {
|
||||
SystemTray systemTray = SystemTray.getSystemTray();
|
||||
TrayIcon[] trayIconsToDispose = systemTray.getTrayIcons();
|
||||
for (TrayIcon ti : trayIconsToDispose) {
|
||||
systemTray.remove(ti);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
// Alert PropertyChangeListeners that the GUI has been disposed.
|
||||
if (changeSupport != null) {
|
||||
changeSupport.firePropertyChange(GUI_DISPOSED, false, true);
|
||||
@ -546,25 +507,6 @@ public final class AppContext {
|
||||
}
|
||||
}
|
||||
|
||||
static final class CreateThreadAction implements PrivilegedAction<Thread> {
|
||||
private final AppContext appContext;
|
||||
private final Runnable runnable;
|
||||
|
||||
CreateThreadAction(AppContext ac, Runnable r) {
|
||||
appContext = ac;
|
||||
runnable = r;
|
||||
}
|
||||
|
||||
public Thread run() {
|
||||
Thread t = new Thread(appContext.getThreadGroup(),
|
||||
runnable, "AppContext Disposer", 0, false);
|
||||
t.setContextClassLoader(appContext.getContextClassLoader());
|
||||
t.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
static void stopEventDispatchThreads() {
|
||||
for (AppContext appContext: getAppContexts()) {
|
||||
if (appContext.isDisposed()) {
|
||||
@ -576,9 +518,11 @@ public final class AppContext {
|
||||
if (appContext != AppContext.getAppContext()) {
|
||||
// Create a thread that belongs to the thread group associated
|
||||
// with the AppContext and invokes EventQueue.postEvent.
|
||||
PrivilegedAction<Thread> action = new CreateThreadAction(appContext, r);
|
||||
@SuppressWarnings("removal")
|
||||
Thread thread = AccessController.doPrivileged(action);
|
||||
Thread thread = new Thread(appContext.getThreadGroup(),
|
||||
r, "AppContext Disposer", 0, false);
|
||||
thread.setContextClassLoader(appContext.getContextClassLoader());
|
||||
thread.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
} else {
|
||||
r.run();
|
||||
@ -806,15 +750,9 @@ public final class AppContext {
|
||||
// Set up JavaAWTAccess in SharedSecrets
|
||||
static {
|
||||
SharedSecrets.setJavaAWTAccess(new JavaAWTAccess() {
|
||||
@SuppressWarnings("removal")
|
||||
private boolean hasRootThreadGroup(final AppContext ecx) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
|
||||
@Override
|
||||
public Boolean run() {
|
||||
return ecx.threadGroup.getParent() == null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the AppContext used for applet logging isolation, or null if
|
||||
|
@ -30,8 +30,6 @@ import java.awt.event.FocusEvent;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serial;
|
||||
import java.lang.reflect.Field;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* This class exists for deserialization compatibility only.
|
||||
@ -72,7 +70,6 @@ class CausedFocusEvent extends FocusEvent {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Serial
|
||||
Object readResolve() throws ObjectStreamException {
|
||||
FocusEvent.Cause newCause;
|
||||
@ -119,17 +116,11 @@ class CausedFocusEvent extends FocusEvent {
|
||||
focusEvent.setSource(null);
|
||||
try {
|
||||
final Field consumedField = FocusEvent.class.getField("consumed");
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
public Object run() {
|
||||
consumedField.setAccessible(true);
|
||||
try {
|
||||
consumedField.set(focusEvent, consumed);
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (NoSuchFieldException e) {
|
||||
}
|
||||
|
||||
|
@ -108,18 +108,11 @@ public final class DebugSettings {
|
||||
* Load debug properties from file, then override
|
||||
* with any command line specified properties
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private synchronized void loadProperties() {
|
||||
// setup initial properties
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
loadDefaultProperties();
|
||||
loadFileProperties();
|
||||
loadSystemProperties();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// echo the initial property settings to stdout
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
|
@ -35,8 +35,6 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -120,7 +118,7 @@ public abstract class FontConfiguration {
|
||||
this.preferPropFonts = preferPropFonts;
|
||||
/* fontConfig should be initialised by default constructor, and
|
||||
* its data tables can be shared, since readFontConfigFile doesn't
|
||||
* update any other state. Also avoid a doPrivileged block.
|
||||
* update any other state.
|
||||
*/
|
||||
initFontConfig();
|
||||
}
|
||||
@ -156,20 +154,8 @@ public abstract class FontConfiguration {
|
||||
short fontNameID = compFontNameIDs[0][0][0];
|
||||
short fileNameID = getComponentFileID(fontNameID);
|
||||
final String fileName = mapFileName(getComponentFileName(fileNameID));
|
||||
@SuppressWarnings("removal")
|
||||
Boolean exists = java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Boolean>() {
|
||||
public Boolean run() {
|
||||
try {
|
||||
File f = new File(fileName);
|
||||
return Boolean.valueOf(f.exists());
|
||||
}
|
||||
catch (Exception e) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
}
|
||||
});
|
||||
return exists.booleanValue();
|
||||
return f.exists();
|
||||
}
|
||||
|
||||
private void findFontConfigFile() {
|
||||
@ -960,18 +946,11 @@ public abstract class FontConfiguration {
|
||||
!charsetName.startsWith("sun.font.")) {
|
||||
fc = Charset.forName(charsetName);
|
||||
} else {
|
||||
@SuppressWarnings("removal")
|
||||
Class<?> fcc = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
|
||||
public Class<?> run() {
|
||||
Class<?> fcc = null;
|
||||
try {
|
||||
return Class.forName(charsetName, true,
|
||||
ClassLoader.getSystemClassLoader());
|
||||
fcc = Class.forName(charsetName, true, ClassLoader.getSystemClassLoader());
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
if (fcc != null) {
|
||||
try {
|
||||
fc = (Charset) fcc.getDeclaredConstructor().newInstance();
|
||||
|
@ -120,10 +120,7 @@ public class FontDescriptor implements Cloneable {
|
||||
}
|
||||
static boolean isLE;
|
||||
static {
|
||||
@SuppressWarnings("removal")
|
||||
String enc = java.security.AccessController.doPrivileged(
|
||||
new sun.security.action.GetPropertyAction("sun.io.unicode.encoding",
|
||||
"UnicodeBig"));
|
||||
String enc = System.getProperty("sun.io.unicode.encoding", "UnicodeBig");
|
||||
isLE = !"UnicodeBig".equals(enc);
|
||||
}
|
||||
}
|
||||
|
@ -52,14 +52,8 @@ class NativeLibLoader {
|
||||
* For now, we know it's done by the implementation, and we assume
|
||||
* that the name of the library is "awt". -br.
|
||||
*/
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
static void loadLibraries() {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("awt");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -62,10 +62,6 @@ import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.IllegalCharsetNameException;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
@ -985,7 +981,6 @@ search:
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private String removeSuspectedData(DataFlavor flavor, final Transferable contents, final String str)
|
||||
throws IOException
|
||||
{
|
||||
if (null == System.getSecurityManager()
|
||||
|| !flavor.isMimeTypeEqual("text/uri-list"))
|
||||
@ -994,10 +989,6 @@ search:
|
||||
}
|
||||
|
||||
final ProtectionDomain userProtectionDomain = getUserProtectionDomain(contents);
|
||||
|
||||
try {
|
||||
return AccessController.doPrivileged((PrivilegedExceptionAction<String>) () -> {
|
||||
|
||||
StringBuilder allowedFiles = new StringBuilder(str.length());
|
||||
String [] uriArray = str.split("(\\s)+");
|
||||
|
||||
@ -1016,12 +1007,7 @@ search:
|
||||
allowedFiles.append(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
return allowedFiles.toString();
|
||||
});
|
||||
} catch (PrivilegedActionException pae) {
|
||||
throw new IOException(pae.getMessage(), pae);
|
||||
}
|
||||
}
|
||||
|
||||
private static ProtectionDomain getUserProtectionDomain(Transferable contents) {
|
||||
@ -1047,8 +1033,6 @@ search:
|
||||
@SuppressWarnings("removal")
|
||||
private ArrayList<String> castToFiles(final List<?> files,
|
||||
final ProtectionDomain userProtectionDomain) throws IOException {
|
||||
try {
|
||||
return AccessController.doPrivileged((PrivilegedExceptionAction<ArrayList<String>>) () -> {
|
||||
ArrayList<String> fileList = new ArrayList<>();
|
||||
for (Object fileObject : files)
|
||||
{
|
||||
@ -1062,10 +1046,6 @@ search:
|
||||
}
|
||||
}
|
||||
return fileList;
|
||||
});
|
||||
} catch (PrivilegedActionException pae) {
|
||||
throw new IOException(pae.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// It is important do not use user's successors
|
||||
@ -1419,7 +1399,6 @@ search:
|
||||
* and also arbitrary Objects which have a constructor which takes an
|
||||
* instance of the Class as its sole parameter.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private Object constructFlavoredObject(Object arg, DataFlavor flavor,
|
||||
Class<?> clazz)
|
||||
throws IOException
|
||||
@ -1429,15 +1408,7 @@ search:
|
||||
if (clazz.equals(dfrc)) {
|
||||
return arg; // simple case
|
||||
} else {
|
||||
Constructor<?>[] constructors;
|
||||
|
||||
try {
|
||||
constructors = AccessController.doPrivileged(
|
||||
(PrivilegedAction<Constructor<?>[]>) dfrc::getConstructors);
|
||||
} catch (SecurityException se) {
|
||||
throw new IOException(se.getMessage());
|
||||
}
|
||||
|
||||
Constructor<?>[] constructors = dfrc.getConstructors();
|
||||
Constructor<?> constructor = Stream.of(constructors)
|
||||
.filter(c -> Modifier.isPublic(c.getModifiers()))
|
||||
.filter(c -> {
|
||||
|
@ -38,8 +38,6 @@ import java.io.ObjectStreamClass;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -111,28 +109,14 @@ final class ClassLoaderObjectOutputStream extends ObjectOutputStream {
|
||||
}
|
||||
|
||||
protected void annotateClass(final Class<?> cl) throws IOException {
|
||||
@SuppressWarnings("removal")
|
||||
ClassLoader classLoader = AccessController.doPrivileged(
|
||||
new PrivilegedAction<ClassLoader>() {
|
||||
public ClassLoader run() {
|
||||
return cl.getClassLoader();
|
||||
}
|
||||
});
|
||||
|
||||
ClassLoader classLoader = cl.getClassLoader();
|
||||
Set<String> s = new HashSet<String>(1);
|
||||
s.add(cl.getName());
|
||||
|
||||
map.put(s, classLoader);
|
||||
}
|
||||
protected void annotateProxyClass(final Class<?> cl) throws IOException {
|
||||
@SuppressWarnings("removal")
|
||||
ClassLoader classLoader = AccessController.doPrivileged(
|
||||
new PrivilegedAction<ClassLoader>() {
|
||||
public ClassLoader run() {
|
||||
return cl.getClassLoader();
|
||||
}
|
||||
});
|
||||
|
||||
ClassLoader classLoader = cl.getClassLoader();
|
||||
Class<?>[] interfaces = cl.getInterfaces();
|
||||
Set<String> s = new HashSet<String>(interfaces.length);
|
||||
for (int i = 0; i < interfaces.length; i++) {
|
||||
|
@ -41,10 +41,6 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.awt.im.spi.InputMethodDescriptor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
@ -252,25 +248,15 @@ class ExecutableInputMethodManager extends InputMethodManager
|
||||
* initializes the input method locator list for all
|
||||
* installed input method descriptors.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private void initializeInputMethodLocatorList() {
|
||||
synchronized (javaInputMethodLocatorList) {
|
||||
javaInputMethodLocatorList.clear();
|
||||
try {
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||
public Object run() {
|
||||
for (InputMethodDescriptor descriptor :
|
||||
ServiceLoader.load(InputMethodDescriptor.class,
|
||||
ClassLoader.getSystemClassLoader())) {
|
||||
ClassLoader cl = descriptor.getClass().getClassLoader();
|
||||
javaInputMethodLocatorList.add(new InputMethodLocator(descriptor, cl, null));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
} catch (PrivilegedActionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
javaInputMethodCount = javaInputMethodLocatorList.size();
|
||||
}
|
||||
|
||||
@ -594,14 +580,9 @@ class ExecutableInputMethodManager extends InputMethodManager
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private Preferences getUserRoot() {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<Preferences>() {
|
||||
public Preferences run() {
|
||||
return Preferences.userRoot();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Locale getAdvertisedLocale(InputMethodLocator locator, Locale locale) {
|
||||
Locale advertised = null;
|
||||
|
@ -44,8 +44,6 @@ import java.awt.event.WindowListener;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
import java.awt.im.spi.InputMethod;
|
||||
import java.lang.Character.Subset;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@ -1036,10 +1034,7 @@ public class InputContext extends java.awt.im.InputContext
|
||||
/**
|
||||
* Initializes the input method selection key definition in preference trees
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
private void initializeInputMethodSelectionKey() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
// Look in user's tree
|
||||
Preferences root = Preferences.userRoot();
|
||||
inputMethodSelectionKey = getInputMethodSelectionKeyStroke(root);
|
||||
@ -1049,9 +1044,6 @@ public class InputContext extends java.awt.im.InputContext
|
||||
root = Preferences.systemRoot();
|
||||
inputMethodSelectionKey = getInputMethodSelectionKeyStroke(root);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private AWTKeyStroke getInputMethodSelectionKeyStroke(Preferences root) {
|
||||
|
@ -37,7 +37,6 @@ import java.awt.event.InputMethodEvent;
|
||||
import java.awt.font.TextHitInfo;
|
||||
import java.awt.im.InputMethodRequests;
|
||||
import java.awt.im.spi.InputMethod;
|
||||
import java.security.AccessController;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
import java.text.AttributedCharacterIterator.Attribute;
|
||||
import java.text.AttributedString;
|
||||
@ -72,9 +71,7 @@ public class InputMethodContext
|
||||
static {
|
||||
// check whether we should use below-the-spot input
|
||||
// get property from command line
|
||||
@SuppressWarnings("removal")
|
||||
String inputStyle = AccessController.doPrivileged
|
||||
(new GetPropertyAction("java.awt.im.style", null));
|
||||
String inputStyle = System.getProperty("java.awt.im.style");
|
||||
// get property from awt.properties file
|
||||
if (inputStyle == null) {
|
||||
inputStyle = Toolkit.getProperty("java.awt.im.style", null);
|
||||
|
@ -27,8 +27,6 @@ package sun.font;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Semaphore;
|
||||
@ -112,11 +110,9 @@ public class CreatedFontTracker {
|
||||
private static HashMap<File, OutputStream> files = new HashMap<>();
|
||||
|
||||
private static Thread t = null;
|
||||
@SuppressWarnings("removal")
|
||||
static void init() {
|
||||
if (t == null) {
|
||||
// Add a shutdown hook to remove the temp file.
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
/* The thread must be a member of a thread group
|
||||
* which will not get GCed before VM exit.
|
||||
* Make its parent the top-level thread group.
|
||||
@ -129,8 +125,6 @@ public class CreatedFontTracker {
|
||||
*/
|
||||
t.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(t);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,11 +35,7 @@ import java.nio.ByteBuffer;
|
||||
import sun.java2d.Disposer;
|
||||
import sun.java2d.DisposerRecord;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
public abstract class FileFont extends PhysicalFont {
|
||||
|
||||
@ -252,15 +248,11 @@ public abstract class FileFont extends PhysicalFont {
|
||||
this.tracker = tracker;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public void dispose() {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
synchronized (fontFile) {
|
||||
count--;
|
||||
if (count > 0) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (fontFile != null) {
|
||||
@ -281,55 +273,10 @@ public abstract class FileFont extends PhysicalFont {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
protected String getPublicFileName() {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm == null) {
|
||||
return platName;
|
||||
}
|
||||
boolean canReadProperty = true;
|
||||
|
||||
try {
|
||||
sm.checkPropertyAccess("java.io.tmpdir");
|
||||
} catch (SecurityException e) {
|
||||
canReadProperty = false;
|
||||
}
|
||||
|
||||
if (canReadProperty) {
|
||||
return platName;
|
||||
}
|
||||
|
||||
final File f = new File(platName);
|
||||
|
||||
Boolean isTmpFile = Boolean.FALSE;
|
||||
try {
|
||||
isTmpFile = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<Boolean>() {
|
||||
public Boolean run() {
|
||||
File tmp = new File(System.getProperty("java.io.tmpdir"));
|
||||
try {
|
||||
String tpath = tmp.getCanonicalPath();
|
||||
String fpath = f.getCanonicalPath();
|
||||
|
||||
return (fpath == null) || fpath.startsWith(tpath);
|
||||
} catch (IOException e) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (PrivilegedActionException e) {
|
||||
// unable to verify whether value of java.io.tempdir will be
|
||||
// exposed, so return only a name of the font file.
|
||||
isTmpFile = Boolean.TRUE;
|
||||
}
|
||||
|
||||
return isTmpFile ? "temp file" : platName;
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,9 @@ package sun.font;
|
||||
|
||||
import sun.awt.OSInfo;
|
||||
|
||||
@SuppressWarnings({"removal", "restricted"})
|
||||
@SuppressWarnings("restricted")
|
||||
public class FontManagerNativeLibrary {
|
||||
static {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
/* REMIND do we really have to load awt here? */
|
||||
System.loadLibrary("awt");
|
||||
if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS) {
|
||||
@ -56,10 +53,6 @@ public class FontManagerNativeLibrary {
|
||||
System.loadLibrary("freetype");
|
||||
}
|
||||
System.loadLibrary("fontmanager");
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -28,9 +28,7 @@ package sun.font;
|
||||
import java.awt.Font;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.security.AccessController;
|
||||
|
||||
import java.security.PrivilegedAction;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
|
||||
import sun.awt.OSInfo;
|
||||
@ -59,12 +57,8 @@ public final class FontUtilities {
|
||||
initStatic();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static void initStatic() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@SuppressWarnings("deprecation") // PlatformLogger.setLevel is deprecated.
|
||||
@Override
|
||||
public Object run() {
|
||||
private static void initStatic() {
|
||||
|
||||
isLinux = OSInfo.getOSType() == OSInfo.OSType.LINUX;
|
||||
|
||||
@ -114,10 +108,6 @@ public final class FontUtilities {
|
||||
}
|
||||
logging = logger.isEnabled();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -263,7 +263,6 @@ public final class StrikeCache {
|
||||
initStatic();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static void initStatic() {
|
||||
|
||||
if (nativeAddressSize < 4) {
|
||||
@ -271,18 +270,13 @@ public final class StrikeCache {
|
||||
nativeAddressSize);
|
||||
}
|
||||
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
|
||||
/* Allow a client to override the reference type used to
|
||||
* cache strikes. The default is "soft" which hints to keep
|
||||
* the strikes around. This property allows the client to
|
||||
* override this to "weak" which hint to the GC to free
|
||||
* memory more aggressively.
|
||||
*/
|
||||
String refType =
|
||||
System.getProperty("sun.java2d.font.reftype", "soft");
|
||||
String refType = System.getProperty("sun.java2d.font.reftype", "soft");
|
||||
cacheRefTypeWeak = refType.equals("weak");
|
||||
|
||||
String minStrikesStr =
|
||||
@ -298,10 +292,6 @@ public final class StrikeCache {
|
||||
}
|
||||
|
||||
recentStrikes = new FontStrike[MINSTRIKES];
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,8 +33,6 @@ import java.io.FileInputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -262,10 +260,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
initStatic();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static void initStatic() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
FontManagerNativeLibrary.load();
|
||||
|
||||
// JNI throws an exception if a class/method/field is not found,
|
||||
@ -283,9 +278,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
jreFontDirName = jreLibDirName + File.separator + "fonts";
|
||||
|
||||
maxSoftRefCnt = Integer.getInteger("sun.java2d.font.maxSoftRefs", 10);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -304,10 +296,7 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
/* Initialise ptrs used by JNI methods */
|
||||
private static native void initIDs();
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
protected SunFontManager() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
File badFontFile =
|
||||
new File(jreFontDirName + File.separator + "badfonts.txt");
|
||||
if (badFontFile.exists()) {
|
||||
@ -443,11 +432,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
}
|
||||
|
||||
initCompositeFonts(fontConfig, null);
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public Font2DHandle getNewComposite(String family, int style,
|
||||
@ -1095,7 +1079,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
|
||||
private boolean haveCheckedUnreferencedFontFiles;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private String[] getFontFilesFromPath(boolean noType1) {
|
||||
final FilenameFilter filter;
|
||||
if (noType1) {
|
||||
@ -1103,8 +1086,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
} else {
|
||||
filter = new TTorT1Filter();
|
||||
}
|
||||
return AccessController.doPrivileged(new PrivilegedAction<String[]>() {
|
||||
public String[] run() {
|
||||
if (pathDirs.length == 1) {
|
||||
File dir = new File(pathDirs[0]);
|
||||
String[] files = dir.list(filter);
|
||||
@ -1130,8 +1111,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
return fileList.toArray(STR_ARRAY);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* This is needed since some windows registry names don't match
|
||||
* the font names.
|
||||
@ -1430,7 +1409,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
return new HashMap<>(0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
Font2D findFontFromPlatformMap(String lcName, int style) {
|
||||
HashMap<String, FamilyDescription> platformFontMap = SunFontManager.platformFontMap;
|
||||
if (platformFontMap == null) {
|
||||
@ -1524,20 +1502,16 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
final String[] files = {
|
||||
plainFile, boldFile, italicFile, boldItalicFile } ;
|
||||
|
||||
failure = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
|
||||
public Boolean run() {
|
||||
for (int i=0; i<files.length; i++) {
|
||||
if (files[i] == null) {
|
||||
continue;
|
||||
}
|
||||
File f = new File(files[i]);
|
||||
if (!f.exists()) {
|
||||
return Boolean.TRUE;
|
||||
failure = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
});
|
||||
|
||||
if (failure) {
|
||||
if (FontUtilities.isLogging()) {
|
||||
@ -1724,22 +1698,12 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
} else if (pathDirs.length==1) {
|
||||
return pathDirs[0] + File.separator + s;
|
||||
} else {
|
||||
@SuppressWarnings("removal")
|
||||
String path = AccessController.doPrivileged(
|
||||
new PrivilegedAction<String>() {
|
||||
public String run() {
|
||||
for (int p = 0; p < pathDirs.length; p++) {
|
||||
File f = new File(pathDirs[p] +File.separator+ s);
|
||||
f = new File(pathDirs[p] + File.separator + s);
|
||||
if (f.exists()) {
|
||||
return f.getAbsolutePath();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
if (path != null) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return s; // shouldn't happen, but harmless
|
||||
}
|
||||
@ -2181,7 +2145,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
|
||||
private int createdFontCount = 0;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public Font2D[] createFont2D(File fontFile, int fontFormat, boolean all,
|
||||
boolean isCopy, CreatedFontTracker tracker)
|
||||
throws FontFormatException {
|
||||
@ -2229,15 +2192,10 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
}
|
||||
} catch (FontFormatException e) {
|
||||
if (isCopy) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
if (_tracker != null) {
|
||||
_tracker.subBytes((int)fFile.length());
|
||||
}
|
||||
fFile.delete();
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
throw(e);
|
||||
}
|
||||
@ -2253,8 +2211,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
if (fileCloser == null) {
|
||||
final Runnable fileCloserRunnable = new Runnable() {
|
||||
public void run() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
for (int i = 0;i < CHANNELPOOLSIZE; i++) {
|
||||
if (fontFileCache[i] != null) {
|
||||
try {
|
||||
@ -2273,19 +2229,13 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||
fileCloser = new Thread(rootTG, fileCloserRunnable,
|
||||
"FileCloser", 0, false);
|
||||
fileCloser.setContextClassLoader(null);
|
||||
Runtime.getRuntime().addShutdownHook(fileCloser);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2930,7 +2880,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
return fontPath;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
protected void loadFonts() {
|
||||
if (discoveredAllFonts) {
|
||||
return;
|
||||
@ -2943,8 +2892,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
}
|
||||
initialiseDeferredFonts();
|
||||
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
if (fontPath == null) {
|
||||
fontPath = getPlatformFontPath(noType1Font);
|
||||
registerFontDirs(fontPath);
|
||||
@ -2962,9 +2909,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
}
|
||||
registerOtherFontFiles(registeredFontFiles);
|
||||
discoveredAllFonts = true;
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -3048,7 +2992,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
return defaultFontName;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public void loadFontFiles() {
|
||||
loadFonts();
|
||||
if (loadedAllFontFiles) {
|
||||
@ -3060,8 +3003,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
Thread.dumpStack();
|
||||
FontUtilities.logInfo("loadAllFontFiles() called");
|
||||
}
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
if (fontPath == null) {
|
||||
fontPath = getPlatformFontPath(noType1Font);
|
||||
}
|
||||
@ -3074,9 +3015,6 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
false, true);
|
||||
}
|
||||
loadedAllFontFiles = true;
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -3402,16 +3340,9 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
// Provides an aperture to add native font family names to the map
|
||||
protected void addNativeFontFamilyNames(TreeMap<String, String> familyNames, Locale requestedLocale) { }
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public void register1dot0Fonts() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
String type1Dir = "/usr/openwin/lib/X11/fonts/Type1";
|
||||
registerFontsInDir(type1Dir, true, Font2D.TYPE1_RANK,
|
||||
false, false);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
registerFontsInDir(type1Dir, true, Font2D.TYPE1_RANK, false, false);
|
||||
}
|
||||
|
||||
/* Really we need only the JRE fonts family names, but there's little
|
||||
@ -3442,11 +3373,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
* on windows and uses that if set.
|
||||
*/
|
||||
private static Locale systemLocale = null;
|
||||
@SuppressWarnings("removal")
|
||||
private static Locale getSystemStartupLocale() {
|
||||
if (systemLocale == null) {
|
||||
systemLocale = AccessController.doPrivileged(new PrivilegedAction<Locale>() {
|
||||
public Locale run() {
|
||||
/* On windows the system locale may be different than the
|
||||
* user locale. This is an unsupported configuration, but
|
||||
* in that case we want to return a dummy locale that will
|
||||
@ -3460,15 +3388,13 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
||||
String fileEncoding = System.getProperty("file.encoding", "");
|
||||
String sysEncoding = System.getProperty("sun.jnu.encoding");
|
||||
if (sysEncoding != null && !sysEncoding.equals(fileEncoding)) {
|
||||
return Locale.ROOT;
|
||||
}
|
||||
|
||||
systemLocale = Locale.ROOT;
|
||||
} else {
|
||||
String language = System.getProperty("user.language", "en");
|
||||
String country = System.getProperty("user.country","");
|
||||
String variant = System.getProperty("user.variant","");
|
||||
return Locale.of(language, country, variant);
|
||||
systemLocale = Locale.of(language, country, variant);
|
||||
}
|
||||
});
|
||||
}
|
||||
return systemLocale;
|
||||
}
|
||||
|
@ -37,8 +37,6 @@ import sun.java2d.DisposerRecord;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.lang.foreign.MemorySegment;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
@ -167,10 +165,7 @@ public final class SunLayoutEngine implements LayoutEngine, LayoutEngineFactory
|
||||
|
||||
static boolean useFFM = true;
|
||||
static {
|
||||
@SuppressWarnings("removal")
|
||||
String prop = AccessController.doPrivileged(
|
||||
(PrivilegedAction<String>) () ->
|
||||
System.getProperty("sun.font.layout.ffm", "true"));
|
||||
String prop = System.getProperty("sun.font.layout.ffm", "true");
|
||||
useFFM = "true".equals(prop);
|
||||
|
||||
}
|
||||
|
@ -38,9 +38,6 @@ import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
@ -246,13 +243,7 @@ public class TrueTypeFont extends FileFont {
|
||||
FontUtilities.logInfo("open TTF: " + platName);
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("removal")
|
||||
RandomAccessFile raf = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<RandomAccessFile>() {
|
||||
public RandomAccessFile run() throws FileNotFoundException {
|
||||
return new RandomAccessFile(platName, "r");
|
||||
}
|
||||
});
|
||||
RandomAccessFile raf = new RandomAccessFile(platName, "r");
|
||||
disposerRecord.channel = raf.getChannel();
|
||||
fileSize = (int)disposerRecord.channel.size();
|
||||
if (usePool) {
|
||||
@ -261,13 +252,6 @@ public class TrueTypeFont extends FileFont {
|
||||
((SunFontManager) fm).addToPool(this);
|
||||
}
|
||||
}
|
||||
} catch (PrivilegedActionException e) {
|
||||
close();
|
||||
Throwable reason = e.getCause();
|
||||
if (reason == null) {
|
||||
reason = e;
|
||||
}
|
||||
throw new FontFormatException(reason.toString());
|
||||
} catch (ClosedChannelException e) {
|
||||
/* NIO I/O is interruptible, recurse to retry operation.
|
||||
* The call to channel.size() above can throw this exception.
|
||||
@ -664,7 +648,6 @@ public class TrueTypeFont extends FileFont {
|
||||
};
|
||||
|
||||
private static String defaultCodePage = null;
|
||||
@SuppressWarnings("removal")
|
||||
static String getCodePage() {
|
||||
|
||||
if (defaultCodePage != null) {
|
||||
@ -672,8 +655,7 @@ public class TrueTypeFont extends FileFont {
|
||||
}
|
||||
|
||||
if (FontUtilities.isWindows) {
|
||||
defaultCodePage =
|
||||
AccessController.doPrivileged(new GetPropertyAction("file.encoding"));
|
||||
defaultCodePage = System.getProperty("file.encoding");
|
||||
} else {
|
||||
if (languages.length != codePages.length) {
|
||||
throw new InternalError("wrong code pages array length");
|
||||
|
@ -83,18 +83,10 @@ public class Type1Font extends FileFont {
|
||||
fileName = name;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public synchronized void dispose() {
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
|
||||
if (fileName != null) {
|
||||
(new java.io.File(fileName)).delete();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,18 +183,11 @@ public class Type1Font extends FileFont {
|
||||
FontUtilities.logInfo("open Type 1 font: " + platName);
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("removal")
|
||||
RandomAccessFile raf = (RandomAccessFile)
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
RandomAccessFile raf = null;
|
||||
try {
|
||||
return new RandomAccessFile(platName, "r");
|
||||
raf = new RandomAccessFile(platName, "r");
|
||||
} catch (FileNotFoundException ffne) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
FileChannel fc = raf.getChannel();
|
||||
fileSize = (int)fc.size();
|
||||
bbuf = ByteBuffer.allocate(fileSize);
|
||||
@ -227,7 +212,6 @@ public class Type1Font extends FileFont {
|
||||
}
|
||||
|
||||
/* called from native code to read file into a direct byte buffer */
|
||||
@SuppressWarnings("removal")
|
||||
void readFile(ByteBuffer buffer) {
|
||||
RandomAccessFile raf = null;
|
||||
FileChannel fc;
|
||||
@ -235,17 +219,10 @@ public class Type1Font extends FileFont {
|
||||
FontUtilities.logInfo("open Type 1 font: " + platName);
|
||||
}
|
||||
try {
|
||||
raf = (RandomAccessFile)
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Object>() {
|
||||
public Object run() {
|
||||
try {
|
||||
return new RandomAccessFile(platName, "r");
|
||||
raf = new RandomAccessFile(platName, "r");
|
||||
} catch (FileNotFoundException fnfe) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
fc = raf.getChannel();
|
||||
while (buffer.remaining() > 0 && fc.read(buffer) != -1) {}
|
||||
} catch (ClosedChannelException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user