diff options
author | Harvey Harrison <[email protected]> | 2013-10-17 21:06:56 -0700 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2013-10-17 21:06:56 -0700 |
commit | 791a2749886f02ec7b8db25bf8862e8269b96da5 (patch) | |
tree | c9be31d0bbbe8033b4a6a0cfad91a22b6575ced1 /src/java/com/jogamp/common | |
parent | 5b77e15500b7b19d35976603dd71e8b997b2d8ea (diff) |
gluegen: remove trailing whitespace
Signed-off-by: Harvey Harrison <[email protected]>
Diffstat (limited to 'src/java/com/jogamp/common')
57 files changed, 1464 insertions, 1464 deletions
diff --git a/src/java/com/jogamp/common/GlueGenVersion.java b/src/java/com/jogamp/common/GlueGenVersion.java index 5ae3412..a20b153 100644 --- a/src/java/com/jogamp/common/GlueGenVersion.java +++ b/src/java/com/jogamp/common/GlueGenVersion.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common; import com.jogamp.common.util.JogampVersion; diff --git a/src/java/com/jogamp/common/JogampRuntimeException.java b/src/java/com/jogamp/common/JogampRuntimeException.java index 1dd7519..7298812 100644 --- a/src/java/com/jogamp/common/JogampRuntimeException.java +++ b/src/java/com/jogamp/common/JogampRuntimeException.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common; /** A generic exception for Jogamp errors used throughout the binding diff --git a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java index 67cc05c..1b19d04 100644 --- a/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java +++ b/src/java/com/jogamp/common/jvm/JNILibLoaderBase.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * 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. */ @@ -62,14 +62,14 @@ import jogamp.common.Debug; import jogamp.common.os.PlatformPropsImpl; public class JNILibLoaderBase { - public static final boolean DEBUG = Debug.debug("JNILibLoader"); + public static final boolean DEBUG = Debug.debug("JNILibLoader"); public interface LoaderAction { /** * Loads the library specified by libname.<br> * The implementation should ignore, if the library has been loaded already.<br> * @param libname the library to load - * @param ignoreError if true, errors during loading the library should be ignored + * @param ignoreError if true, errors during loading the library should be ignored * @param cl optional ClassLoader, used to locate the library * @return true if library loaded successful */ @@ -81,12 +81,12 @@ public class JNILibLoaderBase { * The implementation should ignore, if any library has been loaded already.<br> * @param libname the library to load * @param preload the libraries to load before loading the main library if not null - * @param preloadIgnoreError if true, errors during loading the preload-libraries should be ignored + * @param preloadIgnoreError if true, errors during loading the preload-libraries should be ignored * @param cl optional ClassLoader, used to locate the library */ void loadLibrary(String libname, String[] preload, boolean preloadIgnoreError, ClassLoader cl); } - + private static class DefaultAction implements LoaderAction { public boolean loadLibrary(String libname, boolean ignoreError, ClassLoader cl) { boolean res = true; @@ -143,13 +143,13 @@ public class JNILibLoaderBase { public static void enableLoading() { setLoadingAction(new DefaultAction()); } - + public static synchronized void setLoadingAction(LoaderAction action) { loaderAction = action; } /** - * + * * @param classFromJavaJar * @param classJarURI * @param jarBasename jar basename w/ suffix @@ -170,16 +170,16 @@ public class JNILibLoaderBase { if(TempJarCache.isInitialized()) { final URI jarSubURI = JarUtil.getJarSubURI( classJarURI ); if(null == jarSubURI) { - throw new IllegalArgumentException("JarSubURI is null of: "+classJarURI); + throw new IllegalArgumentException("JarSubURI is null of: "+classJarURI); } final String jarUriRoot_s = IOUtil.getURIDirname( jarSubURI.toString() ); msg.append("[ ").append(jarSubURI.toString()).append(" -> ").append(jarUriRoot_s).append(" ] + "); - + final String nativeLibraryPath = "natives/"+PlatformPropsImpl.os_and_arch+"/"; final ClassLoader cl = classFromJavaJar.getClassLoader(); final URL nativeLibraryURI = cl.getResource(nativeLibraryPath); if( null != nativeLibraryURI ) { - // We probably have one big-fat jar file, containing java classes + // We probably have one big-fat jar file, containing java classes // and all native platform libraries under 'natives/os.and.arch'! final URI nativeJarURI = JarUtil.getJarFileURI(jarUriRoot_s+jarBasename); if( TempJarCache.addNativeLibs(classFromJavaJar, nativeJarURI, nativeLibraryPath) ) { @@ -188,7 +188,7 @@ public class JNILibLoaderBase { } } if( !ok ) { - // We assume one slim native jar file per 'os.and.arch'! + // We assume one slim native jar file per 'os.and.arch'! final URI nativeJarURI = JarUtil.getJarFileURI(jarUriRoot_s+nativeJarBasename); msg.append(nativeJarBasename).append(" -> slim: ").append(nativeJarURI); ok = TempJarCache.addNativeLibs(classFromJavaJar, nativeJarURI, null /* nativeLibraryPath */); @@ -201,22 +201,22 @@ public class JNILibLoaderBase { } return ok; } - + /** * Loads and adds a JAR file's native library to the TempJarCache.<br> * The native library JAR file's URI is derived as follows: * <ul> - * <li> [1] <code>GLProfile.class</code> -> </li> + * <li> [1] <code>GLProfile.class</code> -> </li> * <li> [2] <code>http://lala/</code> -> </li> * <li> [4] <code>http://lala/'nativeJarBaseName'-'os.and.arch'.jar</code> </li> - * </ul> + * </ul> * Where: * <ul> * <li> [1] is the <code>classFromJavaJar</code></li> * <li> [2] is it's <i>URI path</i></li> * <li> [4] is the derived native JAR filename</li> * </ul> - * + * * @param classFromJavaJar GLProfile * @param nativeJarBasename jogl-all * @return true if the native JAR file loaded successful or were loaded already, false in case of an error @@ -234,15 +234,15 @@ public class JNILibLoaderBase { if(DEBUG) { e0.printStackTrace(); } - } + } } else if(DEBUG) { System.err.println("JNILibLoaderBase: addNativeJarLibs1: disabled due to uninitialized TempJarCache"); } return false; } - + /** - * Loads and adds a JAR file's native library to the TempJarCache, + * Loads and adds a JAR file's native library to the TempJarCache, * calling {@link JNILibLoaderBase#addNativeJarLibs(Class[], String, String[])} * with default JOGL deployment configuration: * <pre> @@ -258,7 +258,7 @@ public class JNILibLoaderBase { * <li><i>ClassJar1</i>[-noawt,-mobile,-core,-android]?.jar to <i>ClassJar1</i>-natives-<i>os.and.arch</i>.jar</li> * <li><i>ClassJar2</i>[-noawt,-mobile,-core,-android]?.jar to <i>ClassJar2</i>-natives-<i>os.and.arch</i>.jar</li> * <li>..</li> - * </ul> + * </ul> */ public static final boolean addNativeJarLibsJoglCfg(final Class<?>[] classesFromJavaJars) { return addNativeJarLibs(classesFromJavaJars, "-all", joglDeployCfg); @@ -269,11 +269,11 @@ public class JNILibLoaderBase { * Loads and adds a JAR file's native library to the TempJarCache.<br> * The native library JAR file's URI is derived as follows: * <ul> - * <li> [1] <code>GLProfile.class</code> -> </li> + * <li> [1] <code>GLProfile.class</code> -> </li> * <li> [2] <code>http://lala/gluegen-rt.jar</code> -> </li> * <li> [3] <code>http://lala/gluegen-rt</code> -> </li> * <li> [4] <code>http://lala/gluegen-rt-natives-'os.and.arch'.jar</code> </li> - * </ul> + * </ul> * Where: * <ul> * <li> [1] is one of <code>classesFromJavaJars</code></li> @@ -294,11 +294,11 @@ public class JNILibLoaderBase { * <ul> * <li><i>ClassJar-all</i>[-suff1,-suff2]?.jar to <i>ClassJar-all</i>-natives-<i>os.and.arch</i>.jar</li> * </ul> - * Otherwise the native JAR files will be resolved for each class's JAR file: - * <ul> + * Otherwise the native JAR files will be resolved for each class's JAR file: + * <ul> * <li><i>Class1Jar</i>[-suff1,-suff2]?.jar to <i>Class1Jar</i>-natives-<i>os.and.arch</i>.jar</li> * <li><i>Class2Jar</i>[-suff1,-suff2]?.jar to <i>Class2Jar</i>-natives-<i>os.and.arch</i>.jar</li> - * </ul> + * </ul> * </p> * <p> * Examples: @@ -309,7 +309,7 @@ public class JNILibLoaderBase { // only: jocl.jar -> jocl-natives-<i>os.and.arch</i>.jar addNativeJarLibs(new Class<?>[] { JOCLJNILibLoader.class }, null, null ); * </pre> - * + * * Newt Only: * <pre> // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar, jogl-all-android.jar] -> jogl-all-natives-<i>os.and.arch</i>.jar @@ -334,12 +334,12 @@ public class JNILibLoaderBase { JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core", "-android" } ); * </pre> * </p> - * + * * @param classesFromJavaJars For each given Class, load the native library JAR. * @param singleJarMarker Optional string marker like "-all" to identify the single 'all-in-one' JAR file * after which processing of the class array shall stop. * @param stripBasenameSuffixes Optional substrings to be stripped of the <i>base URI</i> - * + * * @return true if either the 'all-in-one' native JAR or all native JARs loaded successful or were loaded already, * false in case of an error */ @@ -351,7 +351,7 @@ public class JNILibLoaderBase { if(TempJarCache.isInitialized()) { final StringBuilder msg = new StringBuilder(); int count = 0; - try { + try { boolean done = false; ok = true; for(int i=0; !done && ok && i<classesFromJavaJars.length && null!=classesFromJavaJars[i]; i++) { @@ -386,7 +386,7 @@ public class JNILibLoaderBase { } return ok; } - + private static final String stripName(String name, String[] suffixes) { if(null != suffixes) { for(int i=0; i<suffixes.length && null != suffixes[i]; i++) { @@ -398,34 +398,34 @@ public class JNILibLoaderBase { } return name; } - + /** * Loads the library specified by libname, using the {@link LoaderAction} set by {@link #setLoadingAction(LoaderAction)}.<br> * The implementation should ignore, if the library has been loaded already.<br> * @param libname the library to load - * @param ignoreError if true, errors during loading the library should be ignored + * @param ignoreError if true, errors during loading the library should be ignored * @param cl optional ClassLoader, used to locate the library * @return true if library loaded successful */ protected static synchronized boolean loadLibrary(String libname, boolean ignoreError, ClassLoader cl) { if (loaderAction != null) { - return loaderAction.loadLibrary(libname, ignoreError, cl); + return loaderAction.loadLibrary(libname, ignoreError, cl); } return false; } - + /** * Loads the library specified by libname, using the {@link LoaderAction} set by {@link #setLoadingAction(LoaderAction)}.<br> * Optionally preloads the libraries specified by preload.<br> * The implementation should ignore, if any library has been loaded already.<br> * @param libname the library to load * @param preload the libraries to load before loading the main library if not null - * @param preloadIgnoreError if true, errors during loading the preload-libraries should be ignored + * @param preloadIgnoreError if true, errors during loading the preload-libraries should be ignored * @param cl optional ClassLoader, used to locate the library */ protected static synchronized void loadLibrary(String libname, String[] preload, boolean preloadIgnoreError, ClassLoader cl) { if (loaderAction != null) { - loaderAction.loadLibrary(libname, preload, preloadIgnoreError, cl); + loaderAction.loadLibrary(libname, preload, preloadIgnoreError, cl); } } @@ -435,20 +435,20 @@ public class JNILibLoaderBase { static { final String sunAppletLauncherProperty = "sun.jnlp.applet.launcher"; final String sunAppletLauncherClassName = "org.jdesktop.applet.util.JNLPAppletLauncher"; - + final Method loadLibraryMethod = AccessController.doPrivileged(new PrivilegedAction<Method>() { public Method run() { // FIXME: remove - final boolean usingJNLPAppletLauncher = Debug.getBooleanProperty(sunAppletLauncherProperty, true); - + final boolean usingJNLPAppletLauncher = Debug.getBooleanProperty(sunAppletLauncherProperty, true); + Class<?> launcherClass = null; Method loadLibraryMethod = null; - + if (usingJNLPAppletLauncher) { try { launcherClass = Class.forName(sunAppletLauncherClassName); } catch (ClassNotFoundException cnfe) { - // oops .. look like JNLPAppletLauncher doesn't exist, despite property + // oops .. look like JNLPAppletLauncher doesn't exist, despite property // this may happen if a previous applet was using JNLPAppletLauncher in the same JVM System.err.println("JNILibLoaderBase: <"+sunAppletLauncherClassName+"> not found, despite enabled property <"+sunAppletLauncherProperty+">, JNLPAppletLauncher was probably used before"); System.setProperty(sunAppletLauncherProperty, Boolean.FALSE.toString()); @@ -465,7 +465,7 @@ public class JNILibLoaderBase { launcherClass = null; } } - } + } if(null==launcherClass) { String launcherClassName = PropertyAccess.getProperty("jnlp.launcher.class", false); if(null!=launcherClassName) { @@ -490,7 +490,7 @@ public class JNILibLoaderBase { } private static void loadLibraryInternal(String libraryName, ClassLoader cl) { - // Note: special-casing JAWT which is built in to the JDK + // Note: special-casing JAWT which is built in to the JDK int mode = 0; // 1 - custom, 2 - System.load( TempJarCache ), 3 - System.loadLibrary( name ), 4 - System.load( enumLibNames ) if (null!=customLoadLibraryMethod && !libraryName.equals("jawt")) { // FIXME: remove diff --git a/src/java/com/jogamp/common/net/AssetURLConnection.java b/src/java/com/jogamp/common/net/AssetURLConnection.java index f2a5a01..4f2a412 100644 --- a/src/java/com/jogamp/common/net/AssetURLConnection.java +++ b/src/java/com/jogamp/common/net/AssetURLConnection.java @@ -6,31 +6,31 @@ import java.net.URL; /** * See base class {@link PiggybackURLConnection} for motivation. - * + * * <p> * <i>asset</i> resource location protocol connection. * </p> - * + * * <p> * See {@link AssetURLContext#resolve(String)} how resources are being resolved. * </p> * * <h3>Example:</h3> - * + * * Assuming the plain <i>asset entry</i> <b><code>test/lala.txt</code></b> is being resolved by * a class <code>test.LaLaTest</code>, ie. using the <i>asset aware</i> ClassLoader, - * one would use the following <i>asset</i> aware filesystem layout: - * + * one would use the following <i>asset</i> aware filesystem layout: + * * <pre> * test/LaLaTest.class * assets/test/lala.txt * </pre> - * - * The above maybe on a plain filesystem, or within a JAR or an APK file, + * + * The above maybe on a plain filesystem, or within a JAR or an APK file, * e.g. <code>jogamp.test.apk</code>. - * + * * The above would result in the following possible URLs - * reflecting the plain and resolved state of the <i>asset URL</i>: + * reflecting the plain and resolved state of the <i>asset URL</i>: * <pre> * 0 Entry test/lala.txt * 1 Plain asset:test/lala.txt @@ -38,16 +38,16 @@ import java.net.URL; * </pre> * * <p> - * The sub protocol URL of the resolved <i>asset</i> + * The sub protocol URL of the resolved <i>asset</i> * <pre> * 3 Sub-URL jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt * </pre> * can be retrieved using {@link #getSubProtocol()}. * </p> - * + * * In all above cases, the <i>asset entry</i> is <b><code>test/lala.txt</code></b>, * which can be retrieved via {@link #getEntryName()}. - * + * * <p> * <h3>General Implementation Notes:</h3> * An <i>asset</i> URL is resolved using {@link AssetURLContext#getClassLoader()}.{@link ClassLoader#getResource(String) getResource(String)}, @@ -56,43 +56,43 @@ import java.net.URL; * </p> * <p> * <h3>Warning:</h3> - * Since the <i>asset</i> protocol is currently not being implemented + * Since the <i>asset</i> protocol is currently not being implemented * on all platform with an appropriate ClassLoader, a user shall not create the <i>asset</i> URL manually.<br> * </p> - * + * * <h3>Android Implementation Notes:</h3> * <p> - * The Android ClassLoader {@link jogamp.android.launcher.AssetDexClassLoader} + * The Android ClassLoader {@link jogamp.android.launcher.AssetDexClassLoader} * resolves the resource as an <i>asset</i> URL in it's {@link ClassLoader#findResource(String)} implementation.</p> * <p> - * Currently we attach our <i>asset</i> {@link java.net.URLStreamHandlerFactory} + * Currently we attach our <i>asset</i> {@link java.net.URLStreamHandlerFactory} * to allow {@link java.net.URL} to handle <i>asset</i> URLs via our <i>asset</i> {@link java.net.URLStreamHandler} implementation. * </p> */ public class AssetURLConnection extends PiggybackURLConnection<AssetURLContext> { - + public AssetURLConnection(URL url, AssetURLContext implHelper) { super(url, implHelper); } - + @Override public String getEntryName() throws IOException { if(!connected) { throw new IOException("not connected"); } - + final String urlPath ; if(subConn instanceof JarURLConnection) { urlPath = ((JarURLConnection)subConn).getEntryName(); } else { urlPath = subConn.getURL().getPath(); } - + if(urlPath.startsWith(AssetURLContext.assets_folder)) { return urlPath.substring(AssetURLContext.assets_folder.length()); } else { return urlPath; } } - + } diff --git a/src/java/com/jogamp/common/net/AssetURLContext.java b/src/java/com/jogamp/common/net/AssetURLContext.java index 470530e..38691e8 100644 --- a/src/java/com/jogamp/common/net/AssetURLContext.java +++ b/src/java/com/jogamp/common/net/AssetURLContext.java @@ -17,14 +17,14 @@ import com.jogamp.common.util.IOUtil; */ public abstract class AssetURLContext implements PiggybackURLContext { private static final boolean DEBUG = IOUtil.DEBUG; - + /** The <i>asset URL</i> protocol name <code>asset</code> */ public static final String asset_protocol = "asset"; - + /** The <i>asset URL</i> protocol prefix <code>asset:</code> */ public static final String asset_protocol_prefix = "asset:"; - - /** + + /** * The <i>optional</i> <i>asset</i> folder name with ending slash <code>assets/</code>. * <p> * Note that the <i>asset</i> folder is not used on all platforms using the <i>asset</i> protocol @@ -41,11 +41,11 @@ public abstract class AssetURLContext implements PiggybackURLContext { } }; } - + public static AssetURLStreamHandler createHandler(final ClassLoader cl) { return new AssetURLStreamHandler(create(cl)); } - + /** * Create an <i>asset</i> URL, suitable even w/o the registered <i>asset</i> URLStreamHandler. * <p> @@ -62,7 +62,7 @@ public abstract class AssetURLContext implements PiggybackURLContext { public static URL createURL(String path, ClassLoader cl) throws MalformedURLException { return new URL(null, path.startsWith(asset_protocol_prefix) ? path : asset_protocol_prefix + path, createHandler(cl)); } - + /** * Create an <i>asset</i> URL, suitable only with the registered <i>asset</i> URLStreamHandler. * <p> @@ -78,20 +78,20 @@ public abstract class AssetURLContext implements PiggybackURLContext { public static URL createURL(String path) throws MalformedURLException { return new URL(path.startsWith(asset_protocol_prefix) ? path : asset_protocol_prefix + path); } - + /** - * Returns the <i>asset</i> handler previously set via {@link #registerHandler(ClassLoader)}, + * Returns the <i>asset</i> handler previously set via {@link #registerHandler(ClassLoader)}, * or null if none was set. */ public static URLStreamHandler getRegisteredHandler() { final GenericURLStreamHandlerFactory f = GenericURLStreamHandlerFactory.register(); return ( null != f ) ? f.getHandler(asset_protocol) : null; } - + /** - * Registers the generic URLStreamHandlerFactory via {@link GenericURLStreamHandlerFactory#register()} + * Registers the generic URLStreamHandlerFactory via {@link GenericURLStreamHandlerFactory#register()} * and if successful sets the <i>asset</i> <code>handler</code> for the given ClassLoader <code>cl</code>. - * + * * @return true if successful, otherwise false */ public static boolean registerHandler(ClassLoader cl) { @@ -103,11 +103,11 @@ public abstract class AssetURLContext implements PiggybackURLContext { return false; } } - - /** + + /** * Returns an <i>asset</i> aware ClassLoader. * <p> - * The ClassLoader is required to find the <i>asset</i> resource + * The ClassLoader is required to find the <i>asset</i> resource * via it's <code>URL findResource(String)</code> implementation. * </p> * <p> @@ -123,33 +123,33 @@ public abstract class AssetURLContext implements PiggybackURLContext { @Override public String getImplementedProtocol() { return asset_protocol; - } - + } + /** * {@inheritDoc} - * <p> + * <p> * This implementation attempts to resolve <code>path</code> in the following order: * <ol> * <li> as a valid URL: <code>new URL(path)</code>, use sub-protocol if <i>asset</i> URL</li> * <li> via ClassLoader: {@link #getClassLoader()}.{@link ClassLoader#getResource(String) getResource(path)}, use sub-protocol if <i>asset</i> URL </li> * <li> as a File: <code>new File(path).toURI().toURL()</code> * </ol> - * </p> + * </p> * <p> * In case of using the ClassLoader (2) <b>and</b> if running on Android, * the {@link #assets_folder} is being prepended to <code>path</code> if missing. - * </p> - **/ + * </p> + **/ @Override public URLConnection resolve(String path) throws IOException { return resolve(path, getClassLoader()); } - + public static URLConnection resolve(String path, ClassLoader cl) throws IOException { URL url = null; URLConnection conn = null; int type = -1; - + if(DEBUG) { System.err.println("AssetURLContext.resolve: <"+path+">"); } @@ -158,14 +158,14 @@ public abstract class AssetURLContext implements PiggybackURLContext { } catch (URISyntaxException uriEx) { throw new IOException(uriEx); } - + try { // lookup as valid sub-protocol url = new URL(path); conn = open(url); type = null != conn ? 1 : -1; } catch(MalformedURLException e1) { if(DEBUG) { System.err.println("ERR(0): "+e1.getMessage()); } } - + if(null == conn && null != cl) { // lookup via ClassLoader .. cleanup leading '/' String cpath = path; @@ -179,7 +179,7 @@ public abstract class AssetURLContext implements PiggybackURLContext { conn = open(url); type = null != conn ? 2 : -1; } - + if(null == conn) { // lookup as File try { @@ -191,7 +191,7 @@ public abstract class AssetURLContext implements PiggybackURLContext { } } catch (Throwable e) { if(DEBUG) { System.err.println("ERR(1): "+e.getMessage()); } } } - + if(DEBUG) { System.err.println("AssetURLContext.resolve: type "+type+": url <"+url+">, conn <"+conn+">, connURL <"+(null!=conn?conn.getURL():null)+">"); } @@ -200,7 +200,7 @@ public abstract class AssetURLContext implements PiggybackURLContext { } return conn; } - + private static URLConnection open(URL url) { if(null==url) { return null; @@ -209,8 +209,8 @@ public abstract class AssetURLContext implements PiggybackURLContext { final URLConnection c = url.openConnection(); c.connect(); // redundant return c; - } catch (IOException ioe) { if(DEBUG) { System.err.println("ERR: "+ioe.getMessage()); } } + } catch (IOException ioe) { if(DEBUG) { System.err.println("ERR: "+ioe.getMessage()); } } return null; } - + } diff --git a/src/java/com/jogamp/common/net/AssetURLStreamHandler.java b/src/java/com/jogamp/common/net/AssetURLStreamHandler.java index 8d95b2d..6760646 100644 --- a/src/java/com/jogamp/common/net/AssetURLStreamHandler.java +++ b/src/java/com/jogamp/common/net/AssetURLStreamHandler.java @@ -7,31 +7,31 @@ import java.net.URLStreamHandler; import com.jogamp.common.net.AssetURLConnection; -/** +/** * {@link URLStreamHandler} to handle the asset protocol. - * + * * <p> * This is the <i>asset</i> URLStreamHandler variation - * for manual use. + * for manual use. * </p> * <p> * It requires passing a valid {@link AssetURLContext} * for construction, hence it's not suitable for the pkg factory model. * </p> */ -public class AssetURLStreamHandler extends URLStreamHandler { +public class AssetURLStreamHandler extends URLStreamHandler { AssetURLContext ctx; - + public AssetURLStreamHandler(AssetURLContext ctx) { this.ctx = ctx; } - + @Override protected URLConnection openConnection(URL u) throws IOException { final AssetURLConnection c = new AssetURLConnection(u, ctx); c.connect(); return c; } - - + + } diff --git a/src/java/com/jogamp/common/net/GenericURLStreamHandlerFactory.java b/src/java/com/jogamp/common/net/GenericURLStreamHandlerFactory.java index 79d7f71..4ec3f19 100644 --- a/src/java/com/jogamp/common/net/GenericURLStreamHandlerFactory.java +++ b/src/java/com/jogamp/common/net/GenericURLStreamHandlerFactory.java @@ -10,30 +10,30 @@ import java.util.Map; public class GenericURLStreamHandlerFactory implements URLStreamHandlerFactory { private static GenericURLStreamHandlerFactory factory = null; - + private final Map<String, URLStreamHandler> protocolHandlers; private GenericURLStreamHandlerFactory() { protocolHandlers = new HashMap<String, URLStreamHandler>(); } - + /** * Sets the <code>handler</code> for <code>protocol</code>. - * + * * @return the previous set <code>handler</code>, or null if none was set. */ public synchronized final URLStreamHandler setHandler(String protocol, URLStreamHandler handler) { return protocolHandlers.put(protocol, handler); } - + /** - * Returns the <code>protocol</code> handler previously set via {@link #setHandler(String, URLStreamHandler)}, + * Returns the <code>protocol</code> handler previously set via {@link #setHandler(String, URLStreamHandler)}, * or null if none was set. */ public synchronized final URLStreamHandler getHandler(String protocol) { return protocolHandlers.get(protocol); } - + @Override public synchronized final URLStreamHandler createURLStreamHandler(String protocol) { return getHandler(protocol); diff --git a/src/java/com/jogamp/common/net/PiggybackURLConnection.java b/src/java/com/jogamp/common/net/PiggybackURLConnection.java index 39f1637..3b774e8 100644 --- a/src/java/com/jogamp/common/net/PiggybackURLConnection.java +++ b/src/java/com/jogamp/common/net/PiggybackURLConnection.java @@ -6,10 +6,10 @@ import java.net.URL; import java.net.URLConnection; /** - * Generic resource location protocol connection, + * Generic resource location protocol connection, * using another sub-protocol as the vehicle for a piggyback protocol. * <p> - * The details of the sub-protocol can be queried using {@link #getSubProtocol()}. + * The details of the sub-protocol can be queried using {@link #getSubProtocol()}. * </p> * <p> * See example in {@link AssetURLConnection}. @@ -19,7 +19,7 @@ public abstract class PiggybackURLConnection<I extends PiggybackURLContext> exte protected URL subUrl; protected URLConnection subConn; protected I context; - + /** * @param url the specific URL for this instance * @param context the piggyback context, defining state independent code and constants @@ -34,18 +34,18 @@ public abstract class PiggybackURLConnection<I extends PiggybackURLContext> exte * Resolves the URL via {@link PiggybackURLContext#resolve(String)}, * see {@link AssetURLContext#resolve(String)} for an example. * </p> - * + * * {@inheritDoc} */ @Override public synchronized void connect() throws IOException { if(!connected) { - subConn = context.resolve(url.getPath()); - subUrl = subConn.getURL(); + subConn = context.resolve(url.getPath()); + subUrl = subConn.getURL(); connected = true; } } - + @Override public InputStream getInputStream() throws IOException { if(!connected) { @@ -53,26 +53,26 @@ public abstract class PiggybackURLConnection<I extends PiggybackURLContext> exte } return subConn.getInputStream(); } - - /** + + /** * Returns the <i>entry name</i> of the asset. * <pre> * Plain asset:test/lala.txt * Resolved asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt * Result test/lala.txt - * </pre> + * </pre> * @throws IOException is not connected **/ public abstract String getEntryName() throws IOException; - - /** + + /** * Returns the resolved <i>sub protocol</i> of the asset or null, ie: * <pre> * Plain asset:test/lala.txt * Resolved asset:jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt * Result jar:file:/data/app/jogamp.test.apk!/assets/test/lala.txt * </pre> - * + * * @throws IOException is not connected */ public URL getSubProtocol() throws IOException { diff --git a/src/java/com/jogamp/common/net/PiggybackURLContext.java b/src/java/com/jogamp/common/net/PiggybackURLContext.java index 2cb48b5..9e3db69 100644 --- a/src/java/com/jogamp/common/net/PiggybackURLContext.java +++ b/src/java/com/jogamp/common/net/PiggybackURLContext.java @@ -8,11 +8,11 @@ import java.net.URLConnection; */ public interface PiggybackURLContext { - /** Returns the specific protocol, constant for this implementation. */ + /** Returns the specific protocol, constant for this implementation. */ public String getImplementedProtocol(); - - /** - * Resolving path to a URL sub protocol and return it's open URLConnection + + /** + * Resolving path to a URL sub protocol and return it's open URLConnection **/ - public URLConnection resolve(String path) throws IOException; + public URLConnection resolve(String path) throws IOException; } diff --git a/src/java/com/jogamp/common/net/asset/Handler.java b/src/java/com/jogamp/common/net/asset/Handler.java index 1063797..d622221 100644 --- a/src/java/com/jogamp/common/net/asset/Handler.java +++ b/src/java/com/jogamp/common/net/asset/Handler.java @@ -8,12 +8,12 @@ import java.net.URLStreamHandler; import com.jogamp.common.net.AssetURLConnection; import com.jogamp.common.net.AssetURLContext; -/** +/** * {@link URLStreamHandler} to handle the asset protocol. - * + * * <p> * This is the <i>asset</i> URLStreamHandler variation - * using this class ClassLoader for the pkg factory model. + * using this class ClassLoader for the pkg factory model. * </p> */ public class Handler extends URLStreamHandler { @@ -23,16 +23,16 @@ public class Handler extends URLStreamHandler { return Handler.class.getClassLoader(); } }; - + public Handler() { super(); } - + @Override protected URLConnection openConnection(URL u) throws IOException { final AssetURLConnection c = new AssetURLConnection(u, localCL); c.connect(); return c; } - + } diff --git a/src/java/com/jogamp/common/nio/AbstractBuffer.java b/src/java/com/jogamp/common/nio/AbstractBuffer.java index 4afff2a..4213a4d 100644 --- a/src/java/com/jogamp/common/nio/AbstractBuffer.java +++ b/src/java/com/jogamp/common/nio/AbstractBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /* * Created on Saturday, March 27 2010 11:55 */ @@ -51,7 +51,7 @@ public abstract class AbstractBuffer<B extends AbstractBuffer> implements Native Platform.initSingleton(); // loads native gluegen-rt library } - /** + /** * capacity and elementSize should be match the equation w/ target buffer type * <pre> * capacity = elementSizeInBytes(buffer) * buffer.capacity() ) / elementSize @@ -64,14 +64,14 @@ public abstract class AbstractBuffer<B extends AbstractBuffer> implements Native this.buffer = buffer; this.elementSize = elementSize; this.capacity = capacity; - + this.position = 0; } public final int elementSize() { return elementSize; } - + public final int limit() { return capacity; } @@ -113,7 +113,7 @@ public abstract class AbstractBuffer<B extends AbstractBuffer> implements Native public final boolean isDirect() { return buffer.isDirect(); } - + public final boolean hasArray() { return buffer.hasArray(); } @@ -129,7 +129,7 @@ public abstract class AbstractBuffer<B extends AbstractBuffer> implements Native public Object array() throws UnsupportedOperationException { return buffer.array(); } - + @Override public String toString() { return "AbstractBuffer[direct "+isDirect()+", hasArray "+hasArray()+", capacity "+capacity+", position "+position+", elementSize "+elementSize+", buffer[capacity "+buffer.capacity()+", lim "+buffer.limit()+", pos "+buffer.position()+"]]"; diff --git a/src/java/com/jogamp/common/nio/Buffers.java b/src/java/com/jogamp/common/nio/Buffers.java index 851aa69..c63a094 100644 --- a/src/java/com/jogamp/common/nio/Buffers.java +++ b/src/java/com/jogamp/common/nio/Buffers.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * 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. */ @@ -47,7 +47,7 @@ import com.jogamp.common.util.ValueConv; /** * Utility methods allowing easy {@link java.nio.Buffer} manipulations. - * + * * @author Kenneth Russel * @author Sven Gothel * @author Michael Bien @@ -213,7 +213,7 @@ public class Buffers { /** * Calls slice on the specified buffer while maintaining the byteorder. - * @see #slice(java.nio.Buffer, int, int) + * @see #slice(java.nio.Buffer, int, int) */ @SuppressWarnings("unchecked") public static <B extends Buffer> B slice(B buffer) { @@ -264,22 +264,22 @@ public class Buffers { * The returned sliced buffer's start position is not necessarily zero, * but the float position within the host ByteBuffer. * </p> - * <p> + * <p> * The returned sliced buffer is {@link FloatBuffer#mark() marked} at it's starting position. Hence - * {@link FloatBuffer#reset()} will rewind it to start after applying relative operations like {@link FloatBuffer#get()}. + * {@link FloatBuffer#reset()} will rewind it to start after applying relative operations like {@link FloatBuffer#get()}. * </p> - * <p> - * Using a ByteBuffer as the source guarantees - * keeping the source native order programmatically. - * This works around <a href="http://code.google.com/p/android/issues/detail?id=16434">Honeycomb / Android 3.0 Issue 16434</a>. + * <p> + * Using a ByteBuffer as the source guarantees + * keeping the source native order programmatically. + * This works around <a href="http://code.google.com/p/android/issues/detail?id=16434">Honeycomb / Android 3.0 Issue 16434</a>. * This bug is resolved at least in Android 3.2. * </p> - * - * @param buf source Buffer, maybe ByteBuffer (recommended) or FloatBuffer or <code>null</code>. + * + * @param buf source Buffer, maybe ByteBuffer (recommended) or FloatBuffer or <code>null</code>. * Buffer's position is ignored and floatPos is being used. * @param backing source float array or <code>null</code> * @param floatPos {@link Buffers#SIZEOF_FLOAT} position - * @param floatSize {@link Buffers#SIZEOF_FLOAT} size + * @param floatSize {@link Buffers#SIZEOF_FLOAT} size * @return FloatBuffer w/ native byte order as given ByteBuffer */ public static final FloatBuffer slice2Float(Buffer buf, float[] backing, int floatPos, int floatSize) { @@ -318,7 +318,7 @@ public class Buffers { return res; } - + /** * Helper routine to set a ByteBuffer to the native byte order, if * that operation is supported by the underlying NIO @@ -329,7 +329,7 @@ public class Buffers { } /** - * Returns the size of a single element of the given buffer in bytes + * Returns the size of a single element of the given buffer in bytes * or <code>0</code> if the given buffer is <code>null</code>. */ public static int sizeOfBufferElem(Object buffer) { @@ -358,7 +358,7 @@ public class Buffers { /** * Returns the number of remaining elements of the given anonymous <code>buffer</code>. - * + * * @param buffer Anonymous <i>Buffer</i> of type {@link NativeBuffer} or a derivation of {@link Buffer}. * @return If <code>buffer</code> is null, returns <code>0<code>, otherwise the remaining size in elements. * @throws IllegalArgumentException if <code>buffer</code> is of invalid type. @@ -375,10 +375,10 @@ public class Buffers { throw new IllegalArgumentException("Unsupported anonymous buffer type: "+buffer.getClass().getCanonicalName()); } } - + /** * Returns the number of remaining bytes of the given anonymous <code>buffer</code>. - * + * * @param buffer Anonymous <i>Buffer</i> of type {@link NativeBuffer} or a derivation of {@link Buffer}. * @return If <code>buffer</code> is null, returns <code>0<code>, otherwise the remaining size in bytes. * @throws IllegalArgumentException if <code>buffer</code> is of invalid type. @@ -434,11 +434,11 @@ public class Buffers { if (buf instanceof ByteBuffer) { return ((ByteBuffer) buf).isDirect(); } else if (buf instanceof IntBuffer) { - return ((IntBuffer) buf).isDirect(); + return ((IntBuffer) buf).isDirect(); } else if (buf instanceof ShortBuffer) { - return ((ShortBuffer) buf).isDirect(); + return ((ShortBuffer) buf).isDirect(); } else if (buf instanceof FloatBuffer) { - return ((FloatBuffer) buf).isDirect(); + return ((FloatBuffer) buf).isDirect(); } else if (buf instanceof DoubleBuffer) { return ((DoubleBuffer) buf).isDirect(); } else if (buf instanceof LongBuffer) { @@ -490,7 +490,7 @@ public class Buffers { * Helper routine to return the array backing store reference from * a Buffer object. * @throws UnsupportedOperationException if the passed Object does not have an array backing store - * @throws IllegalArgumentException if the passed Object is neither of type {@link java.nio.Buffer} or {@link NativeBuffer}. + * @throws IllegalArgumentException if the passed Object is neither of type {@link java.nio.Buffer} or {@link NativeBuffer}. */ public static Object getArray(Object buf) throws UnsupportedOperationException, IllegalArgumentException { if (buf == null) { @@ -557,7 +557,7 @@ public class Buffers { ByteBuffer dest = newDirectByteBuffer(orig.remaining()); dest.put(orig); dest.rewind(); - orig.position(op0); + orig.position(op0); return dest; } @@ -752,8 +752,8 @@ public class Buffers { //---------------------------------------------------------------------- // Convenient put methods with generic target Buffer w/o value range conversion, i.e. normalization - // - + // + @SuppressWarnings("unchecked") public static <B extends Buffer> B put(B dest, Buffer src) { if ((dest instanceof ByteBuffer) && (src instanceof ByteBuffer)) { @@ -841,7 +841,7 @@ public class Buffers { throw new IllegalArgumentException("Float doesn't match Buffer Class: " + dest); } } - + @SuppressWarnings("unchecked") public static <B extends Buffer> B putd(B dest, double v) { if (dest instanceof FloatBuffer) { @@ -855,15 +855,15 @@ public class Buffers { // Convenient put methods with generic target Buffer and value range conversion, i.e. normalization // - /** + /** * Store byte source value in given buffer after normalizing it to the destination value range * considering signed and unsigned source and destination representation. - * + * * @param dest One of {@link ByteBuffer}, {@link ShortBuffer}, {@link IntBuffer}, {@link FloatBuffer} * @param dSigned true if destination buffer holds signed values, false if destination buffer holds unsigned values * @param v source byte value to be put in dest buffer * @param sSigned true if source represents a signed value, false if source represents an unsigned value - */ + */ @SuppressWarnings("unchecked") public static <B extends Buffer> B putNb(B dest, boolean dSigned, byte v, boolean sSigned) { if (dest instanceof ByteBuffer) { @@ -872,22 +872,22 @@ public class Buffers { return (B) ((ShortBuffer) dest).put( ValueConv.byte_to_short(v, sSigned, dSigned) ); } else if (dest instanceof IntBuffer) { return (B) ((IntBuffer) dest).put( ValueConv.byte_to_int(v, sSigned, dSigned) ); - } else if (dest instanceof FloatBuffer) { + } else if (dest instanceof FloatBuffer) { return (B) ((FloatBuffer) dest).put( ValueConv.byte_to_float(v, sSigned) ); } else { throw new IllegalArgumentException("Byte doesn't match Buffer Class: " + dest); } } - /** + /** * Store short source value in given buffer after normalizing it to the destination value range * considering signed and unsigned source and destination representation. - * + * * @param dest One of {@link ByteBuffer}, {@link ShortBuffer}, {@link IntBuffer}, {@link FloatBuffer} * @param dSigned true if destination buffer holds signed values, false if destination buffer holds unsigned values * @param v source short value to be put in dest buffer * @param sSigned true if source represents a signed value, false if source represents an unsigned value - */ + */ @SuppressWarnings("unchecked") public static <B extends Buffer> B putNs(B dest, boolean dSigned, short v, boolean sSigned) { if (dest instanceof ByteBuffer) { @@ -896,22 +896,22 @@ public class Buffers { return (B) ((ShortBuffer) dest).put( v ); } else if (dest instanceof IntBuffer) { return (B) ((IntBuffer) dest).put( ValueConv.short_to_int(v, sSigned, dSigned) ); - } else if (dest instanceof FloatBuffer) { + } else if (dest instanceof FloatBuffer) { return (B) ((FloatBuffer) dest).put( ValueConv.short_to_float(v, sSigned) ); } else { throw new IllegalArgumentException("Byte doesn't match Buffer Class: " + dest); } } - - /** + + /** * Store short source value in given buffer after normalizing it to the destination value range * considering signed and unsigned source and destination representation. - * + * * @param dest One of {@link ByteBuffer}, {@link ShortBuffer}, {@link IntBuffer}, {@link FloatBuffer} * @param dSigned true if destination buffer holds signed values, false if destination buffer holds unsigned values * @param v source short value to be put in dest buffer * @param sSigned true if source represents a signed value, false if source represents an unsigned value - */ + */ @SuppressWarnings("unchecked") public static <B extends Buffer> B putNi(B dest, boolean dSigned, int v, boolean sSigned) { if (dest instanceof ByteBuffer) { @@ -920,21 +920,21 @@ public class Buffers { return (B) ((ShortBuffer) dest).put( ValueConv.int_to_short(v, sSigned, dSigned) ); } else if (dest instanceof IntBuffer) { return (B) ((IntBuffer) dest).put( v ); - } else if (dest instanceof FloatBuffer) { + } else if (dest instanceof FloatBuffer) { return (B) ((FloatBuffer) dest).put( ValueConv.int_to_float(v, sSigned) ); } else { throw new IllegalArgumentException("Byte doesn't match Buffer Class: " + dest); } } - - /** + + /** * Store float source value in given buffer after normalizing it to the destination value range * considering signed and unsigned destination representation. - * + * * @param dest One of {@link ByteBuffer}, {@link ShortBuffer}, {@link IntBuffer}, {@link FloatBuffer} * @param dSigned true if destination buffer holds signed values, false if destination buffer holds unsigned values * @param v source float value to be put in dest buffer - */ + */ @SuppressWarnings("unchecked") public static <B extends Buffer> B putNf(B dest, boolean dSigned, float v) { if (dest instanceof ByteBuffer) { @@ -943,17 +943,17 @@ public class Buffers { return (B) ((ShortBuffer) dest).put( ValueConv.float_to_short(v, dSigned) ); } else if (dest instanceof IntBuffer) { return (B) ((IntBuffer) dest).put( ValueConv.float_to_int(v, dSigned) ); - } else if (dest instanceof FloatBuffer) { + } else if (dest instanceof FloatBuffer) { return (B) ((FloatBuffer) dest).put( v ); } else { throw new IllegalArgumentException("Byte doesn't match Buffer Class: " + dest); } } - + //---------------------------------------------------------------------- - // Range check methods + // Range check methods // - + public static void rangeCheck(byte[] array, int offset, int minElementsRemaining) { if (array == null) { return; @@ -1049,13 +1049,13 @@ public class Buffers { throw new IndexOutOfBoundsException("Required " + minBytesRemaining + " remaining bytes in buffer, only had " + bytesRemaining); } } - + /** * Appends Buffer details inclusive data to a StringBuilder instance. * @param sb optional pass through StringBuilder - * @param f optional format string of one element, i.e. "%10.5f" for {@link FloatBuffer}, see {@link java.util.Formatter}, - * or <code>null</code> for unformatted output. - * <b>Note:</b> Caller is responsible to match the format string w/ the data type as expected in the given buffer. + * @param f optional format string of one element, i.e. "%10.5f" for {@link FloatBuffer}, see {@link java.util.Formatter}, + * or <code>null</code> for unformatted output. + * <b>Note:</b> Caller is responsible to match the format string w/ the data type as expected in the given buffer. * @param buffer Any valid Buffer instance * @return the modified StringBuilder containing the Buffer details */ @@ -1073,74 +1073,74 @@ public class Buffers { for(int i=0; i<b.limit(); i++) { if(0<i) { sb.append(", "); } if(null == f) { - sb.append(b.get(i)); + sb.append(b.get(i)); } else { - sb.append(String.format(f, b.get(i))); - } + sb.append(String.format(f, b.get(i))); + } } } else if (buffer instanceof FloatBuffer) { final FloatBuffer b = (FloatBuffer)buffer; for(int i=0; i<b.limit(); i++) { if(0<i) { sb.append(", "); } if(null == f) { - sb.append(b.get(i)); + sb.append(b.get(i)); } else { - sb.append(String.format(f, b.get(i))); - } + sb.append(String.format(f, b.get(i))); + } } } else if (buffer instanceof IntBuffer) { final IntBuffer b = (IntBuffer)buffer; for(int i=0; i<b.limit(); i++) { if(0<i) { sb.append(", "); } if(null == f) { - sb.append(b.get(i)); + sb.append(b.get(i)); } else { - sb.append(String.format(f, b.get(i))); - } + sb.append(String.format(f, b.get(i))); + } } } else if (buffer instanceof ShortBuffer) { final ShortBuffer b = (ShortBuffer)buffer; for(int i=0; i<b.limit(); i++) { if(0<i) { sb.append(", "); } if(null == f) { - sb.append(b.get(i)); + sb.append(b.get(i)); } else { - sb.append(String.format(f, b.get(i))); - } + sb.append(String.format(f, b.get(i))); + } } } else if (buffer instanceof DoubleBuffer) { final DoubleBuffer b = (DoubleBuffer)buffer; for(int i=0; i<b.limit(); i++) { if(0<i) { sb.append(", "); } if(null == f) { - sb.append(b.get(i)); + sb.append(b.get(i)); } else { - sb.append(String.format(f, b.get(i))); - } + sb.append(String.format(f, b.get(i))); + } } } else if (buffer instanceof LongBuffer) { final LongBuffer b = (LongBuffer)buffer; for(int i=0; i<b.limit(); i++) { if(0<i) { sb.append(", "); } if(null == f) { - sb.append(b.get(i)); + sb.append(b.get(i)); } else { - sb.append(String.format(f, b.get(i))); - } + sb.append(String.format(f, b.get(i))); + } } } else if (buffer instanceof CharBuffer) { final CharBuffer b = (CharBuffer)buffer; for(int i=0; i<b.limit(); i++) { if(0<i) { sb.append(", "); } if(null == f) { - sb.append(b.get(i)); + sb.append(b.get(i)); } else { - sb.append(String.format(f, b.get(i))); - } + sb.append(String.format(f, b.get(i))); + } } } sb.append("]"); return sb; } - + } diff --git a/src/java/com/jogamp/common/nio/CachedBufferFactory.java b/src/java/com/jogamp/common/nio/CachedBufferFactory.java index b9d75db..6ddff4a 100644 --- a/src/java/com/jogamp/common/nio/CachedBufferFactory.java +++ b/src/java/com/jogamp/common/nio/CachedBufferFactory.java @@ -4,14 +4,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -21,7 +21,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -58,7 +58,7 @@ import java.nio.ShortBuffer; * <li>factories created with createSynchronized(...) are threadsafe</li> * </ul> * </p> - * + * * @author Michael Bien */ public class CachedBufferFactory { @@ -67,20 +67,20 @@ public class CachedBufferFactory { * default size for internal buffer allocation. */ public static final int DEFAULT_ALLOCATION_SIZE = 1024 * 1024; - + private final int ALLOCATION_SIZE; private ByteBuffer currentBuffer; - + private CachedBufferFactory() { this(DEFAULT_ALLOCATION_SIZE, DEFAULT_ALLOCATION_SIZE); } - + private CachedBufferFactory(int initialSize, int allocationSize) { currentBuffer = Buffers.newDirectByteBuffer(initialSize); ALLOCATION_SIZE = allocationSize; } - - + + /** * Creates a factory with initial size and allocation size set to * {@link #DEFAULT_ALLOCATION_SIZE}. @@ -88,7 +88,7 @@ public class CachedBufferFactory { public static CachedBufferFactory create() { return new CachedBufferFactory(); } - + /** * Creates a factory with the specified initial size. The allocation size is set to * {@link #DEFAULT_ALLOCATION_SIZE}. @@ -96,7 +96,7 @@ public class CachedBufferFactory { public static CachedBufferFactory create(int initialSize) { return new CachedBufferFactory(initialSize, DEFAULT_ALLOCATION_SIZE); } - + /** * Creates a factory with the specified initial size. The allocation size is set to * {@link #DEFAULT_ALLOCATION_SIZE}. @@ -106,43 +106,43 @@ public class CachedBufferFactory { public static CachedBufferFactory create(int initialSize, boolean fixed) { return new CachedBufferFactory(initialSize, fixed?-1:DEFAULT_ALLOCATION_SIZE); } - + /** * Creates a factory with the specified initial size and allocation size. */ public static CachedBufferFactory create(int initialSize, int allocationSize) { return new CachedBufferFactory(initialSize, allocationSize); } - - + + /** * Synchronized version of {@link #create()}. */ public static CachedBufferFactory createSynchronized() { return new SynchronizedCachedBufferFactory(); } - + /** * Synchronized version of {@link #create(int)}. */ public static CachedBufferFactory createSynchronized(int initialSize) { return new SynchronizedCachedBufferFactory(initialSize, DEFAULT_ALLOCATION_SIZE); } - + /** * Synchronized version of {@link #create(int, boolean)}. */ public static CachedBufferFactory createSynchronized(int initialSize, boolean fixed) { return new SynchronizedCachedBufferFactory(initialSize, fixed?-1:DEFAULT_ALLOCATION_SIZE); } - + /** * Synchronized version of {@link #create(int, int)}. */ public static CachedBufferFactory createSynchronized(int initialSize, int allocationSize) { return new CachedBufferFactory(initialSize, allocationSize); } - + /** * Returns true only if this factory does not allow to allocate more buffers * as limited by the initial size. @@ -150,7 +150,7 @@ public class CachedBufferFactory { public boolean isFixed() { return ALLOCATION_SIZE == -1; } - + /** * Returns the allocation size used to create new internal buffers. * 0 means that the buffer will not grows, see {@link #isFixed()}. @@ -158,7 +158,7 @@ public class CachedBufferFactory { public int getAllocationSize() { return ALLOCATION_SIZE; } - + /** * @return true if buffer cannot grow, otherwise false */ @@ -175,7 +175,7 @@ public class CachedBufferFactory { } } public ByteBuffer newDirectByteBuffer(int size) { - + // if large enough... just create it if (size > currentBuffer.capacity()) { checkIfFixed(); @@ -194,7 +194,7 @@ public class CachedBufferFactory { currentBuffer.limit(currentBuffer.capacity()); return result; } - + public ByteBuffer newDirectByteBuffer(byte[] values, int offset, int lenght) { return (ByteBuffer)newDirectByteBuffer(lenght).put(values, offset, lenght).rewind(); @@ -326,8 +326,8 @@ public class CachedBufferFactory { public String toString() { return getClass().getName()+"[static:"+isFixed()+" alloc size:"+getAllocationSize()+"]"; } - - + + // nothing special, just synchronized private static class SynchronizedCachedBufferFactory extends CachedBufferFactory { @@ -338,12 +338,12 @@ public class CachedBufferFactory { private SynchronizedCachedBufferFactory(int size, int step) { super(size, step); } - + @Override public synchronized ByteBuffer newDirectByteBuffer(int size) { return super.newDirectByteBuffer(size); } - + } } diff --git a/src/java/com/jogamp/common/nio/NativeBuffer.java b/src/java/com/jogamp/common/nio/NativeBuffer.java index 0273976..d81da9d 100644 --- a/src/java/com/jogamp/common/nio/NativeBuffer.java +++ b/src/java/com/jogamp/common/nio/NativeBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /* * Created on Tuesday, March 30 2010 18:22 */ @@ -43,7 +43,7 @@ import java.nio.Buffer; public interface NativeBuffer<B extends NativeBuffer> { public int elementSize(); - + public int limit(); public int capacity(); @@ -66,8 +66,8 @@ public interface NativeBuffer<B extends NativeBuffer> { * otherwise 0. */ public int arrayOffset(); - - /** + + /** * @return the primitive backup array of the buffer if {@link #hasArray()} is true, * otherwise it throws {@link java.lang.UnsupportedOperationException}. * The returned primitive array maybe of type <code>int[]</code> or <code>long[]</code>, etc .. diff --git a/src/java/com/jogamp/common/nio/PointerBuffer.java b/src/java/com/jogamp/common/nio/PointerBuffer.java index df1c4b1..4a479f0 100644 --- a/src/java/com/jogamp/common/nio/PointerBuffer.java +++ b/src/java/com/jogamp/common/nio/PointerBuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -60,22 +60,22 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> { static PointerBuffer create(ByteBuffer bb) { return Platform.is32Bit() ? new PointerBuffer( bb.asIntBuffer() ) : new PointerBuffer( bb.asLongBuffer() ); } - + /** supports backup array */ PointerBuffer(IntBuffer b) { super(b, ELEMENT_SIZE, b.capacity()); } - + /** supports backup array */ PointerBuffer(LongBuffer b) { super(b, ELEMENT_SIZE, b.capacity()); } - + private final void validateDataMap() { if(null == dataMap) { dataMap = new LongObjectHashMap(); - dataMap.setKeyNotFoundValue(null); - } + dataMap.setKeyNotFoundValue(null); + } } /** Returns a non direct PointerBuffer in native order, having a backup array */ @@ -84,7 +84,7 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> { return new PointerBuffer(IntBuffer.wrap(new int[size])); } else { return new PointerBuffer(LongBuffer.wrap(new long[size])); - } + } } /** Returns a direct PointerBuffer in native order, w/o backup array */ @@ -113,9 +113,9 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> { npb.position = position; return npb; } - - /** - * Relative bulk get method. Copy the source values <code> src[position .. capacity] [</code> + + /** + * Relative bulk get method. Copy the source values <code> src[position .. capacity] [</code> * to this buffer and increment the position by <code>capacity-position</code>. */ public final PointerBuffer put(PointerBuffer src) { if (remaining() < src.remaining()) { @@ -145,7 +145,7 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> { } return this; } - + /** Relative get method. Get the pointer value at the current position and increment the position by one. */ public final long get() { long r = get(position); @@ -164,9 +164,9 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> { return ((LongBuffer) buffer).get(idx); } } - - /** - * Relative bulk get method. Copy the pointer values <code> [ position .. position+length [</code> + + /** + * Relative bulk get method. Copy the pointer values <code> [ position .. position+length [</code> * to the destination array <code> [ dest[offset] .. dest[offset+length] [ </code> * and increment the position by <code>length</code>. */ public final PointerBuffer get(long[] dest, int offset, int length) { @@ -203,8 +203,8 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> { return this; } - /** - * Relative bulk put method. Put the pointer values <code> [ src[offset] .. src[offset+length] [</code> + /** + * Relative bulk put method. Put the pointer values <code> [ src[offset] .. src[offset+length] [</code> * at the current position and increment the position by <code>length</code>. */ public final PointerBuffer put(long[] src, int offset, int length) { if (src.length<offset+length) { @@ -223,8 +223,8 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> { /** Put the address of the given direct Buffer at the given position of this pointer array. Adding a reference of the given direct Buffer to this object. - - @throws IllegalArgumentException if bb is null or not a direct buffer + + @throws IllegalArgumentException if bb is null or not a direct buffer */ public final PointerBuffer referenceBuffer(int index, Buffer bb) { if(null==bb) { @@ -239,7 +239,7 @@ public class PointerBuffer extends AbstractBuffer<PointerBuffer> { throw new RuntimeException("Couldn't determine native address of given Buffer: "+bb); } validateDataMap(); - put(index, bbAddr); + put(index, bbAddr); dataMap.put(bbAddr, bb); return this; } diff --git a/src/java/com/jogamp/common/nio/StructAccessor.java b/src/java/com/jogamp/common/nio/StructAccessor.java index eef9dc5..d6df083 100644 --- a/src/java/com/jogamp/common/nio/StructAccessor.java +++ b/src/java/com/jogamp/common/nio/StructAccessor.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * 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. */ @@ -58,7 +58,7 @@ public class StructAccessor { return bb; } - /** + /** * Returns a slice of the current ByteBuffer starting at the * specified byte offset and extending the specified number of * bytes. Note that this method is not thread-safe with respect to @@ -116,11 +116,11 @@ public class StructAccessor { /** Retrieves the int at the specified byteOffset. */ public final int getIntAt(int byteOffset, int nativeSizeInBytes) { switch(nativeSizeInBytes) { - case 2: + case 2: return (int) bb.getShort(byteOffset) & 0x0000FFFF ; - case 4: + case 4: return bb.getInt(byteOffset); - case 8: + case 8: return (int) ( bb.getLong(byteOffset) & 0x00000000FFFFFFFFL ) ; default: throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes); @@ -130,20 +130,20 @@ public class StructAccessor { /** Puts a int at the specified byteOffset. */ public final void setIntAt(int byteOffset, int v, int nativeSizeInBytes) { switch(nativeSizeInBytes) { - case 2: + case 2: bb.putShort(byteOffset, (short) ( v & 0x0000FFFF ) ); break; - case 4: + case 4: bb.putInt(byteOffset, v); break; - case 8: + case 8: bb.putLong(byteOffset, (long)v & 0x00000000FFFFFFFFL ); break; default: throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes); } } - + /** Retrieves the float at the specified byteOffset. */ public final float getFloatAt(int byteOffset) { return bb.getFloat(byteOffset); @@ -173,13 +173,13 @@ public class StructAccessor { public final void setLongAt(int byteOffset, long v) { bb.putLong(byteOffset, v); } - + /** Retrieves the long at the specified byteOffset. */ public final long getLongAt(int byteOffset, int nativeSizeInBytes) { switch(nativeSizeInBytes) { - case 4: + case 4: return (long) bb.getInt(byteOffset) & 0x00000000FFFFFFFFL; - case 8: + case 8: return bb.getLong(byteOffset); default: throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes); @@ -189,17 +189,17 @@ public class StructAccessor { /** Puts a long at the specified byteOffset. */ public final void setLongAt(int byteOffset, long v, int nativeSizeInBytes) { switch(nativeSizeInBytes) { - case 4: + case 4: bb.putInt(byteOffset, (int) ( v & 0x00000000FFFFFFFFL ) ); break; - case 8: + case 8: bb.putLong(byteOffset, v); break; default: throw new InternalError("invalid nativeSizeInBytes "+nativeSizeInBytes); } } - + public final void setBytesAt(int byteOffset, byte[] v) { for (int i = 0; i < v.length; i++) { bb.put(byteOffset++, v[i]); @@ -225,18 +225,18 @@ public class StructAccessor { } return v; } - + public final void setShortsAt(int byteOffset, short[] v) { for (int i = 0; i < v.length; i++, byteOffset+=2) { bb.putShort(byteOffset, v[i]); - } + } } - + public final short[] getShortsAt(int byteOffset, short[] v) { for (int i = 0; i < v.length; i++, byteOffset+=2) { v[i] = bb.getShort(byteOffset); } - return v; + return v; } public final void setIntsAt(int byteOffset, int[] v) { diff --git a/src/java/com/jogamp/common/os/AndroidVersion.java b/src/java/com/jogamp/common/os/AndroidVersion.java index d2afbbc..a710310 100644 --- a/src/java/com/jogamp/common/os/AndroidVersion.java +++ b/src/java/com/jogamp/common/os/AndroidVersion.java @@ -34,25 +34,25 @@ import com.jogamp.common.util.ReflectionUtil; public class AndroidVersion { public static final boolean isAvailable; - - /** Development codename, or the string "REL" for official release */ + + /** Development codename, or the string "REL" for official release */ public static final String CODENAME; - + /** internal build value used by the underlying source control. */ public static final String INCREMENTAL; - + /** official build version string */ public static final String RELEASE; - + /** SDK Version number, key to VERSION_CODES */ public static final int SDK_INT; /** SDK Version string */ public static final String SDK_NAME; - + private static final String androidBuildVersion = "android.os.Build$VERSION"; private static final String androidBuildVersionCodes = "android.os.Build$VERSION_CODES"; - + static { final ClassLoader cl = AndroidVersion.class.getClassLoader(); Class<?> abvClass = null; @@ -65,7 +65,7 @@ public class AndroidVersion { abvcClass = ReflectionUtil.getClass(androidBuildVersionCodes, true, cl); abvcObject = abvcClass.newInstance(); } catch (Exception e) { /* n/a */ } - isAvailable = null != abvObject; + isAvailable = null != abvObject; if(isAvailable) { CODENAME = getString(abvClass, abvObject, "CODENAME"); INCREMENTAL = getString(abvClass, abvObject, "INCREMENTAL"); @@ -73,16 +73,16 @@ public class AndroidVersion { SDK_INT = getInt(abvClass, abvObject, "SDK_INT"); final IntObjectHashMap version_codes = getVersionCodes(abvcClass, abvcObject); final String sdk_name = (String) version_codes.get(SDK_INT); - SDK_NAME = ( null != sdk_name ) ? sdk_name : "SDK_"+SDK_INT ; + SDK_NAME = ( null != sdk_name ) ? sdk_name : "SDK_"+SDK_INT ; } else { CODENAME = null; INCREMENTAL = null; RELEASE = null; - SDK_INT = -1; + SDK_INT = -1; SDK_NAME = null; } } - + private static final IntObjectHashMap getVersionCodes(Class<?> cls, Object obj) { final Field[] fields = cls.getFields(); IntObjectHashMap map = new IntObjectHashMap( 3 * fields.length / 2, 0.75f ); @@ -93,10 +93,10 @@ public class AndroidVersion { // System.err.println(i+": "+version+": "+version_name); map.put(new Integer(version), version_name); } catch (Exception e) { e.printStackTrace(); /* n/a */ } - } + } return map; } - + private static final String getString(Class<?> cls, Object obj, String name) { try { Field f = cls.getField(name); @@ -112,6 +112,6 @@ public class AndroidVersion { } catch (Exception e) { e.printStackTrace(); /* n/a */ } return -1; } - + // android.os.Build.VERSION } diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java index 56387b6..a69fd7a 100644 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.os; import java.util.ArrayList; @@ -43,7 +43,7 @@ import com.jogamp.common.util.RunnableExecutor; * <li>The JNI glue-code native library, eg jogl_desktop.dll. From here on this is referred as the Glue</li> * </ul> * <p> - * An {@link DynamicLibraryBundleInfo} instance is being passed in the constructor, + * An {@link DynamicLibraryBundleInfo} instance is being passed in the constructor, * providing the required information about the tool and glue libraries. * The ClassLoader of it's implementation is also being used to help locating the native libraries. * </p> @@ -65,7 +65,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { private final List<List<String>> toolLibNames; private final List<String> glueLibNames; private final boolean[] toolLibLoaded; - + private int toolLibLoadedNumber; private final boolean[] glueLibLoaded; @@ -76,15 +76,15 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { private HashSet<String> toolGetProcAddressFuncNameSet; private List<String> toolGetProcAddressFuncNameList; - /** Returns an AWT-EDT {@link RunnableExecutor} implementation if AWT is available, otherwise {@link RunnableExecutor#currentThreadExecutor}. */ + /** Returns an AWT-EDT {@link RunnableExecutor} implementation if AWT is available, otherwise {@link RunnableExecutor#currentThreadExecutor}. */ public static RunnableExecutor getDefaultRunnableExecutor() { return RunnableExecutor.currentThreadExecutor; } - - /** + + /** * Instantiates and loads all {@link NativeLibrary}s incl. JNI libraries. * <p> - * The ClassLoader of the {@link DynamicLibraryBundleInfo} implementation class + * The ClassLoader of the {@link DynamicLibraryBundleInfo} implementation class * is being used to help locating the native libraries. * </p> */ @@ -104,12 +104,12 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { if( toolLibNames.size() == 0 ) { System.err.println("No Tool native library names given"); } - + if( glueLibNames.size() == 0 ) { System.err.println("No Glue native library names given"); } } - + for(int i=toolLibNames.size()-1; i>=0; i--) { toolLibLoaded[i] = false; } @@ -117,17 +117,17 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { for(int i=glueLibNames.size()-1; i>=0; i--) { glueLibLoaded[i] = false; } - + info.getLibLoaderExecutor().invoke(true, new Runnable() { - public void run() { + public void run() { loadLibraries(); - } } ) ; - + } } ) ; + toolGetProcAddressFuncNameList = info.getToolGetProcAddressFuncNameList(); if( null != toolGetProcAddressFuncNameList ) { toolGetProcAddressFuncNameSet = new HashSet<String>(toolGetProcAddressFuncNameList); toolGetProcAddressHandle = getToolGetProcAddressHandle(); - toolGetProcAddressComplete = 0 != toolGetProcAddressHandle; + toolGetProcAddressComplete = 0 != toolGetProcAddressHandle; } else { toolGetProcAddressFuncNameSet = new HashSet<String>(); toolGetProcAddressHandle = 0; @@ -144,7 +144,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { System.err.println(" LibLoaderExecutor: "+info.getLibLoaderExecutor().getClass().getName()); } } - + /** Unload all {@link NativeLibrary}s, and remove all references. */ public final void destroy() { if(DEBUG) { @@ -179,7 +179,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { /** * @return true if all tool libraries are loaded, * otherwise false. - * + * * @see DynamicLibraryBundleInfo#getToolLibNames() */ public final boolean isToolLibComplete() { @@ -207,9 +207,9 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { /** * @return true if the last entry has been loaded, - * while ignoring the preload dependencies. + * while ignoring the preload dependencies. * Otherwise false. - * + * * @see DynamicLibraryBundleInfo#getGlueLibNames() */ public final boolean isGlueLibComplete() { @@ -241,7 +241,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } protected final NativeLibrary loadFirstAvailable(List<String> libNames, ClassLoader loader, boolean global) { - for (int i=0; i < libNames.size(); i++) { + for (int i=0; i < libNames.size(); i++) { final NativeLibrary lib = NativeLibrary.open(libNames.get(i), loader, global); if (lib != null) { return lib; @@ -256,7 +256,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { final ClassLoader cl = info.getClass().getClassLoader(); NativeLibrary lib = null; - for (i=0; i < toolLibNames.size(); i++) { + for (i=0; i < toolLibNames.size(); i++) { final List<String> libNames = toolLibNames.get(i); if( null != libNames && libNames.size() > 0 ) { lib = loadFirstAvailable(libNames, cl, info.shallLinkGlobal()); @@ -282,7 +282,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } glueLibLoadedNumber = 0; - for (i=0; i < glueLibNames.size(); i++) { + for (i=0; i < glueLibNames.size(); i++) { final String libName = glueLibNames.get(i); boolean ignoreError = true; boolean res; @@ -304,7 +304,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } } } - + private final long dynamicLookupFunctionOnLibs(String funcName) { if(!isToolLibLoaded() || null==funcName) { if(DEBUG_LOOKUP && !isToolLibLoaded()) { @@ -347,7 +347,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } return 0; } - + @Override public final long dynamicLookupFunction(String funcName) { if(!isToolLibLoaded() || null==funcName) { @@ -371,11 +371,11 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { addr = dynamicLookupFunctionOnLibs(funcName); } if(0==addr && !useToolGetProcAdressFirst) { - addr = toolDynamicLookupFunction(funcName); + addr = toolDynamicLookupFunction(funcName); } return addr; } - + @Override public final boolean isFunctionAvailable(String funcName) { return 0 != dynamicLookupFunction(funcName); diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java index ef44298..7be5f25 100644 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundleInfo.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.os; import java.util.List; @@ -36,10 +36,10 @@ import com.jogamp.common.util.RunnableExecutor; public interface DynamicLibraryBundleInfo { public static final boolean DEBUG = DynamicLibraryBundle.DEBUG; - /** + /** * If a {@link SecurityManager} is installed, user needs link permissions * for the named libraries. - * + * * @return a list of Tool library names or alternative library name lists.<br> * <ul> * <li>GL/GLU example Unix: [ [ "libGL.so.1", "libGL.so", "GL" ], [ "libGLU.so", "GLU" ] ] </li> @@ -49,10 +49,10 @@ public interface DynamicLibraryBundleInfo { */ public List<List<String>> getToolLibNames(); - /** + /** * If a {@link SecurityManager} is installed, user needs link permissions * for the named libraries. - * + * * @return a list of Glue library names.<br> * <ul> * <li>GL: [ "nativewindow_x11", "jogl_gl2es12", "jogl_desktop" ] </li> @@ -64,15 +64,15 @@ public interface DynamicLibraryBundleInfo { */ public List<String> getGlueLibNames(); - /** + /** * May return the native libraries <pre>GetProcAddressFunc</pre> names, the first found function is being used.<br> * This could be eg: <pre> glXGetProcAddressARB, glXGetProcAddressARB </pre>.<br> * If your Tool does not has this facility, just return null. * @see #toolGetProcAddress(long, String) */ - public List<String> getToolGetProcAddressFuncNameList() ; + public List<String> getToolGetProcAddressFuncNameList() ; - /** + /** * May implement the lookup function using the Tools facility.<br> * The actual function pointer is provided to allow proper bootstrapping of the ProcAddressTable, * using one of the provided function names by {@link #getToolGetProcAddressFuncNameList()}.<br> @@ -81,7 +81,7 @@ public interface DynamicLibraryBundleInfo { /** * @param funcName - * @return true if {@link #toolGetProcAddress(long, String)} shall be tried before + * @return true if {@link #toolGetProcAddress(long, String)} shall be tried before * the system loader for the given function lookup. Otherwise false. * Default is <b>true</b>. */ @@ -90,20 +90,20 @@ public interface DynamicLibraryBundleInfo { /** @return true if the native library symbols shall be made available for symbol resolution of subsequently loaded libraries. */ public boolean shallLinkGlobal(); - /** + /** * If method returns <code>true</code> <i>and</i> if a {@link SecurityManager} is installed, user needs link permissions * for <b>all</b> libraries, i.e. for <code>new RuntimePermission("loadLibrary.*");</code>! - * - * @return true if the dynamic symbol lookup shall happen system wide, over all loaded libraries. - * Otherwise only the loaded native libraries are used for lookup, which shall be the default. + * + * @return true if the dynamic symbol lookup shall happen system wide, over all loaded libraries. + * Otherwise only the loaded native libraries are used for lookup, which shall be the default. */ public boolean shallLookupGlobal(); - + /** - * Returns a suitable {@link RunnableExecutor} implementation, which is being used + * Returns a suitable {@link RunnableExecutor} implementation, which is being used * to load the <code>tool</code> and <code>glue</code> native libraries. * <p> - * This allows the generic {@link DynamicLibraryBundle} implementation to + * This allows the generic {@link DynamicLibraryBundle} implementation to * load the native libraries on a designated thread. * </p> * <p> diff --git a/src/java/com/jogamp/common/os/DynamicLinker.java b/src/java/com/jogamp/common/os/DynamicLinker.java index ed52413..3b1ec3f 100644 --- a/src/java/com/jogamp/common/os/DynamicLinker.java +++ b/src/java/com/jogamp/common/os/DynamicLinker.java @@ -39,10 +39,10 @@ public interface DynamicLinker { * <p> * Opens the named library, allowing system wide access for other <i>users</i>. * </p> - * + * * @param pathname the full pathname for the library to open * @param debug set to true to enable debugging - * @return the library handle, maybe 0 if not found. + * @return the library handle, maybe 0 if not found. * @throws SecurityException if user is not granted access for the named library. */ public long openLibraryGlobal(String pathname, boolean debug) throws SecurityException; @@ -53,50 +53,50 @@ public interface DynamicLinker { * <p> * Opens the named library, restricting access to this process. * </p> - * + * * @param pathname the full pathname for the library to open * @param debug set to true to enable debugging - * @return the library handle, maybe 0 if not found. + * @return the library handle, maybe 0 if not found. * @throws SecurityException if user is not granted access for the named library. */ public long openLibraryLocal(String pathname, boolean debug) throws SecurityException; - + /** * If a {@link SecurityManager} is installed, user needs link permissions * for <b>all</b> libraries, i.e. for <code>new RuntimePermission("loadLibrary.*");</code>! - * + * * @param symbolName global symbol name to lookup up system wide. - * @return the library handle, maybe 0 if not found. + * @return the library handle, maybe 0 if not found. * @throws SecurityException if user is not granted access for all libraries. */ public long lookupSymbolGlobal(String symbolName) throws SecurityException; - + /** - * Security checks are implicit by previous call of + * Security checks are implicit by previous call of * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)} * retrieving the <code>librarHandle</code>. - * + * * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}. * @param symbolName global symbol name to lookup up system wide. - * @return the library handle, maybe 0 if not found. + * @return the library handle, maybe 0 if not found. * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown. */ public long lookupSymbol(long libraryHandle, String symbolName) throws IllegalArgumentException; - + /** - * Security checks are implicit by previous call of + * Security checks are implicit by previous call of * {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)} * retrieving the <code>librarHandle</code>. - * + * * @param libraryHandle a library handle previously retrieved via {@link #openLibraryLocal(String, boolean)} or {@link #openLibraryGlobal(String, boolean)}. * @throws IllegalArgumentException in case case <code>libraryHandle</code> is unknown. */ public void closeLibrary(long libraryHandle) throws IllegalArgumentException; - + /** - * Returns a string containing the last error. - * Maybe called for debuging purposed if any method fails. - * @return error string, maybe null. A null or non-null value has no semantics. + * Returns a string containing the last error. + * Maybe called for debuging purposed if any method fails. + * @return error string, maybe null. A null or non-null value has no semantics. */ public String getLastError(); } diff --git a/src/java/com/jogamp/common/os/DynamicLookupHelper.java b/src/java/com/jogamp/common/os/DynamicLookupHelper.java index 94a7e92..0f87351 100644 --- a/src/java/com/jogamp/common/os/DynamicLookupHelper.java +++ b/src/java/com/jogamp/common/os/DynamicLookupHelper.java @@ -1,21 +1,21 @@ /* * 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 @@ -28,11 +28,11 @@ * 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. */ @@ -41,7 +41,7 @@ package com.jogamp.common.os; import jogamp.common.Debug; -/** Interface callers may use ProcAddressHelper's +/** Interface callers may use ProcAddressHelper's * {@link com.jogamp.gluegen.runtime.ProcAddressTable#reset(com.jogamp.common.os.DynamicLookupHelper) reset} * helper method to install function pointers into a * ProcAddressTable. This must typically be written with native @@ -49,12 +49,12 @@ import jogamp.common.Debug; public interface DynamicLookupHelper { public static final boolean DEBUG = Debug.debug("NativeLibrary"); public static final boolean DEBUG_LOOKUP = Debug.debug("NativeLibrary.Lookup"); - + /** * Returns the function handle for function 'funcName'. */ public long dynamicLookupFunction(String funcName); - + /** * Queries whether function 'funcName' is available. */ diff --git a/src/java/com/jogamp/common/os/MachineDescription.java b/src/java/com/jogamp/common/os/MachineDescription.java index ab0885e..aea9de1 100644 --- a/src/java/com/jogamp/common/os/MachineDescription.java +++ b/src/java/com/jogamp/common/os/MachineDescription.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,11 +29,11 @@ * 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. */ @@ -61,14 +61,14 @@ public class MachineDescription { X86_64_WINDOWS(Platform.CPUType.X86_64), /** {@link Platform.CPUType#SPARC_32} Big Endian Solaris */ SPARC_32_SUNOS(Platform.CPUType.SPARC_32); - + public final Platform.CPUType cpu; ID(Platform.CPUType cpu){ this.cpu = cpu; } - } - + } + /* arch os int, long, float, doubl, ldoubl, ptr, page */ private final static int[] size_armeabi = { 4, 4, 4, 8, 8, 4, 4096 }; private final static int[] size_x86_32_unix = { 4, 4, 4, 8, 12, 4, 4096 }; @@ -78,7 +78,7 @@ public class MachineDescription { private final static int[] size_x86_64_windows = { 4, 4, 4, 8, 16, 8, 4096 }; private final static int[] size_sparc_32_sunos = { 4, 4, 4, 8, 16, 4, 8192 }; - /* arch os i8, i16, i32, i64, int, long, float, doubl, ldoubl, ptr */ + /* arch os i8, i16, i32, i64, int, long, float, doubl, ldoubl, ptr */ private final static int[] align_armeabi = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; private final static int[] align_x86_32_unix = { 1, 2, 4, 4, 4, 4, 4, 4, 4, 4 }; private final static int[] align_x86_32_macos = { 1, 2, 4, 4, 4, 4, 4, 4, 16, 4 }; @@ -86,7 +86,7 @@ public class MachineDescription { private final static int[] align_x86_64_unix = { 1, 2, 4, 8, 4, 8, 4, 8, 16, 8 }; private final static int[] align_x86_64_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 16, 8 }; private final static int[] align_sparc_32_sunos = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; - + public enum StaticConfig { /** {@link MachineDescription.ID#ARMle_EABI } */ ARMle_EABI(ID.ARMle_EABI, true, size_armeabi, align_armeabi), @@ -102,10 +102,10 @@ public class MachineDescription { X86_64_WINDOWS(ID.X86_64_WINDOWS, true, size_x86_64_windows, align_x86_64_windows), /** {@link MachineDescription.ID#SPARC_32_SUNOS } */ SPARC_32_SUNOS(ID.SPARC_32_SUNOS, false, size_sparc_32_sunos, align_sparc_32_sunos); - - public final ID id; + + public final ID id; public final MachineDescription md; - + StaticConfig(ID id, boolean littleEndian, int[] sizes, int[] alignments) { this.id = id; int i=0, j=0; @@ -128,7 +128,7 @@ public class MachineDescription { alignments[j++], alignments[j++]); } - + public StringBuilder toString(StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); @@ -137,23 +137,23 @@ public class MachineDescription { md.toString(sb); return sb; } - + @Override public String toString() { return toString(null).toString(); } } - + final private boolean runtimeValidated; - + final private boolean littleEndian; - + final private int int8SizeInBytes = 1; final private int int16SizeInBytes = 2; final private int int32SizeInBytes = 4; final private int int64SizeInBytes = 8; - + final private int intSizeInBytes; final private int longSizeInBytes; final private int floatSizeInBytes; @@ -162,7 +162,7 @@ public class MachineDescription { final private int pointerSizeInBytes; final private int pageSizeInBytes; final private boolean is32Bit; - + final private int int8AlignmentInBytes; final private int int16AlignmentInBytes; final private int int32AlignmentInBytes; @@ -176,7 +176,7 @@ public class MachineDescription { public MachineDescription(boolean runtimeValidated, boolean littleEndian, - + int intSizeInBytes, int longSizeInBytes, int floatSizeInBytes, @@ -184,7 +184,7 @@ public class MachineDescription { int ldoubleSizeInBytes, int pointerSizeInBytes, int pageSizeInBytes, - + int int8AlignmentInBytes, int int16AlignmentInBytes, int int32AlignmentInBytes, @@ -195,16 +195,16 @@ public class MachineDescription { int doubleAlignmentInBytes, int ldoubleAlignmentInBytes, int pointerAlignmentInBytes) { - this.runtimeValidated = runtimeValidated; + this.runtimeValidated = runtimeValidated; this.littleEndian = littleEndian; - + this.intSizeInBytes = intSizeInBytes; this.longSizeInBytes = longSizeInBytes; this.floatSizeInBytes = floatSizeInBytes; this.doubleSizeInBytes = doubleSizeInBytes; this.ldoubleSizeInBytes = ldoubleSizeInBytes; this.pointerSizeInBytes = pointerSizeInBytes; - this.pageSizeInBytes = pageSizeInBytes; + this.pageSizeInBytes = pageSizeInBytes; this.is32Bit = 4 == pointerSizeInBytes; this.int8AlignmentInBytes = int8AlignmentInBytes; @@ -218,14 +218,14 @@ public class MachineDescription { this.ldoubleAlignmentInBytes = ldoubleAlignmentInBytes; this.pointerAlignmentInBytes = pointerAlignmentInBytes; } - + /** * @return true if all values are validated at runtime, otherwise false (i.e. for static compilation w/ preset values) */ public final boolean isRuntimeValidated() { return runtimeValidated; } - + /** * Returns true only if this system uses little endian byte ordering. */ @@ -246,7 +246,7 @@ public class MachineDescription { public final boolean is64Bit() { return !is32Bit; } - + public final int intSizeInBytes() { return intSizeInBytes; } public final int longSizeInBytes() { return longSizeInBytes; } public final int int8SizeInBytes() { return int8SizeInBytes; } @@ -258,7 +258,7 @@ public class MachineDescription { public final int ldoubleSizeInBytes() { return ldoubleSizeInBytes; } public final int pointerSizeInBytes() { return pointerSizeInBytes; } public final int pageSizeInBytes() { return pageSizeInBytes; } - + public final int intAlignmentInBytes() { return intAlignmentInBytes; } public final int longAlignmentInBytes() { return longAlignmentInBytes; } public final int int8AlignmentInBytes() { return int8AlignmentInBytes; } @@ -269,20 +269,20 @@ public class MachineDescription { public final int doubleAlignmentInBytes() { return doubleAlignmentInBytes; } public final int ldoubleAlignmentInBytes() { return ldoubleAlignmentInBytes; } public final int pointerAlignmentInBytes() { return pointerAlignmentInBytes; } - + /** * @return number of pages required for size in bytes */ public int pageCount(int size) { return ( size + ( pageSizeInBytes - 1) ) / pageSizeInBytes ; // integer arithmetic } - + /** * @return page aligned size in bytes */ public int pageAlignedSize(int size) { return pageCount(size) * pageSizeInBytes; - } + } /** * Checks whether two size objects are equal. Two instances @@ -294,7 +294,7 @@ public class MachineDescription { public final boolean equals(Object obj) { if (this == obj) { return true; } if ( !(obj instanceof MachineDescription) ) { return false; } - final MachineDescription md = (MachineDescription) obj; + final MachineDescription md = (MachineDescription) obj; return pageSizeInBytes == md.pageSizeInBytes && compatible(md); @@ -309,7 +309,7 @@ public class MachineDescription { */ public final boolean compatible(MachineDescription md) { return littleEndian == md.littleEndian && - + intSizeInBytes == md.intSizeInBytes && longSizeInBytes == md.longSizeInBytes && floatSizeInBytes == md.floatSizeInBytes && @@ -317,7 +317,7 @@ public class MachineDescription { ldoubleSizeInBytes == md.ldoubleSizeInBytes && pointerSizeInBytes == md.pointerSizeInBytes && is32Bit == md.is32Bit && - + int8AlignmentInBytes == md.int8AlignmentInBytes && int16AlignmentInBytes == md.int16AlignmentInBytes && int32AlignmentInBytes == md.int32AlignmentInBytes && @@ -329,7 +329,7 @@ public class MachineDescription { ldoubleAlignmentInBytes == md.ldoubleAlignmentInBytes && pointerAlignmentInBytes == md.pointerAlignmentInBytes ; } - + public StringBuilder toString(StringBuilder sb) { if(null==sb) { sb = new StringBuilder(); @@ -345,13 +345,13 @@ public class MachineDescription { sb.append(", double ").append(doubleSizeInBytes) .append(" / ").append(doubleAlignmentInBytes); sb.append(", ldouble ").append(ldoubleSizeInBytes).append(" / ").append(ldoubleAlignmentInBytes).append(Platform.getNewline()); sb.append(" pointer ").append(pointerSizeInBytes).append(" / ").append(pointerAlignmentInBytes); - sb.append(", page ").append(pageSizeInBytes); + sb.append(", page ").append(pageSizeInBytes); return sb; } - + @Override public String toString() { return toString(null).toString(); } - + } diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index 3d81479..df59611 100644 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2011 JogAmp Community. 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 @@ -29,11 +29,11 @@ * 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. */ @@ -72,7 +72,7 @@ import com.jogamp.common.util.cache.TempJarCache; ProcAddressTable glue code generation style without additional supporting code needed in the generated library. */ -public final class NativeLibrary implements DynamicLookupHelper { +public final class NativeLibrary implements DynamicLookupHelper { private static final DynamicLinker dynLink; private static final String[] prefixes; private static final String[] suffixes; @@ -85,7 +85,7 @@ public final class NativeLibrary implements DynamicLookupHelper { prefixes = new String[] { "" }; suffixes = new String[] { ".dll" }; break; - + case MACOS: dynLink = new MacOSXDynamicLinkerImpl(); prefixes = new String[] { "lib" }; @@ -97,12 +97,12 @@ public final class NativeLibrary implements DynamicLookupHelper { prefixes = new String[] { "lib" }; suffixes = new String[] { ".so" }; break; - + /* case FREEBSD: case SUNOS: - case HPUX: - case OPENKODE: + case HPUX: + case OPENKODE: case LINUX: */ default: dynLink = new PosixDynamicLinkerImpl(); @@ -119,7 +119,7 @@ public final class NativeLibrary implements DynamicLookupHelper { // May as well keep around the path to the library we opened private final String libraryPath; - + private final boolean global; // Private constructor to prevent arbitrary instances from floating around @@ -218,7 +218,7 @@ public final class NativeLibrary implements DynamicLookupHelper { if( null != t ) { t.printStackTrace(); } - } + } } if (DEBUG) { @@ -290,10 +290,10 @@ public final class NativeLibrary implements DynamicLookupHelper { /** * Comparison of prefix and suffix of the given libName's basename * is performed case insensitive <br> - * - * @param libName the full path library name with prefix and suffix + * + * @param libName the full path library name with prefix and suffix * @param isLowerCaseAlready indicates if libName is already lower-case - * + * * @return basename of libName w/o path, ie. /usr/lib/libDrinkBeer.so -> DrinkBeer on Unix systems, but null on Windows. */ public static final String isValidNativeLibraryName(String libName, boolean isLowerCaseAlready) { @@ -305,7 +305,7 @@ public final class NativeLibrary implements DynamicLookupHelper { } final String libBaseNameLC = isLowerCaseAlready ? libBaseName : libBaseName.toLowerCase(); int prefixIdx = -1; - for(int i=0; i<prefixes.length && 0 > prefixIdx; i++) { + for(int i=0; i<prefixes.length && 0 > prefixIdx; i++) { if (libBaseNameLC.startsWith(prefixes[i])) { prefixIdx = i; } @@ -319,9 +319,9 @@ public final class NativeLibrary implements DynamicLookupHelper { } } } - return null; + return null; } - + /** Given the base library names (no prefixes/suffixes) for the various platforms, enumerate the possible locations and names of the indicated native library on the system. */ @@ -377,7 +377,7 @@ public final class NativeLibrary implements DynamicLookupHelper { if (searchSystemPathFirst) { if(null != sysPath) { res[i++] = sysPath; - } + } } if(null != usrPath) { res[i++] = usrPath; @@ -385,7 +385,7 @@ public final class NativeLibrary implements DynamicLookupHelper { if (!searchSystemPathFirst) { if(null != sysPath) { res[i++] = sysPath; - } + } } return res; } @@ -422,7 +422,7 @@ public final class NativeLibrary implements DynamicLookupHelper { // Add current location addPaths("/System/Library/Frameworks/" + libName + ".Framework", baseNames, paths); } - + return paths; } @@ -433,7 +433,7 @@ public final class NativeLibrary implements DynamicLookupHelper { switch (PlatformPropsImpl.OS_TYPE) { case WINDOWS: return windowsLibName; - + case MACOS: return macOSXLibName; @@ -441,8 +441,8 @@ public final class NativeLibrary implements DynamicLookupHelper { case FREEBSD: case DALVIK: case SUNOS: - case HPUX: - case OPENKODE: + case HPUX: + case OPENKODE: case LINUX: */ default: return unixLibName; @@ -459,9 +459,9 @@ public final class NativeLibrary implements DynamicLookupHelper { } catch (URISyntaxException uriEx) { throw new IllegalArgumentException(uriEx); } - + int prefixIdx = -1; - for(int i=0; i<prefixes.length && 0 > prefixIdx; i++) { + for(int i=0; i<prefixes.length && 0 > prefixIdx; i++) { if (libBaseNameLC.startsWith(prefixes[i])) { prefixIdx = i; } @@ -494,7 +494,7 @@ public final class NativeLibrary implements DynamicLookupHelper { } } - String[] res = new String[prefixes.length * suffixes.length + + String[] res = new String[prefixes.length * suffixes.length + ( PlatformPropsImpl.OS_TYPE == Platform.OSType.MACOS ? 1 : 0 )]; int idx = 0; for (int i = 0; i < prefixes.length; i++) { diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index a01a4b4..896ea56 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.os; import java.net.URI; @@ -48,7 +48,7 @@ import jogamp.common.os.PlatformPropsImpl; * Utility class for querying platform specific properties. * <p> * Some field declarations and it's static initialization has been delegated - * to it's super class {@link PlatformPropsImpl} to solve + * to it's super class {@link PlatformPropsImpl} to solve * static initialization interdependencies w/ the GlueGen native library loading * and it's derived information {@link #getMachineDescription()}, {@link #is32Bit()}, ..<br> * This mechanism is preferred in this case to avoid synchronization and locking @@ -56,20 +56,20 @@ import jogamp.common.os.PlatformPropsImpl; * </p> */ public class Platform extends PlatformPropsImpl { - + public enum OSType { - LINUX(0), FREEBSD(1), ANDROID(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7); - + LINUX(0), FREEBSD(1), ANDROID(2), MACOS(3), SUNOS(4), HPUX(5), WINDOWS(6), OPENKODE(7); + public final int id; OSType(int id){ this.id = id; } } - + public enum CPUFamily { /** AMD/Intel */ - X86( 0x00000000), + X86( 0x00000000), /** ARM */ ARM( 0x00010000), /** Power PC */ @@ -79,17 +79,17 @@ public class Platform extends PlatformPropsImpl { /** PA RISC */ PA_RISC(0xFFFF0000), /** Itanium */ - IA64( 0xFFFF1000); - + IA64( 0xFFFF1000); + public final int id; CPUFamily(int id){ this.id = id; } } - + public enum CPUType { - /** X86 32bit */ + /** X86 32bit */ X86_32( CPUFamily.X86, 0x0001), /** X86 64bit */ X86_64( CPUFamily.X86, 0x0002), @@ -111,72 +111,72 @@ public class Platform extends PlatformPropsImpl { IA64( CPUFamily.IA64, 0x0000), /** PA_RISC2_0 */ PA_RISC2_0(CPUFamily.PA_RISC, 0x0001); - + public final int id; public final CPUFamily family; - + CPUType(CPUFamily type, int id){ this.family = type; this.id = id; } - + public CPUFamily getFamily() { return family; } - } - + } + public enum ABIType { - GENERIC_ABI ( 0x0000 ), - /** ARM GNU-EABI ARMEL -mfloat-abi=softfp */ + GENERIC_ABI ( 0x0000 ), + /** ARM GNU-EABI ARMEL -mfloat-abi=softfp */ EABI_GNU_ARMEL ( 0x0001 ), - /** ARM GNU-EABI ARMHF -mfloat-abi=hard */ + /** ARM GNU-EABI ARMHF -mfloat-abi=hard */ EABI_GNU_ARMHF ( 0x0002 ); - + public final int id; - + ABIType(int id){ this.id = id; - } + } } - + private static final String useTempJarCachePropName = "jogamp.gluegen.UseTempJarCache"; - + /** fixed basename of JAR file and native library */ - private static final String libBaseName = "gluegen-rt"; - + private static final String libBaseName = "gluegen-rt"; + // // static initialization order: // - + /** - * System property: 'jogamp.gluegen.UseTempJarCache', + * System property: 'jogamp.gluegen.UseTempJarCache', * defaults to true if {@link #OS_TYPE} is not {@link OSType#ANDROID}. */ public static final boolean USE_TEMP_JAR_CACHE; - + // // post loading native lib: // - + private static final MachineDescription machineDescription; - + private static final boolean is32Bit; - + /** <code>true</code> if AWT is available and not in headless mode, otherwise <code>false</code>. */ public static final boolean AWT_AVAILABLE; - + private static final boolean isRunningFromJarURL; - + static { final boolean[] _isRunningFromJarURL = new boolean[] { false }; final boolean[] _USE_TEMP_JAR_CACHE = new boolean[] { false }; final boolean[] _AWT_AVAILABLE = new boolean[] { false }; - - AccessController.doPrivileged(new PrivilegedAction<Object>() { + + AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { - + PlatformPropsImpl.initSingleton(); // documenting the order of static initialization - + final ClassLoader cl = Platform.class.getClassLoader(); - + final URI platformClassJarURI; { URI _platformClassJarURI = null; @@ -185,11 +185,11 @@ public class Platform extends PlatformPropsImpl { } catch (Exception e) { } platformClassJarURI = _platformClassJarURI; } - _isRunningFromJarURL[0] = null != platformClassJarURI; - + _isRunningFromJarURL[0] = null != platformClassJarURI; + _USE_TEMP_JAR_CACHE[0] = ( OS_TYPE != OSType.ANDROID ) && ( null != platformClassJarURI ) && Debug.getBooleanProperty(useTempJarCachePropName, true, true); - + // load GluegenRT native library if(_USE_TEMP_JAR_CACHE[0] && TempJarCache.initSingleton()) { try { @@ -200,13 +200,13 @@ public class Platform extends PlatformPropsImpl { } } DynamicLibraryBundle.GlueJNILibLoader.loadLibrary(libBaseName, false, cl); - + // JVM bug workaround JVMUtil.initSingleton(); // requires gluegen-rt, one-time init. - + // AWT Headless determination if( !Debug.getBooleanProperty("java.awt.headless", true) && - ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.ComponentClass, cl) && + ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.ComponentClass, cl) && ReflectionUtil.isClassAvailable(ReflectionUtil.AWTNames.GraphicsEnvironmentClass, cl) ) { try { _AWT_AVAILABLE[0] = false == ((Boolean)ReflectionUtil.callStaticMethod(ReflectionUtil.AWTNames.GraphicsEnvironmentClass, ReflectionUtil.AWTNames.isHeadlessMethod, null, null, cl)).booleanValue(); @@ -217,7 +217,7 @@ public class Platform extends PlatformPropsImpl { isRunningFromJarURL = _isRunningFromJarURL[0]; USE_TEMP_JAR_CACHE = _USE_TEMP_JAR_CACHE[0]; AWT_AVAILABLE = _AWT_AVAILABLE[0]; - + MachineDescription md = MachineDescriptionRuntime.getRuntime(); if(null == md) { MachineDescription.StaticConfig smd = MachineDescriptionRuntime.getStatic(); @@ -232,7 +232,7 @@ public class Platform extends PlatformPropsImpl { } } machineDescription = md; - is32Bit = machineDescription.is32Bit(); + is32Bit = machineDescription.is32Bit(); } private Platform() {} @@ -240,15 +240,15 @@ public class Platform extends PlatformPropsImpl { /** * @return true if we're running from a Jar URL, otherwise false */ - public static final boolean isRunningFromJarURL() { + public static final boolean isRunningFromJarURL() { return isRunningFromJarURL; } - + /** * kick off static initialization of <i>platform property information</i> and <i>native gluegen-rt lib loading</i> */ - public static void initSingleton() { } - + public static void initSingleton() { } + /** * Returns true only if having {@link java.nio.LongBuffer} and {@link java.nio.DoubleBuffer} available. */ @@ -263,12 +263,12 @@ public class Platform extends PlatformPropsImpl { * </p> * <p> * <i>Note</i>: We claim Android is compatible. - * </p> + * </p> */ public static boolean isJava6() { return JAVA_6; } - + /** * Returns true if this machine is little endian, otherwise false. */ @@ -283,7 +283,7 @@ public class Platform extends PlatformPropsImpl { public static String getOSName() { return OS; } - + /** * Returns the OS version. */ @@ -312,38 +312,38 @@ public class Platform extends PlatformPropsImpl { public static OSType getOSType() { return OS_TYPE; } - + /** * Returns the CPU type. */ public static CPUFamily getCPUFamily() { return CPU_ARCH.getFamily(); } - + /** * Returns the CPU architecture. */ public static CPUType getCPUType() { return CPU_ARCH; } - + /** * Returns the (guessed) ABI. */ public static ABIType getABIType() { return ABI_TYPE; } - + /** * Returns the GlueGen common name for the currently running OSType and CPUType * as implemented in the build system in 'gluegen-cpptasks-base.xml'.<br> - * + * * @see #getOSAndArch(OSType, CPUType) */ public static String getOSAndArch() { return os_and_arch; } - + /** * Returns the JAVA vendor. */ @@ -357,14 +357,14 @@ public class Platform extends PlatformPropsImpl { public static String getJavaVMName() { return JAVA_VM_NAME; } - + /** * Returns the JAVA runtime name. */ public static String getJavaRuntimeName() { return JAVA_RUNTIME_NAME; } - + /** * Returns the JAVA vendor url. */ @@ -417,7 +417,7 @@ public class Platform extends PlatformPropsImpl { public static MachineDescription getMachineDescription() { return machineDescription; } - + /** Returns <code>true</code> if AWT is available and not in headless mode, otherwise <code>false</code>. */ public static boolean isAWTAvailable() { return AWT_AVAILABLE; @@ -426,23 +426,23 @@ public class Platform extends PlatformPropsImpl { // // time / jitter // - - /** + + /** * Returns the unix based current time in milliseconds, based on <code>gettimeofday(..)</code>. * <p> * This is an alternative to {@link System#currentTimeMillis()} and {@link System#nanoTime()}. - * While the named {@link System} methods do provide the required precision, + * While the named {@link System} methods do provide the required precision, * <code>gettimeofday()</code> <i>also</i> guarantees time accuracy, i.e. update interval. * </p> * @see #currentTimeMicros() */ public static native long currentTimeMillis(); - - /** + + /** * Returns the unix based current time in microseconds, based on <code>gettimeofday(..)</code>. * <p> * This is an alternative to {@link System#currentTimeMillis()} and {@link System#nanoTime()}. - * While the named {@link System} methods do provide the required precision, + * While the named {@link System} methods do provide the required precision, * <code>gettimeofday()</code> <i>also</i> guarantees time accuracy, i.e. update interval. * </p> * @see #currentTimeMillis() @@ -458,7 +458,7 @@ public class Platform extends PlatformPropsImpl { public static synchronized long getCurrentSleepJitter() { getCurrentSleepJitterImpl(TimeUnit.MILLISECONDS.toNanos(10), 10); // warm-up return getCurrentSleepJitterImpl(TimeUnit.MILLISECONDS.toNanos(10), 10); - } + } private static long getCurrentSleepJitterImpl(final long nsDuration, final int splitInLoops) { final long nsPeriod = nsDuration / splitInLoops; final long t0_ns = System.nanoTime(); diff --git a/src/java/com/jogamp/common/util/ArrayHashSet.java b/src/java/com/jogamp/common/util/ArrayHashSet.java index ed3590a..a125580 100644 --- a/src/java/com/jogamp/common/util/ArrayHashSet.java +++ b/src/java/com/jogamp/common/util/ArrayHashSet.java @@ -35,7 +35,7 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; -/** +/** * Hashed ArrayList implementation of the List and Collection interface. * * Implementation properties are: @@ -80,12 +80,12 @@ public class ArrayHashSet<E> map = new HashMap<E,E>(initialCapacity); data = new ArrayList<E>(initialCapacity); } - + public ArrayHashSet(int initialCapacity, float loadFactor) { map = new HashMap<E,E>(initialCapacity, loadFactor); data = new ArrayList<E>(initialCapacity); } - + // // Cloneable // @@ -102,15 +102,15 @@ public class ArrayHashSet<E> return newObj; } - + /** Returns this object ordered ArrayList. Use w/ care, it's not a copy. */ public final ArrayList<E> getData() { return data; } /** Returns this object hash map. Use w/ care, it's not a copy. */ public final HashMap<E,E> getMap() { return map; } - + @Override public final String toString() { return data.toString(); } - + // // Collection // @@ -408,7 +408,7 @@ public class ArrayHashSet<E> * Identity method allowing to get the identical object, using the internal hash map. * <br> * This is an O(1) operation. - * + * * @param key hash source to find the identical Object within this list * @return object from this list, identical to the given <code>key</code> hash code, * or null if not contained diff --git a/src/java/com/jogamp/common/util/FloatStack.java b/src/java/com/jogamp/common/util/FloatStack.java index 2addd76..725491c 100644 --- a/src/java/com/jogamp/common/util/FloatStack.java +++ b/src/java/com/jogamp/common/util/FloatStack.java @@ -44,69 +44,69 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { private int position; private /*value*/float/*value*/[] buffer; private int growSize; - + /** * @param initialSize initial size, must be > zero * @param growSize grow size if {@link #position()} is reached, maybe <code>0</code> - * in which case an {@link IndexOutOfBoundsException} is thrown. + * in which case an {@link IndexOutOfBoundsException} is thrown. */ public /*name*/FloatStack/*name*/(int initialSize, int growSize) { this.position = 0; this.growSize = growSize; this.buffer = new /*value*/float/*value*/[initialSize]; } - + @Override public final int capacity() { return buffer.length; } - + @Override public final int position() { return position; } - + @Override public final void position(int newPosition) throws IndexOutOfBoundsException { if( 0 > position || position >= buffer.length ) { throw new IndexOutOfBoundsException("Invalid new position "+newPosition+", "+this.toString()); } - position = newPosition; + position = newPosition; } - + @Override public final int remaining() { return buffer.length - position; } - + @Override public final int getGrowSize() { return growSize; } - + @Override public final void setGrowSize(int newGrowSize) { growSize = newGrowSize; } - + public final String toString() { return "FloatStack[0..(pos "+position+").."+buffer.length+", remaining "+remaining()+"]"; } - + public final /*value*/float/*value*/[] buffer() { return buffer; } - + private final void growIfNecessary(int length) throws IndexOutOfBoundsException { if( position + length > buffer.length ) { if( 0 >= growSize ) { throw new IndexOutOfBoundsException("Out of fixed stack size: "+this); } - /*value*/float/*value*/[] newBuffer = + /*value*/float/*value*/[] newBuffer = new /*value*/float/*value*/[buffer.length + growSize]; System.arraycopy(buffer, 0, newBuffer, 0, position); buffer = newBuffer; - } + } } /** * FILO put operation - * + * * @param src source buffer - * @param srcOffset offset of src - * @param length number of float elements to put from <code>src</code> on-top this stack + * @param srcOffset offset of src + * @param length number of float elements to put from <code>src</code> on-top this stack * @return the src float[] * @throws IndexOutOfBoundsException if stack cannot grow due to zero grow-size or offset+length exceeds src. */ - public final /*value*/float/*value*/[] + public final /*value*/float/*value*/[] putOnTop(/*value*/float/*value*/[] src, int srcOffset, int length) throws IndexOutOfBoundsException { growIfNecessary(length); System.arraycopy(src, srcOffset, buffer, position, length); @@ -116,47 +116,47 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { /** * FILO put operation - * + * * @param src source buffer, it's position is incremented by <code>length</code> - * @param length number of float elements to put from <code>src</code> on-top this stack + * @param length number of float elements to put from <code>src</code> on-top this stack * @return the src FloatBuffer * @throws IndexOutOfBoundsException if stack cannot grow due to zero grow-size * @throws BufferUnderflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>. */ - public final /*value2*/FloatBuffer/*value2*/ + public final /*value2*/FloatBuffer/*value2*/ putOnTop(/*value2*/FloatBuffer/*value2*/ src, int length) throws IndexOutOfBoundsException, BufferUnderflowException { - growIfNecessary(length); + growIfNecessary(length); src.get(buffer, position, length); position += length; return src; } - + /** * FILO get operation - * + * * @param dest destination buffer - * @param destOffset offset of dest - * @param length number of float elements to get from-top this stack to <code>dest</code>. + * @param destOffset offset of dest + * @param length number of float elements to get from-top this stack to <code>dest</code>. * @return the dest float[] * @throws IndexOutOfBoundsException if stack or <code>dest</code> has less elements than <code>length</code>. */ - public final /*value*/float/*value*/[] + public final /*value*/float/*value*/[] getFromTop(/*value*/float/*value*/[] dest, int destOffset, int length) throws IndexOutOfBoundsException { System.arraycopy(buffer, position-length, dest, destOffset, length); position -= length; return dest; } - + /** * FILO get operation - * + * * @param dest destination buffer, it's position is incremented by <code>length</code>. * @param length number of float elements to get from-top this stack to <code>dest</code>. * @return the dest FloatBuffer * @throws IndexOutOfBoundsException if stack has less elements than length * @throws BufferOverflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>. */ - public final /*value2*/FloatBuffer/*value2*/ + public final /*value2*/FloatBuffer/*value2*/ getFromTop(/*value2*/FloatBuffer/*value2*/ dest, int length) throws IndexOutOfBoundsException, BufferOverflowException { dest.put(buffer, position-length, length); position -= length; diff --git a/src/java/com/jogamp/common/util/Function.java b/src/java/com/jogamp/common/util/Function.java index 8bec99c..9b03ce6 100644 --- a/src/java/com/jogamp/common/util/Function.java +++ b/src/java/com/jogamp/common/util/Function.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -41,9 +41,9 @@ public interface Function<R,A> { /** * Implementation may compute variable <code>args</code> list * and returns a result. - * + * * @param args variable argument list, <code>A[]</code>, maybe null * @return the result. */ R eval(A... args); -} +} diff --git a/src/java/com/jogamp/common/util/FunctionTask.java b/src/java/com/jogamp/common/util/FunctionTask.java index 01f85b1..b742d73 100644 --- a/src/java/com/jogamp/common/util/FunctionTask.java +++ b/src/java/com/jogamp/common/util/FunctionTask.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.PrintStream; @@ -41,7 +41,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { /** * Invokes <code>func</code>. - * @param waitUntilDone if <code>true</code>, waits until <code>func</code> execution is completed, otherwise returns immediately. + * @param waitUntilDone if <code>true</code>, waits until <code>func</code> execution is completed, otherwise returns immediately. * @param func the {@link Function} to execute. * @param args the {@link Function} arguments * @return the {@link Function} return value @@ -69,14 +69,14 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { } return res; } - + /** * Create a RunnableTask object w/ synchronization, - * ie. suitable for <code>invokeAndWait()</code>. - * + * ie. suitable for <code>invokeAndWait()</code>. + * * @param runnable the user action * @param syncObject the synchronization object the caller shall wait until <code>runnable</code> execution is completed, - * or <code>null</code> if waiting is not desired. + * or <code>null</code> if waiting is not desired. * @param catchExceptions Influence an occurring exception during <code>runnable</code> execution. * If <code>true</code>, the exception is silenced and can be retrieved via {@link #getThrowable()}, * otherwise the exception is thrown. @@ -96,12 +96,12 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { /** * Sets the arguments for {@link #run()}. - * They will be cleared after calling {@link #run()} or {@link #eval(Object...)}. + * They will be cleared after calling {@link #run()} or {@link #eval(Object...)}. */ public final void setArgs(A... args) { this.args = args; } - + /** * Retrieves the cached result of {@link #run()} * and is cleared within this method. @@ -111,7 +111,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { result = null; return res; } - + /** * {@inheritDoc} * <p> @@ -170,7 +170,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { @Override public final R eval(A... args) { this.args = args; - run(); + run(); final R res = result; result = null; return res; diff --git a/src/java/com/jogamp/common/util/HashUtil.java b/src/java/com/jogamp/common/util/HashUtil.java index c5a3bff..5ce2332 100644 --- a/src/java/com/jogamp/common/util/HashUtil.java +++ b/src/java/com/jogamp/common/util/HashUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -29,7 +29,7 @@ package com.jogamp.common.util; public class HashUtil { /** - * Generates a 32bit equally distributed identity hash value + * Generates a 32bit equally distributed identity hash value * from <code>addr</code> avoiding XOR collision. */ public static int getAddrHash32_EqualDist(long addr) { @@ -38,9 +38,9 @@ public class HashUtil { int hash = 31 + (int) addr ; // lo addr return ((hash << 5) - hash) + (int) ( addr >>> 32 ) ; // hi addr } - + /** - * Generates a 32bit equally distributed identity hash value + * Generates a 32bit equally distributed identity hash value * from <code>addr</code> and <code>size</code> avoiding XOR collision. */ public static int getAddrSizeHash32_EqualDist(long addr, long size) { @@ -51,9 +51,9 @@ public class HashUtil { hash = ((hash << 5) - hash) + (int) size ; // lo size return ((hash << 5) - hash) + (int) ( size >>> 32 ) ; // hi size } - + /** - * Generates a 64bit equally distributed hash value + * Generates a 64bit equally distributed hash value * from <code>addr</code> and <code>size</code> avoiding XOR collisions. */ public static long getHash64(long addr, long size) { @@ -62,5 +62,5 @@ public class HashUtil { return ((hash << 5) - hash) + size; } - + } diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 242f300..16f191b 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -56,7 +56,7 @@ import com.jogamp.common.os.Platform; public class IOUtil { public static final boolean DEBUG = Debug.debug("IOUtil"); - + /** {@value} */ public static final String SCHEME_SEPARATOR = ":"; /** {@value} */ @@ -69,28 +69,28 @@ public class IOUtil { public static final String JAR_SCHEME = "jar"; /** A JAR subprotocol is separeted from the JAR entry w/ this separator {@value}. Even if no class is specified '!/' must follow!. */ public static final String JAR_SCHEME_SEPARATOR = "!"; - + /** Std. temporary directory property key <code>java.io.tmpdir</code>. */ - private static final String java_io_tmpdir_propkey = "java.io.tmpdir"; + private static final String java_io_tmpdir_propkey = "java.io.tmpdir"; private static final String user_home_propkey = "user.home"; private static final String XDG_CACHE_HOME_envkey = "XDG_CACHE_HOME"; - /** Subdirectory within platform's temporary root directory where all JogAmp related temp files are being stored: {@code jogamp} */ + /** Subdirectory within platform's temporary root directory where all JogAmp related temp files are being stored: {@code jogamp} */ public static final String tmpSubDir = "jogamp"; - + private IOUtil() {} - - /** + + /** * Since usage of {@link java.io.FileOutputStream} is considered security critical, * we need to check it's availability for each use. * <p> * In case a SecurityManager is installed, privileged access is required. * </p> - * - * @return the constructor of {@link java.io.FileOutputStream} if available and - * no SecurityManager is installed or privileged access is granted. + * + * @return the constructor of {@link java.io.FileOutputStream} if available and + * no SecurityManager is installed or privileged access is granted. * Otherwise null. - * + * */ private static final Constructor<?> getFOSCtor() { Constructor<?> _fosCtor; @@ -102,7 +102,7 @@ public class IOUtil { _fosCtor = null; _t = t; } - if(DEBUG) { + if(DEBUG) { System.err.println("IOUtil: java.io.FileOutputStream available: "+(null != _fosCtor)); if(null!=_t) { _t.printStackTrace(); @@ -110,24 +110,24 @@ public class IOUtil { } return _fosCtor; } - + /*** - * + * * STREAM COPY STUFF - * + * */ - + /** * Copy the specified URL resource to the specified output file. The total * number of bytes written is returned. Both streams are closed upon completion. - * - * @param conn the open URLConnection + * + * @param conn the open URLConnection * @param outFile the destination * @return * @throws IOException */ public static int copyURLConn2File(URLConnection conn, File outFile) throws IOException { - conn.connect(); // redundant + conn.connect(); // redundant int totalNumBytes = 0; InputStream in = new BufferedInputStream(conn.getInputStream()); @@ -142,10 +142,10 @@ public class IOUtil { /** * Copy the specified input stream to the specified output file. The total * number of bytes written is returned. Both streams are closed upon completion. - * - * @param in the source + * + * @param in the source * @param outFile the destination - * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown + * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown * @return * @throws IOException */ @@ -162,10 +162,10 @@ public class IOUtil { /** * Copy the specified input stream to the specified output stream. The total * number of bytes written is returned. - * - * @param in the source + * + * @param in the source * @param out the destination - * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown + * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown * @return * @throws IOException */ @@ -176,11 +176,11 @@ public class IOUtil { /** * Copy the specified input stream to the specified output stream. The total * number of bytes written is returned. - * + * * @param bufferSize the intermediate buffer size, should be {@link MachineDescription#pageSizeInBytes()} for best performance. - * @param in the source + * @param in the source * @param out the destination - * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown + * @param totalNumBytes informal number of expected bytes, maybe used for user feedback while processing. -1 if unknown * @return * @throws IOException */ @@ -197,7 +197,7 @@ public class IOUtil { } return numBytes; } - + /** * Copy the specified input stream to a byte array, which is being returned. */ @@ -235,17 +235,17 @@ public class IOUtil { /** * Copy the specified input stream to a NIO ByteBuffer w/ native byte order, which is being returned. * <p>The implementation creates the ByteBuffer w/ {@link #copyStream2ByteArray(InputStream)}'s returned byte array.</p> - * + * * @param stream input stream, which will be wrapped into a BufferedInputStream, if not already done. */ public static ByteBuffer copyStream2ByteBuffer(InputStream stream) throws IOException { - return copyStream2ByteBuffer(stream, -1); + return copyStream2ByteBuffer(stream, -1); } - + /** * Copy the specified input stream to a NIO ByteBuffer w/ native byte order, which is being returned. * <p>The implementation creates the ByteBuffer w/ {@link #copyStream2ByteArray(InputStream)}'s returned byte array.</p> - * + * * @param stream input stream, which will be wrapped into a BufferedInputStream, if not already done. * @param initialCapacity initial buffer capacity in bytes, if > available bytes */ @@ -257,7 +257,7 @@ public class IOUtil { if( initialCapacity < avail ) { initialCapacity = avail; } - final MachineDescription machine = Platform.getMachineDescription(); + final MachineDescription machine = Platform.getMachineDescription(); ByteBuffer data = Buffers.newDirectByteBuffer( machine.pageAlignedSize( initialCapacity ) ); byte[] chunk = new byte[machine.pageSizeInBytes()]; int chunk2Read = Math.min(machine.pageSizeInBytes(), avail); @@ -269,13 +269,13 @@ public class IOUtil { newData.put(data); data = newData; } - + numRead = stream.read(chunk, 0, chunk2Read); if (numRead > 0) { data.put(chunk, 0, numRead); } avail = stream.available(); - chunk2Read = Math.min(machine.pageSizeInBytes(), avail); + chunk2Read = Math.min(machine.pageSizeInBytes(), avail); } while ( numRead > 0 ); // EOS: -1 == numRead, EOF maybe reached earlier w/ 0 == numRead data.flip(); @@ -283,13 +283,13 @@ public class IOUtil { } /*** - * + * * RESOURCE / FILE NAME STUFF - * + * */ - + /** - * + * * @param path * @param startWithSlash * @param endWithSlash @@ -297,7 +297,7 @@ public class IOUtil { * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> */ public static String slashify(String path, boolean startWithSlash, boolean endWithSlash) throws URISyntaxException { - String p = path.replace('\\', '/'); // unify file separator + String p = path.replace('\\', '/'); // unify file separator if (startWithSlash && !p.startsWith("/")) { p = "/" + p; } @@ -306,23 +306,23 @@ public class IOUtil { } return cleanPathString(p); } - - /** - * Using the simple conversion via File -> URI, assuming proper characters. + + /** + * Using the simple conversion via File -> URI, assuming proper characters. * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> - * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI + * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI */ public static URI toURISimple(File file) throws URISyntaxException { - return new URI(FILE_SCHEME, null, encodeToURI(slashify(file.getAbsolutePath(), true, file.isDirectory())), null); + return new URI(FILE_SCHEME, null, encodeToURI(slashify(file.getAbsolutePath(), true, file.isDirectory())), null); } - - /** - * Using the simple conversion via File -> URI, assuming proper characters. + + /** + * Using the simple conversion via File -> URI, assuming proper characters. * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> - * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI + * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI */ public static URI toURISimple(String protocol, String file, boolean isDirectory) throws URISyntaxException { - return new URI(protocol, null, encodeToURI(slashify(file, true, isDirectory)), null); + return new URI(protocol, null, encodeToURI(slashify(file, true, isDirectory)), null); } /** @@ -364,14 +364,14 @@ public class IOUtil { return arg.toLowerCase(); } - + /*** * @param file * @param allowOverwrite * @return outputStream The resulting output stream - * @throws IOException if the file already exists and <code>allowOverwrite</code> is false, + * @throws IOException if the file already exists and <code>allowOverwrite</code> is false, * the class {@link java.io.FileOutputStream} is not accessible or - * the user does not have sufficient rights to access the local filesystem. + * the user does not have sufficient rights to access the local filesystem. */ public static FileOutputStream getFileOutputStream(File file, boolean allowOverwrite) throws IOException { final Constructor<?> fosCtor = getFOSCtor(); @@ -387,14 +387,14 @@ public class IOUtil { throw new IOException("error opening " + file + " for write. ", e); } } - + public static String getClassFileName(String clazzBinName) { - // or return clazzBinName.replace('.', File.separatorChar) + ".class"; ? - return clazzBinName.replace('.', '/') + ".class"; + // or return clazzBinName.replace('.', File.separatorChar) + ".class"; ? + return clazzBinName.replace('.', '/') + ".class"; } - + /** - * @param clazzBinName com.jogamp.common.util.cache.TempJarCache + * @param clazzBinName com.jogamp.common.util.cache.TempJarCache * @param cl ClassLoader to locate the JarFile * @return jar:file:/usr/local/projects/JOGL/gluegen/build-x86_64/gluegen-rt.jar!/com/jogamp/common/util/cache/TempJarCache.class * @throws IOException if the jar file could not been found by the ClassLoader @@ -406,7 +406,7 @@ public class IOUtil { } return url; } - + /** * Returns the basename of the given fname w/o directory part * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> @@ -419,7 +419,7 @@ public class IOUtil { } return fname; } - + /** * Returns unified '/' dirname including the last '/' * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> @@ -432,22 +432,22 @@ public class IOUtil { } return fname; } - + /** * The URI's <code><i>protocol</i>:/some/path/gluegen-rt.jar</code> * parent dirname URI <code><i>protocol</i>:/some/path/</code> will be returned. * <p> * <i>protocol</i> may be "file", "http", etc.. * </p> - * + * * @param uri "<i>protocol</i>:/some/path/gluegen-rt.jar" * @return "<i>protocol</i>:/some/path/" * @throws IllegalArgumentException if the URI doesn't match the expected formatting, or is null - * @throws URISyntaxException + * @throws URISyntaxException */ public static URI getURIDirname(URI uri) throws IllegalArgumentException, URISyntaxException { if(null == uri) { - throw new IllegalArgumentException("URI is null"); + throw new IllegalArgumentException("URI is null"); } String uriS = uri.toString(); if( DEBUG ) { @@ -455,24 +455,24 @@ public class IOUtil { } return new URI( getURIDirname(uriS) ); } - + /** * The URI's <code><i>protocol</i>:/some/path/gluegen-rt.jar</code> * parent dirname URI <code><i>protocol</i>:/some/path/</code> will be returned. * <p> * <i>protocol</i> may be "file", "http", etc.. * </p> - * + * * @param uri "<i>protocol</i>:/some/path/gluegen-rt.jar" (URI encoded) * @return "<i>protocol</i>:/some/path/" * @throws IllegalArgumentException if the URI doesn't match the expected formatting, or is null - * @throws URISyntaxException + * @throws URISyntaxException */ public static String getURIDirname(String uriS) throws IllegalArgumentException, URISyntaxException { if(null == uriS) { - throw new IllegalArgumentException("uriS is null"); + throw new IllegalArgumentException("uriS is null"); } - // from + // from // file:/some/path/gluegen-rt.jar _or_ rsrc:gluegen-rt.jar // to // file:/some/path/ _or_ rsrc: @@ -484,15 +484,15 @@ public class IOUtil { throw new IllegalArgumentException("URI does not contain protocol terminator ':', in <"+uriS+">"); } } - uriS = uriS.substring(0, idx+1); // exclude jar name, include terminal '/' or ':' - + uriS = uriS.substring(0, idx+1); // exclude jar name, include terminal '/' or ':' + if( DEBUG ) { System.out.println("getJarURIDirname res: "+uriS); - } + } return uriS; } - - /** + + /** * Converts an {@link URI} to an {@link URL} while using a non encoded path * for <i>file scheme</i>, i.e. <code>file:/</code>. * Otherwise the default {@link URL} translation {@link URI#toURL()} is being used. @@ -551,18 +551,18 @@ public class IOUtil { } return url; } - + /*** - * + * * RESOURCE LOCATION STUFF - * + * */ - + /** * Locating a resource using {@link #getResource(String, ClassLoader)}: * <ul> - * <li><i>relative</i>: <code>context</code>'s package name-path plus <code>resourcePath</code> via <code>context</code>'s ClassLoader. - * This allows locations relative to JAR- and other URLs. + * <li><i>relative</i>: <code>context</code>'s package name-path plus <code>resourcePath</code> via <code>context</code>'s ClassLoader. + * This allows locations relative to JAR- and other URLs. * The <code>resourcePath</code> may start with <code>../</code> to navigate to parent folder.</li> * <li><i>absolute</i>: <code>context</code>'s ClassLoader and the <code>resourcePath</code> as is (filesystem)</li> * </ul> @@ -570,7 +570,7 @@ public class IOUtil { * <p> * Returns the resolved and open URLConnection or null if not found. * </p> - * + * * @see #getResource(String, ClassLoader) * @see ClassLoader#getResource(String) * @see ClassLoader#getSystemResource(String) @@ -578,11 +578,11 @@ public class IOUtil { public static URLConnection getResource(Class<?> context, String resourcePath) { if(null == resourcePath) { return null; - } + } ClassLoader contextCL = (null!=context)?context.getClassLoader():IOUtil.class.getClassLoader(); URLConnection conn = null; if(null != context) { - // scoping the path within the class's package + // scoping the path within the class's package final String className = context.getName().replace('.', '/'); final int lastSlash = className.lastIndexOf('/'); if (lastSlash >= 0) { @@ -647,7 +647,7 @@ public class IOUtil { /** * Generates a path for the 'relativeFile' relative to the 'baseLocation'. - * + * * @param baseLocation denotes a directory * @param relativeFile denotes a relative file to the baseLocation * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> @@ -656,7 +656,7 @@ public class IOUtil { if(null == relativeFile) { return null; } - + if (baseLocation != null) { final File file = new File(baseLocation, relativeFile); // Handle things on Windows @@ -668,14 +668,14 @@ public class IOUtil { /** * @param path assuming a slashified path beginning with "/" as it's root directory, either denotes a file or directory. * @return parent of path - * @throws URISyntaxException if path is empty or has no parent directory available + * @throws URISyntaxException if path is empty or has no parent directory available */ public static String getParentOf(String path) throws URISyntaxException { final int pl = null!=path ? path.length() : 0; if(pl == 0) { throw new IllegalArgumentException("path is empty <"+path+">"); } - + final int e = path.lastIndexOf("/"); if( e < 0 ) { throw new URISyntaxException(path, "path contains no '/'"); @@ -688,7 +688,7 @@ public class IOUtil { // path is file, return it's parent directory return path.substring(0, e+1); } - final int j = path.lastIndexOf("!") + 1; // '!' Separates JARFile entry -> local start of path + final int j = path.lastIndexOf("!") + 1; // '!' Separates JARFile entry -> local start of path // path is a directory .. final int p = path.lastIndexOf("/", e-1); if( p >= j) { @@ -696,10 +696,10 @@ public class IOUtil { } throw new URISyntaxException(path, "parent of path contains no '/'"); } - + /** * @param path assuming a slashified path beginning with "/" as it's root directory, either denotes a file or directory. - * @return clean path string where <code>../</code> and <code>./</code> is resolved. + * @return clean path string where <code>../</code> and <code>./</code> is resolved. * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> */ public static String cleanPathString(String path) throws URISyntaxException { @@ -712,47 +712,47 @@ public class IOUtil { } return path; } - + /** * Generates a URI for the <i>relativePath</i> relative to the <i>baseURI</i>, * hence the result is a absolute location. * <p> - * Impl. operates on the <i>scheme-specific-part</i>, and hence is sub-protocol savvy. + * Impl. operates on the <i>scheme-specific-part</i>, and hence is sub-protocol savvy. * </p> * <p> - * In case <i>baseURI</i> is not a path ending w/ '/', it's a assumed to be a file and it's parent is being used. + * In case <i>baseURI</i> is not a path ending w/ '/', it's a assumed to be a file and it's parent is being used. * </p> - * + * * @param baseURI denotes a URI to a directory ending w/ '/', or a file. In the latter case the file's directory is being used. * @param relativePath denotes a relative file to the baseLocation's parent directory * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> */ - public static URI getRelativeOf(URI baseURI, String relativePath) throws URISyntaxException { + public static URI getRelativeOf(URI baseURI, String relativePath) throws URISyntaxException { return compose(baseURI.getScheme(), baseURI.getSchemeSpecificPart(), encodeToURI(relativePath), baseURI.getFragment()); } - + /** * Wraps {@link #getRelativeOf(URI, String)} for convenience. * @throws IOException */ - public static URL getRelativeOf(URL baseURL, String relativePath) throws IOException { + public static URL getRelativeOf(URL baseURL, String relativePath) throws IOException { try { return getRelativeOf(baseURL.toURI(), relativePath).toURL(); } catch (URISyntaxException e) { throw new IOException(e); } } - + /** * Generates a URI for the <i>relativePath</i> relative to the <i>schemeSpecificPart</i>, * hence the result is a absolute location. * <p> - * <i>schemeSpecificPart</i>'s query, if exist is split to <i>path</i> and <i>query</i>. + * <i>schemeSpecificPart</i>'s query, if exist is split to <i>path</i> and <i>query</i>. * </p> * <p> - * In case <i>path</i> is not a path ending w/ '/', it's a assumed to be a file and it's parent is being used. + * In case <i>path</i> is not a path ending w/ '/', it's a assumed to be a file and it's parent is being used. * </p> - * + * * @param scheme scheme of the resulting URI * @param schemeSpecificPart may include a query, which is separated while processing (URI encoded) * @param relativePath denotes a relative file to the baseLocation's parent directory (URI encoded) @@ -778,12 +778,12 @@ public class IOUtil { } schemeSpecificPart = cleanPathString( schemeSpecificPart ); return new URI(scheme, null == query ? schemeSpecificPart : schemeSpecificPart + "?" + query, fragment); - } - + } + private static final Pattern patternSpaceRaw = Pattern.compile(" "); private static final Pattern patternSpaceEnc = Pattern.compile("%20"); - - /** + + /** * Escapes characters not complying w/ RFC 2396 and the {@link URI#URI(String)} ctor. * <ul> * <li>SPACE -> %20</li> @@ -792,21 +792,21 @@ public class IOUtil { public static String encodeToURI(String s) { return patternSpaceRaw.matcher(s).replaceAll("%20"); } - - /** + + /** * Reverses escaping of characters as performed via {@link #encodeToURI(String)}. */ public static String decodeFromURI(String s) { return patternSpaceEnc.matcher(s).replaceAll(" "); } - + /** * Returns the connected URLConnection, or null if not url is not available */ public static URLConnection openURL(URL url) { return openURL(url, "."); } - + /** * Returns the connected URLConnection, or null if not url is not available */ @@ -819,19 +819,19 @@ public class IOUtil { System.err.println("IOUtil: urlExists("+url+") ["+dbgmsg+"] - true"); } return c; - } catch (IOException ioe) { + } catch (IOException ioe) { if(DEBUG) { System.err.println("IOUtil: urlExists("+url+") ["+dbgmsg+"] - false - "+ioe.getClass().getSimpleName()+": "+ioe.getMessage()); ioe.printStackTrace(); - } + } } } else if(DEBUG) { System.err.println("IOUtil: no url - urlExists(null) ["+dbgmsg+"]"); - } - + } + return null; } - + private static String getShellSuffix() { switch(PlatformPropsImpl.OS_TYPE) { case WINDOWS: @@ -840,18 +840,18 @@ public class IOUtil { return ".sh"; } } - + private static boolean getOSHasNoexecFS() { switch(PlatformPropsImpl.OS_TYPE) { case WINDOWS: case OPENKODE: return false; - + default: return true; } } - + /** * @see <a href="http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html">Free-Desktop - XDG Base Directory Specification</a> */ @@ -862,26 +862,26 @@ public class IOUtil { case WINDOWS: case OPENKODE: return false; - + default: return true; } } - + /** * Test whether {@code file} exists and matches the given requirements - * + * * @param file * @param shallBeDir * @param shallBeWritable * @return */ - public static boolean testFile(File file, boolean shallBeDir, boolean shallBeWritable) { + public static boolean testFile(File file, boolean shallBeDir, boolean shallBeWritable) { if (!file.exists()) { if(DEBUG) { System.err.println("IOUtil.testFile: <"+file.getAbsolutePath()+">: does not exist"); } - return false; + return false; } if (shallBeDir && !file.isDirectory()) { if(DEBUG) { @@ -893,7 +893,7 @@ public class IOUtil { if(DEBUG) { System.err.println("IOUtil.testFile: <"+file.getAbsolutePath()+">: is not writable"); } - return false; + return false; } return true; } @@ -904,9 +904,9 @@ public class IOUtil { * <li>exists, and</li> * <li>is a directory, and</li> * <li>is writeable, and</li> - * <li>files can be executed from the directory</li> + * <li>files can be executed from the directory</li> * </ol> - * + * * @throws SecurityException if file creation and process execution is not allowed within the current security context * @param dir */ @@ -914,12 +914,12 @@ public class IOUtil { throws SecurityException { if (!testFile(dir, true, true)) { - return false; + return false; } if(!getOSHasNoexecFS()) { return true; } - + File exetst; try { exetst = File.createTempFile("jogamp_exe_tst", getShellSuffix(), dir); @@ -951,31 +951,31 @@ public class IOUtil { return 0 == ok; } - private static File testDirImpl(File dir, boolean create, boolean executable) + private static File testDirImpl(File dir, boolean create, boolean executable) throws SecurityException { if (create && !dir.exists()) { - dir.mkdirs(); + dir.mkdirs(); } if( executable ) { if(testDirExec(dir)) { return dir; } } else if(testFile(dir, true, true)) { - return dir; + return dir; } return null; } - + /** * Returns the directory {@code dir}, which is processed and tested as described below. * <ol> * <li>If {@code create} is {@code true} and the directory does not exist yet, it is created incl. all sub-directories.</li> * <li>If {@code dirName} exists, but is not a directory, {@code null} is being returned.</li> * <li>If the directory does not exist or is not writeable, {@code null} is being returned.</li> - * <li>If {@code executable} is {@code true} and files cannot be executed from the directory, {@code null} is being returned.</li> + * <li>If {@code executable} is {@code true} and files cannot be executed from the directory, {@code null} is being returned.</li> * </ol> - * + * * @param dir the directory to process * @param create true if the directory shall be created if not existing * @param executable true if the user intents to launch executables from the temporary directory, otherwise false. @@ -985,14 +985,14 @@ public class IOUtil { throws SecurityException { return testDirImpl(dir, create, executable); - } - - private static boolean isStringSet(String s) { return null != s && 0 < s.length(); } - + } + + private static boolean isStringSet(String s) { return null != s && 0 < s.length(); } + /** * This methods finds [and creates] an available temporary sub-directory: * <pre> - File tmpBaseDir = null; + File tmpBaseDir = null; if(null != testDir(tmpRoot, true, executable)) { // check tmpRoot first for(int i = 0; null == tmpBaseDir && i<=9999; i++) { final String tmpDirSuffix = String.format("_%04d", i); // 4 digits for iteration @@ -1015,7 +1015,7 @@ public class IOUtil { private static File getSubTempDir(File tmpRoot, String tmpSubDirPrefix, boolean executable) throws SecurityException { - File tmpBaseDir = null; + File tmpBaseDir = null; if(null != testDirImpl(tmpRoot, true /* create */, executable)) { // check tmpRoot first for(int i = 0; null == tmpBaseDir && i<=9999; i++) { final String tmpDirSuffix = String.format("_%04d", i); // 4 digits for iteration @@ -1024,16 +1024,16 @@ public class IOUtil { } return tmpBaseDir; } - + /** * Returns a platform independent writable directory for temporary files - * consisting of the platform's {@code temp-root} + {@link #tmpSubDir}, - * e.g. {@code /tmp/jogamp_0000/}. + * consisting of the platform's {@code temp-root} + {@link #tmpSubDir}, + * e.g. {@code /tmp/jogamp_0000/}. * <p> * On standard Java the {@code temp-root} folder is specified by <code>java.io.tempdir</code>. - * </p> + * </p> * <p> - * On Android the {@code temp-root} folder is relative to the applications local folder + * On Android the {@code temp-root} folder is relative to the applications local folder * (see {@link Context#getDir(String, int)}) is returned, if * the Android application/activity has registered it's Application Context * via {@link jogamp.common.os.android.StaticContext.StaticContext#init(Context, ClassLoader) StaticContext.init(..)}. @@ -1042,12 +1042,12 @@ public class IOUtil { * </p> * <p> * In case {@code temp-root} is the users home folder, - * a dot is being prepended to {@link #tmpSubDir}, i.e.: {@code /home/user/.jogamp_0000/}. + * a dot is being prepended to {@link #tmpSubDir}, i.e.: {@code /home/user/.jogamp_0000/}. * </p> * @param executable true if the user intents to launch executables from the temporary directory, otherwise false. * @throws RuntimeException if no temporary directory could be determined * @throws SecurityException if access to <code>java.io.tmpdir</code> is not allowed within the current security context - * + * * @see PropertyAccess#getProperty(String, boolean) * @see Context#getDir(String, int) */ @@ -1066,40 +1066,40 @@ public class IOUtil { return tempRootExec; } } - + final String java_io_tmpdir = PropertyAccess.getProperty(java_io_tmpdir_propkey, false); final String user_home = PropertyAccess.getProperty(user_home_propkey, false); - + final String xdg_cache_home; { String _xdg_cache_home; - if( getOSHasFreeDesktopXDG() ) { + if( getOSHasFreeDesktopXDG() ) { _xdg_cache_home = System.getenv(XDG_CACHE_HOME_envkey); if( !isStringSet(_xdg_cache_home) && isStringSet(user_home) ) { _xdg_cache_home = user_home + File.separator + ".cache" ; // default - } + } } else { _xdg_cache_home = null; } xdg_cache_home = _xdg_cache_home; } - + // 1) java.io.tmpdir/jogamp if( null == tempRootExec && isStringSet(java_io_tmpdir) ) { tempRootExec = getSubTempDir(new File(java_io_tmpdir), tmpSubDir, true /* executable */); } - + // 2) $XDG_CACHE_HOME/jogamp if(null == tempRootExec && isStringSet(xdg_cache_home)) { - tempRootExec = getSubTempDir(new File(xdg_cache_home), tmpSubDir, true /* executable */); + tempRootExec = getSubTempDir(new File(xdg_cache_home), tmpSubDir, true /* executable */); } - + // 3) $HOME/.jogamp - if(null == tempRootExec && isStringSet(user_home)) { + if(null == tempRootExec && isStringSet(user_home)) { tempRootExec = getSubTempDir(new File(user_home), "." + tmpSubDir, true /* executable */); - } - - + } + + if(null != tempRootExec) { tempRootNoexec = tempRootExec; } else { @@ -1107,18 +1107,18 @@ public class IOUtil { if( null == tempRootNoexec && isStringSet(java_io_tmpdir) ) { tempRootNoexec = getSubTempDir(new File(java_io_tmpdir), tmpSubDir, false /* executable */); } - + // 2) $XDG_CACHE_HOME/jogamp if(null == tempRootNoexec && isStringSet(xdg_cache_home)) { - tempRootNoexec = getSubTempDir(new File(xdg_cache_home), tmpSubDir, false /* executable */); + tempRootNoexec = getSubTempDir(new File(xdg_cache_home), tmpSubDir, false /* executable */); } - + // 3) $HOME/.jogamp - if(null == tempRootNoexec && isStringSet(user_home)) { + if(null == tempRootNoexec && isStringSet(user_home)) { tempRootNoexec = getSubTempDir(new File(user_home), "." + tmpSubDir, false /* executable */); - } + } } - + if(DEBUG) { System.err.println("IOUtil.getTempRoot(): temp dirs: exec: "+tempRootExec.getAbsolutePath()+", noexec: "+tempRootNoexec.getAbsolutePath()); } @@ -1136,16 +1136,16 @@ public class IOUtil { private static File tempRootExec = null; // writeable and executable private static File tempRootNoexec = null; // writeable, maybe executable private static volatile boolean tempRootSet = false; - + /** * Utilizing {@link File#createTempFile(String, String, File)} using - * {@link #getTempDir(boolean)} as the directory parameter, ie. location + * {@link #getTempDir(boolean)} as the directory parameter, ie. location * of the root temp folder. - * + * * @see File#createTempFile(String, String) * @see File#createTempFile(String, String, File) * @see #getTempDir(boolean) - * + * * @param prefix * @param suffix * @param executable true if the temporary root folder needs to hold executable files, otherwise false. @@ -1154,9 +1154,9 @@ public class IOUtil { * @throws IOException * @throws SecurityException */ - public static File createTempFile(String prefix, String suffix, boolean executable) - throws IllegalArgumentException, IOException, SecurityException - { + public static File createTempFile(String prefix, String suffix, boolean executable) + throws IllegalArgumentException, IOException, SecurityException + { return File.createTempFile( prefix, suffix, getTempDir(executable) ); } @@ -1172,6 +1172,6 @@ public class IOUtil { e.printStackTrace(); } } - } + } } } diff --git a/src/java/com/jogamp/common/util/IntBitfield.java b/src/java/com/jogamp/common/util/IntBitfield.java index ad27dff..07b24dc 100644 --- a/src/java/com/jogamp/common/util/IntBitfield.java +++ b/src/java/com/jogamp/common/util/IntBitfield.java @@ -29,24 +29,24 @@ package com.jogamp.common.util; /** * Simple bitfield holder class using an int[] storage. - * <p> + * <p> * IntBitfield allows convenient access of a wide field of transient bits using efficient storage in O(1). * </p> * <p> * It can be used e.g. to map key-codes to pressed-state etc. - * </p> + * </p> */ public class IntBitfield { /** Unit size in bits, here 32 bits for one int unit. */ public static final int UNIT_SIZE = 32; - + private static final long UNIT_SHIFT_L = 5L; private static final int UNIT_SHIFT_I = 5; - + private final int[] storage; private final long bitsCountL; private final int bitsCountI; - + /** * @param bitCount */ @@ -54,9 +54,9 @@ public class IntBitfield { final int units = (int) ( ( bitCount + 7L ) >> UNIT_SHIFT_L ); this.storage = new int[units]; this.bitsCountL = (long)units << UNIT_SHIFT_L ; - this.bitsCountI = bitsCountL > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)bitsCountL; + this.bitsCountI = bitsCountL > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int)bitsCountL; } - + /** * @param bitCount */ @@ -66,7 +66,7 @@ public class IntBitfield { this.bitsCountI = units << UNIT_SHIFT_I; this.bitsCountL = bitsCountI; } - + private final void check(long bitnum) { if( 0 > bitnum || bitnum >= bitsCountL ) { throw new ArrayIndexOutOfBoundsException("Bitnum should be within [0.."+(bitsCountL-1)+"], but is "+bitnum); @@ -77,10 +77,10 @@ public class IntBitfield { throw new ArrayIndexOutOfBoundsException("Bitnum should be within [0.."+(bitsCountI-1)+"], but is "+bitnum); } } - + /** Return the capacity of this bit field, i.e. the number of bits stored int this field. */ public final long capacity() { return bitsCountL; } - + /** Return <code>true</code> if the bit at position <code>bitnum</code> is set, otherwise <code>false</code>. */ public final boolean get(long bitnum) { check(bitnum); @@ -88,7 +88,7 @@ public class IntBitfield { final int b = (int) ( bitnum - ( (long)u << UNIT_SHIFT_L ) ); return 0 != ( storage[u] & ( 1 << b ) ) ; } - + /** Return <code>true</code> if the bit at position <code>bitnum</code> is set, otherwise <code>false</code>. */ public final boolean get(int bitnum) { check(bitnum); @@ -96,12 +96,12 @@ public class IntBitfield { final int b = bitnum - ( u << UNIT_SHIFT_I ); return 0 != ( storage[u] & ( 1 << b ) ) ; } - - /** + + /** * Set or clear the bit at position <code>bitnum</code> according to <code>bit</code> - * and return the previous value. + * and return the previous value. */ - public final boolean put(long bitnum, boolean bit) { + public final boolean put(long bitnum, boolean bit) { check(bitnum); final int u = (int) ( bitnum >> UNIT_SHIFT_L ); final int b = (int) ( bitnum - ( (long)u << UNIT_SHIFT_L ) ); @@ -116,12 +116,12 @@ public class IntBitfield { } return prev; } - - /** + + /** * Set or clear the bit at position <code>bitnum</code> according to <code>bit</code> - * and return the previous value. + * and return the previous value. */ - public final boolean put(int bitnum, boolean bit) { + public final boolean put(int bitnum, boolean bit) { check(bitnum); final int u = bitnum >> UNIT_SHIFT_I; final int b = bitnum - ( u << UNIT_SHIFT_I ); @@ -151,8 +151,8 @@ public class IntBitfield { c -= (n >> 2) & 011111111111; return ( (c + ( c >> 3 ) ) & 030707070707 ) % 63; } - - /** + + /** * Returns the number of set bits within this bitfield. */ public long getBitCount() { diff --git a/src/java/com/jogamp/common/util/IntIntHashMap.java b/src/java/com/jogamp/common/util/IntIntHashMap.java index 7909478..06b9a3f 100644 --- a/src/java/com/jogamp/common/util/IntIntHashMap.java +++ b/src/java/com/jogamp/common/util/IntIntHashMap.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + /** * Created on Sunday, March 28 2010 21:01 */ @@ -52,14 +52,14 @@ import java.util.Iterator; * @author Michael Bien * @author Simon Goller * @author Sven Gothel - * + * * @see IntObjectHashMap * @see IntLongHashMap * @see LongObjectHashMap * @see LongLongHashMap * @see LongIntHashMap */ -public class /*name*/IntIntHashMap/*name*/ implements Cloneable, +public class /*name*/IntIntHashMap/*name*/ implements Cloneable, Iterable< /*name*/IntIntHashMap/*name*/.Entry > { private final float loadFactor; @@ -70,34 +70,34 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, private int capacity; private int threshold; private /*value*/int/*value*/ keyNotFoundValue = /*null*/-1/*null*/; - + private static final boolean isPrimitive; private static final Constructor</*name*/IntIntHashMap/*name*/.Entry> entryConstructor; private static final Method equalsMethod; - + static class EntryCM { EntryCM() { c = null; m1 = null; } Constructor<Entry> c; Method m1; }; - + static { final Class<?> valueClazz = /*value*/int/*value*/.class; final Class<?> keyClazz = /*key*/int/*key*/.class; - + isPrimitive = valueClazz.isPrimitive(); - + if(!isPrimitive) { final EntryCM cm = AccessController.doPrivileged(new PrivilegedAction<EntryCM>() { @SuppressWarnings("unchecked") public EntryCM run() { EntryCM r = new EntryCM(); - r.c = (Constructor<Entry>) - ReflectionUtil.getConstructor(Entry.class, + r.c = (Constructor<Entry>) + ReflectionUtil.getConstructor(Entry.class, new Class[] { keyClazz, valueClazz, Entry.class } ); try { r.m1 = valueClazz.getDeclaredMethod("equals", Object.class); - } catch (NoSuchMethodException ex) { + } catch (NoSuchMethodException ex) { throw new JogampRuntimeException("Class "+valueClazz+" doesn't support equals(Object)"); } - return r; - } } ); + return r; + } } ); entryConstructor = cm.c; equalsMethod = cm.m1; } else { @@ -105,7 +105,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, equalsMethod = null; } } - + public /*name*/IntIntHashMap/*name*/() { this(16, 0.75f); } @@ -135,32 +135,32 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, } private /*name*/IntIntHashMap/*name*/(float loadFactor, int table_size, int size, - int mask, int capacity, int threshold, + int mask, int capacity, int threshold, /*value*/int/*value*/ keyNotFoundValue) { this.loadFactor = loadFactor; this.table = new Entry[table_size]; this.size = size; - + this.mask = mask; this.capacity = capacity; this.threshold = threshold; - - this.keyNotFoundValue = keyNotFoundValue; + + this.keyNotFoundValue = keyNotFoundValue; } - + /** * Disclaimer: If the value type doesn't implement {@link Object#clone() clone()}, only the reference is copied. * Note: Due to private fields we cannot implement a copy constructor, sorry. - * + * * @param source the primitive hash map to copy */ @Override public Object clone() { - /*name*/IntIntHashMap/*name*/ n = - new /*name*/IntIntHashMap/*name*/(loadFactor, table.length, size, - mask, capacity, threshold, + /*name*/IntIntHashMap/*name*/ n = + new /*name*/IntIntHashMap/*name*/(loadFactor, table.length, size, + mask, capacity, threshold, keyNotFoundValue); - + for(int i=table.length-1; i>=0; i--) { // single linked list -> ArrayList final ArrayList<Entry> entries = new ArrayList<Entry>(); @@ -182,10 +182,10 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, } // 1st elem of linked list is table entry n.table[i] = de_next; - } + } return n; } - + public boolean containsValue(/*value*/int/*value*/ value) { Entry[] t = this.table; for (int i = t.length; i-- > 0;) { @@ -196,9 +196,9 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, } } else { final Boolean b = (Boolean) ReflectionUtil.callMethod(value, equalsMethod, e.value); - if(b.booleanValue()) { + if(b.booleanValue()) { return true; - } + } } } } @@ -299,7 +299,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, final int index = /*keyHash*/key/*keyHash*/ & mask; Entry prev = t[index]; Entry e = prev; - + while (e != null) { Entry next = e.next; if (e.key == key) { @@ -355,7 +355,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, * * @return the previous key not found value * @see #get - * @see #put + * @see #put */ public /*value*/int/*value*/ setKeyNotFoundValue(/*value*/int/*value*/ newKeyNotFoundValue) { /*value*/int/*value*/ t = keyNotFoundValue; @@ -391,19 +391,19 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, sb.append("}"); return sb; } - + @Override public String toString() { return toString(null).toString(); } - + private final static class EntryIterator implements Iterator<Entry> { private final Entry[] entries; - + private int index; private Entry next; - + private EntryIterator(Entry[] entries){ this.entries = entries; // load next @@ -439,9 +439,9 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, public void remove() { throw new UnsupportedOperationException("Not supported yet."); } - + } - + /** * An entry mapping a key to a value. */ @@ -449,7 +449,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, public final /*key*/int/*key*/ key; public /*value*/int/*value*/ value; - + private Entry next; Entry(/*key*/int/*key*/ k, /*value*/int/*value*/ v, Entry n) { @@ -457,7 +457,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, value = v; next = n; } - + /** * Returns the key of this entry. */ @@ -490,21 +490,21 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, sb.append("[").append(key).append(":").append(value).append("]"); return sb; } - + @Override public String toString() { return toString(null).toString(); } } - + private static Method getCloneMethod(Object obj) { final Class<?> clazz = obj.getClass(); return AccessController.doPrivileged(new PrivilegedAction<Method>() { public Method run() { try { return clazz.getDeclaredMethod("clone"); - } catch (NoSuchMethodException ex) { + } catch (NoSuchMethodException ex) { throw new JogampRuntimeException("Class "+clazz+" doesn't support clone()", ex); } } } ); diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java index 29e7dc7..1689d54 100644 --- a/src/java/com/jogamp/common/util/JarUtil.java +++ b/src/java/com/jogamp/common/util/JarUtil.java @@ -54,17 +54,17 @@ public class JarUtil { private static final boolean DEBUG = Debug.debug("JarUtil"); private static final int BUFFER_SIZE = 4096; - + /** * Interface allowing users to provide an URL resolver that will convert custom classloader * URLs like Eclipse/OSGi <i>bundleresource:</i> URLs to normal <i>jar:</i> URLs. - * <p> + * <p> * This might be required for custom classloader where the URI protocol is unknown - * to the standard runtime environment. + * to the standard runtime environment. * </p> * <p> * Note: The provided resolver is only utilized if a given URI's protocol could not be resolved. - * I.e. it will not be invoked for known protocols like <i>http</i>, <i>https</i>, <i>jar</i> or <i>file</i>. + * I.e. it will not be invoked for known protocols like <i>http</i>, <i>https</i>, <i>jar</i> or <i>file</i>. * </p> */ public interface Resolver { @@ -72,15 +72,15 @@ public class JarUtil { } private static Resolver resolver; - + /** * Setting a custom {@link Resolver} instance. - * + * * @param r {@link Resolver} to use after querying class file URLs from the classloader. * @throws IllegalArgumentException if the passed resolver is <code>null</code> * @throws IllegalStateException if the resolver has already been set. * @throws SecurityException if the security manager doesn't have the setFactory - * permission + * permission */ public static void setResolver(Resolver r) throws IllegalArgumentException, IllegalStateException, SecurityException { if(r == null) { @@ -101,13 +101,13 @@ public class JarUtil { /** * Returns <code>true</code> if the Class's <code>"com.jogamp.common.GlueGenVersion"</code> - * is loaded from a JarFile and hence has a Jar URI like + * is loaded from a JarFile and hence has a Jar URI like * URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"</code>. * <p> * <i>sub_protocol</i> may be "file", "http", etc.. * </p> - * - * @param clazzBinName "com.jogamp.common.GlueGenVersion" + * + * @param clazzBinName "com.jogamp.common.GlueGenVersion" * @param cl * @return true if the class is loaded from a Jar file, otherwise false. * @see {@link #getJarURI(String, ClassLoader)} @@ -118,20 +118,20 @@ public class JarUtil { } catch (Exception e) { /* ignore */ } return false; } - + /** - * The Class's <code>"com.jogamp.common.GlueGenVersion"</code> + * The Class's <code>"com.jogamp.common.GlueGenVersion"</code> * URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"</code> * will be returned. * <p> * <i>sub_protocol</i> may be "file", "http", etc.. * </p> - * - * @param clazzBinName "com.jogamp.common.GlueGenVersion" + * + * @param clazzBinName "com.jogamp.common.GlueGenVersion" * @param cl ClassLoader to locate the JarFile * @return "jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class" * @throws IllegalArgumentException if the URI doesn't match the expected formatting or null arguments - * @throws IOException if the class's Jar file could not been found by the ClassLoader + * @throws IOException if the class's Jar file could not been found by the ClassLoader * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ @@ -148,7 +148,7 @@ public class JarUtil { !scheme.equals( IOUtil.JAR_SCHEME ) && !scheme.equals( IOUtil.FILE_SCHEME ) && !scheme.equals( IOUtil.HTTP_SCHEME ) && - !scheme.equals( IOUtil.HTTPS_SCHEME ) ) + !scheme.equals( IOUtil.HTTPS_SCHEME ) ) { final URL _url = resolver.resolve( url ); uri = _url.toURI(); @@ -171,19 +171,19 @@ public class JarUtil { } return uri; } - - + + /** * The Class's Jar URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code> * Jar basename <code>gluegen-rt.jar</code> will be returned. * <p> * <i>sub_protocol</i> may be "file", "http", etc.. * </p> - * - * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()}, + * + * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()}, * i.e. <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code> * @return <code>gluegen-rt.jar</code> - * @throws IllegalArgumentException if the URI doesn't match the expected formatting or is null + * @throws IllegalArgumentException if the URI doesn't match the expected formatting or is null * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ public static String getJarBasename(URI classJarURI) throws IllegalArgumentException { @@ -194,19 +194,19 @@ public class JarUtil { throw new IllegalArgumentException("URI is not using scheme "+IOUtil.JAR_SCHEME+": <"+classJarURI+">"); } String uriS = classJarURI.getSchemeSpecificPart(); - - // from + + // from // file:/some/path/gluegen-rt.jar!/com/jogamp/common/util/cache/TempJarCache.class // to // file:/some/path/gluegen-rt.jar int idx = uriS.lastIndexOf('!'); if (0 <= idx) { - uriS = uriS.substring(0, idx); // exclude '!/' + uriS = uriS.substring(0, idx); // exclude '!/' } else { throw new IllegalArgumentException("JAR URI does not contain jar uri terminator '!', in <"+classJarURI+">"); } - - // from + + // from // file:/some/path/gluegen-rt.jar // to // gluegen-rt.jar @@ -219,10 +219,10 @@ public class JarUtil { } } uriS = uriS.substring(idx+1); // just the jar name - + if(0 >= uriS.lastIndexOf(".jar")) { throw new IllegalArgumentException("No Jar name in <"+classJarURI+">"); - } + } if(DEBUG) { System.out.println("getJarName res: "+uriS); } @@ -230,17 +230,17 @@ public class JarUtil { } /** - * The Class's <code>com.jogamp.common.GlueGenVersion</code> + * The Class's <code>com.jogamp.common.GlueGenVersion</code> * URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code> * Jar basename <code>gluegen-rt.jar</code> will be returned. * <p> * <i>sub_protocol</i> may be "file", "http", etc.. * </p> - * + * * @param clazzBinName <code>com.jogamp.common.GlueGenVersion</code> * @param cl * @return <code>gluegen-rt.jar</code> - * @throws IllegalArgumentException if the URI doesn't match the expected formatting + * @throws IllegalArgumentException if the URI doesn't match the expected formatting * @throws IOException if the class's Jar file could not been found by the ClassLoader. * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} @@ -248,34 +248,34 @@ public class JarUtil { public static String getJarBasename(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { return getJarBasename( getJarURI(clazzBinName, cl) ); } - + /** * The Class's Jar URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code> * Jar file's sub URI <code><i>sub_protocol</i>:/some/path/gluegen-rt.jar</code> will be returned. * <p> * <i>sub_protocol</i> may be "file", "http", etc.. * </p> - * - * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()}, + * + * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()}, * i.e. <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code> * @return <code><i>sub_protocol</i>:/some/path/gluegen-rt.jar</code> - * @throws IllegalArgumentException if the URI doesn't match the expected formatting or is null + * @throws IllegalArgumentException if the URI doesn't match the expected formatting or is null * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ public static URI getJarSubURI(URI classJarURI) throws IllegalArgumentException, URISyntaxException { if(null == classJarURI) { - throw new IllegalArgumentException("URI is null"); + throw new IllegalArgumentException("URI is null"); } if( !classJarURI.getScheme().equals(IOUtil.JAR_SCHEME) ) { throw new IllegalArgumentException("URI is not a using scheme "+IOUtil.JAR_SCHEME+": <"+classJarURI+">"); } - - // from + + // from // file:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class // to // file:/some/path/gluegen-rt.jar - final String uriS0 = classJarURI.getSchemeSpecificPart(); + final String uriS0 = classJarURI.getSchemeSpecificPart(); int idx = uriS0.lastIndexOf('!'); final String uriS1; if (0 <= idx) { @@ -292,26 +292,26 @@ public class JarUtil { } return new URI(uriS2); } - + /** * The Class's Jar URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code> * Jar file's entry <code>/com/jogamp/common/GlueGenVersion.class</code> will be returned. - * - * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()}, + * + * @param classJarURI as retrieved w/ {@link #getJarURI(String, ClassLoader) getJarURI("com.jogamp.common.GlueGenVersion", cl).toURI()}, * i.e. <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code> * @return <code>/com/jogamp/common/GlueGenVersion.class</code> * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ public static String getJarEntry(URI classJarURI) { if(null == classJarURI) { - throw new IllegalArgumentException("URI is null"); + throw new IllegalArgumentException("URI is null"); } if( !classJarURI.getScheme().equals(IOUtil.JAR_SCHEME) ) { throw new IllegalArgumentException("URI is not a using scheme "+IOUtil.JAR_SCHEME+": <"+classJarURI+">"); } String uriS = classJarURI.getSchemeSpecificPart(); - - // from + + // from // file:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class // to // file:/some/path/gluegen-rt.jar @@ -324,18 +324,18 @@ public class JarUtil { } /** - * The Class's <code>com.jogamp.common.GlueGenVersion</code> + * The Class's <code>com.jogamp.common.GlueGenVersion</code> * URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class</code> * Jar file's sub URI <code><i>sub_protocol</i>:/some/path/gluegen-rt.jar</code> will be returned. * <p> * <i>sub_protocol</i> may be "file", "http", etc.. * </p> - * + * * @param clazzBinName <code>com.jogamp.common.GlueGenVersion</code> * @param cl * @return <code><i>sub_protocol</i>:/some/path/gluegen-rt.jar</code> - * @throws IllegalArgumentException if the URI doesn't match the expected formatting - * @throws IOException if the class's Jar file could not been found by the ClassLoader + * @throws IllegalArgumentException if the URI doesn't match the expected formatting + * @throws IOException if the class's Jar file could not been found by the ClassLoader * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ @@ -344,18 +344,18 @@ public class JarUtil { } /** - * The Class's <code>"com.jogamp.common.GlueGenVersion"</code> + * The Class's <code>"com.jogamp.common.GlueGenVersion"</code> * URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class"</code> * Jar file URI <code>jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/</code> will be returned. * <p> * <i>sub_protocol</i> may be "file", "http", etc.. * </p> - * - * @param clazzBinName "com.jogamp.common.GlueGenVersion" + * + * @param clazzBinName "com.jogamp.common.GlueGenVersion" * @param cl * @return "jar:<i>sub_protocol</i>:/some/path/gluegen-rt.jar!/" - * @throws IllegalArgumentException if the URI doesn't match the expected formatting or null arguments - * @throws IOException if the class's Jar file could not been found by the ClassLoader + * @throws IllegalArgumentException if the URI doesn't match the expected formatting or null arguments + * @throws IOException if the class's Jar file could not been found by the ClassLoader * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ @@ -374,7 +374,7 @@ public class JarUtil { * @param baseUri file:/some/path/ * @param jarFileName gluegen-rt.jar * @return jar:file:/some/path/gluegen-rt.jar!/ - * @throws URISyntaxException + * @throws URISyntaxException * @throws IllegalArgumentException null arguments */ public static URI getJarFileURI(URI baseUri, String jarFileName) throws IllegalArgumentException, URISyntaxException { @@ -383,12 +383,12 @@ public class JarUtil { } return new URI(IOUtil.JAR_SCHEME, baseUri.toString()+jarFileName+"!/", null); } - + /** * @param jarSubUri file:/some/path/gluegen-rt.jar * @return jar:file:/some/path/gluegen-rt.jar!/ * @throws IllegalArgumentException null arguments - * @throws URISyntaxException + * @throws URISyntaxException */ public static URI getJarFileURI(URI jarSubUri) throws IllegalArgumentException, URISyntaxException { if(null == jarSubUri) { @@ -396,12 +396,12 @@ public class JarUtil { } return new URI(IOUtil.JAR_SCHEME, jarSubUri.toString()+"!/", null); } - + /** * @param jarSubUriS file:/some/path/gluegen-rt.jar * @return jar:file:/some/path/gluegen-rt.jar!/ * @throws IllegalArgumentException null arguments - * @throws URISyntaxException + * @throws URISyntaxException */ public static URI getJarFileURI(String jarSubUriS) throws IllegalArgumentException, URISyntaxException { if(null == jarSubUriS) { @@ -409,13 +409,13 @@ public class JarUtil { } return new URI(IOUtil.JAR_SCHEME, jarSubUriS+"!/", null); } - + /** * @param jarFileURI jar:file:/some/path/gluegen-rt.jar!/ * @param jarEntry com/jogamp/common/GlueGenVersion.class * @return jar:file:/some/path/gluegen-rt.jar!/com/jogamp/common/GlueGenVersion.class * @throws IllegalArgumentException null arguments - * @throws URISyntaxException + * @throws URISyntaxException */ public static URI getJarEntryURI(URI jarFileURI, String jarEntry) throws IllegalArgumentException, URISyntaxException { if(null == jarEntry) { @@ -423,12 +423,12 @@ public class JarUtil { } return new URI(jarFileURI.toString()+jarEntry); } - + /** - * @param clazzBinName com.jogamp.common.util.cache.TempJarCache - * @param cl domain + * @param clazzBinName com.jogamp.common.util.cache.TempJarCache + * @param cl domain * @return JarFile containing the named class within the given ClassLoader - * @throws IOException if the class's Jar file could not been found by the ClassLoader + * @throws IOException if the class's Jar file could not been found by the ClassLoader * @throws IllegalArgumentException null arguments * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link #getJarFileURI(String, ClassLoader)} @@ -441,8 +441,8 @@ public class JarUtil { * @param jarFileURI jar:file:/some/path/gluegen-rt.jar!/ * @return JarFile as named by URI within the given ClassLoader * @throws IllegalArgumentException null arguments - * @throws IOException if the Jar file could not been found - * @throws URISyntaxException + * @throws IOException if the Jar file could not been found + * @throws URISyntaxException */ public static JarFile getJarFile(URI jarFileURI) throws IOException, IllegalArgumentException, URISyntaxException { if(null == jarFileURI) { @@ -452,22 +452,22 @@ public class JarUtil { System.out.println("getJarFile: "+jarFileURI.toString()); } final URL jarFileURL = IOUtil.toURL(jarFileURI); - // final URL jarFileURL = jarFileURI.toURL(); // doesn't work due to encoded path even w/ file schema! + // final URL jarFileURL = jarFileURI.toURL(); // doesn't work due to encoded path even w/ file schema! final URLConnection urlc = jarFileURL.openConnection(); if(urlc instanceof JarURLConnection) { JarURLConnection jarConnection = (JarURLConnection)jarFileURL.openConnection(); JarFile jarFile = jarConnection.getJarFile(); if(DEBUG) { System.out.println("getJarFile res: "+jarFile.getName()); - } + } return jarFile; } if(DEBUG) { System.out.println("getJarFile res: NULL"); - } + } return null; } - + /** * Return a map from native-lib-base-name to entry-name. */ @@ -478,12 +478,12 @@ public class JarUtil { final Map<String,String> nameMap = new HashMap<String, String>(); final Enumeration<JarEntry> entries = jarFile.entries(); - + while (entries.hasMoreElements()) { final JarEntry entry = entries.nextElement(); final String entryName = entry.getName(); final String baseName = NativeLibrary.isValidNativeLibraryName(entryName, false); - + if(null != baseName) { nameMap.put(baseName, entryName); } @@ -503,7 +503,7 @@ public class JarUtil { * Root entries are favored over non root entries in case of naming collisions.<br> * Example on a Unix like machine:<br> * <pre> - * mylib.jar!/sub1/libsour.so -> sour (mapped, unique name) + * mylib.jar!/sub1/libsour.so -> sour (mapped, unique name) * mylib.jar!/sub1/libsweet.so (dropped, root entry favored) * mylib.jar!/libsweet.so -> sweet (mapped, root entry favored) * mylib.jar!/sweet.dll -> (dropped, not a unix library name) @@ -515,11 +515,11 @@ public class JarUtil { * In this case, set all flags to true <code>extractNativeLibraries </code>. * <code>extractClassFiles</code>, <code>extractOtherFiles</code>. * </p> - * + * * @param dest * @param nativeLibMap * @param jarFile - * @param nativeLibraryPath if not null, only extracts native libraries within this path. + * @param nativeLibraryPath if not null, only extracts native libraries within this path. * @param extractNativeLibraries * @param extractClassFiles * @param extractOtherFiles @@ -527,7 +527,7 @@ public class JarUtil { * @return * @throws IOException */ - public static final int extract(File dest, Map<String, String> nativeLibMap, + public static final int extract(File dest, Map<String, String> nativeLibMap, JarFile jarFile, String nativeLibraryPath, boolean extractNativeLibraries, @@ -573,7 +573,7 @@ public class JarUtil { } } } - + final boolean isClassFile = entryName.endsWith(".class"); if(isClassFile && !extractClassFiles) { if (DEBUG) { @@ -581,7 +581,7 @@ public class JarUtil { } continue; } - + if(!isNativeLib && !isClassFile && !extractOtherFiles) { if (DEBUG) { System.err.println("JarUtil: JarEntry : " + entryName + " other-file skipped"); @@ -590,16 +590,16 @@ public class JarUtil { } final boolean isDir = entryName.endsWith("/"); - - final boolean isRootEntry = entryName.indexOf('/') == -1 && + + final boolean isRootEntry = entryName.indexOf('/') == -1 && entryName.indexOf(File.separatorChar) == -1; - + if (DEBUG) { - System.err.println("JarUtil: JarEntry : isNativeLib " + isNativeLib + + System.err.println("JarUtil: JarEntry : isNativeLib " + isNativeLib + ", isClassFile " + isClassFile + ", isDir " + isDir + ", isRootEntry " + isRootEntry ); } - + final File destFile = new File(dest, entryName); if(isDir) { if (DEBUG) { @@ -611,12 +611,12 @@ public class JarUtil { if(!destFolder.exists()) { if (DEBUG) { System.err.println("JarUtil: MKDIR (parent): " + entryName + " -> " + destFolder ); - } + } destFolder.mkdirs(); } final InputStream in = new BufferedInputStream(jarFile.getInputStream(entry)); final OutputStream out = new BufferedOutputStream(new FileOutputStream(destFile)); - int numBytes = -1; + int numBytes = -1; try { numBytes = IOUtil.copyStream2Stream(BUFFER_SIZE, in, out, -1); } finally { @@ -626,7 +626,7 @@ public class JarUtil { boolean addedAsNativeLib = false; if (numBytes>0) { num++; - if (isNativeLib && ( isRootEntry || !nativeLibMap.containsKey(libBaseName) ) ) { + if (isNativeLib && ( isRootEntry || !nativeLibMap.containsKey(libBaseName) ) ) { nativeLibMap.put(libBaseName, destFile.getAbsolutePath()); addedAsNativeLib = true; } @@ -647,7 +647,7 @@ public class JarUtil { getCodeSource().getCertificates(); </pre> */ - public static final void validateCertificates(Certificate[] rootCerts, JarFile jarFile) + public static final void validateCertificates(Certificate[] rootCerts, JarFile jarFile) throws IOException, SecurityException { if (DEBUG) { @@ -673,7 +673,7 @@ public class JarUtil { * Check the certificates with the ones in the jar file * (all must match). */ - private static final void validateCertificate(Certificate[] rootCerts, + private static final void validateCertificate(Certificate[] rootCerts, JarFile jar, JarEntry entry, byte[] buf) throws IOException, SecurityException { if (DEBUG) { diff --git a/src/java/com/jogamp/common/util/JogampVersion.java b/src/java/com/jogamp/common/util/JogampVersion.java index 046f18c..2789de7 100644 --- a/src/java/com/jogamp/common/util/JogampVersion.java +++ b/src/java/com/jogamp/common/util/JogampVersion.java @@ -46,16 +46,16 @@ public class JogampVersion { public static final Attributes.Name IMPLEMENTATION_BRANCH = new Attributes.Name("Implementation-Branch"); /** See {@link #getImplementationCommit()} */ public static final Attributes.Name IMPLEMENTATION_COMMIT = new Attributes.Name("Implementation-Commit"); - + private String packageName; private Manifest mf; private int hash; private Attributes mainAttributes; private Set<?>/*<Attributes.Name>*/ mainAttributeNames; - + private final String androidPackageVersionName; - - protected JogampVersion(String packageName, Manifest mf) { + + protected JogampVersion(String packageName, Manifest mf) { this.packageName = packageName; this.mf = ( null != mf ) ? mf : new Manifest(); this.hash = this.mf.hashCode(); @@ -104,7 +104,7 @@ public class JogampVersion { } /** - * @return set of type {@link Attributes.Name}, disguised as anonymous + * @return set of type {@link Attributes.Name}, disguised as anonymous */ public final Set<?>/*<Attributes.Name>*/ getAttributeNames() { return mainAttributeNames; @@ -117,13 +117,13 @@ public class JogampVersion { return this.getAttribute(Attributes.Name.EXTENSION_NAME); } - /** + /** * Returns the implementation build number, e.g. <code>2.0-b456-20130328</code>. */ public final String getImplementationBuild() { return this.getAttribute(GlueGenVersion.IMPLEMENTATION_BUILD); } - + /** * Returns the SCM branch name */ @@ -168,7 +168,7 @@ public class JogampVersion { public final String getAndroidPackageVersionName() { return androidPackageVersionName; } - + public final String getSpecificationTitle() { return this.getAttribute(Attributes.Name.SPECIFICATION_TITLE); } @@ -220,7 +220,7 @@ public class JogampVersion { return sb; } - + @Override public String toString() { return toString(null).toString(); diff --git a/src/java/com/jogamp/common/util/LFRingbuffer.java b/src/java/com/jogamp/common/util/LFRingbuffer.java index f704047..1ca1e20 100644 --- a/src/java/com/jogamp/common/util/LFRingbuffer.java +++ b/src/java/com/jogamp/common/util/LFRingbuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -31,7 +31,7 @@ package com.jogamp.common.util; import java.io.PrintStream; import java.lang.reflect.Array; -/** +/** * Simple implementation of {@link Ringbuffer}, * exposing <i>lock-free</i> * {@link #get() get*(..)} and {@link #put(Object) put*(..)} methods. @@ -80,11 +80,11 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { private volatile int readPos; private volatile int writePos; private volatile int size; - + public final String toString() { return "LFRingbuffer<?>[filled "+size+" / "+(capacityPlusOne-1)+", writePos "+writePos+", readPos "+readPos+"]"; } - + public final void dump(PrintStream stream, String prefix) { stream.println(prefix+" "+toString()+" {"); for(int i=0; i<capacityPlusOne; i++) { @@ -92,10 +92,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } stream.println("}"); } - - /** + + /** * Create a full ring buffer instance w/ the given array's net capacity and content. - * <p> + * <p> * Example for a 10 element Integer array: * <pre> * Integer[] source = new Integer[10]; @@ -111,7 +111,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { * and copy all elements from array <code>copyFrom</code> into the internal array. * </p> * @param copyFrom mandatory source array determining ring buffer's net {@link #capacity()} and initial content. - * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code> + * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code> */ @SuppressWarnings("unchecked") public LFRingbuffer(T[] copyFrom) throws IllegalArgumentException { @@ -119,10 +119,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { array = (T[]) newArray(copyFrom.getClass(), capacityPlusOne); resetImpl(true, copyFrom); } - - /** + + /** * Create an empty ring buffer instance w/ the given net <code>capacity</code>. - * <p> + * <p> * Example for a 10 element Integer array: * <pre> * Ringbuffer<Integer> rb = new LFRingbuffer<Integer>(10, Integer[].class); @@ -142,13 +142,13 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { array = (T[]) newArray(arrayType, capacityPlusOne); resetImpl(false, null /* empty, nothing to copy */ ); } - + @Override public final T[] getInternalArray() { return array; } - + @Override public final int capacity() { return capacityPlusOne-1; } - + @Override public final void clear() { synchronized ( syncGlobal ) { @@ -158,12 +158,12 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } } } - + @Override public final void resetFull(T[] copyFrom) throws IllegalArgumentException { resetImpl(true, copyFrom); } - + private final void resetImpl(boolean full, T[] copyFrom) throws IllegalArgumentException { synchronized ( syncGlobal ) { if( null != copyFrom ) { @@ -185,21 +185,21 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } } } - + @Override public final int size() { return size; } - + @Override public final int getFreeSlots() { return capacityPlusOne - 1 - size; } @Override public final boolean isEmpty() { return 0 == size; } - + @Override public final boolean isFull() { return capacityPlusOne - 1 == size; } - + /** - * {@inheritDoc} + * {@inheritDoc} * <p> * Implementation advances the read position and returns the element at it, if not empty. * </p> @@ -212,7 +212,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } /** - * {@inheritDoc} + * {@inheritDoc} * <p> * Implementation advances the read position and returns the element at it, if not empty. * </p> @@ -221,7 +221,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { public final T getBlocking() throws InterruptedException { return getImpl(true, false); } - + @Override public final T peek() { try { @@ -232,7 +232,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { public final T peekBlocking() throws InterruptedException { return getImpl(true, true); } - + private final T getImpl(boolean blocking, boolean peek) throws InterruptedException { int localReadPos = readPos; if( localReadPos == writePos ) { @@ -258,9 +258,9 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } return r; } - + /** - * {@inheritDoc} + * {@inheritDoc} * <p> * Implementation advances the write position and stores the given element at it, if not full. * </p> @@ -271,9 +271,9 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { return putImpl(e, false, false); } catch (InterruptedException ie) { throw new RuntimeException(ie); } } - - /** - * {@inheritDoc} + + /** + * {@inheritDoc} * <p> * Implementation advances the write position and stores the given element at it, if not full. * </p> @@ -284,10 +284,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { throw new InternalError("Blocking put failed: "+this); } } - + /** * {@inheritDoc} - * <p> + * <p> * Implementation advances the write position and keeps the element at it, if not full. * </p> */ @@ -295,7 +295,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { public final boolean putSame(boolean blocking) throws InterruptedException { return putImpl(null, true, blocking); } - + private final boolean putImpl(T e, boolean sameRef, boolean blocking) throws InterruptedException { int localWritePos = writePos; localWritePos = (localWritePos + 1) % capacityPlusOne; @@ -320,8 +320,8 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } return true; } - - + + @Override public final void waitForFreeSlots(int count) throws InterruptedException { synchronized ( syncRead ) { @@ -332,10 +332,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } } } - + @Override public final void growEmptyBuffer(final T[] newElements) throws IllegalStateException, IllegalArgumentException { - synchronized( syncGlobal ) { + synchronized( syncGlobal ) { if( null == newElements ) { throw new IllegalArgumentException("newElements is null"); } @@ -355,15 +355,15 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { if( readPos != writePos ) { throw new InternalError("R/W pos not equal at empty: "+this); } - + final int growAmount = newElements.length; final int newCapacity = capacityPlusOne + growAmount; final T[] oldArray = array; final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity); - + // writePos == readPos writePos += growAmount; // warp writePos to the end of the new data location - + if( readPos >= 0 ) { System.arraycopy(oldArray, 0, newArray, 0, readPos+1); } @@ -374,13 +374,13 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { if( tail > 0 ) { System.arraycopy(oldArray, readPos+1, newArray, writePos+1, tail); } - size = growAmount; - + size = growAmount; + capacityPlusOne = newCapacity; array = newArray; } } - + @Override public final void growFullBuffer(final int growAmount) throws IllegalStateException, IllegalArgumentException { synchronized ( syncGlobal ) { @@ -389,7 +389,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } if( capacityPlusOne-1 != size ) { throw new IllegalStateException("Buffer is not full: "+this); - } + } final int wp1 = ( writePos + 1 ) % capacityPlusOne; if( wp1 != readPos ) { throw new InternalError("R != W+1 pos at full: "+this); @@ -400,10 +400,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { final int newCapacity = capacityPlusOne + growAmount; final T[] oldArray = array; final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity); - + // writePos == readPos - 1 readPos = ( writePos + 1 + growAmount ) % newCapacity; // warp readPos to the end of the new data location - + if(writePos >= 0) { System.arraycopy(oldArray, 0, newArray, 0, writePos+1); } @@ -411,12 +411,12 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { if( tail > 0 ) { System.arraycopy(oldArray, writePos+1, newArray, readPos, tail); } - + capacityPlusOne = newCapacity; array = newArray; } } - + @SuppressWarnings("unchecked") private static <T> T[] newArray(Class<? extends T[]> arrayType, int length) { return ((Object)arrayType == (Object)Object[].class) diff --git a/src/java/com/jogamp/common/util/PrimitiveStack.java b/src/java/com/jogamp/common/util/PrimitiveStack.java index 89ae72e..e357e4a 100644 --- a/src/java/com/jogamp/common/util/PrimitiveStack.java +++ b/src/java/com/jogamp/common/util/PrimitiveStack.java @@ -31,50 +31,50 @@ package com.jogamp.common.util; * Simple primitive-type stack. */ public interface PrimitiveStack { - - /** + + /** * Returns this stack's current capacity. * <p> * The capacity may grow with a put operation w/ insufficient {@link #remaining()} elements left, if {@link #getGrowSize()} > 0. - * </p> + * </p> */ int capacity(); - - /** + + /** * Returns the current position of this stack. * <p> - * Position is in the range: 0 ≤ position < {@link #capacity()}. + * Position is in the range: 0 ≤ position < {@link #capacity()}. * </p> * <p> * The position equals to the number of elements stored. * </p> **/ int position(); - + /** * Sets the position of this stack. - * + * * @param newPosition the new position * @throws IndexOutOfBoundsException if <code>newPosition</code> is outside of range: 0 ≤ position < {@link #capacity()}. */ void position(int newPosition) throws IndexOutOfBoundsException; - - /** + + /** * Returns the remaining elements left before stack will grow about {@link #getGrowSize()}. * <pre> * remaining := capacity() - position(); * </pre> - * <p> + * <p> * 0 denotes a full stack. - * </p> + * </p> * @see #capacity() * @see #position() **/ int remaining(); - + /** Returns the grow size. A stack grows by this size in case a put operation exceeds it's {@link #capacity()}. */ int getGrowSize(); /** Set new {@link #growSize(). */ - void setGrowSize(int newGrowSize); + void setGrowSize(int newGrowSize); } diff --git a/src/java/com/jogamp/common/util/PropertyAccess.java b/src/java/com/jogamp/common/util/PropertyAccess.java index fdb2665..5a8f082 100644 --- a/src/java/com/jogamp/common/util/PropertyAccess.java +++ b/src/java/com/jogamp/common/util/PropertyAccess.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -38,32 +38,32 @@ public class PropertyAccess { public static final String jnlp_prefix = "jnlp." ; /** trusted build-in property prefix 'javaws.' */ public static final String javaws_prefix = "javaws."; - + static final HashSet<String> trustedPrefixes; static final HashSet<String> trusted; - + static { trustedPrefixes = new HashSet<String>(); trustedPrefixes.add(javaws_prefix); trustedPrefixes.add(jnlp_prefix); // 'jogamp.' and maybe other trusted prefixes will be added later via 'addTrustedPrefix()' - + trusted = new HashSet<String>(); trusted.add("sun.java2d.opengl"); trusted.add("sun.java2d.noddraw"); trusted.add("sun.java2d.d3d"); trusted.add("sun.awt.noerasebackground"); } - + /** * @param prefix New prefix to be registered as trusted. - * @throws AccessControlException as thrown by {@link SecurityUtil#checkAllPermissions()}. + * @throws AccessControlException as thrown by {@link SecurityUtil#checkAllPermissions()}. */ protected static final void addTrustedPrefix(String prefix) throws AccessControlException { SecurityUtil.checkAllPermissions(); trustedPrefixes.add(prefix); } - + public static final boolean isTrusted(String propertyKey) { final int dot1 = propertyKey.indexOf('.'); if(0<=dot1) { @@ -72,7 +72,7 @@ public class PropertyAccess { return false; } } - + /** @see #getProperty(String, boolean) */ public static final int getIntProperty(final String property, final boolean jnlpAlias, int defaultValue) { int i=defaultValue; @@ -120,22 +120,22 @@ public class PropertyAccess { * Query the property with the name <code>propertyKey</code>. * <p> * If <code>jnlpAlias</code> is <code>true</code> and the plain <code>propertyKey</code> - * could not be resolved, an attempt to resolve the JNLP aliased <i>trusted property</i> is made.<br> + * could not be resolved, an attempt to resolve the JNLP aliased <i>trusted property</i> is made.<br> * Example: For the propertyName <code>OneTwo</code>, the jnlp alias name is <code>jnlp.OneTwo</code>, which is considered trusted.<br> * </p> - * - * @param propertyKey the property name to query. + * + * @param propertyKey the property name to query. * @param jnlpAlias true if a fallback attempt to query the JNLP aliased <i>trusted property</i> shall be made, * otherwise false. * @return the property value if exists, or null - * + * * @throws NullPointerException if the property name is null * @throws IllegalArgumentException if the property name is of length 0 * @throws SecurityException if access is not allowed to the given <code>propertyKey</code> - * + * * @see System#getProperty(String) */ - public static final String getProperty(final String propertyKey, final boolean jnlpAlias) + public static final String getProperty(final String propertyKey, final boolean jnlpAlias) throws SecurityException, NullPointerException, IllegalArgumentException { if(null == propertyKey) { throw new NullPointerException("propertyKey is NULL"); @@ -144,14 +144,14 @@ public class PropertyAccess { throw new IllegalArgumentException("propertyKey is empty"); } String s=null; - + if( isTrusted(propertyKey) ) { // 'trusted' property (jnlp., javaws., jogamp., ..) s = getTrustedPropKey(propertyKey); } else { // may throw SecurityException, AccessControlerException s = System.getProperty(propertyKey); - } + } if( null == s && jnlpAlias ) { // Try 'jnlp.' aliased property .. if( !propertyKey.startsWith(jnlp_prefix) ) { @@ -162,9 +162,9 @@ public class PropertyAccess { } return s; } - + /** See {@link #getProperty(String, boolean)}, additionally allows a <code>defaultValue</code> if property value is <code>null</code>. */ - public static final String getProperty(final String propertyKey, final boolean jnlpAlias, String defaultValue) + public static final String getProperty(final String propertyKey, final boolean jnlpAlias, String defaultValue) throws SecurityException, NullPointerException, IllegalArgumentException { final String s = PropertyAccess.getProperty(propertyKey, jnlpAlias); if( null != s ) { @@ -173,7 +173,7 @@ public class PropertyAccess { return defaultValue; } } - + private static final String getTrustedPropKey(final String propertyKey) { return AccessController.doPrivileged(new PrivilegedAction<String>() { public String run() { @@ -183,6 +183,6 @@ public class PropertyAccess { throw new SecurityException("Could not access trusted property '"+propertyKey+"'", se); } } - }); + }); } } diff --git a/src/java/com/jogamp/common/util/ReflectionUtil.java b/src/java/com/jogamp/common/util/ReflectionUtil.java index 8b9476f..598b8b1 100644 --- a/src/java/com/jogamp/common/util/ReflectionUtil.java +++ b/src/java/com/jogamp/common/util/ReflectionUtil.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. 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 @@ -29,7 +29,7 @@ * 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. @@ -43,7 +43,7 @@ import com.jogamp.common.JogampRuntimeException; import jogamp.common.Debug; public final class ReflectionUtil { - + public static final boolean DEBUG = Debug.debug("ReflectionUtil"); public static class AWTNames { @@ -112,16 +112,16 @@ public final class ReflectionUtil { * Returns a compatible constructor * if available, otherwise throws an exception. * <p> - * It first attempts to get the specific Constructor - * using the given <code>cstrArgTypes</code>. + * It first attempts to get the specific Constructor + * using the given <code>cstrArgTypes</code>. * If this fails w/ <code>NoSuchMethodException</code>, a compatible * Constructor is being looked-up w/ with parameter types assignable * from the given <code>cstrArgs</code>. - * </p> - * + * </p> + * * @throws JogampRuntimeException if the constructor can not be delivered. */ - public static final Constructor<?> getConstructor(Class<?> clazz, Class<?> ... cstrArgTypes) + public static final Constructor<?> getConstructor(Class<?> clazz, Class<?> ... cstrArgTypes) throws JogampRuntimeException { if(null == cstrArgTypes) { cstrArgTypes = zeroTypes; @@ -147,13 +147,13 @@ public final class ReflectionUtil { if(types.length == j) { cstr = c; // gotcha } - } + } } } if(null == cstr) { throw new JogampRuntimeException("Constructor: '" + clazz.getName() + "(" + asString(cstrArgTypes) + ")' not found"); } - return cstr; + return cstr; } public static final Constructor<?> getConstructor(String clazzName, ClassLoader cl) @@ -164,7 +164,7 @@ public final class ReflectionUtil { /** * @throws JogampRuntimeException if the instance can not be created. */ - public static final Object createInstance(Constructor<?> cstr, Object ... cstrArgs) + public static final Object createInstance(Constructor<?> cstr, Object ... cstrArgs) throws JogampRuntimeException, RuntimeException { try { @@ -183,17 +183,17 @@ public final class ReflectionUtil { throw new JogampRuntimeException("can not create instance of "+cstr.getName(), t); } } - + /** * @throws JogampRuntimeException if the instance can not be created. */ - public static final Object createInstance(Class<?> clazz, Class<?>[] cstrArgTypes, Object ... cstrArgs) + public static final Object createInstance(Class<?> clazz, Class<?>[] cstrArgTypes, Object ... cstrArgs) throws JogampRuntimeException, RuntimeException { return createInstance(getConstructor(clazz, cstrArgTypes), cstrArgs); } - public static final Object createInstance(Class<?> clazz, Object ... cstrArgs) + public static final Object createInstance(Class<?> clazz, Object ... cstrArgs) throws JogampRuntimeException, RuntimeException { Class<?>[] cstrArgTypes = null; @@ -206,7 +206,7 @@ public final class ReflectionUtil { return createInstance(clazz, cstrArgTypes, cstrArgs); } - public static final Object createInstance(String clazzName, Class<?>[] cstrArgTypes, Object[] cstrArgs, ClassLoader cl) + public static final Object createInstance(String clazzName, Class<?>[] cstrArgTypes, Object[] cstrArgs, ClassLoader cl) throws JogampRuntimeException, RuntimeException { try { @@ -216,7 +216,7 @@ public final class ReflectionUtil { } } - public static final Object createInstance(String clazzName, Object[] cstrArgs, ClassLoader cl) + public static final Object createInstance(String clazzName, Object[] cstrArgs, ClassLoader cl) throws JogampRuntimeException, RuntimeException { Class<?>[] cstrArgTypes = null; @@ -345,24 +345,24 @@ public final class ReflectionUtil { } /** Convenient Method access class */ - public static class MethodAccessor { + public static class MethodAccessor { Method m = null; - + /** Check {@link #available()} before using instance. */ public MethodAccessor(Class<?> clazz, String methodName, Class<?> ... argTypes) { try { m = ReflectionUtil.getMethod(clazz, methodName, argTypes); } catch (JogampRuntimeException jre) { /* method n/a */ } } - + /** Returns true if method is available, otherwise false. */ public boolean available() { return null != m; } - - /** + + /** * Check {@link #available()} before calling to avoid throwing a JogampRuntimeException. - * @throws JogampRuntimeException if method is not available + * @throws JogampRuntimeException if method is not available */ public Object callMethod(Object instance, Object ... args) { if(null == m) { @@ -371,6 +371,6 @@ public final class ReflectionUtil { return ReflectionUtil.callMethod(instance, m, args); } } - + } diff --git a/src/java/com/jogamp/common/util/Ringbuffer.java b/src/java/com/jogamp/common/util/Ringbuffer.java index e524768..7faf5dd 100644 --- a/src/java/com/jogamp/common/util/Ringbuffer.java +++ b/src/java/com/jogamp/common/util/Ringbuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -29,7 +29,7 @@ package com.jogamp.common.util; import java.io.PrintStream; -/** +/** * Ring buffer interface, a.k.a circular buffer. * <p> * Caller can chose whether to block until get / put is able to proceed or not. @@ -39,26 +39,26 @@ import java.io.PrintStream; * or using a preset array for circular access of same objects. * </p> * <p> - * Synchronization and hence thread safety details belong to the implementation. + * Synchronization and hence thread safety details belong to the implementation. * </p> */ public interface Ringbuffer<T> { - - /** Returns a short string representation incl. size/capacity and internal r/w index (impl. dependent). */ + + /** Returns a short string representation incl. size/capacity and internal r/w index (impl. dependent). */ public String toString(); /** Debug functionality - Dumps the contents of the internal array. */ public void dump(PrintStream stream, String prefix); - /** + /** * Returns the internal array as-is, i.e. w/o a copy. * <p> * The layout and size of the internal array is implementation dependent. - * </p> + * </p> * <p> * Users shall not modify or rely on the returned array. - * </p> - * @deprecated This method should not be required + * </p> + * @deprecated This method should not be required */ public T[] getInternalArray(); @@ -66,7 +66,7 @@ public interface Ringbuffer<T> { public int capacity(); /** - * Resets the read and write position according to an empty ring buffer + * Resets the read and write position according to an empty ring buffer * and set all ring buffer slots to <code>null</code>. * <p> * {@link #isEmpty()} will return <code>true</code> after calling this method. @@ -75,14 +75,14 @@ public interface Ringbuffer<T> { public void clear(); /** - * Resets the read and write position according to a full ring buffer + * Resets the read and write position according to a full ring buffer * and fill all slots w/ elements of array <code>copyFrom</code>. * <p> - * Array's <code>copyFrom</code> elements will be copied into the internal array, + * Array's <code>copyFrom</code> elements will be copied into the internal array, * hence it's length must be equal to {@link #capacity()}. * </p> * @param copyFrom Mandatory array w/ length {@link #capacity()} to be copied into the internal array. - * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code>. + * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code>. * @throws IllegalArgumentException if <code>copyFrom</code>'s length is different from {@link #capacity()}. */ public void resetFull(T[] copyFrom) throws IllegalArgumentException; @@ -108,7 +108,7 @@ public interface Ringbuffer<T> { * <p> * Method is non blocking and returns immediately;. * </p> - * @return the oldest put element if available, otherwise null. + * @return the oldest put element if available, otherwise null. */ public T get(); @@ -121,24 +121,24 @@ public interface Ringbuffer<T> { * <p> * Methods blocks until an element becomes available via put. * </p> - * @return the oldest put element - * @throws InterruptedException + * @return the oldest put element + * @throws InterruptedException */ public T getBlocking() throws InterruptedException; - /** + /** * Peeks the next element at the read position w/o modifying pointer, nor blocking. * @return <code>null</code> if empty, otherwise the element which would be read next. */ public T peek(); - /** + /** * Peeks the next element at the read position w/o modifying pointer, but w/ blocking. * @return <code>null</code> if empty, otherwise the element which would be read next. */ public T peekBlocking() throws InterruptedException; - /** + /** * Enqueues the given element. * <p> * Returns true if successful, otherwise false in case buffer is full. @@ -149,16 +149,16 @@ public interface Ringbuffer<T> { */ public boolean put(T e); - /** + /** * Enqueues the given element. * <p> * Method blocks until a free slot becomes available via get. * </p> - * @throws InterruptedException + * @throws InterruptedException */ public void putBlocking(T e) throws InterruptedException; - /** + /** * Enqueues the same element at it's write position, if not full. * <p> * Returns true if successful, otherwise false in case buffer is full. @@ -167,7 +167,7 @@ public interface Ringbuffer<T> { * If <code>blocking</code> is true, method blocks until a free slot becomes available via get. * </p> * @param blocking if true, wait until a free slot becomes available via get. - * @throws InterruptedException + * @throws InterruptedException */ public boolean putSame(boolean blocking) throws InterruptedException; @@ -183,13 +183,13 @@ public interface Ringbuffer<T> { * Growing an empty ring buffer increases it's size about the amount, i.e. renders it not empty. * The new elements are inserted at the read position, able to be read out via {@link #get()} etc. * </p> - * + * * @param newElements array of new full elements the empty buffer shall grow about. * @throws IllegalStateException if buffer is not empty * @throws IllegalArgumentException if newElements is null */ public void growEmptyBuffer(T[] newElements) throws IllegalStateException, IllegalArgumentException; - + /** * Grows a full ring buffer, increasing it's capacity about the amount. * <p> @@ -197,7 +197,7 @@ public interface Ringbuffer<T> { * New <code>null</code> elements are inserted at the write position, able to be written to via {@link #put(Object)} etc. * </p> * @param amount the amount of elements the buffer shall grow about - * + * * @throws IllegalStateException if buffer is not full * @throws IllegalArgumentException if amount is < 0 */ diff --git a/src/java/com/jogamp/common/util/RunnableExecutor.java b/src/java/com/jogamp/common/util/RunnableExecutor.java index 7bf9685..629bc8c 100644 --- a/src/java/com/jogamp/common/util/RunnableExecutor.java +++ b/src/java/com/jogamp/common/util/RunnableExecutor.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -28,23 +28,23 @@ package com.jogamp.common.util; public interface RunnableExecutor { - /** This {@link RunnableExecutor} implementation simply invokes {@link Runnable#run()} + /** This {@link RunnableExecutor} implementation simply invokes {@link Runnable#run()} * on the current thread. */ public static final RunnableExecutor currentThreadExecutor = new CurrentThreadExecutor(); - + /** - * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait. + * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait. * @param r the {@link Runnable} to be executed. */ void invoke(boolean wait, Runnable r); - + static class CurrentThreadExecutor implements RunnableExecutor { private CurrentThreadExecutor() {} - + @Override public void invoke(boolean wait, Runnable r) { - r.run(); - } + r.run(); + } } } diff --git a/src/java/com/jogamp/common/util/RunnableTask.java b/src/java/com/jogamp/common/util/RunnableTask.java index c18556b..1db4810 100644 --- a/src/java/com/jogamp/common/util/RunnableTask.java +++ b/src/java/com/jogamp/common/util/RunnableTask.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.PrintStream; @@ -39,13 +39,13 @@ public class RunnableTask extends TaskBase { /** * Invoks <code>runnable</code>. - * @param waitUntilDone if <code>true</code>, waits until <code>runnable</code> execution is completed, otherwise returns immediately. + * @param waitUntilDone if <code>true</code>, waits until <code>runnable</code> execution is completed, otherwise returns immediately. * @param runnable the {@link Runnable} to execute. */ public static void invoke(boolean waitUntilDone, Runnable runnable) { Throwable throwable = null; final Object sync = new Object(); - final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); + final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); synchronized(sync) { rt.run(); if( waitUntilDone ) { @@ -63,14 +63,14 @@ public class RunnableTask extends TaskBase { } } } - + /** * Create a RunnableTask object w/ synchronization, - * ie. suitable for <code>invokeAndWait()</code>, i.e. {@link #invoke(boolean, Runnable) invoke(true, runnable)}. - * + * ie. suitable for <code>invokeAndWait()</code>, i.e. {@link #invoke(boolean, Runnable) invoke(true, runnable)}. + * * @param runnable The user action * @param syncObject The synchronization object if caller wait until <code>runnable</code> execution is completed, - * or <code>null</code> if waiting is not desired. + * or <code>null</code> if waiting is not desired. * @param catchExceptions Influence an occurring exception during <code>runnable</code> execution. * If <code>true</code>, the exception is silenced and can be retrieved via {@link #getThrowable()}, * otherwise the exception is thrown. @@ -79,7 +79,7 @@ public class RunnableTask extends TaskBase { public RunnableTask(Runnable runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut) { super(syncObject, catchExceptions, exceptionOut); this.runnable = runnable ; - } + } /** Return the user action */ public final Runnable getRunnable() { @@ -104,7 +104,7 @@ public class RunnableTask extends TaskBase { throw new RuntimeException(runnableException); } } finally { - tExecuted = System.currentTimeMillis(); + tExecuted = System.currentTimeMillis(); } } else { synchronized (syncObject) { @@ -125,7 +125,7 @@ public class RunnableTask extends TaskBase { syncObject.notifyAll(); } } - } - } + } + } } diff --git a/src/java/com/jogamp/common/util/SecurityUtil.java b/src/java/com/jogamp/common/util/SecurityUtil.java index 6b35c9c..742de84 100644 --- a/src/java/com/jogamp/common/util/SecurityUtil.java +++ b/src/java/com/jogamp/common/util/SecurityUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -39,11 +39,11 @@ public class SecurityUtil { private static final SecurityManager securityManager; private static final Permission allPermissions; private static final boolean DEBUG = false; - + static { allPermissions = new AllPermission(); securityManager = System.getSecurityManager(); - + if( DEBUG ) { final boolean hasAllPermissions; { @@ -55,12 +55,12 @@ public class SecurityUtil { try { insecPD.implies(allPermissions); _hasAllPermissions = true; - } catch( SecurityException ace ) { + } catch( SecurityException ace ) { _hasAllPermissions = false; } hasAllPermissions = _hasAllPermissions; } - + System.err.println("SecurityUtil: Has SecurityManager: "+ ( null != securityManager ) ) ; System.err.println("SecurityUtil: Has AllPermissions: "+hasAllPermissions); final Certificate[] certs = AccessController.doPrivileged(new PrivilegedAction<Certificate[]>() { @@ -75,7 +75,7 @@ public class SecurityUtil { } } } - + /** * Returns <code>true</code> if no {@link SecurityManager} has been installed * or the installed {@link SecurityManager}'s <code>checkPermission(new AllPermission())</code> @@ -84,7 +84,7 @@ public class SecurityUtil { public static final boolean hasAllPermissions() { return hasPermission(allPermissions); } - + /** * Returns <code>true</code> if no {@link SecurityManager} has been installed * or the installed {@link SecurityManager}'s <code>checkPermission(perm)</code> @@ -94,11 +94,11 @@ public class SecurityUtil { try { checkPermission(perm); return true; - } catch( SecurityException ace ) { + } catch( SecurityException ace ) { return false; } } - + /** * Throws an {@link SecurityException} if an installed {@link SecurityManager} * does not permit the requested {@link AllPermission}. @@ -106,7 +106,7 @@ public class SecurityUtil { public static final void checkAllPermissions() throws SecurityException { checkPermission(allPermissions); } - + /** * Throws an {@link SecurityException} if an installed {@link SecurityManager} * does not permit the requested {@link Permission}. @@ -116,7 +116,7 @@ public class SecurityUtil { securityManager.checkPermission(perm); } } - + /** * Returns <code>true</code> if no {@link SecurityManager} has been installed * or the installed {@link SecurityManager}'s <code>checkLink(libName)</code> @@ -126,11 +126,11 @@ public class SecurityUtil { try { checkLinkPermission(libName); return true; - } catch( SecurityException ace ) { + } catch( SecurityException ace ) { return false; } } - + /** * Throws an {@link SecurityException} if an installed {@link SecurityManager} * does not permit to dynamically link the given libName. @@ -140,7 +140,7 @@ public class SecurityUtil { securityManager.checkLink(libName); } } - + /** * Throws an {@link SecurityException} if an installed {@link SecurityManager} * does not permit to dynamically link to all libraries. @@ -151,7 +151,7 @@ public class SecurityUtil { } } private static final RuntimePermission allLinkPermission = new RuntimePermission("loadLibrary.*"); - + /** * @param clz * @return @@ -163,7 +163,7 @@ public class SecurityUtil { final Certificate[] certs = (null != cs) ? cs.getCertificates() : null; return (null != certs && certs.length>0) ? certs : null; } - + public static final boolean equals(Certificate[] a, Certificate[] b) { if(a == b) { return true; @@ -174,11 +174,11 @@ public class SecurityUtil { if(a.length != b.length) { return false; } - + int i = 0; while( i < a.length && a[i].equals(b[i]) ) { i++; - } + } return i == a.length; - } + } } diff --git a/src/java/com/jogamp/common/util/SyncedRingbuffer.java b/src/java/com/jogamp/common/util/SyncedRingbuffer.java index 747629b..8ef2970 100644 --- a/src/java/com/jogamp/common/util/SyncedRingbuffer.java +++ b/src/java/com/jogamp/common/util/SyncedRingbuffer.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -31,7 +31,7 @@ package com.jogamp.common.util; import java.io.PrintStream; import java.lang.reflect.Array; -/** +/** * Simple synchronized implementation of {@link Ringbuffer}. * <p> * All methods utilize global synchronization. @@ -56,12 +56,12 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { private int readPos; private int writePos; private int size; - + @Override public final String toString() { return "SyncedRingbuffer<?>[filled "+size+" / "+capacity+", writePos "+writePos+", readPos "+readPos+"]"; } - + @Override public final void dump(PrintStream stream, String prefix) { stream.println(prefix+" "+toString()+" {"); @@ -70,10 +70,10 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { } stream.println("}"); } - - /** + + /** * Create a full ring buffer instance w/ the given array's net capacity and content. - * <p> + * <p> * Example for a 10 element Integer array: * <pre> * Integer[] source = new Integer[10]; @@ -89,7 +89,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { * and copy all elements from array <code>copyFrom</code> into the internal array. * </p> * @param copyFrom mandatory source array determining ring buffer's net {@link #capacity()} and initial content. - * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code> + * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code> */ @SuppressWarnings("unchecked") public SyncedRingbuffer(T[] copyFrom) throws IllegalArgumentException { @@ -97,10 +97,10 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { array = (T[]) newArray(copyFrom.getClass(), capacity); resetImpl(true, copyFrom); } - - /** + + /** * Create an empty ring buffer instance w/ the given net <code>capacity</code>. - * <p> + * <p> * Example for a 10 element Integer array: * <pre> * Ringbuffer<Integer> rb = new SyncedRingbuffer<Integer>(10, Integer[].class); @@ -120,13 +120,13 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { this.array = (T[]) newArray(arrayType, capacity); resetImpl(false, null /* empty, nothing to copy */ ); } - + @Override public final T[] getInternalArray() { return array; } - + @Override public final int capacity() { return capacity; } - + /** * {@inheritDoc} * <p> @@ -142,12 +142,12 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { } } } - + @Override public final void resetFull(T[] copyFrom) throws IllegalArgumentException { resetImpl(true, copyFrom); } - + private final void resetImpl(boolean full, T[] copyFrom) throws IllegalArgumentException { synchronized ( syncGlobal ) { if( null != copyFrom ) { @@ -163,14 +163,14 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { size = full ? capacity : 0; } } - + @Override public final int size() { synchronized ( syncGlobal ) { return size; } } - + @Override public final int getFreeSlots() { synchronized ( syncGlobal ) { @@ -184,14 +184,14 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { return 0 == size; } } - + @Override public final boolean isFull() { synchronized ( syncGlobal ) { return capacity == size; } } - + /** * {@inheritDoc} * <p> @@ -215,7 +215,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { public final T getBlocking() throws InterruptedException { return getImpl(true, false); } - + @Override public final T peek() { try { @@ -226,9 +226,9 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { public final T peekBlocking() throws InterruptedException { return getImpl(true, true); } - + private final T getImpl(boolean blocking, boolean peek) throws InterruptedException { - synchronized( syncGlobal ) { + synchronized( syncGlobal ) { if( 0 == size ) { if( blocking ) { while( 0 == size ) { @@ -249,8 +249,8 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { return r; } } - - /** + + /** * {@inheritDoc} * <p> * Implementation stores the element at the current write position and advances it, if not full. @@ -262,8 +262,8 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { return putImpl(e, false, false); } catch (InterruptedException ie) { throw new RuntimeException(ie); } } - - /** + + /** * {@inheritDoc} * <p> * Implementation stores the element at the current write position and advances it, if not full. @@ -275,8 +275,8 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { throw new InternalError("Blocking put failed: "+this); } } - - /** + + /** * {@inheritDoc} * <p> * Implementation keeps the element at the current write position and advances it, if not full. @@ -286,9 +286,9 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { public final boolean putSame(boolean blocking) throws InterruptedException { return putImpl(null, true, blocking); } - + private final boolean putImpl(T e, boolean sameRef, boolean blocking) throws InterruptedException { - synchronized( syncGlobal ) { + synchronized( syncGlobal ) { if( capacity == size ) { if( blocking ) { while( capacity == size ) { @@ -308,7 +308,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { return true; } } - + @Override public final void waitForFreeSlots(int count) throws InterruptedException { synchronized ( syncGlobal ) { @@ -319,8 +319,8 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { } } } - - + + @Override public final void growEmptyBuffer(final T[] newElements) throws IllegalStateException, IllegalArgumentException { synchronized ( syncGlobal ) { @@ -340,15 +340,15 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { if( readPos != writePos ) { throw new InternalError("R/W pos not equal: "+this); } - + final int growAmount = newElements.length; final int newCapacity = capacity + growAmount; final T[] oldArray = array; final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity); - + // writePos == readPos writePos += growAmount; // warp writePos to the end of the new data location - + if( readPos > 0 ) { System.arraycopy(oldArray, 0, newArray, 0, readPos); } @@ -360,12 +360,12 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { System.arraycopy(oldArray, readPos, newArray, writePos, tail); } size = growAmount; - + capacity = newCapacity; array = newArray; } } - + @Override public final void growFullBuffer(final int growAmount) throws IllegalStateException, IllegalArgumentException { synchronized ( syncGlobal ) { @@ -374,7 +374,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { } if( capacity != size ) { throw new IllegalStateException("Buffer is not full: "+this); - } + } if( readPos != writePos ) { throw new InternalError("R/W pos not equal: "+this); } @@ -384,10 +384,10 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { final int newCapacity = capacity + growAmount; final T[] oldArray = array; final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity); - + // writePos == readPos readPos += growAmount; // warp readPos to the end of the new data location - + if(writePos > 0) { System.arraycopy(oldArray, 0, newArray, 0, writePos); } @@ -395,12 +395,12 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { if( tail > 0 ) { System.arraycopy(oldArray, writePos, newArray, readPos, tail); } - + capacity = newCapacity; array = newArray; } } - + @SuppressWarnings("unchecked") private static <T> T[] newArray(Class<? extends T[]> arrayType, int length) { return ((Object)arrayType == (Object)Object[].class) diff --git a/src/java/com/jogamp/common/util/TaskBase.java b/src/java/com/jogamp/common/util/TaskBase.java index 35571e3..e76893d 100644 --- a/src/java/com/jogamp/common/util/TaskBase.java +++ b/src/java/com/jogamp/common/util/TaskBase.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import java.io.PrintStream; @@ -39,17 +39,17 @@ import jogamp.common.Debug; public abstract class TaskBase implements Runnable { /** Enable via the property <code>jogamp.debug.TaskBase.TraceSource</code> */ private static final boolean TRACE_SOURCE; - + static { Debug.initSingleton(); TRACE_SOURCE = Debug.isPropertyDefined("jogamp.debug.TaskBase.TraceSource", true); } - + protected final Object syncObject; protected final boolean catchExceptions; - protected final PrintStream exceptionOut; + protected final PrintStream exceptionOut; protected final Throwable sourceStack; - + protected Object attachment; protected Throwable runnableException; protected long tCreated, tStarted; @@ -66,7 +66,7 @@ public abstract class TaskBase implements Runnable { tExecuted = 0; isFlushed = false; } - + protected final String getExceptionOutIntro() { return catchExceptions ? "A catched" : "An uncatched"; } @@ -76,25 +76,25 @@ public abstract class TaskBase implements Runnable { } } - /** + /** * Return the synchronization object if any. - * @see #RunnableTask(Runnable, Object, boolean) + * @see #RunnableTask(Runnable, Object, boolean) */ public final Object getSyncObject() { return syncObject; } - - /** - * Attach a custom object to this task. - * Useful to piggybag further information, ie tag a task final. + + /** + * Attach a custom object to this task. + * Useful to piggybag further information, ie tag a task final. */ public final void setAttachment(Object o) { attachment = o; } - /** + /** * Return the attachment object if any. - * @see #setAttachment(Object) + * @see #setAttachment(Object) */ public final Object getAttachment() { return attachment; @@ -102,20 +102,20 @@ public abstract class TaskBase implements Runnable { @Override public abstract void run(); - - /** + + /** * Simply flush this task and notify a waiting executor. * The executor which might have been blocked until notified * will be unblocked and the task removed from the queue. - * + * * @see #isFlushed() * @see #isInQueue() - */ + */ public final void flush() { if(!isExecuted() && hasWaiter()) { synchronized (syncObject) { isFlushed = true; - syncObject.notifyAll(); + syncObject.notifyAll(); } } } @@ -124,7 +124,7 @@ public abstract class TaskBase implements Runnable { * @return !{@link #isExecuted()} && !{@link #isFlushed()} */ public final boolean isInQueue() { return 0 != tExecuted && !isFlushed; } - + /** * @return True if executed, otherwise false; */ @@ -136,7 +136,7 @@ public abstract class TaskBase implements Runnable { public final boolean isFlushed() { return isFlushed; } /** - * @return True if invoking thread waits until done, + * @return True if invoking thread waits until done, * ie a <code>notifyObject</code> was passed, otherwise false; */ public final boolean hasWaiter() { return null != syncObject; } diff --git a/src/java/com/jogamp/common/util/ValueConv.java b/src/java/com/jogamp/common/util/ValueConv.java index fa49341..9a16b64 100644 --- a/src/java/com/jogamp/common/util/ValueConv.java +++ b/src/java/com/jogamp/common/util/ValueConv.java @@ -5,14 +5,14 @@ package com.jogamp.common.util; * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -22,7 +22,7 @@ package com.jogamp.common.util; * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -51,7 +51,7 @@ public class ValueConv { } else { return (short) ( v * 65535.0f ); } - } + } public static final int float_to_int(float v, boolean dSigned) { // float significand 0x007fffff // double significand 0x000fffffffffffffL @@ -63,7 +63,7 @@ public class ValueConv { return (int) (long) ( v * 4294967295.0 ); } } - + public static final byte double_to_byte(double v, boolean dSigned) { // lossy if( dSigned ) { @@ -88,27 +88,27 @@ public class ValueConv { return (int) (long) ( v * 4294967295.0 ); } } - + public static final float byte_to_float(byte v, boolean sSigned) { if( sSigned ) { return (v & 0xff) / ( v > 0 ? 127.0f : -128.0f ) ; } else { return (v & 0xff) / 255.0f ; - } + } } public static final double byte_to_double(byte v, boolean sSigned) { if( sSigned ) { return (v & 0xff) / ( v > 0 ? 127.0 : -128.0 ) ; } else { return (v & 0xff) / 255.0 ; - } - } + } + } public static final float short_to_float(short v, boolean sSigned) { if( sSigned ) { return (v & 0xffff) / ( v > 0 ? 32767.0f : -32768.0f ) ; } else { return (v & 0xffff) / 65535.0f ; - } + } } public static final double short_to_double(short v, boolean sSigned) { // lossy @@ -116,8 +116,8 @@ public class ValueConv { return (v & 0xffff) / ( v > 0 ? 32767.0 : -32768.0 ) ; } else { return (v & 0xffff) / 65535.0 ; - } - } + } + } public static final float int_to_float(int v, boolean sSigned) { // lossy // float significand 0x007fffff @@ -128,30 +128,30 @@ public class ValueConv { return (float) ( v / ( v > 0 ? 2147483647.0 : 2147483648.0 ) ); } else { return (float) ( ((long)v & 0xffffffffL) / 4294967295.0 ); - } + } } public static final double int_to_double(int v, boolean sSigned) { if( sSigned ) { return v / ( v > 0 ? 2147483647.0 : 2147483648.0 ) ; } else { return ((long)v & 0xffffffffL) / 4294967295.0 ; - } + } } - + public static final short byte_to_short(byte v, boolean sSigned, boolean dSigned) { return float_to_short(byte_to_float(v, sSigned), dSigned); } public static final int byte_to_int(byte v, boolean sSigned, boolean dSigned) { return float_to_int(byte_to_float(v, sSigned), dSigned); } - + public static final byte short_to_byte(short v, boolean sSigned, boolean dSigned) { return float_to_byte(short_to_float(v, sSigned), dSigned); } public static final int short_to_int(short v, boolean sSigned, boolean dSigned) { return float_to_int(short_to_float(v, sSigned), dSigned); } - + public static final byte int_to_byte(int v, boolean sSigned, boolean dSigned) { return float_to_byte(int_to_float(v, sSigned), dSigned); } diff --git a/src/java/com/jogamp/common/util/VersionNumber.java b/src/java/com/jogamp/common/util/VersionNumber.java index b1d8963..addc879 100644 --- a/src/java/com/jogamp/common/util/VersionNumber.java +++ b/src/java/com/jogamp/common/util/VersionNumber.java @@ -33,7 +33,7 @@ import java.util.regex.Matcher; /** * Simple version number class containing a version number * either being {@link #VersionNumber(int, int, int) defined explicit} - * or {@link #VersionNumber(String, String) derived from a string}. + * or {@link #VersionNumber(String, String) derived from a string}. * <p> * For the latter case, you can query whether a component has been defined explicitly by the given <code>versionString</code>, * via {@link #hasMajor()}, {@link #hasMinor()} and {@link #hasSub()}. @@ -46,45 +46,45 @@ import java.util.regex.Matcher; */ public class VersionNumber implements Comparable<Object> { - /** - * A {@link #isZero() zero} version instance, w/o any component defined explicitly. + /** + * A {@link #isZero() zero} version instance, w/o any component defined explicitly. * @see #hasMajor() * @see #hasMinor() - * @see #hasSub() + * @see #hasSub() */ public static final VersionNumber zeroVersion = new VersionNumber(0, 0, 0, -1, (short)0); - + /** - * Returns the {@link java.util.regex.Pattern pattern} - * with Perl regular expression: + * Returns the {@link java.util.regex.Pattern pattern} + * with Perl regular expression: * <pre> * "\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+))?)?" * </pre> * </p> * <p> - * A whitespace within the version number will end the parser. + * A whitespace within the version number will end the parser. * </p> * <p> * Capture groups represent the major (1), optional minor (2) and optional sub version number (3) component in this order. * </p> * <p> - * Each capture group ignores any leading non-digit and uses only contiguous digits, i.e. ignores pending non-digits. + * Each capture group ignores any leading non-digit and uses only contiguous digits, i.e. ignores pending non-digits. * </p> * @param delim the delimiter, e.g. "." */ public static java.util.regex.Pattern getVersionNumberPattern(String delim) { return java.util.regex.Pattern.compile("\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+))?)?"); } - + /** - * Returns the default {@link java.util.regex.Pattern pattern} using {@link #getVersionNumberPattern(String)} + * Returns the default {@link java.util.regex.Pattern pattern} using {@link #getVersionNumberPattern(String)} * with delimiter "<b>.</b>". * <p> * Instance is cached. - * </p> - */ + * </p> + */ public static java.util.regex.Pattern getDefaultVersionNumberPattern() { - if( null == defPattern ) { // volatile dbl-checked-locking OK + if( null == defPattern ) { // volatile dbl-checked-locking OK synchronized( VersionNumber.class ) { if( null == defPattern ) { defPattern = getVersionNumberPattern("."); @@ -96,7 +96,7 @@ public class VersionNumber implements Comparable<Object> { private static volatile java.util.regex.Pattern defPattern = null; protected final int major, minor, sub, strEnd; - + protected final short state; protected final static short HAS_MAJOR = 1 << 0 ; protected final static short HAS_MINOR = 1 << 1 ; @@ -109,12 +109,12 @@ public class VersionNumber implements Comparable<Object> { strEnd = _strEnd; state = _state; } - - /** + + /** * Explicit version number instantiation, with all components defined explicitly. * @see #hasMajor() * @see #hasMinor() - * @see #hasSub() + * @see #hasSub() */ public VersionNumber(int majorRev, int minorRev, int subMinorRev) { this(majorRev, minorRev, subMinorRev, -1, (short)(HAS_MAJOR | HAS_MINOR | HAS_SUB)); @@ -124,41 +124,41 @@ public class VersionNumber implements Comparable<Object> { * String derived version number instantiation. * <p> * Utilizing the default {@link java.util.regex.Pattern pattern} parser with delimiter "<b>.</b>", see {@link #getDefaultVersionNumberPattern()}. - * </p> + * </p> * <p> * You can query whether a component has been defined explicitly by the given <code>versionString</code>, * via {@link #hasMajor()}, {@link #hasMinor()} and {@link #hasSub()}. * </p> * @param versionString should be given as [MAJOR[.MINOR[.SUB]]] - * + * * @see #hasMajor() * @see #hasMinor() - * @see #hasSub() + * @see #hasSub() */ public VersionNumber(final String versionString) { this(versionString, getDefaultVersionNumberPattern()); } - + /** * String derived version number instantiation. * <p> * Utilizing {@link java.util.regex.Pattern pattern} parser created via {@link #getVersionNumberPattern(String)}. - * </p> + * </p> * <p> * You can query whether a component has been defined explicitly by the given <code>versionString</code>, * via {@link #hasMajor()}, {@link #hasMinor()} and {@link #hasSub()}. * </p> * @param versionString should be given as [MAJOR[.MINOR[.SUB]]] * @param delim the delimiter, e.g. "." - * + * * @see #hasMajor() * @see #hasMinor() - * @see #hasSub() + * @see #hasSub() */ public VersionNumber(final String versionString, final String delim) { this(versionString, getVersionNumberPattern(delim)); } - + /** * String derived version number instantiation. * <p> @@ -167,10 +167,10 @@ public class VersionNumber implements Comparable<Object> { * </p> * @param versionString should be given as [MAJOR[.MINOR[.SUB]]] * @param versionPattern the {@link java.util.regex.Pattern pattern} parser, must be compatible w/ {@link #getVersionNumberPattern(String)} - * + * * @see #hasMajor() * @see #hasMinor() - * @see #hasSub() + * @see #hasSub() */ public VersionNumber(final String versionString, final java.util.regex.Pattern versionPattern) { // group1: \d* == digits major @@ -198,32 +198,32 @@ public class VersionNumber implements Comparable<Object> { } } } catch (Exception e) { } - + major = val[0]; minor = val[1]; sub = val[2]; strEnd = _strEnd; state = _state; } - - /** Returns <code>true</code>, if all version components are zero, otherwise <code>false</code>. */ + + /** Returns <code>true</code>, if all version components are zero, otherwise <code>false</code>. */ public final boolean isZero() { return major == 0 && minor == 0 && sub == 0; } - + /** Returns <code>true</code>, if the major component is defined explicitly, otherwise <code>false</code>. Undefined components has the value <code>0</code>. */ - public final boolean hasMajor() { return 0 != ( HAS_MAJOR & state ); } + public final boolean hasMajor() { return 0 != ( HAS_MAJOR & state ); } /** Returns <code>true</code>, if the optional minor component is defined explicitly, otherwise <code>false</code>. Undefined components has the value <code>0</code>. */ public final boolean hasMinor() { return 0 != ( HAS_MINOR & state ); } /** Returns <code>true</code>, if the optional sub component is defined explicitly, otherwise <code>false</code>. Undefined components has the value <code>0</code>. */ public final boolean hasSub() { return 0 != ( HAS_SUB & state ); } - - /** + + /** * If constructed with <code>version-string</code>, returns the string offset <i>after</i> the last matching character, * or <code>0</code> if none matched, or <code>-1</code> if not constructed with a string. */ public final int endOfStringMatch() { return strEnd; } - + @Override public final int hashCode() { // 31 * x == (x << 5) - x @@ -239,7 +239,7 @@ public class VersionNumber implements Comparable<Object> { } return false; } - + @Override public final int compareTo(Object o) { if ( ! ( o instanceof VersionNumber ) ) { @@ -265,7 +265,7 @@ public class VersionNumber implements Comparable<Object> { } return 0; } - + public final int getMajor() { return major; } diff --git a/src/java/com/jogamp/common/util/VersionNumberString.java b/src/java/com/jogamp/common/util/VersionNumberString.java index 143d57c..e23300c 100644 --- a/src/java/com/jogamp/common/util/VersionNumberString.java +++ b/src/java/com/jogamp/common/util/VersionNumberString.java @@ -34,28 +34,28 @@ package com.jogamp.common.util; */ public class VersionNumberString extends VersionNumber { - /** - * A {@link #isZero() zero} version instance, w/o any component defined explicitly. + /** + * A {@link #isZero() zero} version instance, w/o any component defined explicitly. * @see #hasMajor() * @see #hasMinor() - * @see #hasSub() + * @see #hasSub() */ public static final VersionNumberString zeroVersion = new VersionNumberString(0, 0, 0, -1, (short)0, "n/a"); - + protected final String strVal; protected VersionNumberString(int majorRev, int minorRev, int subMinorRev, int strEnd, short _state, String versionString) { super(majorRev, minorRev, subMinorRev, strEnd, _state); strVal = versionString; } - + /** * See {@link VersionNumber#VersionNumber(int, int, int)}. */ public VersionNumberString(int majorRev, int minorRev, int subMinorRev, String versionString) { this(majorRev, minorRev, subMinorRev, -1, (short)(HAS_MAJOR | HAS_MINOR | HAS_SUB), versionString); } - + /** * See {@link VersionNumber#VersionNumber(String)}. */ @@ -63,7 +63,7 @@ public class VersionNumberString extends VersionNumber { super( versionString); strVal = versionString; } - + /** * See {@link VersionNumber#VersionNumber(String, String)}. */ @@ -71,7 +71,7 @@ public class VersionNumberString extends VersionNumber { super( versionString, delim); strVal = versionString; } - + /** * See {@link VersionNumber#VersionNumber(String, java.util.regex.Pattern)}. */ @@ -79,10 +79,10 @@ public class VersionNumberString extends VersionNumber { super( versionString, versionPattern); strVal = versionString; } - + /** Returns the version string this version number is derived from. */ public final String getVersionString() { return strVal; } - + @Override public String toString() { return super.toString() + " ("+strVal+")" ; diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java index 8030e94..c4451ac 100644 --- a/src/java/com/jogamp/common/util/VersionUtil.java +++ b/src/java/com/jogamp/common/util/VersionUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; import com.jogamp.common.os.AndroidVersion; @@ -97,16 +97,16 @@ public class VersionUtil { public static Manifest getManifest(ClassLoader cl, String extension) { return getManifest(cl, new String[] { extension } ); } - + /** - * Returns the manifest of the jar which contains one of the specified extensions. + * Returns the manifest of the jar which contains one of the specified extensions. * The provided ClassLoader is used for resource loading. * @param cl A ClassLoader which should find the manifest. * @param extensions The values of many 'Extension-Name's jar-manifest attribute; used to identify the manifest. - * Matching is applied in decreasing order, i.e. first element is favored over the second, etc. + * Matching is applied in decreasing order, i.e. first element is favored over the second, etc. * @return the requested manifest or null when not found. */ - public static Manifest getManifest(ClassLoader cl, String[] extensions) { + public static Manifest getManifest(ClassLoader cl, String[] extensions) { final Manifest[] extManifests = new Manifest[extensions.length]; try { Enumeration<URL> resources = cl.getResources("META-INF/MANIFEST.MF"); diff --git a/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java b/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java index a43b738..e98478e 100644 --- a/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java +++ b/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions 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. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -37,12 +37,12 @@ import com.jogamp.common.util.RunnableExecutor; */ public class AWTEDTExecutor implements RunnableExecutor { /** {@link RunnableExecutor} implementation invoking {@link Runnable#run()} - * on the AWT EDT. + * on the AWT EDT. */ public static final AWTEDTExecutor singleton = new AWTEDTExecutor(); private AWTEDTExecutor() {} - + @Override public void invoke(boolean wait, Runnable r) { if(EventQueue.isDispatchThread()) { @@ -76,12 +76,12 @@ public class AWTEDTExecutor implements RunnableExecutor { * <p> * Otherwise the runnable is not executed and <code>false</code> is returned. * </p> - * + * * @param treeLock representing the AWT-tree-lock, i.e. {@link java.awt.Component#getTreeLock()} * @param allowOnNonEDT allow execution on non AWT-EDT in case current thread is not AWT-EDT and the tree-lock is being hold - * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait. + * @param wait if true method waits until {@link Runnable#run()} is completed, otherwise don't wait. * @param r the {@link Runnable} to be executed. - * @return <code>true</code> if the {@link Runnable} has been issued for execution, otherwise <code>false</code> + * @return <code>true</code> if the {@link Runnable} has been issued for execution, otherwise <code>false</code> */ public boolean invoke(Object treeLock, boolean allowOnNonEDT, boolean wait, Runnable r) { if( EventQueue.isDispatchThread() ) { @@ -93,7 +93,7 @@ public class AWTEDTExecutor implements RunnableExecutor { EventQueue.invokeAndWait(r); } else { EventQueue.invokeLater(r); - } + } } catch (InvocationTargetException e) { throw new RuntimeException(e.getTargetException()); } catch (InterruptedException e) { diff --git a/src/java/com/jogamp/common/util/cache/TempFileCache.java b/src/java/com/jogamp/common/util/cache/TempFileCache.java index 32f5c2a..5898d50 100644 --- a/src/java/com/jogamp/common/util/cache/TempFileCache.java +++ b/src/java/com/jogamp/common/util/cache/TempFileCache.java @@ -43,9 +43,9 @@ public class TempFileCache { // Flag indicating that we got a fatal error in the static initializer. private static boolean staticInitError = false; - + private static final String tmpDirPrefix = "file_cache"; - + // Lifecycle: For one user's JVMs, ClassLoader and time. private static final File tmpBaseDir; @@ -71,12 +71,12 @@ public class TempFileCache { static { // Global Lock ! - synchronized (System.out) { + synchronized (System.out) { // Create / initialize the temp root directory, starting the Reaper // thread to reclaim old installations if necessary. If we get an // exception, set an error code. File _tmpBaseDir = null; - try { + try { _tmpBaseDir = new File(IOUtil.getTempDir(true /* executable */), tmpDirPrefix); _tmpBaseDir = IOUtil.testDir(_tmpBaseDir, true /* create */, false /* executable */); // executable already checked } catch (Exception ex) { @@ -85,12 +85,12 @@ public class TempFileCache { staticInitError = true; } tmpBaseDir = _tmpBaseDir; - + if (DEBUG) { System.err.println("TempFileCache: Static Initialization ---------------------------------------------- OK: "+(!staticInitError)); System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode())+", tempBaseDir "+tmpBaseDir.getAbsolutePath()); } - + if(!staticInitError) { try { initTmpRoot(); @@ -105,15 +105,15 @@ public class TempFileCache { } } } - + /** * Documented way to kick off static initialization * @return true is static initialization was successful */ public static boolean initSingleton() { - return !staticInitError; + return !staticInitError; } - + /** * This method is called by the static initializer to create / initialize * the temp root directory that will hold the temp directories for this @@ -197,7 +197,7 @@ public class TempFileCache { System.clearProperty(tmpRootPropName); } } - + if (tmpRootPropValue == null) { // Create ${tmpbase}/jlnNNNN.tmp then lock the file File tmpFile = File.createTempFile("jln", ".tmp", tmpBaseDir); @@ -413,7 +413,7 @@ public class TempFileCache { System.err.println("TempFileCache: new TempFileCache() --------------------- (static ok: "+(!staticInitError)+")"); System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode())+", this 0x"+Integer.toHexString(hashCode())); } - if(!staticInitError) { + if(!staticInitError) { try { createTmpDir(); } catch (Exception ex) { @@ -424,16 +424,16 @@ public class TempFileCache { if (DEBUG) { System.err.println("TempFileCache: tempDir "+individualTmpDir+" (ok: "+(!initError)+")"); System.err.println("----------------------------------------------------------"); - } + } } - + /** Delete the <code>individualTmpDir</code> recursively and remove it's reference. */ public void destroy() { if (DEBUG) { System.err.println("TempFileCache: destroy() --------------------- (static ok: "+(!staticInitError)+")"); System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(TempFileCache.class.getClassLoader().hashCode())+", this 0x"+Integer.toHexString(hashCode())); } - if(!staticInitError) { + if(!staticInitError) { try { removeAll(individualTmpDir); } catch (Exception ex) { @@ -443,26 +443,26 @@ public class TempFileCache { individualTmpDir = null; if (DEBUG) { System.err.println("TempFileCache: destroy() END"); - } + } } - + /** * @return true is static and object initialization was successful */ public boolean isValid() { return !staticInitError && !initError; } - + /** * Base temp directory used by TempFileCache. - * - * <p> + * + * <p> * Lifecycle: For one user's JVMs, ClassLoader and time. * </p> - * + * * This is set to: * <pre> * ${java.io.tmpdir}/tmpDirPrefix * </pre> - * + * * @return */ public File getBaseDir() { return tmpBaseDir; } @@ -481,18 +481,18 @@ public class TempFileCache { * * <p> * Use Case: Per ClassLoader files, eg. native libraries. - * </p> + * </p> * * <p> * Old temp directories are cleaned up the next time a JVM is launched that * uses TempFileCache. * </p> * - * + * * @return */ public File getRootDir() { return tmpRootDir; } - + /** * Temporary directory for individual files (eg. native libraries of one ClassLoader instance). * The directory name is: @@ -508,12 +508,12 @@ public class TempFileCache { * where jlnMMMMM is the unique filename created by File.createTempFile() * without the ".tmp" extension. * - * + * * @return */ public File getTempDir() { return individualTmpDir; } - - + + /** * Create the temp directory in tmpRootDir. To do this, we create a temp * file with a ".tmp" extension, and then create a directory of the diff --git a/src/java/com/jogamp/common/util/cache/TempJarCache.java b/src/java/com/jogamp/common/util/cache/TempJarCache.java index ecf6e56..48d8081 100644 --- a/src/java/com/jogamp/common/util/cache/TempJarCache.java +++ b/src/java/com/jogamp/common/util/cache/TempJarCache.java @@ -45,7 +45,7 @@ import com.jogamp.common.util.SecurityUtil; public class TempJarCache { private static final boolean DEBUG = Debug.debug("TempJarCache"); - + // A HashMap of native libraries that can be loaded with System.load() // The key is the string name of the library as passed into the loadLibrary // call; it is the file name without the directory or the platform-dependent @@ -55,8 +55,8 @@ public class TempJarCache { public enum LoadState { LOOKED_UP, LOADED; - - public boolean compliesWith(LoadState o2) { + + public boolean compliesWith(LoadState o2) { return null != o2 ? compareTo(o2) >= 0 : false; } } @@ -66,20 +66,20 @@ public class TempJarCache { } return has.compliesWith(exp); } - + // Set of jar files added private static Map<URI, LoadState> nativeLibJars; private static Map<URI, LoadState> classFileJars; private static Map<URI, LoadState> resourceFileJars; private static TempFileCache tmpFileCache; - + private static boolean staticInitError = false; private static volatile boolean isInit = false; - + /** * Documented way to kick off static initialization. - * + * * @return true is static initialization was successful */ public static boolean initSingleton() { @@ -88,12 +88,12 @@ public class TempJarCache { if (!isInit) { isInit = true; staticInitError = !TempFileCache.initSingleton(); - + if(!staticInitError) { tmpFileCache = new TempFileCache(); - staticInitError = !tmpFileCache.isValid(); + staticInitError = !tmpFileCache.isValid(); } - + if(!staticInitError) { // Initialize the collections of resources nativeLibMap = new HashMap<String, String>(); @@ -109,20 +109,20 @@ public class TempJarCache { } return !staticInitError; } - + /** * This is <b>not recommended</b> since the JNI libraries may still be * in use by the ClassLoader they are loaded via {@link System#load(String)}. * </p> * <p> - * In JogAmp, JNI native libraries loaded and registered by {@link JNILibLoaderBase} - * derivations, where the native JARs might be loaded via {@link JNILibLoaderBase#addNativeJarLibs(Class, String) }. + * In JogAmp, JNI native libraries loaded and registered by {@link JNILibLoaderBase} + * derivations, where the native JARs might be loaded via {@link JNILibLoaderBase#addNativeJarLibs(Class, String) }. * </p> * <p> * The only valid use case to shutdown the TempJarCache is at bootstrapping, * i.e. when no native library is guaranteed to be loaded. This could be useful * if bootstrapping needs to find the proper native library type. - * </p> + * </p> * public static void shutdown() { if (isInit) { // volatile: ok @@ -141,7 +141,7 @@ public class TempJarCache { classFileJars = null; resourceFileJars.clear(); resourceFileJars = null; - + tmpFileCache.destroy(); tmpFileCache = null; } @@ -149,32 +149,32 @@ public class TempJarCache { } } } */ - + /** * @return true if this class has been properly initialized, ie. is in use, otherwise false. */ public static boolean isInitialized() { return isInit && !staticInitError; } - + /* package */ static void checkInitialized() { if(!isInit) { throw new RuntimeException("initSingleton() has to be called first."); } } - + public static TempFileCache getTempFileCache() { checkInitialized(); return tmpFileCache; } - + public synchronized static boolean checkNativeLibs(URI jarURI, LoadState exp) throws IOException { checkInitialized(); if(null == jarURI) { throw new IllegalArgumentException("jarURI is null"); } return testLoadState(nativeLibJars.get(jarURI), exp); - } + } public synchronized static boolean checkClasses(URI jarURI, LoadState exp) throws IOException { checkInitialized(); @@ -182,7 +182,7 @@ public class TempJarCache { throw new IllegalArgumentException("jarURI is null"); } return testLoadState(classFileJars.get(jarURI), exp); - } + } public synchronized static boolean checkResources(URI jarURI, LoadState exp) throws IOException { checkInitialized(); @@ -191,29 +191,29 @@ public class TempJarCache { } return testLoadState(resourceFileJars.get(jarURI), exp); } - + /** * Adds native libraries, if not yet added. - * - * @param certClass if class is certified, the JarFile entries needs to have the same certificate + * + * @param certClass if class is certified, the JarFile entries needs to have the same certificate * @param jarURI * @param nativeLibraryPath if not null, only extracts native libraries within this path. * @return true if native libraries were added or previously loaded from given jarURI, otherwise false * @throws IOException if the <code>jarURI</code> could not be loaded or a previous load attempt failed * @throws SecurityException - * @throws URISyntaxException - * @throws IllegalArgumentException + * @throws URISyntaxException + * @throws IllegalArgumentException */ - public synchronized static final boolean addNativeLibs(Class<?> certClass, URI jarURI, String nativeLibraryPath) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException { + public synchronized static final boolean addNativeLibs(Class<?> certClass, URI jarURI, String nativeLibraryPath) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException { final LoadState nativeLibJarsLS = nativeLibJars.get(jarURI); - if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) ) { + if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) ) { nativeLibJars.put(jarURI, LoadState.LOOKED_UP); final JarFile jarFile = JarUtil.getJarFile(jarURI); if(DEBUG) { System.err.println("TempJarCache: addNativeLibs: "+jarURI+": nativeJar "+jarFile.getName()+" (NEW)"); } validateCertificates(certClass, jarFile); - final int num = JarUtil.extract(tmpFileCache.getTempDir(), nativeLibMap, jarFile, nativeLibraryPath, true, false, false); + final int num = JarUtil.extract(tmpFileCache.getTempDir(), nativeLibMap, jarFile, nativeLibraryPath, true, false, false); nativeLibJars.put(jarURI, LoadState.LOADED); return num > 0; } else if( testLoadState(nativeLibJarsLS, LoadState.LOADED) ) { @@ -224,78 +224,78 @@ public class TempJarCache { } throw new IOException("TempJarCache: addNativeLibs: "+jarURI+", previous load attempt failed"); } - + /** * Adds native classes, if not yet added. - * + * * TODO class access pending * needs Classloader.defineClass(..) access, ie. own derivation - will do when needed .. - * - * @param certClass if class is certified, the JarFile entries needs to have the same certificate + * + * @param certClass if class is certified, the JarFile entries needs to have the same certificate * @param jarURI * @throws IOException if the <code>jarURI</code> could not be loaded or a previous load attempt failed * @throws SecurityException - * @throws URISyntaxException - * @throws IllegalArgumentException + * @throws URISyntaxException + * @throws IllegalArgumentException */ public synchronized static final void addClasses(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException { final LoadState classFileJarsLS = classFileJars.get(jarURI); - if( !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) ) { + if( !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) ) { classFileJars.put(jarURI, LoadState.LOOKED_UP); final JarFile jarFile = JarUtil.getJarFile(jarURI); if(DEBUG) { System.err.println("TempJarCache: addClasses: "+jarURI+": nativeJar "+jarFile.getName()); } validateCertificates(certClass, jarFile); - JarUtil.extract(tmpFileCache.getTempDir(), null, jarFile, - null /* nativeLibraryPath */, false, true, false); + JarUtil.extract(tmpFileCache.getTempDir(), null, jarFile, + null /* nativeLibraryPath */, false, true, false); classFileJars.put(jarURI, LoadState.LOADED); } else if( !testLoadState(classFileJarsLS, LoadState.LOADED) ) { throw new IOException("TempJarCache: addClasses: "+jarURI+", previous load attempt failed"); } } - + /** * Adds native resources, if not yet added. - * - * @param certClass if class is certified, the JarFile entries needs to have the same certificate + * + * @param certClass if class is certified, the JarFile entries needs to have the same certificate * @param jarURI * @return * @throws IOException if the <code>jarURI</code> could not be loaded or a previous load attempt failed * @throws SecurityException - * @throws URISyntaxException - * @throws IllegalArgumentException + * @throws URISyntaxException + * @throws IllegalArgumentException */ - public synchronized static final void addResources(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException { + public synchronized static final void addResources(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException { final LoadState resourceFileJarsLS = resourceFileJars.get(jarURI); - if( !testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP) ) { + if( !testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP) ) { resourceFileJars.put(jarURI, LoadState.LOOKED_UP); final JarFile jarFile = JarUtil.getJarFile(jarURI); if(DEBUG) { System.err.println("TempJarCache: addResources: "+jarURI+": nativeJar "+jarFile.getName()); } validateCertificates(certClass, jarFile); - JarUtil.extract(tmpFileCache.getTempDir(), null, jarFile, - null /* nativeLibraryPath */, false, false, true); + JarUtil.extract(tmpFileCache.getTempDir(), null, jarFile, + null /* nativeLibraryPath */, false, false, true); resourceFileJars.put(jarURI, LoadState.LOADED); } else if( !testLoadState(resourceFileJarsLS, LoadState.LOADED) ) { throw new IOException("TempJarCache: addResources: "+jarURI+", previous load attempt failed"); } } - + /** * Adds all types, native libraries, class files and other files (resources) * if not yet added. - * + * * TODO class access pending * needs Classloader.defineClass(..) access, ie. own derivation - will do when needed .. - * - * @param certClass if class is certified, the JarFile entries needs to have the same certificate + * + * @param certClass if class is certified, the JarFile entries needs to have the same certificate * @param jarURI * @throws IOException if the <code>jarURI</code> could not be loaded or a previous load attempt failed * @throws SecurityException - * @throws URISyntaxException - * @throws IllegalArgumentException + * @throws URISyntaxException + * @throws IllegalArgumentException */ public synchronized static final void addAll(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException { checkInitialized(); @@ -305,14 +305,14 @@ public class TempJarCache { final LoadState nativeLibJarsLS = nativeLibJars.get(jarURI); final LoadState classFileJarsLS = classFileJars.get(jarURI); final LoadState resourceFileJarsLS = resourceFileJars.get(jarURI); - if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) || - !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) || + if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) || + !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) || !testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP) ) { - + final boolean extractNativeLibraries = !testLoadState(nativeLibJarsLS, LoadState.LOADED); final boolean extractClassFiles = !testLoadState(classFileJarsLS, LoadState.LOADED); final boolean extractOtherFiles = !testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP); - + // mark looked-up (those who are not loaded) if(extractNativeLibraries) { nativeLibJars.put(jarURI, LoadState.LOOKED_UP); @@ -323,15 +323,15 @@ public class TempJarCache { if(extractOtherFiles) { resourceFileJars.put(jarURI, LoadState.LOOKED_UP); } - + final JarFile jarFile = JarUtil.getJarFile(jarURI); if(DEBUG) { System.err.println("TempJarCache: addAll: "+jarURI+": nativeJar "+jarFile.getName()); } validateCertificates(certClass, jarFile); - JarUtil.extract(tmpFileCache.getTempDir(), nativeLibMap, jarFile, + JarUtil.extract(tmpFileCache.getTempDir(), nativeLibMap, jarFile, null /* nativeLibraryPath */, extractNativeLibraries, extractClassFiles, extractOtherFiles); - + // mark loaded (those were just loaded) if(extractNativeLibraries) { nativeLibJars.put(jarURI, LoadState.LOADED); @@ -342,20 +342,20 @@ public class TempJarCache { if(extractOtherFiles) { resourceFileJars.put(jarURI, LoadState.LOADED); } - } else if( !testLoadState(nativeLibJarsLS, LoadState.LOADED) || - !testLoadState(classFileJarsLS, LoadState.LOADED) || + } else if( !testLoadState(nativeLibJarsLS, LoadState.LOADED) || + !testLoadState(classFileJarsLS, LoadState.LOADED) || !testLoadState(resourceFileJarsLS, LoadState.LOADED) ) { - throw new IOException("TempJarCache: addAll: "+jarURI+", previous load attempt failed"); + throw new IOException("TempJarCache: addAll: "+jarURI+", previous load attempt failed"); } } - + public synchronized static final String findLibrary(String libName) { checkInitialized(); // try with mapped library basename first String path = nativeLibMap.get(libName); if(null == path) { // if valid library name, try absolute path in temp-dir - if(null != NativeLibrary.isValidNativeLibraryName(libName, false)) { + if(null != NativeLibrary.isValidNativeLibraryName(libName, false)) { final File f = new File(tmpFileCache.getTempDir(), libName); if(f.exists()) { path = f.getAbsolutePath(); @@ -364,9 +364,9 @@ public class TempJarCache { } return path; } - + /** TODO class access pending - * needs Classloader.defineClass(..) access, ie. own derivation - will do when needed .. + * needs Classloader.defineClass(..) access, ie. own derivation - will do when needed .. public static Class<?> findClass(String name, ClassLoader cl) throws IOException, ClassFormatError { checkInitialized(); final File f = new File(nativeTmpFileCache.getTempDir(), IOUtil.getClassFileName(name)); @@ -379,7 +379,7 @@ public class TempJarCache { } return null; } */ - + public synchronized static final String findResource(String name) { checkInitialized(); final File f = new File(tmpFileCache.getTempDir(), name); @@ -388,7 +388,7 @@ public class TempJarCache { } return null; } - + public synchronized static final URI getResource(String name) throws URISyntaxException { checkInitialized(); final File f = new File(tmpFileCache.getTempDir(), name); @@ -397,7 +397,7 @@ public class TempJarCache { } return null; } - + private static void validateCertificates(Class<?> certClass, JarFile jarFile) throws IOException, SecurityException { if(null == certClass) { throw new IllegalArgumentException("certClass is null"); @@ -411,9 +411,9 @@ public class TempJarCache { JarUtil.validateCertificates(rootCerts, jarFile); if(DEBUG) { System.err.println("TempJarCache: validateCertificates: OK - Matching rootCerts in given class "+certClass.getName()+", nativeJar "+jarFile.getName()); - } + } } else if(DEBUG) { System.err.println("TempJarCache: validateCertificates: OK - No rootCerts in given class "+certClass.getName()+", nativeJar "+jarFile.getName()); } - } + } } diff --git a/src/java/com/jogamp/common/util/locks/Lock.java b/src/java/com/jogamp/common/util/locks/Lock.java index df645ed..5130876 100644 --- a/src/java/com/jogamp/common/util/locks/Lock.java +++ b/src/java/com/jogamp/common/util/locks/Lock.java @@ -43,8 +43,8 @@ public interface Lock { /** The default {@link #TIMEOUT} value, of {@value} ms */ public static final long DEFAULT_TIMEOUT = 5000; // 5s default timeout - - /** + + /** * The <code>TIMEOUT</code> for {@link #lock()} in ms, * defaults to {@link #DEFAULT_TIMEOUT}. * <p> @@ -78,7 +78,7 @@ public interface Lock { * @throws RuntimeException in case the lock is not acquired by this thread. */ void unlock() throws RuntimeException; - + /** Query if locked */ boolean isLocked(); } diff --git a/src/java/com/jogamp/common/util/locks/LockFactory.java b/src/java/com/jogamp/common/util/locks/LockFactory.java index bb2d5f4..e1ec2d7 100644 --- a/src/java/com/jogamp/common/util/locks/LockFactory.java +++ b/src/java/com/jogamp/common/util/locks/LockFactory.java @@ -35,25 +35,25 @@ import jogamp.common.util.locks.RecursiveThreadGroupLockImpl01Unfairish; public class LockFactory { public enum ImplType { - Int01(0), Java5(1), Int02ThreadGroup(2); - + Int01(0), Java5(1), Int02ThreadGroup(2); + public final int id; ImplType(int id){ this.id = id; } - } - + } + /** default is ImplType.Int01, unfair'ish (fastest w/ least deviation) */ public static RecursiveLock createRecursiveLock() { return new RecursiveLockImpl01Unfairish(); } - + /** default is ImplType.Int02ThreadGroup, unfair'ish (fastest w/ least deviation) */ public static RecursiveThreadGroupLock createRecursiveThreadGroupLock() { return new RecursiveThreadGroupLockImpl01Unfairish(); } - + public static RecursiveLock createRecursiveLock(ImplType t, boolean fair) { switch(t) { case Int01: @@ -65,5 +65,5 @@ public class LockFactory { } throw new InternalError("XXX"); } - + } diff --git a/src/java/com/jogamp/common/util/locks/RecursiveLock.java b/src/java/com/jogamp/common/util/locks/RecursiveLock.java index 3e0a873..c56a5ef 100644 --- a/src/java/com/jogamp/common/util/locks/RecursiveLock.java +++ b/src/java/com/jogamp/common/util/locks/RecursiveLock.java @@ -32,7 +32,7 @@ package com.jogamp.common.util.locks; * Reentrance capable locking toolkit. */ public interface RecursiveLock extends ThreadLock { - /** + /** * Return the number of locks issued to this lock by the same thread. * <ul> * <li>A hold count of 0 identifies this lock as unlocked.</li> diff --git a/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java b/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java index 626199f..a23c320 100644 --- a/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java +++ b/src/java/com/jogamp/common/util/locks/RecursiveThreadGroupLock.java @@ -34,67 +34,67 @@ package com.jogamp.common.util.locks; * </p> */ public interface RecursiveThreadGroupLock extends RecursiveLock { - /** - * Returns true if the current thread is the original lock owner, ie. + /** + * Returns true if the current thread is the original lock owner, ie. * successfully claimed this lock the first time, ie. {@link #getHoldCount()} == 1. */ boolean isOriginalOwner(); - - /** - * Returns true if the passed thread is the original lock owner, ie. + + /** + * Returns true if the passed thread is the original lock owner, ie. * successfully claimed this lock the first time, ie. {@link #getHoldCount()} == 1. */ boolean isOriginalOwner(Thread thread); - - /** + + /** * Add a thread to the list of additional lock owners, which enables them to recursively claim this lock. * <p> * The caller must hold this lock and be the original lock owner, see {@link #isOriginalOwner()}. * </p> * <p> - * If the original owner releases this lock via {@link #unlock()} + * If the original owner releases this lock via {@link #unlock()} * all additional lock owners are released as well. * This ensures consistency of spawn off additional lock owner threads and it's release. - * </p> + * </p> * Use case: * <pre> * Thread2 thread2 = new Thread2(); - * + * * Thread1 { - * + * * // Claim this lock and become the original lock owner. * lock.lock(); - * + * * try { - * + * * // Allow Thread2 to claim the lock, ie. make thread2 an additional lock owner * addOwner(thread2); - * + * * // Start thread2 * thread2.start(); - * + * * // Wait until thread2 has finished requiring this lock, but keep thread2 running - * while(!thread2.waitForResult()) sleep(); - * + * while(!thread2.waitForResult()) sleep(); + * * // Optional: Only if sure that this thread doesn't hold the lock anymore, - * // otherwise just release the lock via unlock(). + * // otherwise just release the lock via unlock(). * removeOwner(thread2); - * + * * } finally { - * + * * // Release this lock and remove all additional lock owners. * // Implicit wait until thread2 gets off the lock. * lock.unlock(); - * + * * } - * + * * }.start(); * </pre> - * - * @param t the thread to be added to the list of additional owning threads + * + * @param t the thread to be added to the list of additional owning threads * @throws RuntimeException if the current thread does not hold the lock. * @throws IllegalArgumentException if the passed thread is the lock owner or already added. - * + * * @see #removeOwner(Thread) * @see #unlock() * @see #lock() @@ -109,31 +109,31 @@ public interface RecursiveThreadGroupLock extends RecursiveLock { * <p> * Only use this method if sure that the thread doesn't hold the lock anymore. * </p> - * - * @param t the thread to be removed from the list of additional owning threads + * + * @param t the thread to be removed from the list of additional owning threads * @throws RuntimeException if the current thread does not hold the lock. * @throws IllegalArgumentException if the passed thread is not added by {@link #addOwner(Thread)} */ void removeOwner(Thread t) throws RuntimeException, IllegalArgumentException; - + /** * <p> * Wait's until all additional owners released this lock before releasing it. * </p> - * + * * {@inheritDoc} */ @Override void unlock() throws RuntimeException; - + /** * <p> * Wait's until all additional owners released this lock before releasing it. * </p> - * + * * {@inheritDoc} */ @Override - void unlock(Runnable taskAfterUnlockBeforeNotify); - + void unlock(Runnable taskAfterUnlockBeforeNotify); + } diff --git a/src/java/com/jogamp/common/util/locks/SingletonInstance.java b/src/java/com/jogamp/common/util/locks/SingletonInstance.java index 825098d..f016d4b 100644 --- a/src/java/com/jogamp/common/util/locks/SingletonInstance.java +++ b/src/java/com/jogamp/common/util/locks/SingletonInstance.java @@ -44,7 +44,7 @@ public abstract class SingletonInstance implements Lock { public static SingletonInstance createFileLock(long poll_ms, File lockFile) { return new SingletonInstanceFileLock(poll_ms, lockFile); } - + /** * A user shall use <b>ephemeral ports</b>: * <ul> @@ -54,23 +54,23 @@ public abstract class SingletonInstance implements Lock { * <li>FreeBSD < 4.6 and BSD use ports 1024 through 4999.</li> * <li>Microsoft Windows operating systems through Server 2003 use the range 1025 to 5000</li> * <li>Windows Vista, Windows 7, and Server 2008 use the IANA range.</li> - * </ul> + * </ul> * @param pollPeriod - * @param portNumber to be used for this single instance server socket. + * @param portNumber to be used for this single instance server socket. */ public static SingletonInstance createServerSocket(long poll_ms, int portNumber) { return new SingletonInstanceServerSocket(poll_ms, portNumber); } - + protected SingletonInstance(long poll_ms) { this.poll_ms = Math.max(10, poll_ms); } - + public final long getPollPeriod() { return poll_ms; } public abstract String getName(); @Override public final String toString() { return getName(); } - + @Override public synchronized void lock() throws RuntimeException { try { @@ -99,7 +99,7 @@ public abstract class SingletonInstance implements Lock { if( DEBUG ) { final long t2 = System.currentTimeMillis(); System.err.println(infoPrefix(t2)+" +++ "+getName()+" - Locked within "+(t2-t0)+" ms, "+(i+1)+" attempts"); - } + } return true; } if( DEBUG && 0==i ) { @@ -118,9 +118,9 @@ public abstract class SingletonInstance implements Lock { System.err.println(infoPrefix(t2)+" +++ EEE (2) "+getName()+" - couldn't get lock within "+(t2-t0)+" ms, "+i+" attempts"); } return false; - } + } protected abstract boolean tryLockImpl(); - + @Override public void unlock() throws RuntimeException { final long t0 = System.currentTimeMillis(); @@ -145,7 +145,7 @@ public abstract class SingletonInstance implements Lock { protected String infoPrefix() { return infoPrefix(System.currentTimeMillis()); } - + private final long poll_ms; private boolean locked = false; } diff --git a/src/java/com/jogamp/common/util/locks/ThreadLock.java b/src/java/com/jogamp/common/util/locks/ThreadLock.java index 65260bc..26e7475 100644 --- a/src/java/com/jogamp/common/util/locks/ThreadLock.java +++ b/src/java/com/jogamp/common/util/locks/ThreadLock.java @@ -33,27 +33,27 @@ package com.jogamp.common.util.locks; */ public interface ThreadLock extends Lock { - /** Query whether the lock is hold by the a thread other than the current thread. */ + /** Query whether the lock is hold by the a thread other than the current thread. */ boolean isLockedByOtherThread(); - /** Query whether the lock is hold by the given thread. */ + /** Query whether the lock is hold by the given thread. */ boolean isOwner(Thread thread); - + /** * @return the Thread owning this lock if locked, otherwise null */ Thread getOwner(); /** - * @throws RuntimeException if current thread does not hold the lock + * @throws RuntimeException if current thread does not hold the lock */ void validateLocked() throws RuntimeException; - + /** * Execute the {@link Runnable Runnable taskAfterUnlockBeforeNotify} while holding the exclusive lock. * <p> * Then release the lock. - * </p> + * </p> */ - void unlock(Runnable taskAfterUnlockBeforeNotify); + void unlock(Runnable taskAfterUnlockBeforeNotify); } |