2003/03/29 22:16:22
[org.ibex.core.git] / src / org / xwt / plat / Java2.java
index 629858c..f1a2acd 100644 (file)
@@ -104,7 +104,21 @@ public class Java2 extends AWT {
     protected DoubleBuffer _createDoubleBuffer(int w, int h, Surface owner) { return new Java2DoubleBuffer(w, h); }
     protected Surface _createSurface(final Box root, final boolean framed) {
         return (Surface)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
-                public Object run() { return isJava14 ? new Java14Surface(root, framed) : new Java2Surface(root, framed); }
+                public Object run() {
+                   if (isJava14) {
+                       try {
+                            // weaken the binding here to avoid link errors on 1.3.x
+                            Class java14SurfaceClass = Class.forName(Java2.class.getName() + "$Java14Surface");
+                            Constructor ctor = java14SurfaceClass.getConstructor(new Class[] { Box.class, Boolean.TYPE });
+                            return (Surface)ctor.newInstance(new Object[] { root, new Boolean(framed) });
+                       } catch (Exception e) {
+                           Log.log(this, e);
+                           throw new LinkageError("error: " + e);
+                       }
+                   } else {
+                       return new Java2Surface(root, framed);
+                   }
+               }
             });
     }
 
@@ -263,7 +277,7 @@ public class Java2 extends AWT {
             });
     }
 
-    protected String getDescriptiveName() { return "Java 1.2+ JVM"; }
+    protected String getDescriptiveName() { return isJava14 ? "Java 1.4+ JVM" : "Java 1.2+ JVM"; }
 
     protected void _newBrowserWindow(String url) {
         if (Main.applet == null) {