summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util/cache
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-07-03 16:06:47 +0200
committerSven Gothel <[email protected]>2014-07-03 16:06:47 +0200
commitdf9ff7f340a5ab4e07efc613f5f264eeae63d4c7 (patch)
tree239ae276b82024b140428e6c0fe5d739fdd686a4 /src/java/com/jogamp/common/util/cache
parenteb47aaba63e3b1bf55f274a0f338f1010a017ae4 (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/com/jogamp/common/util/cache')
-rw-r--r--src/java/com/jogamp/common/util/cache/TempFileCache.java60
-rw-r--r--src/java/com/jogamp/common/util/cache/TempJarCache.java26
2 files changed, 43 insertions, 43 deletions
diff --git a/src/java/com/jogamp/common/util/cache/TempFileCache.java b/src/java/com/jogamp/common/util/cache/TempFileCache.java
index e1b1aab..b58ea28 100644
--- a/src/java/com/jogamp/common/util/cache/TempFileCache.java
+++ b/src/java/com/jogamp/common/util/cache/TempFileCache.java
@@ -79,7 +79,7 @@ public class TempFileCache {
try {
_tmpBaseDir = new File(IOUtil.getTempDir(true /* executable */), tmpDirPrefix);
_tmpBaseDir = IOUtil.testDir(_tmpBaseDir, true /* create */, false /* executable */); // executable already checked
- } catch (Exception ex) {
+ } catch (final Exception ex) {
System.err.println("Warning: Caught Exception while retrieving executable temp base directory:");
ex.printStackTrace();
staticInitError = true;
@@ -94,7 +94,7 @@ public class TempFileCache {
if(!staticInitError) {
try {
initTmpRoot();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
System.err.println("Warning: Caught Exception due to initializing TmpRoot:");
ex.printStackTrace();
staticInitError = true;
@@ -200,7 +200,7 @@ public class TempFileCache {
if (tmpRootPropValue == null) {
// 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());
}
@@ -209,12 +209,12 @@ public class TempFileCache {
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());
}
@@ -248,7 +248,7 @@ public class TempFileCache {
tmpLock.release();
lckOut.close();
lckLock.release();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
// Do nothing
}
}
@@ -262,7 +262,7 @@ public class TempFileCache {
}
// Start a new Reaper thread to do stuff...
- Thread reaperThread = new Thread() {
+ final Thread reaperThread = new Thread() {
/* @Override */
@Override
public void run() {
@@ -286,10 +286,10 @@ public class TempFileCache {
// 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 */
@Override
- public boolean accept(File dir, String name) {
+ public boolean accept(final File dir, final String name) {
return name.endsWith(".lck") && !name.equals(ourLockFile);
}
};
@@ -299,16 +299,16 @@ public class TempFileCache {
// (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;
@@ -319,7 +319,7 @@ public class TempFileCache {
tmpOut = new FileOutputStream(tmpFile);
tmpChannel = tmpOut.getChannel();
tmpLock = tmpChannel.tryLock();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
// Ignore exceptions
if (DEBUG) {
ex.printStackTrace();
@@ -335,7 +335,7 @@ public class TempFileCache {
lckOut = new FileOutputStream(lckFile);
lckChannel = lckOut.getChannel();
lckLock = lckChannel.tryLock();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
if (DEBUG) {
ex.printStackTrace();
}
@@ -355,12 +355,12 @@ public class TempFileCache {
// 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 {
@@ -373,7 +373,7 @@ public class TempFileCache {
// on the *.tmp file
tmpOut.close();
tmpLock.release();
- } catch (IOException ex) {
+ } catch (final IOException ex) {
if (DEBUG) {
ex.printStackTrace();
}
@@ -393,14 +393,14 @@ public class TempFileCache {
* 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]);
@@ -419,7 +419,7 @@ public class TempFileCache {
if(!staticInitError) {
try {
createTmpDir();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
ex.printStackTrace();
initError = true;
}
@@ -439,7 +439,7 @@ public class TempFileCache {
if(!staticInitError) {
try {
removeAll(individualTmpDir);
- } catch (Exception ex) {
+ } catch (final Exception ex) {
ex.printStackTrace();
}
}
@@ -525,9 +525,9 @@ public class TempFileCache {
* 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/com/jogamp/common/util/cache/TempJarCache.java b/src/java/com/jogamp/common/util/cache/TempJarCache.java
index 99bb272..1b322d7 100644
--- a/src/java/com/jogamp/common/util/cache/TempJarCache.java
+++ b/src/java/com/jogamp/common/util/cache/TempJarCache.java
@@ -56,11 +56,11 @@ public class TempJarCache {
public enum LoadState {
LOOKED_UP, LOADED;
- public boolean compliesWith(LoadState o2) {
+ public boolean compliesWith(final LoadState o2) {
return null != o2 ? compareTo(o2) >= 0 : false;
}
}
- private static boolean testLoadState(LoadState has, LoadState exp) {
+ private static boolean testLoadState(final LoadState has, final LoadState exp) {
if(null == has) {
return null == exp;
}
@@ -182,7 +182,7 @@ public class TempJarCache {
return tmpFileCache;
}
- public synchronized static boolean checkNativeLibs(URI jarURI, LoadState exp) throws IOException {
+ public synchronized static boolean checkNativeLibs(final URI jarURI, final LoadState exp) throws IOException {
checkInitialized();
if(null == jarURI) {
throw new IllegalArgumentException("jarURI is null");
@@ -190,7 +190,7 @@ public class TempJarCache {
return testLoadState(nativeLibJars.get(jarURI), exp);
}
- public synchronized static boolean checkClasses(URI jarURI, LoadState exp) throws IOException {
+ public synchronized static boolean checkClasses(final URI jarURI, final LoadState exp) throws IOException {
checkInitialized();
if(null == jarURI) {
throw new IllegalArgumentException("jarURI is null");
@@ -198,7 +198,7 @@ public class TempJarCache {
return testLoadState(classFileJars.get(jarURI), exp);
}
- public synchronized static boolean checkResources(URI jarURI, LoadState exp) throws IOException {
+ public synchronized static boolean checkResources(final URI jarURI, final LoadState exp) throws IOException {
checkInitialized();
if(null == jarURI) {
throw new IllegalArgumentException("jarURI is null");
@@ -218,7 +218,7 @@ public class TempJarCache {
* @throws URISyntaxException
* @throws IllegalArgumentException
*/
- public synchronized static final boolean addNativeLibs(Class<?> certClass, URI jarURI, String nativeLibraryPath) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
+ public synchronized static final boolean addNativeLibs(final Class<?> certClass, final URI jarURI, final String nativeLibraryPath) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
checkInitialized();
final LoadState nativeLibJarsLS = nativeLibJars.get(jarURI);
if( !testLoadState(nativeLibJarsLS, LoadState.LOOKED_UP) ) {
@@ -253,7 +253,7 @@ public class TempJarCache {
* @throws URISyntaxException
* @throws IllegalArgumentException
*/
- public synchronized static final void addClasses(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
+ public synchronized static final void addClasses(final Class<?> certClass, final URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
checkInitialized();
final LoadState classFileJarsLS = classFileJars.get(jarURI);
if( !testLoadState(classFileJarsLS, LoadState.LOOKED_UP) ) {
@@ -282,7 +282,7 @@ public class TempJarCache {
* @throws URISyntaxException
* @throws IllegalArgumentException
*/
- public synchronized static final void addResources(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
+ public synchronized static final void addResources(final Class<?> certClass, final URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
checkInitialized();
final LoadState resourceFileJarsLS = resourceFileJars.get(jarURI);
if( !testLoadState(resourceFileJarsLS, LoadState.LOOKED_UP) ) {
@@ -314,7 +314,7 @@ public class TempJarCache {
* @throws URISyntaxException
* @throws IllegalArgumentException
*/
- public synchronized static final void addAll(Class<?> certClass, URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
+ public synchronized static final void addAll(final Class<?> certClass, final URI jarURI) throws IOException, SecurityException, IllegalArgumentException, URISyntaxException {
checkInitialized();
if(null == jarURI) {
throw new IllegalArgumentException("jarURI is null");
@@ -366,7 +366,7 @@ public class TempJarCache {
}
}
- public synchronized static final String findLibrary(String libName) {
+ public synchronized static final String findLibrary(final String libName) {
checkInitialized();
// try with mapped library basename first
String path = nativeLibMap.get(libName);
@@ -398,7 +398,7 @@ public class TempJarCache {
} */
/** Similar to {@link ClassLoader#getResource(String)}. */
- public synchronized static final String findResource(String name) {
+ public synchronized static final String findResource(final String name) {
checkInitialized();
final File f = new File(tmpFileCache.getTempDir(), name);
if(f.exists()) {
@@ -408,7 +408,7 @@ public class TempJarCache {
}
/** Similar to {@link ClassLoader#getResource(String)}. */
- public synchronized static final URI getResource(String name) throws URISyntaxException {
+ public synchronized static final URI getResource(final String name) throws URISyntaxException {
checkInitialized();
final File f = new File(tmpFileCache.getTempDir(), name);
if(f.exists()) {
@@ -417,7 +417,7 @@ public class TempJarCache {
return null;
}
- private static void validateCertificates(Class<?> certClass, JarFile jarFile) throws IOException, SecurityException {
+ private static void validateCertificates(final Class<?> certClass, final JarFile jarFile) throws IOException, SecurityException {
if(null == certClass) {
throw new IllegalArgumentException("certClass is null");
}