diff options
Diffstat (limited to 'make/config/nwi/jawt-DrawingSurfaceInfo-CustomJavaCode.java')
-rwxr-xr-x | make/config/nwi/jawt-DrawingSurfaceInfo-CustomJavaCode.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/make/config/nwi/jawt-DrawingSurfaceInfo-CustomJavaCode.java b/make/config/nwi/jawt-DrawingSurfaceInfo-CustomJavaCode.java new file mode 100755 index 000000000..1cc13e7d8 --- /dev/null +++ b/make/config/nwi/jawt-DrawingSurfaceInfo-CustomJavaCode.java @@ -0,0 +1,38 @@ +public JAWT_PlatformInfo platformInfo() { + return newPlatformInfo(platformInfo0(getBuffer())); +} + +private native ByteBuffer platformInfo0(Buffer jthis0); + +private static java.lang.reflect.Method platformInfoFactoryMethod; + +private static JAWT_PlatformInfo newPlatformInfo(ByteBuffer buf) { + if (platformInfoFactoryMethod == null) { + String osName = (String) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty("os.name").toLowerCase(); + } + }); + try { + Class factoryClass; + if (osName.startsWith("wind")) { + factoryClass = Class.forName("com.sun.nwi.impl.jawt.windows.JAWT_Win32DrawingSurfaceInfo"); + } else if (osName.startsWith("mac os x")) { + factoryClass = Class.forName("com.sun.nwi.impl.jawt.macosx.JAWT_MacOSXDrawingSurfaceInfo"); + } else { + // Assume Linux, Solaris, etc. Should probably test for these explicitly. + factoryClass = Class.forName("com.sun.nwi.impl.jawt.x11.JAWT_X11DrawingSurfaceInfo"); + } + platformInfoFactoryMethod = factoryClass.getMethod("create", + new Class[] { ByteBuffer.class }); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + try { + return (JAWT_PlatformInfo) + platformInfoFactoryMethod.invoke(null, new Object[] { buf }); + } catch (Exception e) { + throw new RuntimeException(e); + } +} |