From cd2716edf42406f9e245257554355a6c5a0d3d9e Mon Sep 17 00:00:00 2001
From: Kenneth Russel <kbrussel@alum.mit.edu>
Date: Fri, 9 Apr 2004 23:40:07 +0000
Subject: Fixed build problems in X11SunJDKReflection.java

git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@98 232f8b59-042b-4e1e-8c03-345bb8c30851
---
 .../games/jogl/impl/x11/X11SunJDKReflection.java   | 39 ++++++++++++++--------
 1 file changed, 25 insertions(+), 14 deletions(-)

(limited to 'src/net/java/games/jogl/impl/x11/X11SunJDKReflection.java')

diff --git a/src/net/java/games/jogl/impl/x11/X11SunJDKReflection.java b/src/net/java/games/jogl/impl/x11/X11SunJDKReflection.java
index 8debae7c8..a59bf7137 100755
--- a/src/net/java/games/jogl/impl/x11/X11SunJDKReflection.java
+++ b/src/net/java/games/jogl/impl/x11/X11SunJDKReflection.java
@@ -39,8 +39,10 @@
 
 package net.java.games.jogl.impl.x11;
 
+import java.awt.GraphicsConfiguration;
 import java.awt.GraphicsDevice;
 import java.lang.reflect.*;
+import java.security.*;
 
 /** This class encapsulates the reflection routines necessary to peek
     inside a few data structures in the AWT implementation on X11 for
@@ -50,26 +52,27 @@ public class X11SunJDKReflection {
   private static Class   x11GraphicsDeviceClass;
   private static Method  x11GraphicsDeviceGetScreenMethod;
   private static Class   x11GraphicsConfigClass;
-  private static Class   x11GraphicsConfigGetVisualMethod;
+  private static Method  x11GraphicsConfigGetVisualMethod;
   private static boolean initted;
 
   static {
-    try {
     AccessController.doPrivileged(new PrivilegedAction() {
         public Object run() {
-          x11GraphicsDeviceClass = Class.forName("sun.awt.X11GraphicsDevice");
-          x11GraphicsDeviceGetScreenMethod = x11GraphicsDeviceClass.getDeclaredMethod("getScreen", new Class[] {});
-          x11GraphicsDeviceGetScreenMethod.setAccessible(true);
+          try {
+            x11GraphicsDeviceClass = Class.forName("sun.awt.X11GraphicsDevice");
+            x11GraphicsDeviceGetScreenMethod = x11GraphicsDeviceClass.getDeclaredMethod("getScreen", new Class[] {});
+            x11GraphicsDeviceGetScreenMethod.setAccessible(true);
 
-          x11GraphicsConfigClass = Class.forName("sun.awt.X11GraphicsConfig");
-          x11GraphicsConfigGetVisualMethod = x11GraphicsConfigClass.getDeclaredMethod("getVisual", new Class[] {});
-          x11GraphicsConfigGetVisualMethod.setAccessible(true);
-          initted = true;
+            x11GraphicsConfigClass = Class.forName("sun.awt.X11GraphicsConfig");
+            x11GraphicsConfigGetVisualMethod = x11GraphicsConfigClass.getDeclaredMethod("getVisual", new Class[] {});
+            x11GraphicsConfigGetVisualMethod.setAccessible(true);
+            initted = true;
+          } catch (Exception e) {
+            // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
+          }
+          return null;
         }
       });
-    } catch (Exception e) {
-      // Either not a Sun JDK or the interfaces have changed since 1.4.2 / 1.5
-    }
   }
 
   public static int graphicsDeviceGetScreen(GraphicsDevice device) {
@@ -77,7 +80,11 @@ public class X11SunJDKReflection {
       return 0;
     }
 
-    return ((Integer) x11GraphicsDeviceGetScreenMethod.invoke(device, new Object[] {})).intValue();
+    try {
+      return ((Integer) x11GraphicsDeviceGetScreenMethod.invoke(device, new Object[] {})).intValue();
+    } catch (Exception e) {
+      return 0;
+    }
   }
 
   public static int graphicsConfigurationGetVisualID(GraphicsConfiguration config) {
@@ -85,6 +92,10 @@ public class X11SunJDKReflection {
       return 0;
     }
 
-    return ((Integer) x11GraphicsConfigGetVisualMethod.invoke(config, new Object[] {})).intValue();
+    try {
+      return ((Integer) x11GraphicsConfigGetVisualMethod.invoke(config, new Object[] {})).intValue();
+    } catch (Exception e) {
+      return 0;
+    }
   }
 }
-- 
cgit v1.2.3