6744401: Consider removal of code disabling JIT in Toolkit.getDefaultToolkit
Reviewed-by: anthony, pchelko
This commit is contained in:
parent
c45342182e
commit
74ff5d8776
@ -26,10 +26,6 @@
|
|||||||
package java.awt;
|
package java.awt;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.util.MissingResourceException;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
import java.awt.peer.*;
|
import java.awt.peer.*;
|
||||||
import java.awt.im.InputMethodHighlight;
|
import java.awt.im.InputMethodHighlight;
|
||||||
@ -855,50 +851,39 @@ public abstract class Toolkit {
|
|||||||
*/
|
*/
|
||||||
public static synchronized Toolkit getDefaultToolkit() {
|
public static synchronized Toolkit getDefaultToolkit() {
|
||||||
if (toolkit == null) {
|
if (toolkit == null) {
|
||||||
try {
|
java.security.AccessController.doPrivileged(
|
||||||
// We disable the JIT during toolkit initialization. This
|
new java.security.PrivilegedAction<Void>() {
|
||||||
// tends to touch lots of classes that aren't needed again
|
public Void run() {
|
||||||
// later and therefore JITing is counter-productiive.
|
Class<?> cls = null;
|
||||||
java.lang.Compiler.disable();
|
String nm = System.getProperty("awt.toolkit");
|
||||||
|
try {
|
||||||
java.security.AccessController.doPrivileged(
|
cls = Class.forName(nm);
|
||||||
new java.security.PrivilegedAction<Void>() {
|
} catch (ClassNotFoundException e) {
|
||||||
public Void run() {
|
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||||
String nm = null;
|
if (cl != null) {
|
||||||
Class<?> cls = null;
|
|
||||||
try {
|
|
||||||
nm = System.getProperty("awt.toolkit");
|
|
||||||
try {
|
try {
|
||||||
cls = Class.forName(nm);
|
cls = cl.loadClass(nm);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (final ClassNotFoundException ignored) {
|
||||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
throw new AWTError("Toolkit not found: " + nm);
|
||||||
if (cl != null) {
|
|
||||||
try {
|
|
||||||
cls = cl.loadClass(nm);
|
|
||||||
} catch (ClassNotFoundException ee) {
|
|
||||||
throw new AWTError("Toolkit not found: " + nm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (cls != null) {
|
|
||||||
toolkit = (Toolkit)cls.newInstance();
|
|
||||||
if (GraphicsEnvironment.isHeadless()) {
|
|
||||||
toolkit = new HeadlessToolkit(toolkit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (InstantiationException e) {
|
|
||||||
throw new AWTError("Could not instantiate Toolkit: " + nm);
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new AWTError("Could not access Toolkit: " + nm);
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
});
|
try {
|
||||||
loadAssistiveTechnologies();
|
if (cls != null) {
|
||||||
} finally {
|
toolkit = (Toolkit)cls.newInstance();
|
||||||
// Make sure to always re-enable the JIT.
|
if (GraphicsEnvironment.isHeadless()) {
|
||||||
java.lang.Compiler.enable();
|
toolkit = new HeadlessToolkit(toolkit);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} catch (final InstantiationException ignored) {
|
||||||
|
throw new AWTError("Could not instantiate Toolkit: " + nm);
|
||||||
|
} catch (final IllegalAccessException ignored) {
|
||||||
|
throw new AWTError("Could not access Toolkit: " + nm);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
loadAssistiveTechnologies();
|
||||||
}
|
}
|
||||||
return toolkit;
|
return toolkit;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user