jdk/src/share/classes/java/awt/GraphicsEnvironment.java
changeset 20107 18e644411f0b
parent 13349 b12dcd2c3e07
child 21278 ef8a3a2a72f2
equal deleted inserted replaced
20106:5d5f2c72f262 20107:18e644411f0b
    93     private static GraphicsEnvironment createGE() {
    93     private static GraphicsEnvironment createGE() {
    94         GraphicsEnvironment ge;
    94         GraphicsEnvironment ge;
    95         String nm = AccessController.doPrivileged(new GetPropertyAction("java.awt.graphicsenv", null));
    95         String nm = AccessController.doPrivileged(new GetPropertyAction("java.awt.graphicsenv", null));
    96         try {
    96         try {
    97 //          long t0 = System.currentTimeMillis();
    97 //          long t0 = System.currentTimeMillis();
    98             Class geCls;
    98             Class<GraphicsEnvironment> geCls;
    99             try {
    99             try {
   100                 // First we try if the bootclassloader finds the requested
   100                 // First we try if the bootclassloader finds the requested
   101                 // class. This way we can avoid to run in a privileged block.
   101                 // class. This way we can avoid to run in a privileged block.
   102                 geCls = Class.forName(nm);
   102                 geCls = (Class<GraphicsEnvironment>)Class.forName(nm);
   103             } catch (ClassNotFoundException ex) {
   103             } catch (ClassNotFoundException ex) {
   104                 // If the bootclassloader fails, we try again with the
   104                 // If the bootclassloader fails, we try again with the
   105                 // application classloader.
   105                 // application classloader.
   106                 ClassLoader cl = ClassLoader.getSystemClassLoader();
   106                 ClassLoader cl = ClassLoader.getSystemClassLoader();
   107                 geCls = Class.forName(nm, true, cl);
   107                 geCls = (Class<GraphicsEnvironment>)Class.forName(nm, true, cl);
   108             }
   108             }
   109             ge = (GraphicsEnvironment) geCls.newInstance();
   109             ge = geCls.newInstance();
   110 //          long t1 = System.currentTimeMillis();
   110 //          long t1 = System.currentTimeMillis();
   111 //          System.out.println("GE creation took " + (t1-t0)+ "ms.");
   111 //          System.out.println("GE creation took " + (t1-t0)+ "ms.");
   112             if (isHeadless()) {
   112             if (isHeadless()) {
   113                 ge = new HeadlessGraphicsEnvironment(ge);
   113                 ge = new HeadlessGraphicsEnvironment(ge);
   114             }
   114             }
   159      * @since 1.4
   159      * @since 1.4
   160      */
   160      */
   161     private static boolean getHeadlessProperty() {
   161     private static boolean getHeadlessProperty() {
   162         if (headless == null) {
   162         if (headless == null) {
   163             java.security.AccessController.doPrivileged(
   163             java.security.AccessController.doPrivileged(
   164             new java.security.PrivilegedAction() {
   164             new java.security.PrivilegedAction<Object>() {
   165                 public Object run() {
   165                 public Object run() {
   166                     String nm = System.getProperty("java.awt.headless");
   166                     String nm = System.getProperty("java.awt.headless");
   167 
   167 
   168                     if (nm == null) {
   168                     if (nm == null) {
   169                         /* No need to ask for DISPLAY when run in a browser */
   169                         /* No need to ask for DISPLAY when run in a browser */