GP-0: Remove unnecessary call to java.lang.Compiler.disable(). It's

currently a no-op, and it's removed in JDK 21.
This commit is contained in:
Ryan Kurtz 2024-02-05 07:29:26 -05:00
parent a5ea18bd55
commit 65dbaeaf57

View file

@ -162,34 +162,27 @@ public class MyHeadlessToolkit extends Toolkit {
} }
private void getRealToolkit() { private void getRealToolkit() {
Class<?> cls = null;
try { try {
// We disable the JIT during toolkit initialization. This try {
// tends to touch lots of classes that aren't needed again cls = Class.forName(preferredToolkit);
// later and therefore JITing is counter-productiive. }
java.lang.Compiler.disable(); catch (ClassNotFoundException ee) {
throw new AWTError("Toolkit not found: " + preferredToolkit);
Class<?> cls = null; }
try { if (cls != null) {
try { localToolKit = (Toolkit) cls.newInstance();
cls = Class.forName(preferredToolkit); if (GraphicsEnvironment.isHeadless()) {
} catch (ClassNotFoundException ee) { localToolKit = new HeadlessToolkit(localToolKit);
throw new AWTError("Toolkit not found: " + preferredToolkit); }
} }
if (cls != null) { }
localToolKit = (Toolkit)cls.newInstance(); catch (InstantiationException e) {
if (GraphicsEnvironment.isHeadless()) { throw new AWTError("Could not instantiate Toolkit: " + preferredToolkit);
localToolKit = new HeadlessToolkit(localToolKit); }
} catch (IllegalAccessException e) {
} throw new AWTError("Could not access Toolkit: " + preferredToolkit);
} catch (InstantiationException e) { }
throw new AWTError("Could not instantiate Toolkit: " + preferredToolkit);
} catch (IllegalAccessException e) {
throw new AWTError("Could not access Toolkit: " + preferredToolkit);
}
} finally {
// Make sure to always re-enable the JIT.
java.lang.Compiler.enable();
}
} }
} }