diff options
author | Sven Gothel <[email protected]> | 2014-07-03 16:06:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-03 16:06:47 +0200 |
commit | df9ff7f340a5ab4e07efc613f5f264eeae63d4c7 (patch) | |
tree | 239ae276b82024b140428e6c0fe5d739fdd686a4 /src/java/jogamp | |
parent | eb47aaba63e3b1bf55f274a0f338f1010a017ae4 (diff) |
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74)
- Change non static accesses to static members using declaring type
- Change indirect accesses to static members to direct accesses (accesses through subtypes)
- Add final modifier to private fields
- Add final modifier to method parameters
- Add final modifier to local variables
- Remove unnecessary casts
- Remove unnecessary '$NON-NLS$' tags
- Remove trailing white spaces on all lines
Diffstat (limited to 'src/java/jogamp')
37 files changed, 489 insertions, 495 deletions
diff --git a/src/java/jogamp/android/launcher/ActivityLauncher.java b/src/java/jogamp/android/launcher/ActivityLauncher.java index 72b7c0a..99bead8 100644 --- a/src/java/jogamp/android/launcher/ActivityLauncher.java +++ b/src/java/jogamp/android/launcher/ActivityLauncher.java @@ -48,7 +48,7 @@ public class ActivityLauncher extends Activity { Object activityObject = null; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { Log.d(TAG, "onCreate - S"); super.onCreate(savedInstanceState); @@ -57,7 +57,7 @@ public class ActivityLauncher extends Activity { data.setSystemProperties(); dataSet = true; - ClassLoader cl = ClassLoaderUtil.createClassLoader(this, data.getSysPackages(), data.getUsrPackages(), null); + final ClassLoader cl = ClassLoaderUtil.createClassLoader(this, data.getSysPackages(), data.getUsrPackages(), null); if(null != cl) { try { activityClazz = Class.forName(data.getActivityName(), true, cl); @@ -72,7 +72,7 @@ public class ActivityLauncher extends Activity { mSetRootActivity = activityClazz.getMethod("setRootActivity", Activity.class); activityObject = createInstance(activityClazz, null); Log.d(TAG, "Activity Object "+activityObject); - } catch (Exception e) { + } catch (final Exception e) { Log.d(TAG, "error: "+e, e); throw new RuntimeException(e); } @@ -81,7 +81,7 @@ public class ActivityLauncher extends Activity { if( null == mOnCreate || null == mOnDestroy || null == mOnPause || null == mOnRestart || null == mOnResume || null == mSetRootActivity ) { - RuntimeException e = new RuntimeException("XXX - incomplete method set"); + final RuntimeException e = new RuntimeException("XXX - incomplete method set"); Log.d(TAG, "error: "+e, e); throw e; } @@ -172,18 +172,18 @@ public class ActivityLauncher extends Activity { /** * @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(final Class<?> clazz, final Class<?>[] cstrArgTypes, final Object ... cstrArgs) throws RuntimeException { return createInstance(getConstructor(clazz, cstrArgTypes), cstrArgs); } - public static final Object createInstance(Constructor<?> cstr, Object ... cstrArgs) + public static final Object createInstance(final Constructor<?> cstr, final Object ... cstrArgs) throws RuntimeException { try { return cstr.newInstance(cstrArgs); - } catch (Exception e) { + } catch (final Exception e) { Throwable t = e; if (t instanceof InvocationTargetException) { t = ((InvocationTargetException) t).getTargetException(); @@ -201,22 +201,22 @@ public class ActivityLauncher extends Activity { /** * @throws JogampRuntimeException if the constructor can not be delivered. */ - protected static final Constructor<?> getConstructor(Class<?> clazz, Class<?> ... cstrArgTypes) + protected static final Constructor<?> getConstructor(final Class<?> clazz, Class<?> ... cstrArgTypes) throws RuntimeException { try { if(null == cstrArgTypes) { cstrArgTypes = zeroTypes; } return clazz.getDeclaredConstructor(cstrArgTypes); - } catch (NoSuchMethodException ex) { + } catch (final NoSuchMethodException ex) { throw new RuntimeException("Constructor: '" + clazz + "(" + asString(cstrArgTypes) + ")' not found", ex); } } protected static final Class<?>[] zeroTypes = new Class[0]; - protected static final String asString(Class<?>[] argTypes) { - StringBuilder args = new StringBuilder(); + protected static final String asString(final Class<?>[] argTypes) { + final StringBuilder args = new StringBuilder(); boolean coma = false; if(null != argTypes) { for (int i = 0; i < argTypes.length; i++) { @@ -230,12 +230,12 @@ public class ActivityLauncher extends Activity { return args.toString(); } - protected static final Object callMethod(Object instance, Method method, Object ... args) + protected static final Object callMethod(final Object instance, final Method method, final Object ... args) throws RuntimeException { try { return method.invoke(instance, args); - } catch (Exception e) { + } catch (final Exception e) { Throwable t = e; if (t instanceof InvocationTargetException) { t = ((InvocationTargetException) t).getTargetException(); diff --git a/src/java/jogamp/android/launcher/AssetDexClassLoader.java b/src/java/jogamp/android/launcher/AssetDexClassLoader.java index fb2d7d3..84e5318 100644 --- a/src/java/jogamp/android/launcher/AssetDexClassLoader.java +++ b/src/java/jogamp/android/launcher/AssetDexClassLoader.java @@ -9,11 +9,11 @@ import dalvik.system.DexClassLoader; public class AssetDexClassLoader extends DexClassLoader { private static final boolean DEBUG = false; private static final String assets_folder = "assets/"; - + private static int next_id = 1; private final int id; - - public AssetDexClassLoader(String dexPath, String dexOutputDir, String libPath, ClassLoader parent) { + + public AssetDexClassLoader(final String dexPath, final String dexOutputDir, final String libPath, final ClassLoader parent) { super(dexPath, dexOutputDir, libPath, parent); synchronized(AssetDexClassLoader.class) { id = next_id++; @@ -22,27 +22,27 @@ public class AssetDexClassLoader extends DexClassLoader { Log.d(getSimpleName(), getIdName()+".ctor: dexPath " + dexPath + ", dexOutputDir " + dexOutputDir + ", libPath " + libPath + ", parent " + parent); } } - + protected final String getSimpleName() { return AssetDexClassLoader.class.getSimpleName(); } protected final String getIdName() { return "ADCL["+id+"]"; } - + @Override - public String findLibrary(String libName) { - final String res = super.findLibrary(libName); + public String findLibrary(final String libName) { + final String res = super.findLibrary(libName); if(DEBUG) { Log.d(getSimpleName(), getIdName()+".findLibrary: " + libName + " -> " + res); } return res; } - + @Override - public URL findResource(String name) { + public URL findResource(final String name) { final String assetName = name.startsWith(assets_folder) ? name : assets_folder + name ; - URL url = super.findResource(assetName); + final URL url = super.findResource(assetName); if(DEBUG) { Log.d(getSimpleName(), getIdName()+".findResource: " + name + " -> " + assetName + " -> " + url); } diff --git a/src/java/jogamp/android/launcher/ClassLoaderUtil.java b/src/java/jogamp/android/launcher/ClassLoaderUtil.java index 76dbf53..5238fd4 100644 --- a/src/java/jogamp/android/launcher/ClassLoaderUtil.java +++ b/src/java/jogamp/android/launcher/ClassLoaderUtil.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. @@ -40,33 +40,33 @@ import android.util.Log; public class ClassLoaderUtil { private static final String TAG = "JogampClassLoader"; - + private static HashMap<String, ClassLoader> cachedClassLoader = new HashMap<String, ClassLoader>(); - + // location where optimized dex files will be written private static final String dexPathName= "jogampDex"; - private static File dexPath = null; - - private static LauncherTempFileCache tmpFileCache = null; - + private static File dexPath = null; + + private static LauncherTempFileCache tmpFileCache = null; + private static final String PATH_SEP = "/"; private static final String ELEM_SEP = ":"; - - private static synchronized void init(Context ctx) { + + private static synchronized void init(final Context ctx) { if(null == tmpFileCache) { if(!LauncherTempFileCache.initSingleton(ctx)) { throw new InternalError("TempFileCache initialization error"); } tmpFileCache = new LauncherTempFileCache(); if(!tmpFileCache.isValid()) { - throw new InternalError("TempFileCache instantiation error"); - } + throw new InternalError("TempFileCache instantiation error"); + } dexPath = new File(tmpFileCache.getTempDir(), dexPathName); Log.d(TAG, "jogamp dexPath: " + dexPath.getAbsolutePath()); dexPath.mkdir(); - } + } } - + /** * @param ctx * @param cachedPackageName list of package names w/ native libraries for which a ClassLoader shall be cached, i.e. persistence. @@ -75,11 +75,11 @@ public class ClassLoaderUtil { * @param userAPKNames optional non-cached user APKs * @return */ - public static synchronized ClassLoader createClassLoader(Context ctx, List<String> cachedPackageName, - List<String> userPackageNames, List<String> userAPKNames) { - return createClassLoader(ctx, cachedPackageName, userPackageNames, userAPKNames, null); + public static synchronized ClassLoader createClassLoader(final Context ctx, final List<String> cachedPackageName, + final List<String> userPackageNames, final List<String> userAPKNames) { + return createClassLoader(ctx, cachedPackageName, userPackageNames, userAPKNames, null); } - + /** * @param ctx * @param cachedPackageNames list of package names w/ native libraries for which a ClassLoader shall be cached, i.e. persistence. @@ -89,11 +89,11 @@ public class ClassLoaderUtil { * @param parent * @return */ - public static synchronized ClassLoader createClassLoader(Context ctx, List<String> cachedPackageNames, - List<String> userPackageNames, List<String> userAPKNames, - ClassLoader parent) { + public static synchronized ClassLoader createClassLoader(final Context ctx, final List<String> cachedPackageNames, + final List<String> userPackageNames, final List<String> userAPKNames, + final ClassLoader parent) { init(ctx); - + final String cacheKey = cachedPackageNames.toString(); ClassLoader clCached = cachedClassLoader.get(cacheKey); if( null == clCached ) { @@ -101,12 +101,12 @@ public class ClassLoaderUtil { cachedClassLoader.put(cacheKey, clCached); Log.d(TAG, "NEW cached-CL: cachedPackageNames: "+cacheKey); } else { - Log.d(TAG, "REUSE cached-CL: cachedPackageNames: "+cacheKey); + Log.d(TAG, "REUSE cached-CL: cachedPackageNames: "+cacheKey); } - - return createClassLoaderImpl(ctx, userPackageNames, false, userAPKNames, clCached); + + return createClassLoaderImpl(ctx, userPackageNames, false, userAPKNames, clCached); } - + /** * @param ctx * @param packageNames list of package names @@ -115,33 +115,33 @@ public class ClassLoaderUtil { * @param parent * @return */ - private static synchronized ClassLoader createClassLoaderImpl(Context ctx, List<String> packageNames, boolean addLibPath, - List<String> apkNames, ClassLoader parent) { - + private static synchronized ClassLoader createClassLoaderImpl(final Context ctx, final List<String> packageNames, final boolean addLibPath, + final List<String> apkNames, final ClassLoader parent) { + final ApplicationInfo appInfoLauncher= ctx.getApplicationInfo(); final String appDirLauncher = new File(appInfoLauncher.dataDir).getParent(); final String libSubDef = "lib"; Log.d(TAG, "S: userPackageNames: "+packageNames+"; Launcher: appDir "+appDirLauncher+", dataDir: "+appInfoLauncher.dataDir+", nativeLibraryDir "+appInfoLauncher.nativeLibraryDir); - + final StringBuilder apks = new StringBuilder(); final StringBuilder libs = new StringBuilder(); int apkCount = 0; String lastUserPackageName = null; // the very last one reflects the Activity - + if( null != packageNames ) { - for(Iterator<String> i=packageNames.iterator(); i.hasNext(); ) { + for(final Iterator<String> i=packageNames.iterator(); i.hasNext(); ) { lastUserPackageName = i.next(); - + String userAPK = null; String nativeLibraryDir=null; try { final PackageManager pm = ctx.getPackageManager(); final ApplicationInfo appInfo = pm.getApplicationInfo(lastUserPackageName, 0); - final String appDir = new File(appInfoLauncher.dataDir).getParent(); + final String appDir = new File(appInfoLauncher.dataDir).getParent(); userAPK = appInfo.sourceDir; nativeLibraryDir = appInfo.nativeLibraryDir; Log.d(TAG, "S: userPackage: "+lastUserPackageName+", apk "+userAPK+", appDir "+appDir+", dataDir: "+appInfo.dataDir+", nativeLibraryDir "+nativeLibraryDir); - } catch (PackageManager.NameNotFoundException e) { + } catch (final PackageManager.NameNotFoundException e) { Log.d(TAG, "error: "+e, e); } if(null != userAPK) { @@ -173,10 +173,10 @@ public class ClassLoaderUtil { } } final int userAPKCount = apkCount; - + if( null != apkNames ) { - for(Iterator<String> i=apkNames.iterator(); i.hasNext(); ) { - String userAPK = i.next(); + for(final Iterator<String> i=apkNames.iterator(); i.hasNext(); ) { + final String userAPK = i.next(); if(apkCount>0) { apks.append(ELEM_SEP); } @@ -189,13 +189,13 @@ public class ClassLoaderUtil { return null; } } - + // return new TraceDexClassLoader(apks.toString(), dexPath.getAbsolutePath(), libs.toString(), parent); return new AssetDexClassLoader(apks.toString(), dexPath.getAbsolutePath(), libs.toString(), parent); } - + /*** - * + * public boolean setAPKClassLoader(String activityPackageName, ClassLoader classLoader) { try { @@ -212,9 +212,9 @@ public class ClassLoaderUtil { Field mClassLoader = getField(apkClass, "mClassLoader"); mClassLoader.set(apk, classLoader); - + Log.d(TAG, "setAPKClassLoader: OK"); - + return true; } catch (IllegalArgumentException e) { e.printStackTrace(); @@ -238,6 +238,6 @@ public class ClassLoaderUtil { } return null; } - */ + */ } diff --git a/src/java/jogamp/android/launcher/LauncherTempFileCache.java b/src/java/jogamp/android/launcher/LauncherTempFileCache.java index c7b9ad0..6836dd9 100644 --- a/src/java/jogamp/android/launcher/LauncherTempFileCache.java +++ b/src/java/jogamp/android/launcher/LauncherTempFileCache.java @@ -42,14 +42,14 @@ public class LauncherTempFileCache { // Lifecycle: For all JVMs, ClassLoader and times. private static final String tmpSubDir = "jogamp"; private static final String tmpDirPrefix = "file_cache"; - + // Get the value of the tmproot system property // Lifecycle: For all JVMs and ClassLoader /* package */ static final String tmpRootPropName = "jnlp.jogamp.tmp.cache.root"; // Flag indicating that we got a fatal error in the static initializer. private static boolean staticInitError = false; - + private static File tmpBaseDir; // String representing the name of the temp root directory relative to the @@ -66,26 +66,26 @@ public class LauncherTempFileCache { private boolean initError = false; private File individualTmpDir; - + /** * Documented way to kick off static initialization * @return true is static initialization was successful */ - public static synchronized boolean initSingleton(Context ctx) { + public static synchronized boolean initSingleton(final Context ctx) { if(null == tmpRootDir && !staticInitError) { // 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. try { initTmpRoot(ctx); - } catch (Exception ex) { + } catch (final Exception ex) { ex.printStackTrace(); staticInitError = true; } } - 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 @@ -136,7 +136,7 @@ public class LauncherTempFileCache { * * 6. Start the Reaper thread to cleanup old installations. */ - private static void initTmpRoot(Context ctx) throws IOException { + private static void initTmpRoot(final Context ctx) throws IOException { if (DEBUG) { System.err.println("TempFileCache: Static Initialization ----------------------------------------------"); System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(LauncherTempFileCache.class.getClassLoader().hashCode())); @@ -165,7 +165,7 @@ public class LauncherTempFileCache { tmpRootDir = new File(tmpBaseDir, tmpRootPropValue); if (DEBUG) { System.err.println("TempFileCache: Trying tmpRootDir = " + tmpRootDir.getAbsolutePath()); - } + } if (tmpRootDir.isDirectory()) { if (!tmpRootDir.canWrite()) { throw new IOException("Temp root directory is not writable: " + tmpRootDir.getAbsolutePath()); @@ -177,9 +177,9 @@ public class LauncherTempFileCache { tmpRootPropValue = null; tmpRootDir = null; System.clearProperty(tmpRootPropName); - } + } } - + if (tmpRootPropValue == null) { // Create the tmpbase directory if it doesn't already exist tmpBaseDir.mkdirs(); @@ -188,7 +188,7 @@ public class LauncherTempFileCache { } // Create ${tmpbase}/jlnNNNN.tmp then lock the file - File tmpFile = File.createTempFile("jln", ".tmp", tmpBaseDir); + final File tmpFile = File.createTempFile("jln", ".tmp", tmpBaseDir); if (DEBUG) { System.err.println("TempFileCache: tmpFile = " + tmpFile.getAbsolutePath()); } @@ -197,12 +197,12 @@ public class LauncherTempFileCache { final FileLock tmpLock = tmpChannel.lock(); // Strip off the ".tmp" to get the name of the tmprootdir - String tmpFileName = tmpFile.getAbsolutePath(); - String tmpRootName = tmpFileName.substring(0, tmpFileName.lastIndexOf(".tmp")); + final String tmpFileName = tmpFile.getAbsolutePath(); + final String tmpRootName = tmpFileName.substring(0, tmpFileName.lastIndexOf(".tmp")); // create ${tmpbase}/jlnNNNN.lck then lock the file - String lckFileName = tmpRootName + ".lck"; - File lckFile = new File(lckFileName); + final String lckFileName = tmpRootName + ".lck"; + final File lckFile = new File(lckFileName); if (DEBUG) { System.err.println("TempFileCache: lckFile = " + lckFile.getAbsolutePath()); } @@ -235,7 +235,7 @@ public class LauncherTempFileCache { tmpLock.release(); lckOut.close(); lckLock.release(); - } catch (IOException ex) { + } catch (final IOException ex) { // Do nothing } } @@ -249,7 +249,7 @@ public class LauncherTempFileCache { } // Start a new Reaper thread to do stuff... - Thread reaperThread = new Thread() { + final Thread reaperThread = new Thread() { /* @Override */ public void run() { deleteOldTempDirs(); @@ -276,9 +276,9 @@ public class LauncherTempFileCache { // enumerate list of jnl*.lck files, ignore our own jlnNNNN file final String ourLockFile = tmpRootPropValue + ".lck"; - FilenameFilter lckFilter = new FilenameFilter() { + final FilenameFilter lckFilter = new FilenameFilter() { /* @Override */ - public boolean accept(File dir, String name) { + public boolean accept(final File dir, final String name) { return name.endsWith(".lck") && !name.equals(ourLockFile); } }; @@ -288,16 +288,16 @@ public class LauncherTempFileCache { // (which should always succeed unless there is a problem). If we can // get the lock on both files, then it must be an old installation, and // we will delete it. - String[] fileNames = tmpBaseDir.list(lckFilter); + final String[] fileNames = tmpBaseDir.list(lckFilter); if (fileNames != null) { for (int i = 0; i < fileNames.length; i++) { - String lckFileName = fileNames[i]; - String tmpDirName = lckFileName.substring(0, lckFileName.lastIndexOf(".lck")); - String tmpFileName = tmpDirName + ".tmp"; + final String lckFileName = fileNames[i]; + final String tmpDirName = lckFileName.substring(0, lckFileName.lastIndexOf(".lck")); + final String tmpFileName = tmpDirName + ".tmp"; - File lckFile = new File(tmpBaseDir, lckFileName); - File tmpFile = new File(tmpBaseDir, tmpFileName); - File tmpDir = new File(tmpBaseDir, tmpDirName); + final File lckFile = new File(tmpBaseDir, lckFileName); + final File tmpFile = new File(tmpBaseDir, tmpFileName); + final File tmpDir = new File(tmpBaseDir, tmpDirName); if (lckFile.exists() && tmpFile.exists() && tmpDir.isDirectory()) { FileOutputStream tmpOut = null; @@ -308,7 +308,7 @@ public class LauncherTempFileCache { tmpOut = new FileOutputStream(tmpFile); tmpChannel = tmpOut.getChannel(); tmpLock = tmpChannel.tryLock(); - } catch (Exception ex) { + } catch (final Exception ex) { // Ignore exceptions if (DEBUG) { ex.printStackTrace(); @@ -324,7 +324,7 @@ public class LauncherTempFileCache { lckOut = new FileOutputStream(lckFile); lckChannel = lckOut.getChannel(); lckLock = lckChannel.tryLock(); - } catch (Exception ex) { + } catch (final Exception ex) { if (DEBUG) { ex.printStackTrace(); } @@ -344,12 +344,12 @@ public class LauncherTempFileCache { // occasional 0-byte .lck or .tmp file left around try { lckOut.close(); - } catch (IOException ex) { + } catch (final IOException ex) { } lckFile.delete(); try { tmpOut.close(); - } catch (IOException ex) { + } catch (final IOException ex) { } tmpFile.delete(); } else { @@ -362,7 +362,7 @@ public class LauncherTempFileCache { // on the *.tmp file tmpOut.close(); tmpLock.release(); - } catch (IOException ex) { + } catch (final IOException ex) { if (DEBUG) { ex.printStackTrace(); } @@ -382,14 +382,14 @@ public class LauncherTempFileCache { * Remove the specified file or directory. If "path" is a directory, then * recursively remove all entries, then remove the directory itself. */ - private static void removeAll(File path) { + private static void removeAll(final File path) { if (DEBUG) { System.err.println("TempFileCache: removeAll(" + path + ")"); } if (path.isDirectory()) { // Recursively remove all files/directories in this directory - File[] list = path.listFiles(); + final File[] list = path.listFiles(); if (list != null) { for (int i = 0; i < list.length; i++) { removeAll(list[i]); @@ -405,10 +405,10 @@ public class LauncherTempFileCache { System.err.println("TempFileCache: new TempFileCache() --------------------- (static ok: "+(!staticInitError)+")"); System.err.println("TempFileCache: Thread: "+Thread.currentThread().getName()+", CL 0x"+Integer.toHexString(LauncherTempFileCache.class.getClassLoader().hashCode())+", this 0x"+Integer.toHexString(hashCode())); } - if(!staticInitError) { + if(!staticInitError) { try { createTmpDir(); - } catch (Exception ex) { + } catch (final Exception ex) { ex.printStackTrace(); initError = true; } @@ -416,23 +416,23 @@ public class LauncherTempFileCache { if (DEBUG) { System.err.println("tempDir: "+individualTmpDir+" (ok: "+(!initError)+")"); System.err.println("----------------------------------------------------------"); - } + } } - + /** * @return true is static and object initialization was successful */ public boolean isValid() { return !staticInitError && !initError; } - + /** - * Base temp directory used by TempFileCache. + * Base temp directory used by TempFileCache. * Lifecycle: For all JVMs, ClassLoader and times. - * + * * This is set to: * * ${java.io.tmpdir}/<tmpDirPrefix> * - * + * * @return */ public File getBaseDir() { return tmpBaseDir; } @@ -445,16 +445,16 @@ public class LauncherTempFileCache { * * <tmpBaseDir>/<tmpRootPropValue> * - * Use Case: Per ClassLoader files, eg. native libraries. + * Use Case: Per ClassLoader files, eg. native libraries. * * Old temp directories are cleaned up the next time a JVM is launched that * uses TempFileCache. * - * + * * @return */ public File getRootDir() { return tmpRootDir; } - + /** * Temporary directory for individual files (eg. native libraries of one ClassLoader instance). * The directory name is: @@ -466,12 +466,12 @@ public class LauncherTempFileCache { * 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 @@ -480,9 +480,9 @@ public class LauncherTempFileCache { * We avoid deleteOnExit, because it doesn't work reliably. */ private void createTmpDir() throws IOException { - File tmpFile = File.createTempFile("jln", ".tmp", tmpRootDir); - String tmpFileName = tmpFile.getAbsolutePath(); - String tmpDirName = tmpFileName.substring(0, tmpFileName.lastIndexOf(".tmp")); + final File tmpFile = File.createTempFile("jln", ".tmp", tmpRootDir); + final String tmpFileName = tmpFile.getAbsolutePath(); + final String tmpDirName = tmpFileName.substring(0, tmpFileName.lastIndexOf(".tmp")); individualTmpDir = new File(tmpDirName); if (!individualTmpDir.mkdir()) { throw new IOException("Cannot create " + individualTmpDir); diff --git a/src/java/jogamp/android/launcher/LauncherUtil.java b/src/java/jogamp/android/launcher/LauncherUtil.java index 1dfc218..2b7bd79 100644 --- a/src/java/jogamp/android/launcher/LauncherUtil.java +++ b/src/java/jogamp/android/launcher/LauncherUtil.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. @@ -43,45 +43,45 @@ import android.util.Log; * Helper class to parse Uri's and programmatically add package names and properties to create an Uri or Intend. * <p> * The order of the Uri segments (any arguments) is preserved. - * </p> + * </p> */ public class LauncherUtil { - + /** Default launch mode. */ public static final String LAUNCH_ACTIVITY_NORMAL = "org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL"; - + /** Transparent launch mode. Note: This seems to be required to achieve translucency, since setTheme(..) doesn't work. */ public static final String LAUNCH_ACTIVITY_TRANSPARENT = "org.jogamp.launcher.action.LAUNCH_ACTIVITY_TRANSPARENT"; - + /** FIXME: TODO */ public static final String LAUNCH_MAIN = "org.jogamp.launcher.action.LAUNCH_MAIN"; - + /** FIXME: TODO */ public static final String LAUNCH_JUNIT = "org.jogamp.launcher.action.LAUNCH_JUNIT"; - + /** The protocol <code>launch</code> */ public static final String SCHEME = "launch"; - + /** The host <code>jogamp.org</code> */ public static final String HOST = "jogamp.org"; - + static final String SYS_PKG = "sys"; - + static final String USR_PKG = "pkg"; - + static final String ARG = "arg"; - + public static abstract class BaseActivityLauncher extends Activity { final OrderedProperties props = new OrderedProperties(); final ArrayList<String> args = new ArrayList<String>(); - /** + /** * Returns the default {@link LauncherUtil#LAUNCH_ACTIVITY_NORMAL} action. * <p> * Should be overridden for other action, eg. {@link LauncherUtil#LAUNCH_ACTIVITY_TRANSPARENT}. * </p> */ public String getAction() { return LAUNCH_ACTIVITY_NORMAL; } - + /** * Returns the properties, which are being propagated to the target activity. * <p> @@ -89,58 +89,58 @@ public class LauncherUtil { * </p> */ public final OrderedProperties getProperties() { return props; } - + /** * Returns the commandline arguments, which are being propagated to the target activity. * <p> * Maybe be used to set custom commandline arguments. * </p> */ - public final ArrayList<String> getArguments() { return args; } - + public final ArrayList<String> getArguments() { return args; } + /** Custom initialization hook which can be overriden to setup data, e.g. fill the properties retrieved by {@link #getProperties()}. */ public void init() { } - + /** Returns true if this launcher activity shall end after starting the downstream activity. Defaults to <code>true</code>, override to change behavior. */ public boolean finishAfterDelegate() { return true; } - + /** Must return the downstream Activity class name */ public abstract String getActivityName(); - + /** Must return a list of required user packages, at least one containing the activity. */ public abstract List<String> getUsrPackages(); - + /** Return a list of required system packages w/ native libraries, may return null or a zero sized list. */ public abstract List<String> getSysPackages(); @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - + init(); - + final DataSet data = new DataSet(); data.setActivityName(getActivityName()); data.addAllSysPackages(getSysPackages()); data.addAllUsrPackages(getUsrPackages()); data.addAllProperties(props); data.addAllArguments(args); - + final Intent intent = LauncherUtil.getIntent(getAction(), data); Log.d(getClass().getSimpleName(), "Launching Activity: "+intent); startActivity (intent); - + if(finishAfterDelegate()) { finish(); // done } - } + } } - + public static class OrderedProperties { HashMap<String, String> map = new HashMap<String, String>(); - ArrayList<String> keyList = new ArrayList<String>(); - - public final void setProperty(String key, String value) { + ArrayList<String> keyList = new ArrayList<String>(); + + public final void setProperty(final String key, final String value) { if(key.equals(SYS_PKG)) { throw new IllegalArgumentException("Illegal property key, '"+SYS_PKG+"' is reserved"); } @@ -157,36 +157,36 @@ public class LauncherUtil { } keyList.add(key); // new key } - - public final void addAll(OrderedProperties props) { - Iterator<String> argKeys = props.keyList.iterator(); + + public final void addAll(final OrderedProperties props) { + final Iterator<String> argKeys = props.keyList.iterator(); while(argKeys.hasNext()) { final String key = argKeys.next(); setProperty(key, props.map.get(key)); - } + } } - + public final void setSystemProperties() { - Iterator<String> argKeys = keyList.iterator(); + final Iterator<String> argKeys = keyList.iterator(); while(argKeys.hasNext()) { final String key = argKeys.next(); System.setProperty(key, map.get(key)); } } public final void clearSystemProperties() { - Iterator<String> argKeys = keyList.iterator(); + final Iterator<String> argKeys = keyList.iterator(); while(argKeys.hasNext()) { System.clearProperty(argKeys.next()); } } - - public final String getProperty(String key) { return map.get(key); } + + public final String getProperty(final String key) { return map.get(key); } public final Map<String, String> getProperties() { return map; } - + /** Returns the list of property keys in the order, as they were added. */ - public final List<String> getPropertyKeys() { return keyList; } + public final List<String> getPropertyKeys() { return keyList; } } - + /** * Data set to transfer from and to launch URI consisting out of: * <ul> @@ -205,56 +205,56 @@ public class LauncherUtil { static final char ASSIG = '='; static final String COLSLASH2 = "://"; static final String EMPTY = ""; - + String activityName = null; ArrayList<String> sysPackages = new ArrayList<String>(); ArrayList<String> usrPackages = new ArrayList<String>(); OrderedProperties properties = new OrderedProperties(); ArrayList<String> arguments = new ArrayList<String>(); - - public final void setActivityName(String name) { activityName = name; } + + public final void setActivityName(final String name) { activityName = name; } public final String getActivityName() { return activityName; } - - public final void addSysPackage(String p) { - sysPackages.add(p); - } - public final void addAllSysPackages(List<String> plist) { + + public final void addSysPackage(final String p) { + sysPackages.add(p); + } + public final void addAllSysPackages(final List<String> plist) { sysPackages.addAll(plist); - } + } public final List<String> getSysPackages() { return sysPackages; } - - public final void addUsrPackage(String p) { - usrPackages.add(p); - } - public final void addAllUsrPackages(List<String> plist) { + + public final void addUsrPackage(final String p) { + usrPackages.add(p); + } + public final void addAllUsrPackages(final List<String> plist) { usrPackages.addAll(plist); - } + } public final List<String> getUsrPackages() { return usrPackages; } - - public final void setProperty(String key, String value) { + + public final void setProperty(final String key, final String value) { properties.setProperty(key, value); } - public final void addAllProperties(OrderedProperties props) { + public final void addAllProperties(final OrderedProperties props) { properties.addAll(props); } public final void setSystemProperties() { properties.setSystemProperties(); - } + } public final void clearSystemProperties() { properties.clearSystemProperties(); - } - public final String getProperty(String key) { return properties.getProperty(key); } + } + public final String getProperty(final String key) { return properties.getProperty(key); } public final OrderedProperties getProperties() { return properties; } public final List<String> getPropertyKeys() { return properties.getPropertyKeys(); } - - public final void addArgument(String arg) { arguments.add(arg); } - public final void addAllArguments(List<String> args) { + + public final void addArgument(final String arg) { arguments.add(arg); } + public final void addAllArguments(final List<String> args) { arguments.addAll(args); } public final ArrayList<String> getArguments() { return arguments; } - + public final Uri getUri() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); sb.append(SCHEME).append(COLSLASH2).append(HOST).append(SLASH).append(getActivityName()); boolean needsQMark = true; boolean needsSep = false; @@ -284,7 +284,7 @@ public class LauncherUtil { needsSep = true; } } - Iterator<String> propKeys = properties.keyList.iterator(); + final Iterator<String> propKeys = properties.keyList.iterator(); while(propKeys.hasNext()) { if( needsQMark ) { sb.append(QMARK); @@ -297,7 +297,7 @@ public class LauncherUtil { sb.append(key).append(ASSIG).append(properties.map.get(key)); needsSep = true; } - Iterator<String> args = arguments.iterator(); + final Iterator<String> args = arguments.iterator(); while(args.hasNext()) { if( needsQMark ) { sb.append(QMARK); @@ -308,18 +308,18 @@ public class LauncherUtil { } sb.append(ARG).append(ASSIG).append(args.next()); needsSep = true; - } + } return Uri.parse(sb.toString()); } - - public static final DataSet create(Uri uri) { + + public static final DataSet create(final Uri uri) { if(!uri.getScheme().equals(SCHEME)) { return null; } if(!uri.getHost().equals(HOST)) { return null; } - DataSet data = new DataSet(); + final DataSet data = new DataSet(); { String an = uri.getPath(); if(SLASH == an.charAt(0)) { @@ -330,16 +330,16 @@ public class LauncherUtil { } data.setActivityName(an); } - + final String q = uri.getQuery(); final int q_l = null != q ? q.length() : -1; int q_e = -1; while(q_e < q_l) { - int q_b = q_e + 1; // next term + final int q_b = q_e + 1; // next term q_e = q.indexOf(AMPER, q_b); if(0 == q_e) { // single separator - continue; + continue; } if(0 > q_e) { // end @@ -381,41 +381,41 @@ public class LauncherUtil { data.validate(); return data; } - + public final void validate() { if(null == activityName) { throw new RuntimeException("Activity is not NULL"); } } } - - public final static Intent getIntent(String action, DataSet data) { + + public final static Intent getIntent(final String action, final DataSet data) { data.validate(); return new Intent(action, data.getUri()); } - + public static void main(String[] args) { if(args.length==0) { args = new String[] { - SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+SYS_PKG+"=jogamp.pack1&"+SYS_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&"+USR_PKG+"=com.jogamp.pack4&jogamp.common.debug=true&com.jogamp.test=false", + SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+SYS_PKG+"=jogamp.pack1&"+SYS_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&"+USR_PKG+"=com.jogamp.pack4&jogamp.common.debug=true&com.jogamp.test=false", SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+SYS_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false", SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false", SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+USR_PKG+"=com.jogamp.pack2", - SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+USR_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3", - SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3", - SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3" + SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+USR_PKG+"=javax.pack2&"+USR_PKG+"=com.jogamp.pack3&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3", + SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&jogamp.common.debug=true&com.jogamp.test=false&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3", + SCHEME+"://"+HOST+"/com.jogamp.TestActivity?"+USR_PKG+"=jogamp.pack1&"+ARG+"=arg1&"+ARG+"=arg2=arg2value&"+ARG+"=arg3" }; } int errors = 0; for(int i=0; i<args.length; i++) { - String uri_s = args[i]; - Uri uri0 = Uri.parse(uri_s); - DataSet data = DataSet.create(uri0); + final String uri_s = args[i]; + final Uri uri0 = Uri.parse(uri_s); + final DataSet data = DataSet.create(uri0); if(null == data) { errors++; System.err.println("Error: NULL JogAmpLauncherUtil: <"+uri_s+"> -> "+uri0+" -> NULL"); } else { - Uri uri1 = data.getUri(); + final Uri uri1 = data.getUri(); if(!uri0.equals(uri1)) { errors++; System.err.println("Error: Not equal: <"+uri_s+"> -> "+uri0+" -> "+uri1); @@ -426,5 +426,5 @@ public class LauncherUtil { } System.err.println("LauncherUtil Self Test: Errors: "+errors); } - + } diff --git a/src/java/jogamp/android/launcher/LauncherVersionActivity.java b/src/java/jogamp/android/launcher/LauncherVersionActivity.java index de78f5d..d26981f 100644 --- a/src/java/jogamp/android/launcher/LauncherVersionActivity.java +++ b/src/java/jogamp/android/launcher/LauncherVersionActivity.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. @@ -35,9 +35,9 @@ import android.util.Log; public class LauncherVersionActivity extends Activity { static final String TAG = "JogAmp-LauncherVersion"; TextView tv = null; - + @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { Log.d(TAG, "onCreate - S"); super.onCreate(savedInstanceState); tv = new TextView(this); @@ -47,14 +47,14 @@ public class LauncherVersionActivity extends Activity { setContentView(tv); Log.d(TAG, "onCreate - X"); } - + @Override public void onStart() { Log.d(TAG, "onStart - S"); super.onStart(); Log.d(TAG, "onStart - X"); } - + @Override public void onRestart() { Log.d(TAG, "onRestart - S"); @@ -79,14 +79,14 @@ public class LauncherVersionActivity extends Activity { @Override public void onStop() { Log.d(TAG, "onStop - S"); - super.onStop(); + super.onStop(); Log.d(TAG, "onStop - X"); } @Override public void onDestroy() { Log.d(TAG, "onDestroy - S"); - super.onDestroy(); + super.onDestroy(); Log.d(TAG, "onDestroy - X"); - } + } } diff --git a/src/java/jogamp/android/launcher/MainLauncher.java b/src/java/jogamp/android/launcher/MainLauncher.java index f37fa57..0dc6b4a 100644 --- a/src/java/jogamp/android/launcher/MainLauncher.java +++ b/src/java/jogamp/android/launcher/MainLauncher.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. @@ -40,72 +40,72 @@ import android.util.Log; public class MainLauncher extends Activity { static final String TAG = "JogAmp-MainLauncher"; - + // private static final String[] frameworkAPKs = { "/system/framework/core-junit.jar", "/data/projects/gluegen/make/lib/ant-junit-all.apk" }; // private static final String[] frameworkAPKs = { "/data/projects/gluegen/make/lib/ant-junit-all.apk" }; private static final String[] frameworkAPKs = { "/sdcard/ant-junit-all.apk" }; - + LauncherUtil.DataSet data = null; - + Class<?> mainClazz = null; Method mainClazzMain = null; - + Class<?> staticContextClazz = null; Method mStaticContextInit = null; Method mStaticContextClear = null; String[] mainClassArgs = null; - + @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { Log.d(TAG, "onCreate - S"); super.onCreate(savedInstanceState); - + final Uri uri = getIntent().getData(); data = LauncherUtil.DataSet.create(uri); data.setSystemProperties(); - ClassLoader cl = ClassLoaderUtil.createClassLoader(this, data.getSysPackages(), data.getUsrPackages(), Arrays.asList(frameworkAPKs)); + final ClassLoader cl = ClassLoaderUtil.createClassLoader(this, data.getSysPackages(), data.getUsrPackages(), Arrays.asList(frameworkAPKs)); if(null != cl) { try { staticContextClazz = Class.forName("jogamp.common.os.android.StaticContext", true, cl); mStaticContextInit = staticContextClazz.getMethod("init", android.content.Context.class, android.view.ViewGroup.class); - mStaticContextClear = staticContextClazz.getMethod("clear"); - + mStaticContextClear = staticContextClazz.getMethod("clear"); + mainClazz = Class.forName(data.getActivityName(), true, cl); Log.d(TAG, "Main Clazz "+mainClazz); mainClazzMain = mainClazz.getDeclaredMethod("main", new Class[] { String[].class }); Log.d(TAG, "Main Clazz Main "+mainClazzMain); - } catch (Exception e) { + } catch (final Exception e) { Log.d(TAG, "error: "+e, e); throw new RuntimeException(e); } } if( null == mStaticContextInit || null == mStaticContextClear || null == mainClazzMain ) { - RuntimeException e = new RuntimeException("XXX - incomplete method set"); + final RuntimeException e = new RuntimeException("XXX - incomplete method set"); Log.d(TAG, "error: "+e, e); throw e; } - + final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getApplicationContext()); getWindow().setContentView(viewGroup); - + callMethod(null, mStaticContextInit, getApplicationContext(), viewGroup); - - List<String> args = data.getArguments(); + + final List<String> args = data.getArguments(); mainClassArgs=new String[args.size()]; - args.toArray(mainClassArgs); - + args.toArray(mainClassArgs); + Log.d(TAG, "onCreate - X"); } - + @Override public void onStart() { Log.d(TAG, "onStart - S"); super.onStart(); Log.d(TAG, "onStart - X"); } - + @Override public void onRestart() { Log.d(TAG, "onRestart - S"); @@ -122,9 +122,9 @@ public class MainLauncher extends Activity { try { Log.d(TAG, "onResume - main.0 - "+Thread.currentThread().getName()); mainClazzMain.invoke(null, new Object[] { mainClassArgs } ); - } catch (InvocationTargetException ite) { + } catch (final InvocationTargetException ite) { ite.getTargetException().printStackTrace(); - } catch (Throwable t) { + } catch (final Throwable t) { t.printStackTrace(); } Log.d(TAG, "onResume - main.X -> finish() - "+Thread.currentThread().getName()); @@ -144,7 +144,7 @@ public class MainLauncher extends Activity { @Override public void onStop() { Log.d(TAG, "onStop - S"); - super.onStop(); + super.onStop(); Log.d(TAG, "onStop - X"); } @@ -156,32 +156,32 @@ public class MainLauncher extends Activity { data = null; } callMethod(null, mStaticContextClear); - super.onDestroy(); + super.onDestroy(); Log.d(TAG, "onDestroy - X"); - } + } @Override public void finish() { Log.d(TAG, "finish - S"); - super.finish(); + super.finish(); Log.d(TAG, "finish - X"); - } + } /** * @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(final Class<?> clazz, final Class<?>[] cstrArgTypes, final Object ... cstrArgs) throws RuntimeException { return createInstance(getConstructor(clazz, cstrArgTypes), cstrArgs); } - public static final Object createInstance(Constructor<?> cstr, Object ... cstrArgs) + public static final Object createInstance(final Constructor<?> cstr, final Object ... cstrArgs) throws RuntimeException { try { return cstr.newInstance(cstrArgs); - } catch (Exception e) { + } catch (final Exception e) { Throwable t = e; if (t instanceof InvocationTargetException) { t = ((InvocationTargetException) t).getTargetException(); @@ -195,26 +195,26 @@ public class MainLauncher extends Activity { throw new RuntimeException("can not create instance of "+cstr.getName(), t); } } - + /** * @throws JogampRuntimeException if the constructor can not be delivered. */ - protected static final Constructor<?> getConstructor(Class<?> clazz, Class<?> ... cstrArgTypes) + protected static final Constructor<?> getConstructor(final Class<?> clazz, Class<?> ... cstrArgTypes) throws RuntimeException { try { if(null == cstrArgTypes) { cstrArgTypes = zeroTypes; } return clazz.getDeclaredConstructor(cstrArgTypes); - } catch (NoSuchMethodException ex) { + } catch (final NoSuchMethodException ex) { throw new RuntimeException("Constructor: '" + clazz + "(" + asString(cstrArgTypes) + ")' not found", ex); } } - + protected static final Class<?>[] zeroTypes = new Class[0]; - protected static final String asString(Class<?>[] argTypes) { - StringBuilder args = new StringBuilder(); + protected static final String asString(final Class<?>[] argTypes) { + final StringBuilder args = new StringBuilder(); boolean coma = false; if(null != argTypes) { for (int i = 0; i < argTypes.length; i++) { @@ -227,13 +227,13 @@ public class MainLauncher extends Activity { } return args.toString(); } - - protected static final Object callMethod(Object instance, Method method, Object ... args) + + protected static final Object callMethod(final Object instance, final Method method, final Object ... args) throws RuntimeException { try { return method.invoke(instance, args); - } catch (Exception e) { + } catch (final Exception e) { Throwable t = e; if (t instanceof InvocationTargetException) { t = ((InvocationTargetException) t).getTargetException(); diff --git a/src/java/jogamp/android/launcher/TraceDexClassLoader.java b/src/java/jogamp/android/launcher/TraceDexClassLoader.java index 0b00489..452120a 100644 --- a/src/java/jogamp/android/launcher/TraceDexClassLoader.java +++ b/src/java/jogamp/android/launcher/TraceDexClassLoader.java @@ -8,16 +8,16 @@ import dalvik.system.DexClassLoader; public class TraceDexClassLoader extends DexClassLoader { private static final boolean DEBUG = false; - - public TraceDexClassLoader(String dexPath, String dexOutputDir, String libPath, ClassLoader parent) { + + public TraceDexClassLoader(final String dexPath, final String dexOutputDir, final String libPath, final ClassLoader parent) { super(dexPath, dexOutputDir, libPath, parent); if(DEBUG) { Log.d(TraceDexClassLoader.class.getSimpleName(), "ctor: dexPath " + dexPath + ", dexOutputDir " + dexOutputDir + ", libPath " + libPath + ", parent " + parent); } } - + @Override - public URL findResource(String name) { + public URL findResource(final String name) { final URL url = super.findResource(name); if(DEBUG) { Log.d(TraceDexClassLoader.class.getSimpleName(), "findResource: " + name + " -> " + url); diff --git a/src/java/jogamp/common/Debug.java b/src/java/jogamp/common/Debug.java index 6dc2098..4f3b673 100644 --- a/src/java/jogamp/common/Debug.java +++ b/src/java/jogamp/common/Debug.java @@ -75,7 +75,7 @@ public class Debug extends PropertyAccess { return debugAll; } - public static final boolean debug(String subcomponent) { + public static final boolean debug(final String subcomponent) { return debugAll() || isPropertyDefined("jogamp.debug." + subcomponent, true); } } diff --git a/src/java/jogamp/common/jvm/JVMUtil.java b/src/java/jogamp/common/jvm/JVMUtil.java index e655654..76f8ea5 100644 --- a/src/java/jogamp/common/jvm/JVMUtil.java +++ b/src/java/jogamp/common/jvm/JVMUtil.java @@ -54,12 +54,12 @@ public class JVMUtil { private static final boolean DEBUG = Debug.debug("JVMUtil"); static { - ByteBuffer buffer = Buffers.newDirectByteBuffer(64); + final ByteBuffer buffer = Buffers.newDirectByteBuffer(64); if( ! initialize(buffer) ) { throw new RuntimeException("Failed to initialize the JVMUtil "+Thread.currentThread().getName()); } if(DEBUG) { - Exception e = new Exception("JVMUtil.initSingleton() .. initialized "+Thread.currentThread().getName()); + final Exception e = new Exception("JVMUtil.initSingleton() .. initialized "+Thread.currentThread().getName()); e.printStackTrace(); } } diff --git a/src/java/jogamp/common/os/AndroidUtils.java b/src/java/jogamp/common/os/AndroidUtils.java index bb09ba9..299dbc5 100644 --- a/src/java/jogamp/common/os/AndroidUtils.java +++ b/src/java/jogamp/common/os/AndroidUtils.java @@ -58,7 +58,7 @@ public class AndroidUtils { * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)}, * otherwise the found package version code of <code>packageName</code> is returned. */ - public static final int getPackageInfoVersionCode(String packageName) { + public static final int getPackageInfoVersionCode(final String packageName) { if(null != androidGetPackageInfoVersionCodeMethod) { return ((Integer) ReflectionUtil.callMethod(null, androidGetPackageInfoVersionCodeMethod, packageName)).intValue(); } @@ -70,7 +70,7 @@ public class AndroidUtils { * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)}, * otherwise the found package version name of <code>packageName</code> is returned. */ - public static final String getPackageInfoVersionName(String packageName) { + public static final String getPackageInfoVersionName(final String packageName) { if(null != androidGetPackageInfoVersionNameMethod) { return (String) ReflectionUtil.callMethod(null, androidGetPackageInfoVersionNameMethod, packageName); } diff --git a/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java b/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java index 09057f8..b293776 100644 --- a/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java @@ -44,17 +44,17 @@ public final class BionicDynamicLinkerImpl extends UnixDynamicLinkerImpl { private static final int RTLD_GLOBAL = 0x00002; @Override - public final long openLibraryLocal(String pathname, boolean debug) throws SecurityException { + public final long openLibraryLocal(final String pathname, final boolean debug) throws SecurityException { return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_LOCAL, debug); } @Override - public final long openLibraryGlobal(String pathname, boolean debug) throws SecurityException { + public final long openLibraryGlobal(final String pathname, final boolean debug) throws SecurityException { return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_GLOBAL, debug); } @Override - public final long lookupSymbolGlobal(String symbolName) throws SecurityException { + public final long lookupSymbolGlobal(final String symbolName) throws SecurityException { return this.lookupSymbolGlobalImpl(RTLD_DEFAULT, symbolName); } diff --git a/src/java/jogamp/common/os/DynamicLinkerImpl.java b/src/java/jogamp/common/os/DynamicLinkerImpl.java index dde4d5c..392d906 100644 --- a/src/java/jogamp/common/os/DynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/DynamicLinkerImpl.java @@ -41,7 +41,7 @@ import com.jogamp.common.util.LongObjectHashMap; private final LongObjectHashMap libHandle2Name = new LongObjectHashMap( 16 /* initialCapacity */ ); protected static final class LibRef { - public LibRef(String name) { + public LibRef(final String name) { this.name = name; this.refCount = 1; } @@ -57,11 +57,11 @@ import com.jogamp.common.util.LongObjectHashMap; private int refCount; } - protected final synchronized LibRef getLibRef(long handle) { + protected final synchronized LibRef getLibRef(final long handle) { return (LibRef) libHandle2Name.get(handle); } - protected final synchronized LibRef incrLibRefCount(long handle, String libName) { + protected final synchronized LibRef incrLibRefCount(final long handle, final String libName) { LibRef libRef = getLibRef(handle); if( null == libRef ) { libRef = new LibRef(libName); @@ -75,8 +75,8 @@ import com.jogamp.common.util.LongObjectHashMap; return libRef; } - protected final synchronized LibRef decrLibRefCount(long handle) { - LibRef libRef = getLibRef(handle); + protected final synchronized LibRef decrLibRefCount(final long handle) { + final LibRef libRef = getLibRef(handle); if( null != libRef ) { if( 0 == libRef.decrRefCount() ) { libHandle2Name.remove(handle); diff --git a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java index b2f0f31..0fdfc8b 100644 --- a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java @@ -42,17 +42,17 @@ public final class MacOSXDynamicLinkerImpl extends UnixDynamicLinkerImpl { private static final int RTLD_GLOBAL = 0x00008; @Override - public final long openLibraryLocal(String pathname, boolean debug) throws SecurityException { + public final long openLibraryLocal(final String pathname, final boolean debug) throws SecurityException { return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_LOCAL, debug); } @Override - public final long openLibraryGlobal(String pathname, boolean debug) throws SecurityException { + public final long openLibraryGlobal(final String pathname, final boolean debug) throws SecurityException { return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_GLOBAL, debug); } @Override - public final long lookupSymbolGlobal(String symbolName) throws SecurityException { + public final long lookupSymbolGlobal(final String symbolName) throws SecurityException { return this.lookupSymbolGlobalImpl(RTLD_DEFAULT, symbolName); } diff --git a/src/java/jogamp/common/os/MachineDescriptionRuntime.java b/src/java/jogamp/common/os/MachineDescriptionRuntime.java index 254cda2..e62c914 100644 --- a/src/java/jogamp/common/os/MachineDescriptionRuntime.java +++ b/src/java/jogamp/common/os/MachineDescriptionRuntime.java @@ -131,11 +131,11 @@ public class MachineDescriptionRuntime { private static MachineDescription getRuntimeImpl() { try { Platform.initSingleton(); // loads native gluegen-rt library - } catch (UnsatisfiedLinkError err) { + } catch (final UnsatisfiedLinkError err) { return null; } - int pointerSizeInBytes = getPointerSizeInBytesImpl(); + final int pointerSizeInBytes = getPointerSizeInBytesImpl(); switch(pointerSizeInBytes) { case 4: case 8: diff --git a/src/java/jogamp/common/os/PlatformPropsImpl.java b/src/java/jogamp/common/os/PlatformPropsImpl.java index 1b9128d..61a5369 100644 --- a/src/java/jogamp/common/os/PlatformPropsImpl.java +++ b/src/java/jogamp/common/os/PlatformPropsImpl.java @@ -106,7 +106,7 @@ public abstract class PlatformPropsImpl { usOff = 1; } if( 0 < usIdx ) { - final String buildS = Platform.JAVA_VERSION.substring(usIdx+usOff); + final String buildS = PlatformPropsImpl.JAVA_VERSION.substring(usIdx+usOff); final VersionNumber update = new VersionNumber(buildS); JAVA_VERSION_UPDATE = update.getMajor(); } else { @@ -251,7 +251,7 @@ public abstract class PlatformPropsImpl { Class.forName("java.nio.LongBuffer"); Class.forName("java.nio.DoubleBuffer"); return true; - } catch(ClassNotFoundException ex) { + } catch(final ClassNotFoundException ex) { // continue with Java SE check } @@ -259,9 +259,9 @@ public abstract class PlatformPropsImpl { } private static final boolean queryIsLittleEndianImpl() { - ByteBuffer tst_b = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT); // 32bit in native order - IntBuffer tst_i = tst_b.asIntBuffer(); - ShortBuffer tst_s = tst_b.asShortBuffer(); + final ByteBuffer tst_b = Buffers.newDirectByteBuffer(Buffers.SIZEOF_INT); // 32bit in native order + final IntBuffer tst_i = tst_b.asIntBuffer(); + final ShortBuffer tst_s = tst_b.asShortBuffer(); tst_i.put(0, 0x0A0B0C0D); return 0x0C0D == tst_s.get(0); } @@ -356,7 +356,7 @@ public abstract class PlatformPropsImpl { if( null != file ) { res = queryABITypeImpl(file, cpuType, abiType); } - } catch(Throwable t) { + } catch(final Throwable t) { if(DEBUG) { t.printStackTrace(); } @@ -408,7 +408,7 @@ public abstract class PlatformPropsImpl { abiType[0] = ABIType.GENERIC_ABI; } res = eh; - } catch(Throwable t) { + } catch(final Throwable t) { if(DEBUG) { System.err.println("Caught: "+t.getMessage()); t.printStackTrace(); @@ -417,7 +417,7 @@ public abstract class PlatformPropsImpl { if(null != in) { try { in.close(); - } catch (IOException e) { } + } catch (final IOException e) { } } } if(DEBUG) { @@ -428,7 +428,7 @@ public abstract class PlatformPropsImpl { private static boolean checkFileReadAccess(final File file) { try { return file.isFile() && file.canRead(); - } catch (Throwable t) { } + } catch (final Throwable t) { } return false; } private static File findSysLib(final String libName) { diff --git a/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java b/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java index f2aa360..f929e03 100644 --- a/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/PosixDynamicLinkerImpl.java @@ -38,17 +38,17 @@ public final class PosixDynamicLinkerImpl extends UnixDynamicLinkerImpl { private static final int RTLD_GLOBAL = 0x00100; @Override - public final long openLibraryLocal(String pathname, boolean debug) throws SecurityException { + public final long openLibraryLocal(final String pathname, final boolean debug) throws SecurityException { return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_LOCAL, debug); } @Override - public final long openLibraryGlobal(String pathname, boolean debug) throws SecurityException { + public final long openLibraryGlobal(final String pathname, final boolean debug) throws SecurityException { return this.openLibraryImpl(pathname, RTLD_LAZY | RTLD_GLOBAL, debug); } @Override - public final long lookupSymbolGlobal(String symbolName) throws SecurityException { + public final long lookupSymbolGlobal(final String symbolName) throws SecurityException { return this.lookupSymbolGlobalImpl(RTLD_DEFAULT, symbolName); } } diff --git a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java index 7a0e3b0..59be76c 100644 --- a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java @@ -49,7 +49,7 @@ import com.jogamp.common.util.SecurityUtil; /** Interface to C language function: <br> <code> void * dlsym(void * , const char * ); </code> */ protected static native long dlsym(long arg0, java.lang.String arg1); - protected final long openLibraryImpl(String pathname, int dlSymFlags, boolean debug) throws SecurityException { + protected final long openLibraryImpl(final String pathname, final int dlSymFlags, final boolean debug) throws SecurityException { SecurityUtil.checkLinkPermission(pathname); final long handle = dlopen(pathname, dlSymFlags); if( 0 != handle ) { @@ -60,7 +60,7 @@ import com.jogamp.common.util.SecurityUtil; return handle; } - protected final long lookupSymbolGlobalImpl(long dlSymGlobalFlag, String symbolName) throws SecurityException { + protected final long lookupSymbolGlobalImpl(final long dlSymGlobalFlag, final String symbolName) throws SecurityException { SecurityUtil.checkAllLinkPermission(); final long addr = dlsym(dlSymGlobalFlag, symbolName); if(DEBUG_LOOKUP) { @@ -70,7 +70,7 @@ import com.jogamp.common.util.SecurityUtil; } @Override - public final long lookupSymbol(long libraryHandle, String symbolName) throws IllegalArgumentException { + public final long lookupSymbol(final long libraryHandle, final String symbolName) throws IllegalArgumentException { if( null == getLibRef( libraryHandle ) ) { throw new IllegalArgumentException("Library handle 0x"+Long.toHexString(libraryHandle)+" unknown."); } @@ -82,7 +82,7 @@ import com.jogamp.common.util.SecurityUtil; } @Override - public final void closeLibrary(long libraryHandle) throws IllegalArgumentException { + public final void closeLibrary(final long libraryHandle) throws IllegalArgumentException { if( null == decrLibRefCount( libraryHandle ) ) { throw new IllegalArgumentException("Library handle 0x"+Long.toHexString(libraryHandle)+" unknown."); } diff --git a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java index 76bb2f8..de69d0c 100644 --- a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java @@ -44,27 +44,27 @@ public final class WindowsDynamicLinkerImpl extends DynamicLinkerImpl { private static native long LoadLibraryW(java.lang.String lpLibFileName); @Override - public final long openLibraryLocal(String libraryName, boolean debug) throws SecurityException { + public final long openLibraryLocal(final String libraryName, final boolean debug) throws SecurityException { // How does that work under Windows ? // Don't know .. so it's an alias for the time being return openLibraryGlobal(libraryName, debug); } @Override - public final long openLibraryGlobal(String libraryName, boolean debug) throws SecurityException { + public final long openLibraryGlobal(final String libraryName, final boolean debug) throws SecurityException { SecurityUtil.checkLinkPermission(libraryName); final long handle = LoadLibraryW(libraryName); if( 0 != handle ) { incrLibRefCount(handle, libraryName); } else if ( DEBUG || debug ) { - int err = GetLastError(); + final int err = GetLastError(); System.err.println("LoadLibraryW \""+libraryName+"\" failed, error code: 0x"+Integer.toHexString(err)+", "+err); } return handle; } @Override - public final long lookupSymbolGlobal(String symbolName) throws SecurityException { + public final long lookupSymbolGlobal(final String symbolName) throws SecurityException { SecurityUtil.checkAllLinkPermission(); if(DEBUG_LOOKUP) { System.err.println("lookupSymbolGlobal: Not supported on Windows"); @@ -74,7 +74,7 @@ public final class WindowsDynamicLinkerImpl extends DynamicLinkerImpl { } @Override - public final long lookupSymbol(long libraryHandle, String symbolName) throws IllegalArgumentException { + public final long lookupSymbol(final long libraryHandle, final String symbolName) throws IllegalArgumentException { if( null == getLibRef( libraryHandle ) ) { throw new IllegalArgumentException("Library handle 0x"+Long.toHexString(libraryHandle)+" unknown."); } @@ -97,7 +97,7 @@ public final class WindowsDynamicLinkerImpl extends DynamicLinkerImpl { } @Override - public final void closeLibrary(long libraryHandle) throws IllegalArgumentException { + public final void closeLibrary(final long libraryHandle) throws IllegalArgumentException { if( null == decrLibRefCount( libraryHandle ) ) { throw new IllegalArgumentException("Library handle 0x"+Long.toHexString(libraryHandle)+" unknown."); } diff --git a/src/java/jogamp/common/os/android/AndroidUtilsImpl.java b/src/java/jogamp/common/os/android/AndroidUtilsImpl.java index fc8d606..8dcdd6f 100644 --- a/src/java/jogamp/common/os/android/AndroidUtilsImpl.java +++ b/src/java/jogamp/common/os/android/AndroidUtilsImpl.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. @@ -36,39 +36,39 @@ import android.util.Log; public class AndroidUtilsImpl { private static boolean DEBUG = false; - - public static final PackageInfo getPackageInfo(String packageName) { + + public static final PackageInfo getPackageInfo(final String packageName) { return getPackageInfo(StaticContext.getContext(), packageName); } - - public static final PackageInfo getPackageInfo(Context ctx, String packageName) { + + public static final PackageInfo getPackageInfo(final Context ctx, final String packageName) { if(null != ctx) { try { final PackageInfo pi = ctx.getPackageManager().getPackageInfo(packageName, PackageManager.GET_META_DATA); if(DEBUG) Log.d(MD.TAG, "getPackageInfo("+packageName+"): "+pi); return pi; - } catch (Exception e) { if(DEBUG) { Log.d(MD.TAG, "getPackageInfo("+packageName+")", e); } } + } catch (final Exception e) { if(DEBUG) { Log.d(MD.TAG, "getPackageInfo("+packageName+")", e); } } } if(DEBUG) Log.d(MD.TAG, "getPackageInfo("+packageName+"): NULL"); return null; } - - public static final int getPackageInfoVersionCode(String packageName) { + + public static final int getPackageInfoVersionCode(final String packageName) { final PackageInfo pInfo = getPackageInfo(packageName); return ( null != pInfo ) ? pInfo.versionCode : -1 ; } - - public static final String getPackageInfoVersionName(String packageName) { + + public static final String getPackageInfoVersionName(final String packageName) { final PackageInfo pInfo = getPackageInfo(packageName); final String s = ( null != pInfo ) ? pInfo.versionName : null ; if(DEBUG) Log.d(MD.TAG, "getPackageInfoVersionName("+packageName+"): "+s); return s; } - + /** - * @return null if no Android Context is registered - * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)}, - * otherwise the context relative world readable <code>temp</code> directory returned. + * @return null if no Android Context is registered + * via {@link jogamp.common.os.android.StaticContext#init(android.content.Context) StaticContext.init(..)}, + * otherwise the context relative world readable <code>temp</code> directory returned. */ public static File getTempRoot() throws SecurityException, RuntimeException @@ -86,5 +86,5 @@ public class AndroidUtilsImpl { } return null; } - + } diff --git a/src/java/jogamp/common/os/android/GluegenVersionActivity.java b/src/java/jogamp/common/os/android/GluegenVersionActivity.java index 5db3213..c216867 100644 --- a/src/java/jogamp/common/os/android/GluegenVersionActivity.java +++ b/src/java/jogamp/common/os/android/GluegenVersionActivity.java @@ -28,6 +28,8 @@ package jogamp.common.os.android; +import jogamp.common.os.PlatformPropsImpl; + import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionUtil; @@ -42,7 +44,7 @@ public class GluegenVersionActivity extends Activity { TextView tv = null; @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { Log.d(MD.TAG, "onCreate - S"); super.onCreate(savedInstanceState); StaticContext.init(this.getApplicationContext()); @@ -54,7 +56,7 @@ public class GluegenVersionActivity extends Activity { scroller.addView(tv); setContentView(scroller); - tv.setText(VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+Platform.NEWLINE); + tv.setText(VersionUtil.getPlatformInfo()+PlatformPropsImpl.NEWLINE+GlueGenVersion.getInstance()+PlatformPropsImpl.NEWLINE+PlatformPropsImpl.NEWLINE); Log.d(MD.TAG, "onCreate - X"); } @@ -63,7 +65,7 @@ public class GluegenVersionActivity extends Activity { Log.d(MD.TAG, "onStart - S"); super.onStart(); if(null != tv) { - tv.append("> started"+Platform.NEWLINE); + tv.append("> started"+PlatformPropsImpl.NEWLINE); } Log.d(MD.TAG, "onStart - X"); } @@ -73,7 +75,7 @@ public class GluegenVersionActivity extends Activity { Log.d(MD.TAG, "onRestart - S"); super.onRestart(); if(null != tv) { - tv.append("> restarted"+Platform.NEWLINE); + tv.append("> restarted"+PlatformPropsImpl.NEWLINE); } Log.d(MD.TAG, "onRestart - X"); } @@ -82,7 +84,7 @@ public class GluegenVersionActivity extends Activity { public void onResume() { Log.d(MD.TAG, "onResume - S"); if(null != tv) { - tv.append("> resumed"+Platform.NEWLINE); + tv.append("> resumed"+PlatformPropsImpl.NEWLINE); } super.onResume(); Log.d(MD.TAG, "onResume - X"); @@ -92,7 +94,7 @@ public class GluegenVersionActivity extends Activity { public void onPause() { Log.d(MD.TAG, "onPause - S"); if(null != tv) { - tv.append("> paused"+Platform.NEWLINE); + tv.append("> paused"+PlatformPropsImpl.NEWLINE); } super.onPause(); // Log.d(MD.TAG, "onPause - x"); @@ -104,7 +106,7 @@ public class GluegenVersionActivity extends Activity { public void onStop() { Log.d(MD.TAG, "onStop - S"); if(null != tv) { - tv.append("> stopped"+Platform.NEWLINE); + tv.append("> stopped"+PlatformPropsImpl.NEWLINE); } super.onStop(); Log.d(MD.TAG, "onStop - X"); @@ -114,7 +116,7 @@ public class GluegenVersionActivity extends Activity { public void onDestroy() { Log.d(MD.TAG, "onDestroy - S"); if(null != tv) { - tv.append("> destroyed"+Platform.NEWLINE); + tv.append("> destroyed"+PlatformPropsImpl.NEWLINE); } Log.d(MD.TAG, "onDestroy - x"); StaticContext.clear(); diff --git a/src/java/jogamp/common/os/android/MD.java b/src/java/jogamp/common/os/android/MD.java index d6a2e48..4d0d631 100644 --- a/src/java/jogamp/common/os/android/MD.java +++ b/src/java/jogamp/common/os/android/MD.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. diff --git a/src/java/jogamp/common/os/android/StaticContext.java b/src/java/jogamp/common/os/android/StaticContext.java index 359e603..5585407 100644 --- a/src/java/jogamp/common/os/android/StaticContext.java +++ b/src/java/jogamp/common/os/android/StaticContext.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. @@ -34,27 +34,27 @@ import android.view.ViewGroup; public class StaticContext { private static Context appContext = null; private static ViewGroup contentViewGroup = null; - + private static boolean DEBUG = false; - + /** * Register Android application context for static usage. - * + * * @param appContext mandatory application Context * @throws RuntimeException if the context is already registered. */ - public static final synchronized void init(Context appContext) { + public static final synchronized void init(final Context appContext) { init(appContext, null); } - + /** * Register Android application context w/ a ViewGroup for static usage. - * + * * @param appContext mandatory application Context * @param contentViewGroup optional ViewGroup acting as the Window's ContentView, usually a FrameLayout instance. * @throws RuntimeException if the context is already registered. */ - public static final synchronized void init(Context appContext, ViewGroup contentViewGroup) { + public static final synchronized void init(final Context appContext, final ViewGroup contentViewGroup) { if(null != StaticContext.appContext) { throw new RuntimeException("Context already set"); } @@ -62,7 +62,7 @@ public class StaticContext { StaticContext.appContext = appContext; StaticContext.contentViewGroup = contentViewGroup; } - + /** * Unregister the Android application Context and ViewGroup */ @@ -71,15 +71,15 @@ public class StaticContext { appContext = null; contentViewGroup = null; } - + /** * Return the registered Android application Context * @return */ public static final synchronized Context getContext() { return appContext; - } - + } + /** * Return the registered Android ViewGroup acting as the Window's ContentView * @return diff --git a/src/java/jogamp/common/os/elf/Ehdr.java b/src/java/jogamp/common/os/elf/Ehdr.java index d787f67..e12ef4f 100644 --- a/src/java/jogamp/common/os/elf/Ehdr.java +++ b/src/java/jogamp/common/os/elf/Ehdr.java @@ -3,10 +3,6 @@ package jogamp.common.os.elf; -import java.nio.*; - -import com.jogamp.gluegen.runtime.*; -import com.jogamp.common.os.*; import com.jogamp.common.nio.*; import jogamp.common.os.MachineDescriptionRuntime; @@ -41,11 +37,11 @@ public class Ehdr { return create(Buffers.newDirectByteBuffer(size())); } - public static Ehdr create(java.nio.ByteBuffer buf) { + public static Ehdr create(final java.nio.ByteBuffer buf) { return new Ehdr(buf); } - Ehdr(java.nio.ByteBuffer buf) { + Ehdr(final java.nio.ByteBuffer buf) { accessor = new StructAccessor(buf); } @@ -53,14 +49,14 @@ public class Ehdr { return accessor.getBuffer(); } - public Ehdr setE_ident(byte[] val) { + public Ehdr setE_ident(final byte[] val) { accessor.setBytesAt(e_ident_offset[mdIdx], val); return this; } public byte[] getE_ident() { return accessor.getBytesAt(e_ident_offset[mdIdx], new byte[16]); } - public Ehdr setE_type(short val) { + public Ehdr setE_type(final short val) { accessor.setShortAt(e_type_offset[mdIdx], val); return this; } @@ -69,7 +65,7 @@ public class Ehdr { return accessor.getShortAt(e_type_offset[mdIdx]); } - public Ehdr setE_machine(short val) { + public Ehdr setE_machine(final short val) { accessor.setShortAt(e_machine_offset[mdIdx], val); return this; } @@ -78,7 +74,7 @@ public class Ehdr { return accessor.getShortAt(e_machine_offset[mdIdx]); } - public Ehdr setE_version(int val) { + public Ehdr setE_version(final int val) { accessor.setIntAt(e_version_offset[mdIdx], val); return this; } @@ -87,7 +83,7 @@ public class Ehdr { return accessor.getIntAt(e_version_offset[mdIdx]); } - public Ehdr setE_entry(long val) { + public Ehdr setE_entry(final long val) { accessor.setLongAt(e_entry_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); return this; } @@ -96,7 +92,7 @@ public class Ehdr { return accessor.getLongAt(e_entry_offset[mdIdx], MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); } - public Ehdr setE_phoff(long val) { + public Ehdr setE_phoff(final long val) { accessor.setLongAt(e_phoff_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); return this; } @@ -105,7 +101,7 @@ public class Ehdr { return accessor.getLongAt(e_phoff_offset[mdIdx], MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); } - public Ehdr setE_shoff(long val) { + public Ehdr setE_shoff(final long val) { accessor.setLongAt(e_shoff_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); return this; } @@ -114,7 +110,7 @@ public class Ehdr { return accessor.getLongAt(e_shoff_offset[mdIdx], MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); } - public Ehdr setE_flags(int val) { + public Ehdr setE_flags(final int val) { accessor.setIntAt(e_flags_offset[mdIdx], val); return this; } @@ -123,7 +119,7 @@ public class Ehdr { return accessor.getIntAt(e_flags_offset[mdIdx]); } - public Ehdr setE_ehsize(short val) { + public Ehdr setE_ehsize(final short val) { accessor.setShortAt(e_ehsize_offset[mdIdx], val); return this; } @@ -132,7 +128,7 @@ public class Ehdr { return accessor.getShortAt(e_ehsize_offset[mdIdx]); } - public Ehdr setE_phentsize(short val) { + public Ehdr setE_phentsize(final short val) { accessor.setShortAt(e_phentsize_offset[mdIdx], val); return this; } @@ -141,7 +137,7 @@ public class Ehdr { return accessor.getShortAt(e_phentsize_offset[mdIdx]); } - public Ehdr setE_phnum(short val) { + public Ehdr setE_phnum(final short val) { accessor.setShortAt(e_phnum_offset[mdIdx], val); return this; } @@ -150,7 +146,7 @@ public class Ehdr { return accessor.getShortAt(e_phnum_offset[mdIdx]); } - public Ehdr setE_shentsize(short val) { + public Ehdr setE_shentsize(final short val) { accessor.setShortAt(e_shentsize_offset[mdIdx], val); return this; } @@ -159,7 +155,7 @@ public class Ehdr { return accessor.getShortAt(e_shentsize_offset[mdIdx]); } - public Ehdr setE_shnum(short val) { + public Ehdr setE_shnum(final short val) { accessor.setShortAt(e_shnum_offset[mdIdx], val); return this; } @@ -168,7 +164,7 @@ public class Ehdr { return accessor.getShortAt(e_shnum_offset[mdIdx]); } - public Ehdr setE_shstrndx(short val) { + public Ehdr setE_shstrndx(final short val) { accessor.setShortAt(e_shstrndx_offset[mdIdx], val); return this; } diff --git a/src/java/jogamp/common/os/elf/ElfHeader.java b/src/java/jogamp/common/os/elf/ElfHeader.java index f12ccad..3447107 100644 --- a/src/java/jogamp/common/os/elf/ElfHeader.java +++ b/src/java/jogamp/common/os/elf/ElfHeader.java @@ -358,7 +358,7 @@ public class ElfHeader { public static final short EM_MICROBLAZE = 189; public static final short EM_CUDA = 190; - public static final boolean isIdentityValid(byte[] ident) { + public static final boolean isIdentityValid(final byte[] ident) { return ELFMAG0 == ident[0] && ELFMAG1 == ident[1] && ELFMAG2 == ident[2] && @@ -381,7 +381,7 @@ public class ElfHeader { * @throws IOException if reading from the given input stream fails or less then ELF Header size bytes * @throws IllegalArgumentException if the given input stream does not represent an ELF Header */ - public static ElfHeader read(RandomAccessFile in) throws IOException, IllegalArgumentException { + public static ElfHeader read(final RandomAccessFile in) throws IOException, IllegalArgumentException { final int eh_sz = Ehdr.size(); final byte[] buf = new byte[eh_sz]; readBytes (in, buf, 0, eh_sz); @@ -394,7 +394,7 @@ public class ElfHeader { * @throws IllegalArgumentException if the given buffer does not represent an ELF Header * @throws IOException */ - ElfHeader(java.nio.ByteBuffer buf, RandomAccessFile in) throws IllegalArgumentException, IOException { + ElfHeader(final java.nio.ByteBuffer buf, final RandomAccessFile in) throws IllegalArgumentException, IOException { d = Ehdr.create(buf); if( !isIdentityValid(d.getE_ident()) ) { throw new IllegalArgumentException("Buffer is not an ELF Header"); @@ -530,7 +530,7 @@ public class ElfHeader { } /** Returns the 1st occurence of matching SectionHeader {@link SectionHeader#getType() type}, or null if not exists. */ - public final SectionHeader getSectionHeader(int type) { + public final SectionHeader getSectionHeader(final int type) { for(int i=0; i<sht.length; i++) { final SectionHeader sh = sht[i]; if( sh.getType() == type ) { @@ -541,7 +541,7 @@ public class ElfHeader { } /** Returns the 1st occurence of matching SectionHeader {@link SectionHeader#getName() name}, or null if not exists. */ - public final SectionHeader getSectionHeader(String name) { + public final SectionHeader getSectionHeader(final String name) { for(int i=0; i<sht.length; i++) { final SectionHeader sh = sht[i]; if( sh.getName().equals(name) ) { @@ -589,7 +589,7 @@ public class ElfHeader { ", abi[os "+getOSABI()+", vers "+getOSABIVersion()+"], flags["+toHexString(getFlags())+armFlagsS+"], type "+getType()+", sh-num "+sht.length+"]"; } - final SectionHeader[] readSectionHeaderTable(RandomAccessFile in) throws IOException, IllegalArgumentException { + final SectionHeader[] readSectionHeaderTable(final RandomAccessFile in) throws IOException, IllegalArgumentException { // positioning { final long off = d.getE_shoff(); // absolute offset @@ -607,7 +607,7 @@ public class ElfHeader { // Read 1st table 1st and use it's sh_size final byte[] buf0 = new byte[size]; readBytes(in, buf0, 0, size); - SectionHeader sh0 = new SectionHeader(buf0, 0, size, 0); + final SectionHeader sh0 = new SectionHeader(buf0, 0, size, 0); num = (int) sh0.d.getSh_size(); if( 0 >= num ) { throw new IllegalArgumentException("EHdr sh_num == 0 and 1st SHdr size == 0"); diff --git a/src/java/jogamp/common/os/elf/IOUtils.java b/src/java/jogamp/common/os/elf/IOUtils.java index 57b7a48..62b47db 100644 --- a/src/java/jogamp/common/os/elf/IOUtils.java +++ b/src/java/jogamp/common/os/elf/IOUtils.java @@ -36,11 +36,11 @@ import com.jogamp.common.util.Bitstream; class IOUtils { static final long MAX_INT_VALUE = ( Integer.MAX_VALUE & 0xffffffffL ) ; - static String toHexString(int i) { return "0x"+Integer.toHexString(i); } + static String toHexString(final int i) { return "0x"+Integer.toHexString(i); } - static String toHexString(long i) { return "0x"+Long.toHexString(i); } + static String toHexString(final long i) { return "0x"+Long.toHexString(i); } - static int shortToInt(short s) { + static int shortToInt(final short s) { return s & 0x0000ffff; } @@ -57,7 +57,7 @@ class IOUtils { in.readFully(out, offset, len); } - static void seek(final RandomAccessFile in, long newPos) throws IOException { + static void seek(final RandomAccessFile in, final long newPos) throws IOException { in.seek(newPos); } @@ -83,7 +83,7 @@ class IOUtils { * @return the parsed string * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>. */ - static String getString(final byte[] sb, final int offset, final int remaining, int[] offset_post) throws IndexOutOfBoundsException { + static String getString(final byte[] sb, final int offset, final int remaining, final int[] offset_post) throws IndexOutOfBoundsException { Bitstream.checkBounds(sb, offset, remaining); int strlen = 0; for(; strlen < remaining && sb[strlen + offset] != 0; strlen++) { } @@ -102,7 +102,7 @@ class IOUtils { * @return the number of parsed strings * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>. */ - static int getStringCount(final byte[] sb, int offset, final int remaining) throws IndexOutOfBoundsException { + static int getStringCount(final byte[] sb, final int offset, final int remaining) throws IndexOutOfBoundsException { Bitstream.checkBounds(sb, offset, remaining); int strnum=0; for(int i=0; i < remaining; i++) { @@ -120,7 +120,7 @@ class IOUtils { * @return the parsed strings * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>. */ - public static String[] getStrings(final byte[] sb, int offset, final int remaining) throws IndexOutOfBoundsException { + public static String[] getStrings(final byte[] sb, final int offset, final int remaining) throws IndexOutOfBoundsException { final int strnum = getStringCount(sb, offset, remaining); // System.err.println("XXX: strnum "+strnum+", sb_off "+sb_off+", sb_len "+sb_len); diff --git a/src/java/jogamp/common/os/elf/Section.java b/src/java/jogamp/common/os/elf/Section.java index 01dc62b..29dc209 100644 --- a/src/java/jogamp/common/os/elf/Section.java +++ b/src/java/jogamp/common/os/elf/Section.java @@ -33,7 +33,7 @@ public class Section { public int offset; public int length; - Section(SectionHeader sh, byte[] data, int offset, int length) { + Section(final SectionHeader sh, final byte[] data, final int offset, final int length) { this.sh = sh; this.data = data; this.offset = offset; diff --git a/src/java/jogamp/common/os/elf/SectionArmAttributes.java b/src/java/jogamp/common/os/elf/SectionArmAttributes.java index db6710a..91e8c31 100644 --- a/src/java/jogamp/common/os/elf/SectionArmAttributes.java +++ b/src/java/jogamp/common/os/elf/SectionArmAttributes.java @@ -48,7 +48,7 @@ public class SectionArmAttributes extends Section { * Returns true if value is either {@link #ABI_VFP_ARGS_IS_VFP_VARIANT} or {@link #ABI_VFP_ARGS_IS_BOTH_BASE_AND_VFP_VARIANT} * @param v ULEB128 Value from {@link Tag#ABI_VFP_args} attribute */ - public static final boolean abiVFPArgsAcceptsVFPVariant(byte v) { + public static final boolean abiVFPArgsAcceptsVFPVariant(final byte v) { return ABI_VFP_ARGS_IS_VFP_VARIANT == v || ABI_VFP_ARGS_IS_BOTH_BASE_AND_VFP_VARIANT == v; } @@ -113,7 +113,7 @@ public class SectionArmAttributes extends Section { return null; } - Tag(int id, Type type){ + Tag(final int id, final Type type){ this.id = id; this.type = type; } @@ -123,7 +123,7 @@ public class SectionArmAttributes extends Section { public final Tag tag; private final Object value; - Attribute(Tag tag, Object value) { + Attribute(final Tag tag, final Object value) { this.tag = tag; this.value = value; } @@ -158,7 +158,7 @@ public class SectionArmAttributes extends Section { public final String vendor; public final List<Attribute> attributes; - VendorAttributes(String vendor, List<Attribute> attributes) { + VendorAttributes(final String vendor, final List<Attribute> attributes) { this.vendor = vendor; this.attributes = attributes; } @@ -170,7 +170,7 @@ public class SectionArmAttributes extends Section { } public final List<VendorAttributes> vendorAttributesList; - SectionArmAttributes(SectionHeader sh, byte[] data, int offset, int length) throws IndexOutOfBoundsException, IllegalArgumentException { + SectionArmAttributes(final SectionHeader sh, final byte[] data, final int offset, final int length) throws IndexOutOfBoundsException, IllegalArgumentException { super(sh, data, offset, length); this.vendorAttributesList = parse(data, offset, length); } @@ -180,7 +180,7 @@ public class SectionArmAttributes extends Section { return "SectionArmAttributes["+super.toSubString()+", "+vendorAttributesList.toString()+"]"; } - public final Attribute get(Tag tag) { + public final Attribute get(final Tag tag) { for(int i=0; i<vendorAttributesList.size(); i++) { final List<Attribute> attributes = vendorAttributesList.get(i).attributes; for(int j=0; j<attributes.size(); j++) { @@ -193,11 +193,11 @@ public class SectionArmAttributes extends Section { return null; } - public final List<Attribute> get(String vendor) { + public final List<Attribute> get(final String vendor) { return get(vendorAttributesList, vendor); } - static final List<Attribute> get(final List<VendorAttributes> vendorAttributesList, String vendor) { + static final List<Attribute> get(final List<VendorAttributes> vendorAttributesList, final String vendor) { for(int i=0; i<vendorAttributesList.size(); i++) { final VendorAttributes vas = vendorAttributesList.get(i); if( vas.vendor.equals(vendor) ) { @@ -232,7 +232,7 @@ public class SectionArmAttributes extends Section { final String vendor; { - int[] i_post = new int[] { 0 }; + final int[] i_post = new int[] { 0 }; vendor = getString(in, i, secLen - 4, i_post); i = i_post[0]; } @@ -240,7 +240,7 @@ public class SectionArmAttributes extends Section { final List<Attribute> attributes = new ArrayList<Attribute>(); while(i < secLen) { - int[] i_post = new int[] { 0 }; + final int[] i_post = new int[] { 0 }; parseSub(in, i, secLen - i, i_post, attributes); i = i_post[0]; } @@ -268,7 +268,7 @@ public class SectionArmAttributes extends Section { * @throws IndexOutOfBoundsException if <code>offset + remaining > sb.length</code>. * @throws IllegalArgumentException if section parsing failed, i.e. incompatible version or data. */ - static void parseSub(final byte[] in, final int offset, final int remaining, int[] offset_post, List<Attribute> attributes) throws IndexOutOfBoundsException, IllegalArgumentException { + static void parseSub(final byte[] in, final int offset, final int remaining, final int[] offset_post, final List<Attribute> attributes) throws IndexOutOfBoundsException, IllegalArgumentException { Bitstream.checkBounds(in, offset, remaining); // Starts w/ sub-section Tag @@ -299,7 +299,7 @@ public class SectionArmAttributes extends Section { switch(tag.type) { case NTBS: { - int[] i_post = new int[] { 0 }; + final int[] i_post = new int[] { 0 }; final String value = getString(in, i, subSecLen + offset - i, i_post); attributes.add(new Attribute(tag, value)); i = i_post[0]; diff --git a/src/java/jogamp/common/os/elf/SectionHeader.java b/src/java/jogamp/common/os/elf/SectionHeader.java index 8a83b61..20a40a5 100644 --- a/src/java/jogamp/common/os/elf/SectionHeader.java +++ b/src/java/jogamp/common/os/elf/SectionHeader.java @@ -174,13 +174,13 @@ public class SectionHeader { /** Public access to the raw elf section header */ public final Shdr d; - private int idx; + private final int idx; private String name; - SectionHeader(byte[] buf, int offset, int length, int sectionIdx) { + SectionHeader(final byte[] buf, final int offset, final int length, final int sectionIdx) { this( ByteBuffer.wrap(buf, 0, buf.length), sectionIdx ); } - SectionHeader(java.nio.ByteBuffer buf, int idx) { + SectionHeader(final java.nio.ByteBuffer buf, final int idx) { d = Shdr.create(buf); this.idx = idx; name = null; @@ -231,7 +231,7 @@ public class SectionHeader { * @throws IOException if read error occurs * @throws IllegalArgumentException if section offset or size mismatch including size > {@link Integer#MAX_VALUE} */ - public Section readSection(RandomAccessFile in) throws IOException, IllegalArgumentException { + public Section readSection(final RandomAccessFile in) throws IOException, IllegalArgumentException { final int s_size = long2Int(d.getSh_size()); if( 0 == s_size || 0 > s_size ) { throw new IllegalArgumentException("Shdr["+idx+"] has invalid int size: "+d.getSh_size()+" -> "+s_size); @@ -251,7 +251,7 @@ public class SectionHeader { * @throws IllegalArgumentException if section offset or size mismatch including size > {@link Integer#MAX_VALUE} * @throws IllegalArgumentException if requested read length is > section size */ - public Section readSection(RandomAccessFile in, byte[] b, int b_off, int r_len) throws IOException, IllegalArgumentException { + public Section readSection(final RandomAccessFile in, final byte[] b, final int b_off, final int r_len) throws IOException, IllegalArgumentException { final int s_size = long2Int(d.getSh_size()); if( 0 == s_size || 0 > s_size ) { throw new IllegalArgumentException("Shdr["+idx+"] has invalid int size: "+d.getSh_size()+" -> "+s_size); @@ -262,7 +262,7 @@ public class SectionHeader { return readSectionImpl(in, b, b_off, r_len); } - Section readSectionImpl(RandomAccessFile in, byte[] b, int b_off, int r_len) throws IOException, IllegalArgumentException { + Section readSectionImpl(final RandomAccessFile in, final byte[] b, final int b_off, final int r_len) throws IOException, IllegalArgumentException { final long s_off = d.getSh_offset(); seek(in, s_off); readBytes(in, b, b_off, r_len); diff --git a/src/java/jogamp/common/os/elf/Shdr.java b/src/java/jogamp/common/os/elf/Shdr.java index 5465b3d..d31aec2 100644 --- a/src/java/jogamp/common/os/elf/Shdr.java +++ b/src/java/jogamp/common/os/elf/Shdr.java @@ -3,10 +3,6 @@ package jogamp.common.os.elf; -import java.nio.*; - -import com.jogamp.gluegen.runtime.*; -import com.jogamp.common.os.*; import com.jogamp.common.nio.*; import jogamp.common.os.MachineDescriptionRuntime; @@ -37,11 +33,11 @@ public class Shdr { return create(Buffers.newDirectByteBuffer(size())); } - public static Shdr create(java.nio.ByteBuffer buf) { + public static Shdr create(final java.nio.ByteBuffer buf) { return new Shdr(buf); } - Shdr(java.nio.ByteBuffer buf) { + Shdr(final java.nio.ByteBuffer buf) { accessor = new StructAccessor(buf); } @@ -49,7 +45,7 @@ public class Shdr { return accessor.getBuffer(); } - public Shdr setSh_name(int val) { + public Shdr setSh_name(final int val) { accessor.setIntAt(sh_name_offset[mdIdx], val); return this; } @@ -58,7 +54,7 @@ public class Shdr { return accessor.getIntAt(sh_name_offset[mdIdx]); } - public Shdr setSh_type(int val) { + public Shdr setSh_type(final int val) { accessor.setIntAt(sh_type_offset[mdIdx], val); return this; } @@ -67,7 +63,7 @@ public class Shdr { return accessor.getIntAt(sh_type_offset[mdIdx]); } - public Shdr setSh_flags(long val) { + public Shdr setSh_flags(final long val) { accessor.setLongAt(sh_flags_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); return this; } @@ -76,7 +72,7 @@ public class Shdr { return accessor.getLongAt(sh_flags_offset[mdIdx], MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); } - public Shdr setSh_addr(long val) { + public Shdr setSh_addr(final long val) { accessor.setLongAt(sh_addr_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); return this; } @@ -85,7 +81,7 @@ public class Shdr { return accessor.getLongAt(sh_addr_offset[mdIdx], MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); } - public Shdr setSh_offset(long val) { + public Shdr setSh_offset(final long val) { accessor.setLongAt(sh_offset_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); return this; } @@ -94,7 +90,7 @@ public class Shdr { return accessor.getLongAt(sh_offset_offset[mdIdx], MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); } - public Shdr setSh_size(long val) { + public Shdr setSh_size(final long val) { accessor.setLongAt(sh_size_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); return this; } @@ -103,7 +99,7 @@ public class Shdr { return accessor.getLongAt(sh_size_offset[mdIdx], MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); } - public Shdr setSh_link(int val) { + public Shdr setSh_link(final int val) { accessor.setIntAt(sh_link_offset[mdIdx], val); return this; } @@ -112,7 +108,7 @@ public class Shdr { return accessor.getIntAt(sh_link_offset[mdIdx]); } - public Shdr setSh_info(int val) { + public Shdr setSh_info(final int val) { accessor.setIntAt(sh_info_offset[mdIdx], val); return this; } @@ -121,7 +117,7 @@ public class Shdr { return accessor.getIntAt(sh_info_offset[mdIdx]); } - public Shdr setSh_addralign(long val) { + public Shdr setSh_addralign(final long val) { accessor.setLongAt(sh_addralign_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); return this; } @@ -130,7 +126,7 @@ public class Shdr { return accessor.getLongAt(sh_addralign_offset[mdIdx], MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); } - public Shdr setSh_entsize(long val) { + public Shdr setSh_entsize(final long val) { accessor.setLongAt(sh_entsize_offset[mdIdx], val, MachineDescriptionRuntime.getStatic().md.longSizeInBytes()); return this; } diff --git a/src/java/jogamp/common/util/locks/LockDebugUtil.java b/src/java/jogamp/common/util/locks/LockDebugUtil.java index ee0a8e8..6f7ee63 100644 --- a/src/java/jogamp/common/util/locks/LockDebugUtil.java +++ b/src/java/jogamp/common/util/locks/LockDebugUtil.java @@ -64,13 +64,13 @@ public class LockDebugUtil { } } - public static void dumpRecursiveLockTrace(PrintStream out) { + public static void dumpRecursiveLockTrace(final PrintStream out) { if(Lock.DEBUG) { - List<Throwable> ls = getRecursiveLockTrace(); + final List<Throwable> ls = getRecursiveLockTrace(); if(null!=ls && ls.size()>0) { int j=0; out.println("TLSLockedStacks: locks "+ls.size()); - for(Iterator<Throwable> i=ls.iterator(); i.hasNext(); j++) { + for(final Iterator<Throwable> i=ls.iterator(); i.hasNext(); j++) { out.print(j+": "); i.next().printStackTrace(out); } diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java b/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java index f49e406..c930dff 100644 --- a/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java +++ b/src/java/jogamp/common/util/locks/RecursiveLockImpl01CompleteFair.java @@ -43,7 +43,7 @@ import com.jogamp.common.util.locks.RecursiveLock; public class RecursiveLockImpl01CompleteFair implements RecursiveLock { private static class WaitingThread { - WaitingThread(Thread t) { + WaitingThread(final Thread t) { thread = t; signaledByUnlock = false; } @@ -59,11 +59,11 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { private final Thread getOwner() { return getExclusiveOwnerThread(); } - private final void setOwner(Thread t) { + private final void setOwner(final Thread t) { setExclusiveOwnerThread(t); } - private final void setLockedStack(Throwable s) { - List<Throwable> ls = LockDebugUtil.getRecursiveLockTrace(); + private final void setLockedStack(final Throwable s) { + final List<Throwable> ls = LockDebugUtil.getRecursiveLockTrace(); if(s==null) { ls.remove(lockedStack); } else { @@ -78,7 +78,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { /** stack trace of the lock, only used if DEBUG */ private Throwable lockedStack = null; } - private Sync sync = new Sync(); + private final Sync sync = new Sync(); public RecursiveLockImpl01CompleteFair() { } @@ -102,7 +102,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { } @Override - public final boolean isOwner(Thread thread) { + public final boolean isOwner(final Thread thread) { synchronized(sync) { return sync.getOwner() == thread ; } @@ -155,7 +155,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { } throw new RuntimeException("Waited "+TIMEOUT+"ms for: "+toString()+" - "+threadName(Thread.currentThread())); } - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RuntimeException("Interrupted", e); } } @@ -187,14 +187,14 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { } // enqueue at the start - WaitingThread wCur = new WaitingThread(cur); + final WaitingThread wCur = new WaitingThread(cur); sync.queue.add(0, wCur); do { final long t0 = System.currentTimeMillis(); try { sync.wait(timeout); timeout -= System.currentTimeMillis() - t0; - } catch (InterruptedException e) { + } catch (final InterruptedException e) { if( !wCur.signaledByUnlock ) { sync.queue.remove(wCur); // O(n) throw e; // propagate interruption not send by unlock @@ -255,7 +255,7 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { } @Override - public final void unlock(Runnable taskAfterUnlockBeforeNotify) { + public final void unlock(final Runnable taskAfterUnlockBeforeNotify) { synchronized(sync) { validateLocked(); final Thread cur = Thread.currentThread(); @@ -314,6 +314,6 @@ public class RecursiveLockImpl01CompleteFair implements RecursiveLock { private final String syncName() { return "<"+Integer.toHexString(this.hashCode())+", "+Integer.toHexString(sync.hashCode())+">"; } - private final String threadName(Thread t) { return null!=t ? "<"+t.getName()+">" : "<NULL>" ; } + private final String threadName(final Thread t) { return null!=t ? "<"+t.getName()+">" : "<NULL>" ; } } diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java b/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java index 8c9f720..132a9a2 100644 --- a/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java +++ b/src/java/jogamp/common/util/locks/RecursiveLockImpl01Unfairish.java @@ -72,11 +72,11 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { return getExclusiveOwnerThread(); } @Override - public boolean isOwner(Thread t) { + public boolean isOwner(final Thread t) { return getExclusiveOwnerThread()==t; } @Override - public final void setOwner(Thread t) { + public final void setOwner(final Thread t) { setExclusiveOwnerThread(t); } @Override @@ -84,8 +84,8 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { return lockedStack; } @Override - public final void setLockedStack(Throwable s) { - List<Throwable> ls = LockDebugUtil.getRecursiveLockTrace(); + public final void setLockedStack(final Throwable s) { + final List<Throwable> ls = LockDebugUtil.getRecursiveLockTrace(); if(s==null) { ls.remove(lockedStack); } else { @@ -96,9 +96,9 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { @Override public final int getHoldCount() { return holdCount; } @Override - public void incrHoldCount(Thread t) { holdCount++; } + public void incrHoldCount(final Thread t) { holdCount++; } @Override - public void decrHoldCount(Thread t) { holdCount--; } + public void decrHoldCount(final Thread t) { holdCount--; } @Override public final int getQSz() { return qsz; } @@ -117,7 +117,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { protected final Sync sync; - public RecursiveLockImpl01Unfairish(Sync sync) { + public RecursiveLockImpl01Unfairish(final Sync sync) { this.sync = sync; } @@ -144,7 +144,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } @Override - public final boolean isOwner(Thread thread) { + public final boolean isOwner(final Thread thread) { synchronized(sync) { return sync.isOwner(thread); } @@ -197,7 +197,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } throw new RuntimeException("Waited "+TIMEOUT+"ms for: "+toString()+" - "+threadName(Thread.currentThread())); } - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RuntimeException("Interrupted", e); } } @@ -270,7 +270,7 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { } @Override - public void unlock(Runnable taskAfterUnlockBeforeNotify) { + public void unlock(final Runnable taskAfterUnlockBeforeNotify) { synchronized(sync) { validateLocked(); final Thread cur = Thread.currentThread(); @@ -315,6 +315,6 @@ public class RecursiveLockImpl01Unfairish implements RecursiveLock { /* package */ final String syncName() { return "<"+Integer.toHexString(this.hashCode())+", "+Integer.toHexString(sync.hashCode())+">"; } - /* package */ final String threadName(Thread t) { return null!=t ? "<"+t.getName()+">" : "<NULL>" ; } + /* package */ final String threadName(final Thread t) { return null!=t ? "<"+t.getName()+">" : "<NULL>" ; } } diff --git a/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java b/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java index f3dfa42..badaa72 100644 --- a/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java +++ b/src/java/jogamp/common/util/locks/RecursiveLockImplJava5.java @@ -10,7 +10,7 @@ public class RecursiveLockImplJava5 implements RecursiveLock { volatile Thread owner = null; ReentrantLock lock; - public RecursiveLockImplJava5(boolean fair) { + public RecursiveLockImplJava5(final boolean fair) { lock = new ReentrantLock(fair); } @@ -20,14 +20,14 @@ public class RecursiveLockImplJava5 implements RecursiveLock { if(!tryLock(TIMEOUT)) { throw new RuntimeException("Waited "+TIMEOUT+"ms for: "+threadName(owner)+" - "+threadName(Thread.currentThread())+", with count "+getHoldCount()+", lock: "+this); } - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RuntimeException("Interrupted", e); } owner = Thread.currentThread(); } @Override - public boolean tryLock(long timeout) throws InterruptedException { + public boolean tryLock(final long timeout) throws InterruptedException { if(lock.tryLock(timeout, TimeUnit.MILLISECONDS)) { owner = Thread.currentThread(); return true; @@ -41,7 +41,7 @@ public class RecursiveLockImplJava5 implements RecursiveLock { } @Override - public void unlock(Runnable taskAfterUnlockBeforeNotify) { + public void unlock(final Runnable taskAfterUnlockBeforeNotify) { validateLocked(); owner = null; if(null!=taskAfterUnlockBeforeNotify) { @@ -66,7 +66,7 @@ public class RecursiveLockImplJava5 implements RecursiveLock { } @Override - public boolean isOwner(Thread thread) { + public boolean isOwner(final Thread thread) { return lock.isLocked() && owner == thread; } @@ -91,5 +91,5 @@ public class RecursiveLockImplJava5 implements RecursiveLock { return lock.getQueueLength(); } - private String threadName(Thread t) { return null!=t ? "<"+t.getName()+">" : "<NULL>" ; } + private String threadName(final Thread t) { return null!=t ? "<"+t.getName()+">" : "<NULL>" ; } } diff --git a/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java b/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java index 7a386d6..77f73d8 100644 --- a/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java +++ b/src/java/jogamp/common/util/locks/RecursiveThreadGroupLockImpl01Unfairish.java @@ -44,14 +44,14 @@ public class RecursiveThreadGroupLockImpl01Unfairish holdCountAdditionOwner = 0; } @Override - public final void incrHoldCount(Thread t) { + public final void incrHoldCount(final Thread t) { super.incrHoldCount(t); if(!isOriginalOwner(t)) { holdCountAdditionOwner++; } } @Override - public final void decrHoldCount(Thread t) { + public final void decrHoldCount(final Thread t) { super.decrHoldCount(t); if(!isOriginalOwner(t)) { holdCountAdditionOwner--; @@ -61,11 +61,11 @@ public class RecursiveThreadGroupLockImpl01Unfairish return holdCountAdditionOwner; } - public final boolean isOriginalOwner(Thread t) { + public final boolean isOriginalOwner(final Thread t) { return super.isOwner(t); } @Override - public final boolean isOwner(Thread t) { + public final boolean isOwner(final Thread t) { if(getExclusiveOwnerThread()==t) { return true; } @@ -80,7 +80,7 @@ public class RecursiveThreadGroupLockImpl01Unfairish public final int getAddOwnerCount() { return threadNum; } - public final void addOwner(Thread t) throws IllegalArgumentException { + public final void addOwner(final Thread t) throws IllegalArgumentException { if(null == threads) { if(threadNum>0) { throw new InternalError("XXX"); @@ -106,7 +106,7 @@ public class RecursiveThreadGroupLockImpl01Unfairish threadNum=0; } - public final void removeOwner(Thread t) throws IllegalArgumentException { + public final void removeOwner(final Thread t) throws IllegalArgumentException { for (int i = 0 ; i < threadNum ; i++) { if (threads[i] == t) { threadNum--; @@ -119,7 +119,7 @@ public class RecursiveThreadGroupLockImpl01Unfairish } String addOwnerToString() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); for(int i=0; i<threadNum; i++) { if(i>0) { sb.append(", "); @@ -145,14 +145,14 @@ public class RecursiveThreadGroupLockImpl01Unfairish } @Override - public final boolean isOriginalOwner(Thread thread) { + public final boolean isOriginalOwner(final Thread thread) { synchronized(sync) { return ((ThreadGroupSync)sync).isOriginalOwner(thread) ; } } @Override - public final void addOwner(Thread t) throws RuntimeException, IllegalArgumentException { + public final void addOwner(final Thread t) throws RuntimeException, IllegalArgumentException { validateLocked(); final Thread cur = Thread.currentThread(); final ThreadGroupSync tgSync = (ThreadGroupSync)sync; @@ -166,7 +166,7 @@ public class RecursiveThreadGroupLockImpl01Unfairish } @Override - public final void unlock(Runnable taskAfterUnlockBeforeNotify) { + public final void unlock(final Runnable taskAfterUnlockBeforeNotify) { synchronized(sync) { final Thread cur = Thread.currentThread(); final ThreadGroupSync tgSync = (ThreadGroupSync)sync; @@ -182,7 +182,7 @@ public class RecursiveThreadGroupLockImpl01Unfairish while ( tgSync.getAdditionalOwnerHoldCount() > 0 ) { try { sync.wait(); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { // regular wake up! } } @@ -205,7 +205,7 @@ public class RecursiveThreadGroupLockImpl01Unfairish } @Override - public final void removeOwner(Thread t) throws RuntimeException, IllegalArgumentException { + public final void removeOwner(final Thread t) throws RuntimeException, IllegalArgumentException { validateLocked(); ((ThreadGroupSync)sync).removeOwner(t); } diff --git a/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java b/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java index a3d3ac9..44a5d28 100644 --- a/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java +++ b/src/java/jogamp/common/util/locks/SingletonInstanceFileLock.java @@ -41,11 +41,11 @@ public class SingletonInstanceFileLock extends SingletonInstance { static { String s = null; try { - File tmpFile = File.createTempFile("TEST", "tst"); - String absTmpFile = tmpFile.getCanonicalPath(); + final File tmpFile = File.createTempFile("TEST", "tst"); + final String absTmpFile = tmpFile.getCanonicalPath(); tmpFile.delete(); s = absTmpFile.substring(0, absTmpFile.lastIndexOf(File.separator)); - } catch (IOException ex) { + } catch (final IOException ex) { ex.printStackTrace(); } temp_file_path = s; @@ -55,17 +55,17 @@ public class SingletonInstanceFileLock extends SingletonInstance { return temp_file_path; } - public static String getCanonicalTempLockFilePath(String basename) { + public static String getCanonicalTempLockFilePath(final String basename) { return getCanonicalTempPath() + File.separator + basename; } - public SingletonInstanceFileLock(long poll_ms, String lockFileBasename) { + public SingletonInstanceFileLock(final long poll_ms, final String lockFileBasename) { super(poll_ms); file = new File ( getCanonicalTempLockFilePath ( lockFileBasename ) ); setupFileCleanup(); } - public SingletonInstanceFileLock(long poll_ms, File lockFile) { + public SingletonInstanceFileLock(final long poll_ms, final File lockFile) { super(poll_ms); file = lockFile ; setupFileCleanup(); @@ -96,7 +96,7 @@ public class SingletonInstanceFileLock extends SingletonInstance { if (fileLock != null) { return true; } - } catch (Exception e) { + } catch (final Exception e) { System.err.println(infoPrefix()+" III "+getName()+" - Unable to create and/or lock file"); e.printStackTrace(); } @@ -118,7 +118,7 @@ public class SingletonInstanceFileLock extends SingletonInstance { file.delete(); } return true; - } catch (Exception e) { + } catch (final Exception e) { System.err.println(infoPrefix()+" EEE "+getName()+" - Unable to remove lock file"); e.printStackTrace(); } finally { diff --git a/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java b/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java index a1ca2ff..b1b42c3 100644 --- a/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java +++ b/src/java/jogamp/common/util/locks/SingletonInstanceServerSocket.java @@ -40,30 +40,30 @@ public class SingletonInstanceServerSocket extends SingletonInstance { private final Server singletonServer; private final String fullName; - public SingletonInstanceServerSocket(long poll_ms, int portNumber) { + public SingletonInstanceServerSocket(final long poll_ms, final int portNumber) { super(poll_ms); // Gather the local InetAddress, loopback is prioritized InetAddress ilh = null; try { ilh = InetAddress.getByName(null); // loopback - } catch (UnknownHostException e1) { } + } catch (final UnknownHostException e1) { } if(null == ilh) { try { ilh = InetAddress.getByName("localhost"); if(null!=ilh && !ilh.isLoopbackAddress()) { ilh = null; } - } catch (UnknownHostException e1) { } + } catch (final UnknownHostException e1) { } } if(null == ilh) { try { ilh = InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 } ); if(null!=ilh && !ilh.isLoopbackAddress()) { ilh = null; } - } catch (UnknownHostException e) { } + } catch (final UnknownHostException e) { } } if(null == ilh) { try { ilh = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { } + } catch (final UnknownHostException e) { } } if(null == ilh) { throw new RuntimeException(infoPrefix()+" EEE Could not determine local InetAddress"); @@ -97,11 +97,11 @@ public class SingletonInstanceServerSocket extends SingletonInstance { } // check if other JVM's locked the server socket .. - Socket clientSocket = singletonServer.connect(); + final Socket clientSocket = singletonServer.connect(); if(null != clientSocket) { try { clientSocket.close(); - } catch (IOException e) { } + } catch (final IOException e) { } return false; } @@ -124,11 +124,11 @@ public class SingletonInstanceServerSocket extends SingletonInstance { private volatile boolean shallQuit = false; private volatile boolean alive = false; - private Object syncOnStartStop = new Object(); + private final Object syncOnStartStop = new Object(); private ServerSocket serverSocket = null; private Thread serverThread = null; // allowing kill() to force-stop last server-thread - public Server(InetAddress localInetAddress, int portNumber) { + public Server(final InetAddress localInetAddress, final int portNumber) { this.localInetAddress = localInetAddress; this.portNumber = portNumber; } @@ -145,11 +145,11 @@ public class SingletonInstanceServerSocket extends SingletonInstance { serverThread.start(); try { syncOnStartStop.wait(); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { ie.printStackTrace(); } } - boolean ok = isBound(); + final boolean ok = isBound(); if(!ok) { shutdown(); } @@ -164,7 +164,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance { connect(); try { syncOnStartStop.wait(); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { ie.printStackTrace(); } } @@ -188,14 +188,14 @@ public class SingletonInstanceServerSocket extends SingletonInstance { if(null != serverThread) { try { serverThread.stop(); - } catch(Throwable t) { } + } catch(final Throwable t) { } } if(null != serverSocket) { try { final ServerSocket ss = serverSocket; serverSocket = null; ss.close(); - } catch (Throwable t) { } + } catch (final Throwable t) { } } } @@ -208,7 +208,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance { public final Socket connect() { try { return new Socket(localInetAddress, portNumber); - } catch (Exception e) { } + } catch (final Exception e) { } return null; } @@ -227,7 +227,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance { serverSocket = new ServerSocket(portNumber, 1, localInetAddress); serverSocket.setReuseAddress(true); // reuse same port w/ subsequent instance, i.e. overcome TO state when JVM crashed alive = true; - } catch (IOException e) { + } catch (final IOException e) { System.err.println(infoPrefix()+" III - Unable to install ServerSocket: "+e.getMessage()); shallQuit = true; } finally { @@ -239,7 +239,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance { try { final Socket clientSocket = serverSocket.accept(); clientSocket.close(); - } catch (IOException ioe) { + } catch (final IOException ioe) { System.err.println(infoPrefix()+" EEE - Exception during accept: " + ioe.getMessage()); } } @@ -249,7 +249,7 @@ public class SingletonInstanceServerSocket extends SingletonInstance { if(null != serverSocket) { serverSocket.close(); } - } catch (IOException e) { + } catch (final IOException e) { System.err.println(infoPrefix()+" EEE - Exception during close: " + e.getMessage()); } finally { serverSocket = null; |