From 3ad5bf195cec28d7578ee417f9425a871ce7ef57 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Tue, 17 Mar 2009 19:51:26 +0000 Subject: Continue moving javax.media.nwi -> javax.media.nativewindow git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1880 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../classes/com/sun/nativewindow/impl/Debug.java | 93 ++++++++++++ .../com/sun/nativewindow/impl/NWReflection.java | 149 +++++++++++++++++++ .../sun/nativewindow/impl/NativeLibLoaderBase.java | 115 +++++++++++++++ .../nativewindow/impl/NativeWindowFactoryImpl.java | 121 ++++++++++++++++ .../com/sun/nativewindow/impl/NullWindow.java | 128 ++++++++++++++++ .../impl/jawt/JAWTNativeLibLoader.java | 71 +++++++++ .../com/sun/nativewindow/impl/jawt/JAWTUtil.java | 94 ++++++++++++ .../com/sun/nativewindow/impl/jawt/JAWTWindow.java | 157 ++++++++++++++++++++ .../nativewindow/impl/jawt/JAWT_PlatformInfo.java | 47 ++++++ .../impl/jawt/macosx/MacOSXJAWTWindow.java | 151 +++++++++++++++++++ .../impl/jawt/windows/WindowsJAWTWindow.java | 161 +++++++++++++++++++++ .../nativewindow/impl/jawt/x11/X11JAWTWindow.java | 133 +++++++++++++++++ .../impl/jawt/x11/X11SunJDKReflection.java | 103 +++++++++++++ .../com/sun/nativewindow/impl/x11/X11Util.java | 75 ++++++++++ .../impl/x11/awt/X11AWTNativeWindowFactory.java | 86 +++++++++++ .../classes/com/sun/nwi/impl/Debug.java | 93 ------------ .../classes/com/sun/nwi/impl/NWReflection.java | 149 ------------------- .../com/sun/nwi/impl/NativeLibLoaderBase.java | 115 --------------- .../com/sun/nwi/impl/NativeWindowFactoryImpl.java | 121 ---------------- .../classes/com/sun/nwi/impl/NullWindow.java | 128 ---------------- .../com/sun/nwi/impl/jawt/JAWTNativeLibLoader.java | 71 --------- .../classes/com/sun/nwi/impl/jawt/JAWTUtil.java | 94 ------------ .../classes/com/sun/nwi/impl/jawt/JAWTWindow.java | 157 -------------------- .../com/sun/nwi/impl/jawt/JAWT_PlatformInfo.java | 47 ------ .../sun/nwi/impl/jawt/macosx/MacOSXJAWTWindow.java | 151 ------------------- .../nwi/impl/jawt/windows/WindowsJAWTWindow.java | 161 --------------------- .../com/sun/nwi/impl/jawt/x11/X11JAWTWindow.java | 133 ----------------- .../sun/nwi/impl/jawt/x11/X11SunJDKReflection.java | 103 ------------- .../classes/com/sun/nwi/impl/x11/X11Util.java | 75 ---------- .../impl/x11/awt/X11AWTNativeWindowFactory.java | 86 ----------- 30 files changed, 1684 insertions(+), 1684 deletions(-) create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/NativeWindowFactoryImpl.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/NullWindow.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTNativeLibLoader.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTUtil.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWTWindow.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/jawt/JAWT_PlatformInfo.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/jawt/macosx/MacOSXJAWTWindow.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/jawt/windows/WindowsJAWTWindow.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11JAWTWindow.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/jawt/x11/X11SunJDKReflection.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/x11/X11Util.java create mode 100644 src/nativewindow/classes/com/sun/nativewindow/impl/x11/awt/X11AWTNativeWindowFactory.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/Debug.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/NWReflection.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/NativeLibLoaderBase.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/NativeWindowFactoryImpl.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/NullWindow.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/jawt/JAWTNativeLibLoader.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/jawt/JAWTUtil.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/jawt/JAWTWindow.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/jawt/JAWT_PlatformInfo.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/jawt/macosx/MacOSXJAWTWindow.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/jawt/windows/WindowsJAWTWindow.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/jawt/x11/X11JAWTWindow.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/jawt/x11/X11SunJDKReflection.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/x11/X11Util.java delete mode 100644 src/nativewindow/classes/com/sun/nwi/impl/x11/awt/X11AWTNativeWindowFactory.java (limited to 'src/nativewindow/classes/com/sun') diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java b/src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java new file mode 100644 index 000000000..73379e87b --- /dev/null +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/Debug.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.sun.nwi.impl; + +import java.security.*; + +/** Helper routines for logging and debugging. */ + +public class Debug { + // Some common properties + private static boolean verbose; + private static boolean debugAll; + + static { + verbose = isPropertyDefined("nwi.verbose"); + debugAll = isPropertyDefined("nwi.debug"); + if (verbose) { + Package p = Package.getPackage("javax.media.nwi"); + System.err.println("NWI specification version " + p.getSpecificationVersion()); + System.err.println("NWI implementation version " + p.getImplementationVersion()); + System.err.println("NWI implementation vendor " + p.getImplementationVendor()); + } + } + + public static boolean getBooleanProperty(final String property) { + Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + boolean val = Boolean.getBoolean(property); + return (val ? Boolean.TRUE : Boolean.FALSE); + } + }); + return b.booleanValue(); + } + + public static boolean isPropertyDefined(final String property) { + Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + String val = System.getProperty(property); + return (val != null ? Boolean.TRUE : Boolean.FALSE); + } + }); + return b.booleanValue(); + } + + public static boolean verbose() { + return verbose; + } + + public static boolean debugAll() { + return debugAll; + } + + public static boolean debug(String subcomponent) { + return debugAll() || isPropertyDefined("nwi.debug." + subcomponent); + } +} diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java new file mode 100644 index 000000000..51037af28 --- /dev/null +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NWReflection.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + */ + +package com.sun.nwi.impl; + +import java.lang.reflect.*; +import javax.media.nwi.*; + +public final class NWReflection { + public static final boolean DEBUG = Debug.debug("NWReflection"); + + public static final boolean isClassAvailable(String clazzName) { + try { + Class clazz = Class.forName(clazzName); + return null!=clazz; + } catch (Throwable e) { } + return false; + } + + public static final Class getClass(String clazzName) { + try { + return Class.forName(clazzName); + } catch (Throwable e) { } + return null; + } + + public static final Constructor getConstructor(String clazzName, Class[] cstrArgTypes) { + Class factoryClass = null; + Constructor factory = null; + + try { + factoryClass = Class.forName(clazzName); + if (factoryClass == null) { + throw new NWException(clazzName + " not available"); + } + try { + factory = factoryClass.getDeclaredConstructor( cstrArgTypes ); + } catch(NoSuchMethodException nsme) { + throw new NWException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found"); + } + return factory; + } catch (Throwable e) { + if (DEBUG) { + e.printStackTrace(); + } + throw new NWException(e); + } + } + + public static final Constructor getConstructor(String clazzName) { + return getConstructor(clazzName, new Class[0]); + } + + public static final Object createInstance(String clazzName, Class[] cstrArgTypes, Object[] cstrArgs) { + Constructor factory = null; + + try { + factory = getConstructor(clazzName, cstrArgTypes); + return factory.newInstance( cstrArgs ) ; + } catch (Exception e) { + throw new NWException(e); + } + } + + public static final Object createInstance(String clazzName, Object[] cstrArgs) { + Class[] cstrArgTypes = new Class[cstrArgs.length]; + for(int i=0; i=0; i--) { + Class face = clazzes[i]; + if(face.getName().equals(faceName)) { + return true; + } + } + clazz = clazz.getSuperclass(); + } while (clazz!=null); + return false; + } + + public static boolean isAWTComponent(Object target) { + return instanceOf(target, "java.awt.Component"); + } + + public static boolean isAWTComponent(Class clazz) { + return instanceOf(clazz, "java.awt.Component"); + } + +} + diff --git a/src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java new file mode 100644 index 000000000..9e072fec0 --- /dev/null +++ b/src/nativewindow/classes/com/sun/nativewindow/impl/NativeLibLoaderBase.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.sun.nwi.impl; + +// FIXME: refactor Java SE dependencies +//import java.awt.Toolkit; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.HashSet; + +public class NativeLibLoaderBase { + public interface LoaderAction { + /** + * Loads the library specified by libname. Optionally preloads the libraries specified by + * preload. The implementation should ignore, if the preload-libraries have already been + * loaded. + * @param libname the library to load + * @param preload the libraries to load before loading the main library if not null + * @param preloadIgnoreError true, if errors during loading the preload-libraries should be ignored + */ + void loadLibrary(String libname, String[] preload, + boolean preloadIgnoreError); + } + + private static class DefaultAction implements LoaderAction { + public void loadLibrary(String libname, String[] preload, + boolean preloadIgnoreError) { + if (null!=preload) { + for (int i=0; i 0) { + --recursionCount; + return; + } + owner = null; + JAWTUtil.unlockToolkit(); + } + }; + + public ToolkitLock getToolkitLock() { + return toolkitLock; + } +} diff --git a/src/nativewindow/classes/com/sun/nwi/impl/Debug.java b/src/nativewindow/classes/com/sun/nwi/impl/Debug.java deleted file mode 100644 index 73379e87b..000000000 --- a/src/nativewindow/classes/com/sun/nwi/impl/Debug.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package com.sun.nwi.impl; - -import java.security.*; - -/** Helper routines for logging and debugging. */ - -public class Debug { - // Some common properties - private static boolean verbose; - private static boolean debugAll; - - static { - verbose = isPropertyDefined("nwi.verbose"); - debugAll = isPropertyDefined("nwi.debug"); - if (verbose) { - Package p = Package.getPackage("javax.media.nwi"); - System.err.println("NWI specification version " + p.getSpecificationVersion()); - System.err.println("NWI implementation version " + p.getImplementationVersion()); - System.err.println("NWI implementation vendor " + p.getImplementationVendor()); - } - } - - public static boolean getBooleanProperty(final String property) { - Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - boolean val = Boolean.getBoolean(property); - return (val ? Boolean.TRUE : Boolean.FALSE); - } - }); - return b.booleanValue(); - } - - public static boolean isPropertyDefined(final String property) { - Boolean b = (Boolean) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - String val = System.getProperty(property); - return (val != null ? Boolean.TRUE : Boolean.FALSE); - } - }); - return b.booleanValue(); - } - - public static boolean verbose() { - return verbose; - } - - public static boolean debugAll() { - return debugAll; - } - - public static boolean debug(String subcomponent) { - return debugAll() || isPropertyDefined("nwi.debug." + subcomponent); - } -} diff --git a/src/nativewindow/classes/com/sun/nwi/impl/NWReflection.java b/src/nativewindow/classes/com/sun/nwi/impl/NWReflection.java deleted file mode 100644 index 51037af28..000000000 --- a/src/nativewindow/classes/com/sun/nwi/impl/NWReflection.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - */ - -package com.sun.nwi.impl; - -import java.lang.reflect.*; -import javax.media.nwi.*; - -public final class NWReflection { - public static final boolean DEBUG = Debug.debug("NWReflection"); - - public static final boolean isClassAvailable(String clazzName) { - try { - Class clazz = Class.forName(clazzName); - return null!=clazz; - } catch (Throwable e) { } - return false; - } - - public static final Class getClass(String clazzName) { - try { - return Class.forName(clazzName); - } catch (Throwable e) { } - return null; - } - - public static final Constructor getConstructor(String clazzName, Class[] cstrArgTypes) { - Class factoryClass = null; - Constructor factory = null; - - try { - factoryClass = Class.forName(clazzName); - if (factoryClass == null) { - throw new NWException(clazzName + " not available"); - } - try { - factory = factoryClass.getDeclaredConstructor( cstrArgTypes ); - } catch(NoSuchMethodException nsme) { - throw new NWException("Constructor: '" + clazzName + "("+cstrArgTypes+")' not found"); - } - return factory; - } catch (Throwable e) { - if (DEBUG) { - e.printStackTrace(); - } - throw new NWException(e); - } - } - - public static final Constructor getConstructor(String clazzName) { - return getConstructor(clazzName, new Class[0]); - } - - public static final Object createInstance(String clazzName, Class[] cstrArgTypes, Object[] cstrArgs) { - Constructor factory = null; - - try { - factory = getConstructor(clazzName, cstrArgTypes); - return factory.newInstance( cstrArgs ) ; - } catch (Exception e) { - throw new NWException(e); - } - } - - public static final Object createInstance(String clazzName, Object[] cstrArgs) { - Class[] cstrArgTypes = new Class[cstrArgs.length]; - for(int i=0; i=0; i--) { - Class face = clazzes[i]; - if(face.getName().equals(faceName)) { - return true; - } - } - clazz = clazz.getSuperclass(); - } while (clazz!=null); - return false; - } - - public static boolean isAWTComponent(Object target) { - return instanceOf(target, "java.awt.Component"); - } - - public static boolean isAWTComponent(Class clazz) { - return instanceOf(clazz, "java.awt.Component"); - } - -} - diff --git a/src/nativewindow/classes/com/sun/nwi/impl/NativeLibLoaderBase.java b/src/nativewindow/classes/com/sun/nwi/impl/NativeLibLoaderBase.java deleted file mode 100644 index 9e072fec0..000000000 --- a/src/nativewindow/classes/com/sun/nwi/impl/NativeLibLoaderBase.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package com.sun.nwi.impl; - -// FIXME: refactor Java SE dependencies -//import java.awt.Toolkit; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.HashSet; - -public class NativeLibLoaderBase { - public interface LoaderAction { - /** - * Loads the library specified by libname. Optionally preloads the libraries specified by - * preload. The implementation should ignore, if the preload-libraries have already been - * loaded. - * @param libname the library to load - * @param preload the libraries to load before loading the main library if not null - * @param preloadIgnoreError true, if errors during loading the preload-libraries should be ignored - */ - void loadLibrary(String libname, String[] preload, - boolean preloadIgnoreError); - } - - private static class DefaultAction implements LoaderAction { - public void loadLibrary(String libname, String[] preload, - boolean preloadIgnoreError) { - if (null!=preload) { - for (int i=0; i 0) { - --recursionCount; - return; - } - owner = null; - JAWTUtil.unlockToolkit(); - } - }; - - public ToolkitLock getToolkitLock() { - return toolkitLock; - } -} -- cgit v1.2.3