jdk/src/share/classes/java/awt/Toolkit.java

Print this page




 846      * and a single instance of each is created using
 847      * Class.forName(class).newInstance().  This is done just after
 848      * the AWT toolkit is created.  All errors are handled via an
 849      * AWTError exception.
 850      * @return    the default toolkit.
 851      * @exception  AWTError  if a toolkit could not be found, or
 852      *                 if one could not be accessed or instantiated.
 853      */
 854     public static synchronized Toolkit getDefaultToolkit() {
 855         if (toolkit == null) {
 856             try {
 857                 // We disable the JIT during toolkit initialization.  This
 858                 // tends to touch lots of classes that aren't needed again
 859                 // later and therefore JITing is counter-productiive.
 860                 java.lang.Compiler.disable();
 861 
 862                 java.security.AccessController.doPrivileged(
 863                         new java.security.PrivilegedAction<Void>() {
 864                     public Void run() {
 865                         String nm = null;
 866                         Class cls = null;
 867                         try {
 868                             nm = System.getProperty("awt.toolkit");
 869                             try {
 870                                 cls = Class.forName(nm);
 871                             } catch (ClassNotFoundException e) {
 872                                 ClassLoader cl = ClassLoader.getSystemClassLoader();
 873                                 if (cl != null) {
 874                                     try {
 875                                         cls = cl.loadClass(nm);
 876                                     } catch (ClassNotFoundException ee) {
 877                                         throw new AWTError("Toolkit not found: " + nm);
 878                                     }
 879                                 }
 880                             }
 881                             if (cls != null) {
 882                                 toolkit = (Toolkit)cls.newInstance();
 883                                 if (GraphicsEnvironment.isHeadless()) {
 884                                     toolkit = new HeadlessToolkit(toolkit);
 885                                 }
 886                             }




 846      * and a single instance of each is created using
 847      * Class.forName(class).newInstance().  This is done just after
 848      * the AWT toolkit is created.  All errors are handled via an
 849      * AWTError exception.
 850      * @return    the default toolkit.
 851      * @exception  AWTError  if a toolkit could not be found, or
 852      *                 if one could not be accessed or instantiated.
 853      */
 854     public static synchronized Toolkit getDefaultToolkit() {
 855         if (toolkit == null) {
 856             try {
 857                 // We disable the JIT during toolkit initialization.  This
 858                 // tends to touch lots of classes that aren't needed again
 859                 // later and therefore JITing is counter-productiive.
 860                 java.lang.Compiler.disable();
 861 
 862                 java.security.AccessController.doPrivileged(
 863                         new java.security.PrivilegedAction<Void>() {
 864                     public Void run() {
 865                         String nm = null;
 866                         Class<?> cls = null;
 867                         try {
 868                             nm = System.getProperty("awt.toolkit");
 869                             try {
 870                                 cls = Class.forName(nm);
 871                             } catch (ClassNotFoundException e) {
 872                                 ClassLoader cl = ClassLoader.getSystemClassLoader();
 873                                 if (cl != null) {
 874                                     try {
 875                                         cls = cl.loadClass(nm);
 876                                     } catch (ClassNotFoundException ee) {
 877                                         throw new AWTError("Toolkit not found: " + nm);
 878                                     }
 879                                 }
 880                             }
 881                             if (cls != null) {
 882                                 toolkit = (Toolkit)cls.newInstance();
 883                                 if (GraphicsEnvironment.isHeadless()) {
 884                                     toolkit = new HeadlessToolkit(toolkit);
 885                                 }
 886                             }