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/com/jogamp/common/util | |
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/com/jogamp/common/util')
27 files changed, 405 insertions, 403 deletions
diff --git a/src/java/com/jogamp/common/util/ArrayHashSet.java b/src/java/com/jogamp/common/util/ArrayHashSet.java index a125580..34e84c4 100644 --- a/src/java/com/jogamp/common/util/ArrayHashSet.java +++ b/src/java/com/jogamp/common/util/ArrayHashSet.java @@ -76,12 +76,12 @@ public class ArrayHashSet<E> data = new ArrayList<E>(); } - public ArrayHashSet(int initialCapacity) { + public ArrayHashSet(final int initialCapacity) { map = new HashMap<E,E>(initialCapacity); data = new ArrayList<E>(initialCapacity); } - public ArrayHashSet(int initialCapacity, float loadFactor) { + public ArrayHashSet(final int initialCapacity, final float loadFactor) { map = new HashMap<E,E>(initialCapacity, loadFactor); data = new ArrayList<E>(initialCapacity); } @@ -130,7 +130,7 @@ public class ArrayHashSet<E> * otherwise false (already contained). */ @Override - public final boolean add(E element) { + public final boolean add(final E element) { final boolean exists = map.containsKey(element); if(!exists) { if(null != map.put(element, element)) { @@ -153,7 +153,7 @@ public class ArrayHashSet<E> * otherwise false (not contained). */ @Override - public final boolean remove(Object element) { + public final boolean remove(final Object element) { if ( null != map.remove(element) ) { if ( ! data.remove(element) ) { throw new InternalError("Couldn't remove prev mapped element: "+element); @@ -172,9 +172,9 @@ public class ArrayHashSet<E> * otherwise false (completely container). */ @Override - public final boolean addAll(Collection<? extends E> c) { + public final boolean addAll(final Collection<? extends E> c) { boolean mod = false; - for (E o : c) { + for (final E o : c) { mod |= add(o); } return mod; @@ -189,7 +189,7 @@ public class ArrayHashSet<E> * otherwise false. */ @Override - public final boolean contains(Object element) { + public final boolean contains(final Object element) { return map.containsKey(element); } @@ -202,8 +202,8 @@ public class ArrayHashSet<E> * otherwise false. */ @Override - public final boolean containsAll(Collection<?> c) { - for (Object o : c) { + public final boolean containsAll(final Collection<?> c) { + for (final Object o : c) { if (!this.contains(o)) { return false; } @@ -220,9 +220,9 @@ public class ArrayHashSet<E> * otherwise false. */ @Override - public final boolean removeAll(Collection<?> c) { + public final boolean removeAll(final Collection<?> c) { boolean mod = false; - for (Object o : c) { + for (final Object o : c) { mod |= this.remove(o); } return mod; @@ -238,9 +238,9 @@ public class ArrayHashSet<E> * otherwise false. */ @Override - public final boolean retainAll(Collection<?> c) { + public final boolean retainAll(final Collection<?> c) { boolean mod = false; - for (Object o : c) { + for (final Object o : c) { if (!c.contains(o)) { mod |= this.remove(o); } @@ -255,7 +255,7 @@ public class ArrayHashSet<E> * Performance: arrayHashSet(1) */ @Override - public final boolean equals(Object arrayHashSet) { + public final boolean equals(final Object arrayHashSet) { if ( !(arrayHashSet instanceof ArrayHashSet) ) { return false; } @@ -294,7 +294,7 @@ public class ArrayHashSet<E> } @Override - public final <T> T[] toArray(T[] a) { + public final <T> T[] toArray(final T[] a) { return data.toArray(a); } @@ -303,12 +303,12 @@ public class ArrayHashSet<E> // @Override - public final E get(int index) { + public final E get(final int index) { return data.get(index); } @Override - public final int indexOf(Object element) { + public final int indexOf(final Object element) { return data.indexOf(element); } @@ -320,7 +320,7 @@ public class ArrayHashSet<E> * @throws IllegalArgumentException if the given element was already contained */ @Override - public final void add(int index, E element) { + public final void add(final int index, final E element) { if ( map.containsKey(element) ) { throw new IllegalArgumentException("Element "+element+" is already contained"); } @@ -334,7 +334,7 @@ public class ArrayHashSet<E> * @throws UnsupportedOperationException */ @Override - public final boolean addAll(int index, Collection<? extends E> c) { + public final boolean addAll(final int index, final Collection<? extends E> c) { throw new UnsupportedOperationException("Not supported yet."); } @@ -342,7 +342,7 @@ public class ArrayHashSet<E> * @throws UnsupportedOperationException */ @Override - public final E set(int index, E element) { + public final E set(final int index, final E element) { final E old = remove(index); if(null!=old) { add(index, element); @@ -358,7 +358,7 @@ public class ArrayHashSet<E> * @return the removed object */ @Override - public final E remove(int index) { + public final E remove(final int index) { final E o = get(index); if( null!=o && remove(o) ) { return o; @@ -374,7 +374,7 @@ public class ArrayHashSet<E> * @return index of element, or -1 if not found */ @Override - public final int lastIndexOf(Object o) { + public final int lastIndexOf(final Object o) { return indexOf(o); } @@ -384,12 +384,12 @@ public class ArrayHashSet<E> } @Override - public final ListIterator<E> listIterator(int index) { + public final ListIterator<E> listIterator(final int index) { return data.listIterator(index); } @Override - public final List<E> subList(int fromIndex, int toIndex) { + public final List<E> subList(final int fromIndex, final int toIndex) { return data.subList(fromIndex, toIndex); } @@ -413,7 +413,7 @@ public class ArrayHashSet<E> * @return object from this list, identical to the given <code>key</code> hash code, * or null if not contained */ - public final E get(Object key) { + public final E get(final Object key) { return map.get(key); } @@ -427,7 +427,7 @@ public class ArrayHashSet<E> * @return object from this list, identical to the given <code>key</code> hash code, * or add the given <code>key</code> and return it. */ - public final E getOrAdd(E key) { + public final E getOrAdd(final E key) { final E identity = get(key); if(null == identity) { // object not contained yet, add it @@ -451,7 +451,7 @@ public class ArrayHashSet<E> * @return true if the given element is contained by this list using slow equals operation, * otherwise false. */ - public final boolean containsSafe(Object element) { + public final boolean containsSafe(final Object element) { return data.contains(element); } diff --git a/src/java/com/jogamp/common/util/Bitstream.java b/src/java/com/jogamp/common/util/Bitstream.java index 393108b..7d9c4fd 100644 --- a/src/java/com/jogamp/common/util/Bitstream.java +++ b/src/java/com/jogamp/common/util/Bitstream.java @@ -595,7 +595,7 @@ public class Bitstream<T> { * Default behavior for I/O methods is not to throw an {@link IOException}, but to return {@link #EOS}. * </p> */ - public final void setThrowIOExceptionOnEOF(boolean enable) { + public final void setThrowIOExceptionOnEOF(final boolean enable) { throwIOExceptionOnEOF = enable; } diff --git a/src/java/com/jogamp/common/util/FloatStack.java b/src/java/com/jogamp/common/util/FloatStack.java index 8cb2e5b..b9be29c 100644 --- a/src/java/com/jogamp/common/util/FloatStack.java +++ b/src/java/com/jogamp/common/util/FloatStack.java @@ -50,7 +50,7 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { * @param growSize grow size if {@link #position()} is reached, maybe <code>0</code> * in which case an {@link IndexOutOfBoundsException} is thrown. */ - public /*name*/FloatStack/*name*/(int initialSize, int growSize) { + public /*name*/FloatStack/*name*/(final int initialSize, final int growSize) { this.position = 0; this.growSize = growSize; this.buffer = new /*value*/float/*value*/[initialSize]; @@ -63,7 +63,7 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { public final int position() { return position; } @Override - public final void position(int newPosition) throws IndexOutOfBoundsException { + public final void position(final int newPosition) throws IndexOutOfBoundsException { if( 0 > position || position >= buffer.length ) { throw new IndexOutOfBoundsException("Invalid new position "+newPosition+", "+this.toString()); } @@ -77,7 +77,7 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { public final int getGrowSize() { return growSize; } @Override - public final void setGrowSize(int newGrowSize) { growSize = newGrowSize; } + public final void setGrowSize(final int newGrowSize) { growSize = newGrowSize; } @Override public final String toString() { @@ -86,12 +86,12 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { public final /*value*/float/*value*/[] buffer() { return buffer; } - private final void growIfNecessary(int length) throws IndexOutOfBoundsException { + private final void growIfNecessary(final int length) throws IndexOutOfBoundsException { if( position + length > buffer.length ) { if( 0 >= growSize ) { throw new IndexOutOfBoundsException("Out of fixed stack size: "+this); } - /*value*/float/*value*/[] newBuffer = + final /*value*/float/*value*/[] newBuffer = new /*value*/float/*value*/[buffer.length + growSize]; System.arraycopy(buffer, 0, newBuffer, 0, position); buffer = newBuffer; @@ -108,7 +108,7 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { * @throws IndexOutOfBoundsException if stack cannot grow due to zero grow-size or offset+length exceeds src. */ public final /*value*/float/*value*/[] - putOnTop(/*value*/float/*value*/[] src, int srcOffset, int length) throws IndexOutOfBoundsException { + putOnTop(final /*value*/float/*value*/[] src, final int srcOffset, final int length) throws IndexOutOfBoundsException { growIfNecessary(length); System.arraycopy(src, srcOffset, buffer, position, length); position += length; @@ -125,7 +125,7 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { * @throws BufferUnderflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>. */ public final /*value2*/FloatBuffer/*value2*/ - putOnTop(/*value2*/FloatBuffer/*value2*/ src, int length) throws IndexOutOfBoundsException, BufferUnderflowException { + putOnTop(final /*value2*/FloatBuffer/*value2*/ src, final int length) throws IndexOutOfBoundsException, BufferUnderflowException { growIfNecessary(length); src.get(buffer, position, length); position += length; @@ -142,7 +142,7 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { * @throws IndexOutOfBoundsException if stack or <code>dest</code> has less elements than <code>length</code>. */ public final /*value*/float/*value*/[] - getFromTop(/*value*/float/*value*/[] dest, int destOffset, int length) throws IndexOutOfBoundsException { + getFromTop(final /*value*/float/*value*/[] dest, final int destOffset, final int length) throws IndexOutOfBoundsException { System.arraycopy(buffer, position-length, dest, destOffset, length); position -= length; return dest; @@ -158,7 +158,7 @@ public class /*name*/FloatStack/*name*/ implements PrimitiveStack { * @throws BufferOverflowException if <code>src</code> FloatBuffer has less remaining elements than <code>length</code>. */ public final /*value2*/FloatBuffer/*value2*/ - getFromTop(/*value2*/FloatBuffer/*value2*/ dest, int length) throws IndexOutOfBoundsException, BufferOverflowException { + getFromTop(final /*value2*/FloatBuffer/*value2*/ dest, final int length) throws IndexOutOfBoundsException, BufferOverflowException { dest.put(buffer, position-length, length); position -= length; return dest; diff --git a/src/java/com/jogamp/common/util/FunctionTask.java b/src/java/com/jogamp/common/util/FunctionTask.java index b742d73..4ac64d3 100644 --- a/src/java/com/jogamp/common/util/FunctionTask.java +++ b/src/java/com/jogamp/common/util/FunctionTask.java @@ -46,7 +46,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { * @param args the {@link Function} arguments * @return the {@link Function} return value */ - public static <U,V> U invoke(boolean waitUntilDone, Function<U,V> func, V... args) { + public static <U,V> U invoke(final boolean waitUntilDone, final Function<U,V> func, final V... args) { Throwable throwable = null; final Object sync = new Object(); final FunctionTask<U,V> rt = new FunctionTask<U,V>( func, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); @@ -56,7 +56,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { if( waitUntilDone ) { try { sync.wait(); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { throwable = ie; } if(null==throwable) { @@ -82,7 +82,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { * otherwise the exception is thrown. * @param exceptionOut If not <code>null</code>, exceptions are written to this {@link PrintStream}. */ - public FunctionTask(Function<R,A> runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut) { + public FunctionTask(final Function<R,A> runnable, final Object syncObject, final boolean catchExceptions, final PrintStream exceptionOut) { super(syncObject, catchExceptions, exceptionOut); this.runnable = runnable ; result = null; @@ -98,7 +98,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { * Sets the arguments for {@link #run()}. * They will be cleared after calling {@link #run()} or {@link #eval(Object...)}. */ - public final void setArgs(A... args) { + public final void setArgs(final A... args) { this.args = args; } @@ -132,7 +132,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { if(null == syncObject) { try { this.result = runnable.eval(args); - } catch (Throwable t) { + } catch (final Throwable t) { runnableException = t; if(null != exceptionOut) { exceptionOut.println("FunctionTask.run(): "+getExceptionOutIntro()+" exception occured on thread "+Thread.currentThread().getName()+": "+toString()); @@ -149,7 +149,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { synchronized (syncObject) { try { this.result = runnable.eval(args); - } catch (Throwable t) { + } catch (final Throwable t) { runnableException = t; if(null != exceptionOut) { exceptionOut.println("FunctionTask.run(): "+getExceptionOutIntro()+" exception occured on thread "+Thread.currentThread().getName()+": "+toString()); @@ -168,7 +168,7 @@ public class FunctionTask<R,A> extends TaskBase implements Function<R,A> { } @Override - public final R eval(A... args) { + public final R eval(final A... args) { this.args = args; run(); final R res = result; diff --git a/src/java/com/jogamp/common/util/HashUtil.java b/src/java/com/jogamp/common/util/HashUtil.java index 5ce2332..b567bca 100644 --- a/src/java/com/jogamp/common/util/HashUtil.java +++ b/src/java/com/jogamp/common/util/HashUtil.java @@ -32,10 +32,10 @@ public class HashUtil { * Generates a 32bit equally distributed identity hash value * from <code>addr</code> avoiding XOR collision. */ - public static int getAddrHash32_EqualDist(long addr) { + public static int getAddrHash32_EqualDist(final long addr) { // avoid xor collisions of low/high parts // 31 * x == (x << 5) - x - int hash = 31 + (int) addr ; // lo addr + final int hash = 31 + (int) addr ; // lo addr return ((hash << 5) - hash) + (int) ( addr >>> 32 ) ; // hi addr } @@ -43,7 +43,7 @@ public class HashUtil { * Generates a 32bit equally distributed identity hash value * from <code>addr</code> and <code>size</code> avoiding XOR collision. */ - public static int getAddrSizeHash32_EqualDist(long addr, long size) { + public static int getAddrSizeHash32_EqualDist(final long addr, final long size) { // avoid xor collisions of low/high parts // 31 * x == (x << 5) - x int hash = 31 + (int) addr ; // lo addr @@ -56,7 +56,7 @@ public class HashUtil { * Generates a 64bit equally distributed hash value * from <code>addr</code> and <code>size</code> avoiding XOR collisions. */ - public static long getHash64(long addr, long size) { + public static long getHash64(final long addr, final long size) { // 31 * x == (x << 5) - x final long hash = 31 + addr; return ((hash << 5) - hash) + size; diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index c70fa92..3b145af 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -98,7 +98,7 @@ public class IOUtil { try { _fosCtor = ReflectionUtil.getConstructor("java.io.FileOutputStream", new Class<?>[] { File.class }, true, IOUtil.class.getClassLoader()); _t = null; - } catch (Throwable t) { + } catch (final Throwable t) { _fosCtor = null; _t = t; } @@ -126,11 +126,11 @@ public class IOUtil { * @return * @throws IOException */ - public static int copyURLConn2File(URLConnection conn, File outFile) throws IOException { + public static int copyURLConn2File(final URLConnection conn, final File outFile) throws IOException { conn.connect(); // redundant int totalNumBytes = 0; - InputStream in = new BufferedInputStream(conn.getInputStream()); + final InputStream in = new BufferedInputStream(conn.getInputStream()); try { totalNumBytes = copyStream2File(in, outFile, conn.getContentLength()); } finally { @@ -149,8 +149,8 @@ public class IOUtil { * @return * @throws IOException */ - public static int copyStream2File(InputStream in, File outFile, int totalNumBytes) throws IOException { - OutputStream out = new BufferedOutputStream(new FileOutputStream(outFile)); + public static int copyStream2File(final InputStream in, final File outFile, int totalNumBytes) throws IOException { + final OutputStream out = new BufferedOutputStream(new FileOutputStream(outFile)); try { totalNumBytes = copyStream2Stream(in, out, totalNumBytes); } finally { @@ -169,7 +169,7 @@ public class IOUtil { * @return * @throws IOException */ - public static int copyStream2Stream(InputStream in, OutputStream out, int totalNumBytes) throws IOException { + public static int copyStream2Stream(final InputStream in, final OutputStream out, final int totalNumBytes) throws IOException { return copyStream2Stream(Platform.getMachineDescription().pageSizeInBytes(), in, out, totalNumBytes); } @@ -184,7 +184,7 @@ public class IOUtil { * @return * @throws IOException */ - public static int copyStream2Stream(int bufferSize, InputStream in, OutputStream out, int totalNumBytes) throws IOException { + public static int copyStream2Stream(final int bufferSize, final InputStream in, final OutputStream out, final int totalNumBytes) throws IOException { final byte[] buf = new byte[bufferSize]; int numBytes = 0; while (true) { @@ -238,7 +238,7 @@ public class IOUtil { * * @param stream input stream, which will be wrapped into a BufferedInputStream, if not already done. */ - public static ByteBuffer copyStream2ByteBuffer(InputStream stream) throws IOException { + public static ByteBuffer copyStream2ByteBuffer(final InputStream stream) throws IOException { return copyStream2ByteBuffer(stream, -1); } @@ -259,7 +259,7 @@ public class IOUtil { } final MachineDescription machine = Platform.getMachineDescription(); ByteBuffer data = Buffers.newDirectByteBuffer( machine.pageAlignedSize( initialCapacity ) ); - byte[] chunk = new byte[machine.pageSizeInBytes()]; + final byte[] chunk = new byte[machine.pageSizeInBytes()]; int chunk2Read = Math.min(machine.pageSizeInBytes(), avail); int numRead = 0; do { @@ -296,7 +296,7 @@ public class IOUtil { * @return * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> */ - public static String slashify(String path, boolean startWithSlash, boolean endWithSlash) throws URISyntaxException { + public static String slashify(final String path, final boolean startWithSlash, final boolean endWithSlash) throws URISyntaxException { String p = path.replace('\\', '/'); // unify file separator if (startWithSlash && !p.startsWith("/")) { p = "/" + p; @@ -312,7 +312,7 @@ public class IOUtil { * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI */ - public static URI toURISimple(File file) throws URISyntaxException { + public static URI toURISimple(final File file) throws URISyntaxException { return new URI(FILE_SCHEME, null, slashify(file.getAbsolutePath(), true /* startWithSlash */, file.isDirectory() /* endWithSlash */), null); } @@ -321,7 +321,7 @@ public class IOUtil { * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> * @throws URISyntaxException if the resulting string does not comply w/ an RFC 2396 URI */ - public static URI toURISimple(String protocol, String path, boolean isDirectory) throws URISyntaxException { + public static URI toURISimple(final String protocol, final String path, final boolean isDirectory) throws URISyntaxException { return new URI(protocol, null, slashify(new File(path).getAbsolutePath(), true /* startWithSlash */, isDirectory /* endWithSlash */), null); } @@ -336,7 +336,7 @@ public class IOUtil { * @throws NullPointerException if file is null */ - public static String getFileSuffix(File file) { + public static String getFileSuffix(final File file) { return getFileSuffix(file.getName()); } @@ -350,14 +350,14 @@ public class IOUtil { * @return lowercase suffix of the file name * @throws NullPointerException if filename is null */ - public static String getFileSuffix(String filename) { - int lastDot = filename.lastIndexOf('.'); + public static String getFileSuffix(final String filename) { + final int lastDot = filename.lastIndexOf('.'); if (lastDot < 0) { return null; } return toLowerCase(filename.substring(lastDot + 1)); } - private static String toLowerCase(String arg) { + private static String toLowerCase(final String arg) { if (arg == null) { return null; } @@ -373,7 +373,7 @@ public class IOUtil { * the class {@link java.io.FileOutputStream} is not accessible or * the user does not have sufficient rights to access the local filesystem. */ - public static FileOutputStream getFileOutputStream(File file, boolean allowOverwrite) throws IOException { + public static FileOutputStream getFileOutputStream(final File file, final boolean allowOverwrite) throws IOException { final Constructor<?> fosCtor = getFOSCtor(); if(null == fosCtor) { throw new IOException("Cannot open file (" + file + ") for writing, FileOutputStream feature not available."); @@ -383,12 +383,12 @@ public class IOUtil { } try { return (FileOutputStream) fosCtor.newInstance(new Object[] { file }); - } catch (Exception e) { + } catch (final Exception e) { throw new IOException("error opening " + file + " for write. ", e); } } - public static String getClassFileName(String clazzBinName) { + public static String getClassFileName(final String clazzBinName) { // or return clazzBinName.replace('.', File.separatorChar) + ".class"; ? return clazzBinName.replace('.', '/') + ".class"; } @@ -399,7 +399,7 @@ public class IOUtil { * @return jar:file:/usr/local/projects/JOGL/gluegen/build-x86_64/gluegen-rt.jar!/com/jogamp/common/util/cache/TempJarCache.class * @throws IOException if the jar file could not been found by the ClassLoader */ - public static URL getClassURL(String clazzBinName, ClassLoader cl) throws IOException { + public static URL getClassURL(final String clazzBinName, final ClassLoader cl) throws IOException { final URL url = cl.getResource(getClassFileName(clazzBinName)); if(null == url) { throw new IOException("Cannot not find: "+clazzBinName); @@ -413,7 +413,7 @@ public class IOUtil { */ public static String getBasename(String fname) throws URISyntaxException { fname = slashify(fname, false /* startWithSlash */, false /* endWithSlash */); - int lios = fname.lastIndexOf('/'); // strip off dirname + final int lios = fname.lastIndexOf('/'); // strip off dirname if(lios>=0) { fname = fname.substring(lios+1); } @@ -426,7 +426,7 @@ public class IOUtil { */ public static String getDirname(String fname) throws URISyntaxException { fname = slashify(fname, false /* startWithSlash */, false /* endWithSlash */); - int lios = fname.lastIndexOf('/'); // strip off dirname + final int lios = fname.lastIndexOf('/'); // strip off dirname if(lios>=0) { fname = fname.substring(0, lios+1); } @@ -445,11 +445,11 @@ public class IOUtil { * @throws IllegalArgumentException if the URI doesn't match the expected formatting, or is null * @throws URISyntaxException */ - public static URI getURIDirname(URI uri) throws IllegalArgumentException, URISyntaxException { + public static URI getURIDirname(final URI uri) throws IllegalArgumentException, URISyntaxException { if(null == uri) { throw new IllegalArgumentException("URI is null"); } - String uriS = uri.toString(); + final String uriS = uri.toString(); if( DEBUG ) { System.err.println("getURIDirname "+uri+", extForm: "+uriS); } @@ -556,7 +556,7 @@ public class IOUtil { File f; try { f = new File( decodeFromURI( specificURI.getPath() ) ); // validates uri, uses decoded uri.getPath() and normalizes it - } catch(Exception iae) { + } catch(final Exception iae) { if( DEBUG ) { System.err.println("Caught "+iae.getClass().getSimpleName()+": new File("+decodeFromURI( specificURI.getPath() )+") failed: "+iae.getMessage()); iae.printStackTrace(); @@ -584,7 +584,7 @@ public class IOUtil { final URL fUrl = fUri.toURL(); System.err.println("IOUtil.toURL.1b: fUri "+fUri+PlatformPropsImpl.NEWLINE+ "\t, fUrl "+fUrl); - } catch (Exception ee) { + } catch (final Exception ee) { System.err.println("Caught "+ee.getClass().getSimpleName()+": f.toURI().toURL() failed: "+ee.getMessage()); ee.printStackTrace(); } @@ -612,7 +612,7 @@ public class IOUtil { url = new URL(urlS); mode = 2; } - } catch (Exception mue) { + } catch (final Exception mue) { if( DEBUG ) { System.err.println("Caught "+mue.getClass().getSimpleName()+": new URL("+urlS+") failed: "+mue.getMessage()); mue.printStackTrace(); @@ -624,7 +624,7 @@ public class IOUtil { try { url = uri.toURL(); mode = 3; - } catch (Exception e) { + } catch (final Exception e) { if( DEBUG ) { System.err.println("Caught "+e.getClass().getSimpleName()+": "+uri+".toURL() failed: "+e.getMessage()); e.printStackTrace(); @@ -662,7 +662,7 @@ public class IOUtil { * @param contextCL class instance to {@link #resolve(int)} {@link #resourcePaths}. * @param resourcePaths array of strings denominating multiple resource paths. None shall be null. */ - public ClassResources(Class<?> contextCL, String[] resourcePaths) { + public ClassResources(final Class<?> contextCL, final String[] resourcePaths) { for(int i=resourcePaths.length-1; i>=0; i--) { if( null == resourcePaths[i] ) { throw new IllegalArgumentException("resourcePath["+i+"] is null"); @@ -676,7 +676,7 @@ public class IOUtil { * Resolving one of the {@link #resourcePaths} indexed by <code>uriIndex</code> using {@link #contextCL} and {@link IOUtil#getResource(Class, String)}. * @throws ArrayIndexOutOfBoundsException if <code>uriIndex</code> is < 0 or >= {@link #resourceCount()}. */ - public URLConnection resolve(int uriIndex) throws ArrayIndexOutOfBoundsException { + public URLConnection resolve(final int uriIndex) throws ArrayIndexOutOfBoundsException { return getResource(contextCL, resourcePaths[uriIndex]); } } @@ -698,11 +698,11 @@ public class IOUtil { * @see ClassLoader#getResource(String) * @see ClassLoader#getSystemResource(String) */ - public static URLConnection getResource(Class<?> context, String resourcePath) { + public static URLConnection getResource(final Class<?> context, final String resourcePath) { if(null == resourcePath) { return null; } - ClassLoader contextCL = (null!=context)?context.getClassLoader():IOUtil.class.getClassLoader(); + final ClassLoader contextCL = (null!=context)?context.getClassLoader():IOUtil.class.getClassLoader(); URLConnection conn = null; if(null != context) { // scoping the path within the class's package @@ -738,7 +738,7 @@ public class IOUtil { * @see URL#URL(String) * @see File#File(String) */ - public static URLConnection getResource(String resourcePath, ClassLoader cl) { + public static URLConnection getResource(final String resourcePath, final ClassLoader cl) { if(null == resourcePath) { return null; } @@ -748,7 +748,7 @@ public class IOUtil { if(resourcePath.startsWith(AssetURLContext.asset_protocol_prefix)) { try { return AssetURLContext.createURL(resourcePath, cl).openConnection(); - } catch (IOException ioe) { + } catch (final IOException ioe) { if(DEBUG) { System.err.println("IOUtil: Caught Exception:"); ioe.printStackTrace(); @@ -758,7 +758,7 @@ public class IOUtil { } else { try { return AssetURLContext.resolve(resourcePath, cl); - } catch (IOException ioe) { + } catch (final IOException ioe) { if(DEBUG) { System.err.println("IOUtil: Caught Exception:"); ioe.printStackTrace(); @@ -775,7 +775,7 @@ public class IOUtil { * @param relativeFile denotes a relative file to the baseLocation * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> */ - public static String getRelativeOf(File baseLocation, String relativeFile) throws URISyntaxException { + public static String getRelativeOf(final File baseLocation, final String relativeFile) throws URISyntaxException { if(null == relativeFile) { return null; } @@ -793,7 +793,7 @@ public class IOUtil { * @return parent of path * @throws URISyntaxException if path is empty or has no parent directory available */ - public static String getParentOf(String path) throws URISyntaxException { + public static String getParentOf(final String path) throws URISyntaxException { final int pl = null!=path ? path.length() : 0; if(pl == 0) { throw new IllegalArgumentException("path is empty <"+path+">"); @@ -850,7 +850,7 @@ public class IOUtil { * @param relativePath denotes a relative file to the baseLocation's parent directory * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> */ - public static URI getRelativeOf(URI baseURI, String relativePath) throws URISyntaxException { + public static URI getRelativeOf(final URI baseURI, final String relativePath) throws URISyntaxException { return compose(baseURI.getScheme(), baseURI.getSchemeSpecificPart(), relativePath, baseURI.getFragment()); } @@ -858,10 +858,10 @@ public class IOUtil { * Wraps {@link #getRelativeOf(URI, String)} for convenience. * @throws IOException */ - public static URL getRelativeOf(URL baseURL, String relativePath) throws IOException { + public static URL getRelativeOf(final URL baseURL, final String relativePath) throws IOException { try { return getRelativeOf(baseURL.toURI(), relativePath).toURL(); - } catch (URISyntaxException e) { + } catch (final URISyntaxException e) { throw new IOException(e); } } @@ -883,7 +883,7 @@ public class IOUtil { * @throws URISyntaxException if path is empty or has no parent directory available while resolving <code>../</code> * @see #encodeToURI(String) */ - public static URI compose(String scheme, String schemeSpecificPart, String relativePath, String fragment) throws URISyntaxException { + public static URI compose(final String scheme, String schemeSpecificPart, final String relativePath, final String fragment) throws URISyntaxException { // cut off optional query in scheme-specific-part final String query; final int queryI = schemeSpecificPart.lastIndexOf('?'); @@ -912,7 +912,7 @@ public class IOUtil { * <li>SPACE -> %20</li> * </ul> */ - public static String encodeToURI(String s) { + public static String encodeToURI(final String s) { return patternSpaceRaw.matcher(s).replaceAll("%20"); } @@ -922,7 +922,7 @@ public class IOUtil { * <li>%20 -> SPACE</li> * </ul> */ - public static String decodeFromURI(String s) { + public static String decodeFromURI(final String s) { return patternSpaceEnc.matcher(s).replaceAll(" "); } @@ -1019,14 +1019,14 @@ public class IOUtil { /** * Returns the connected URLConnection, or null if not url is not available */ - public static URLConnection openURL(URL url) { + public static URLConnection openURL(final URL url) { return openURL(url, "."); } /** * Returns the connected URLConnection, or null if not url is not available */ - public static URLConnection openURL(URL url, String dbgmsg) { + public static URLConnection openURL(final URL url, final String dbgmsg) { if(null!=url) { try { final URLConnection c = url.openConnection(); @@ -1035,7 +1035,7 @@ public class IOUtil { System.err.println("IOUtil: urlExists("+url+") ["+dbgmsg+"] - true"); } return c; - } catch (IOException ioe) { + } catch (final IOException ioe) { if(DEBUG) { System.err.println("IOUtil: urlExists("+url+") ["+dbgmsg+"] - false - "+ioe.getClass().getSimpleName()+": "+ioe.getMessage()); ioe.printStackTrace(); @@ -1092,7 +1092,7 @@ public class IOUtil { * @param shallBeWritable * @return */ - public static boolean testFile(File file, boolean shallBeDir, boolean shallBeWritable) { + public static boolean testFile(final File file, final boolean shallBeDir, final boolean shallBeWritable) { if (!file.exists()) { if(DEBUG) { System.err.println("IOUtil.testFile: <"+file.getAbsolutePath()+">: does not exist"); @@ -1126,7 +1126,7 @@ public class IOUtil { * @throws SecurityException if file creation and process execution is not allowed within the current security context * @param dir */ - public static boolean testDirExec(File dir) + public static boolean testDirExec(final File dir) throws SecurityException { if (!testFile(dir, true, true)) { @@ -1145,9 +1145,9 @@ public class IOUtil { File exetst; try { exetst = File.createTempFile("jogamp_exe_tst", getShellSuffix(), dir); - } catch (SecurityException se) { + } catch (final SecurityException se) { throw se; // fwd Security exception - } catch (IOException e) { + } catch (final IOException e) { if(DEBUG) { e.printStackTrace(); } @@ -1156,12 +1156,12 @@ public class IOUtil { int res = -1; if(exetst.setExecutable(true /* exec */, true /* ownerOnly */)) { try { - Process pr = Runtime.getRuntime().exec(exetst.getCanonicalPath()); + final Process pr = Runtime.getRuntime().exec(exetst.getCanonicalPath()); pr.waitFor() ; res = pr.exitValue(); - } catch (SecurityException se) { + } catch (final SecurityException se) { throw se; // fwd Security exception - } catch (Throwable t) { + } catch (final Throwable t) { res = -2; if(DEBUG) { System.err.println("IOUtil.testDirExec: <"+exetst.getAbsolutePath()+">: Caught "+t.getClass().getSimpleName()+": "+t.getMessage()); @@ -1176,7 +1176,7 @@ public class IOUtil { return 0 == res; } - private static File testDirImpl(File dir, boolean create, boolean executable, String dbgMsg) + private static File testDirImpl(final File dir, final boolean create, final boolean executable, final String dbgMsg) throws SecurityException { final File res; @@ -1214,7 +1214,7 @@ public class IOUtil { return testDirImpl(dir, create, executable, "testDir"); } - private static boolean isStringSet(String s) { return null != s && 0 < s.length(); } + private static boolean isStringSet(final String s) { return null != s && 0 < s.length(); } /** * This methods finds [and creates] an available temporary sub-directory: @@ -1240,7 +1240,7 @@ public class IOUtil { * @return a temporary directory, writable by this user * @throws SecurityException */ - private static File getSubTempDir(File tmpRoot, String tmpSubDirPrefix, boolean executable, String dbgMsg) + private static File getSubTempDir(final File tmpRoot, final String tmpSubDirPrefix, final boolean executable, final String dbgMsg) throws SecurityException { File tmpBaseDir = null; @@ -1411,17 +1411,17 @@ public class IOUtil { * @throws IOException * @throws SecurityException */ - public static File createTempFile(String prefix, String suffix, boolean executable) + public static File createTempFile(final String prefix, final String suffix, final boolean executable) throws IllegalArgumentException, IOException, SecurityException { return File.createTempFile( prefix, suffix, getTempDir(executable) ); } - public static void close(Closeable stream, boolean throwRuntimeException) throws RuntimeException { + public static void close(final Closeable stream, final boolean throwRuntimeException) throws RuntimeException { if(null != stream) { try { stream.close(); - } catch (IOException e) { + } catch (final IOException e) { if(throwRuntimeException) { throw new RuntimeException(e); } else if(DEBUG) { diff --git a/src/java/com/jogamp/common/util/IntBitfield.java b/src/java/com/jogamp/common/util/IntBitfield.java index 2d2f1ef..74e37ac 100644 --- a/src/java/com/jogamp/common/util/IntBitfield.java +++ b/src/java/com/jogamp/common/util/IntBitfield.java @@ -50,7 +50,7 @@ public class IntBitfield { /** * @param bitCount */ - public IntBitfield(long bitCount) { + public IntBitfield(final long bitCount) { final int units = (int) Math.max(1L, ( bitCount + 7L ) >>> UNIT_SHIFT_L); this.storage = new int[units]; this.bitsCountL = (long)units << UNIT_SHIFT_L ; @@ -60,19 +60,19 @@ public class IntBitfield { /** * @param bitCount */ - public IntBitfield(int bitCount) { + public IntBitfield(final int bitCount) { final int units = Math.max(1, ( bitCount + 7 ) >>> UNIT_SHIFT_I); this.storage = new int[units]; this.bitsCountI = units << UNIT_SHIFT_I; this.bitsCountL = bitsCountI; } - private final void check(long bitnum) { + private final void check(final long bitnum) { if( 0 > bitnum || bitnum >= bitsCountL ) { throw new ArrayIndexOutOfBoundsException("Bitnum should be within [0.."+(bitsCountL-1)+"], but is "+bitnum); } } - private final void check(int bitnum) { + private final void check(final int bitnum) { if( 0 > bitnum || bitnum >= bitsCountI ) { throw new ArrayIndexOutOfBoundsException("Bitnum should be within [0.."+(bitsCountI-1)+"], but is "+bitnum); } @@ -82,7 +82,7 @@ public class IntBitfield { public final long capacity() { return bitsCountL; } /** Return <code>true</code> if the bit at position <code>bitnum</code> is set, otherwise <code>false</code>. */ - public final boolean get(long bitnum) { + public final boolean get(final long bitnum) { check(bitnum); final int u = (int) ( bitnum >>> UNIT_SHIFT_L ); final int b = (int) ( bitnum - ( (long)u << UNIT_SHIFT_L ) ); @@ -90,7 +90,7 @@ public class IntBitfield { } /** Return <code>true</code> if the bit at position <code>bitnum</code> is set, otherwise <code>false</code>. */ - public final boolean get(int bitnum) { + public final boolean get(final int bitnum) { check(bitnum); final int u = bitnum >>> UNIT_SHIFT_I; final int b = bitnum - ( u << UNIT_SHIFT_I ); @@ -101,7 +101,7 @@ public class IntBitfield { * Set or clear the bit at position <code>bitnum</code> according to <code>bit</code> * and return the previous value. */ - public final boolean put(long bitnum, boolean bit) { + public final boolean put(final long bitnum, final boolean bit) { check(bitnum); final int u = (int) ( bitnum >>> UNIT_SHIFT_L ); final int b = (int) ( bitnum - ( (long)u << UNIT_SHIFT_L ) ); @@ -121,7 +121,7 @@ public class IntBitfield { * Set or clear the bit at position <code>bitnum</code> according to <code>bit</code> * and return the previous value. */ - public final boolean put(int bitnum, boolean bit) { + public final boolean put(final int bitnum, final boolean bit) { check(bitnum); final int u = bitnum >>> UNIT_SHIFT_I; final int b = bitnum - ( u << UNIT_SHIFT_I ); diff --git a/src/java/com/jogamp/common/util/IntIntHashMap.java b/src/java/com/jogamp/common/util/IntIntHashMap.java index ef6159b..4cb2329 100644 --- a/src/java/com/jogamp/common/util/IntIntHashMap.java +++ b/src/java/com/jogamp/common/util/IntIntHashMap.java @@ -88,13 +88,13 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, @Override @SuppressWarnings("unchecked") public EntryCM run() { - EntryCM r = new EntryCM(); + final EntryCM r = new EntryCM(); r.c = (Constructor<Entry>) ReflectionUtil.getConstructor(Entry.class, new Class[] { keyClazz, valueClazz, Entry.class } ); try { r.m1 = valueClazz.getDeclaredMethod("equals", Object.class); - } catch (NoSuchMethodException ex) { + } catch (final NoSuchMethodException ex) { throw new JogampRuntimeException("Class "+valueClazz+" doesn't support equals(Object)"); } return r; @@ -111,11 +111,11 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, this(16, 0.75f); } - public /*name*/IntIntHashMap/*name*/(int initialCapacity) { + public /*name*/IntIntHashMap/*name*/(final int initialCapacity) { this(initialCapacity, 0.75f); } - public /*name*/IntIntHashMap/*name*/(int initialCapacity, float loadFactor) { + public /*name*/IntIntHashMap/*name*/(final int initialCapacity, final float loadFactor) { if (initialCapacity > 1 << 30) { throw new IllegalArgumentException("initialCapacity is too large."); } @@ -135,9 +135,9 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, this.mask = capacity - 1; } - private /*name*/IntIntHashMap/*name*/(float loadFactor, int table_size, int size, - int mask, int capacity, int threshold, - /*value*/int/*value*/ keyNotFoundValue) { + private /*name*/IntIntHashMap/*name*/(final float loadFactor, final int table_size, final int size, + final int mask, final int capacity, final int threshold, + final /*value*/int/*value*/ keyNotFoundValue) { this.loadFactor = loadFactor; this.table = new Entry[table_size]; this.size = size; @@ -157,7 +157,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, */ @Override public Object clone() { - /*name*/IntIntHashMap/*name*/ n = + final /*name*/IntIntHashMap/*name*/ n = new /*name*/IntIntHashMap/*name*/(loadFactor, table.length, size, mask, capacity, threshold, keyNotFoundValue); @@ -187,8 +187,8 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, return n; } - public boolean containsValue(/*value*/int/*value*/ value) { - Entry[] t = this.table; + public boolean containsValue(final /*value*/int/*value*/ value) { + final Entry[] t = this.table; for (int i = t.length; i-- > 0;) { for (Entry e = t[i]; e != null; e = e.next) { if( isPrimitive ) { @@ -207,7 +207,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, } // @SuppressWarnings(value="cast") - public boolean containsKey(/*key*/int/*key*/ key) { + public boolean containsKey(final /*key*/int/*key*/ key) { final Entry[] t = this.table; final int index = /*keyHash*/key/*keyHash*/ & mask; for (Entry e = t[index]; e != null; e = e.next) { @@ -223,7 +223,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, * or {@link #getKeyNotFoundValue} if this map contains no mapping for the key. */ // @SuppressWarnings(value="cast") - public /*value*/int/*value*/ get(/*key*/int/*key*/ key) { + public /*value*/int/*value*/ get(final /*key*/int/*key*/ key) { final Entry[] t = this.table; final int index = /*keyHash*/key/*keyHash*/ & mask; for (Entry e = t[index]; e != null; e = e.next) { @@ -239,7 +239,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, * the previous value will be returned (otherwise {@link #getKeyNotFoundValue}). */ // @SuppressWarnings(value="cast") - public /*value*/int/*value*/ put(/*key*/int/*key*/ key, /*value*/int/*value*/ value) { + public /*value*/int/*value*/ put(final /*key*/int/*key*/ key, final /*value*/int/*value*/ value) { final Entry[] t = this.table; final int index = /*keyHash*/key/*keyHash*/ & mask; // Check if key already exists. @@ -247,7 +247,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, if (e.key != key) { continue; } - /*value*/int/*value*/ oldValue = e.value; + final /*value*/int/*value*/ oldValue = e.value; e.value = value; return oldValue; } @@ -263,7 +263,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, if (e != null) { t[j] = null; do { - Entry next = e.next; + final Entry next = e.next; final int index2 = /*keyHash*/e.key/*keyHash*/ & newMask; e.next = newTable[index2]; newTable[index2] = e; @@ -282,7 +282,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, /** * Copies all of the mappings from the specified map to this map. */ - public void putAll(/*name*/IntIntHashMap/*name*/ source) { + public void putAll(final /*name*/IntIntHashMap/*name*/ source) { final Iterator<Entry> itr = source.iterator(); while(itr.hasNext()) { final Entry e = itr.next(); @@ -295,14 +295,14 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, * Returns the previously mapped value or {@link #getKeyNotFoundValue} if no such mapping exists. */ // @SuppressWarnings(value="cast") - public /*value*/int/*value*/ remove(/*key*/int/*key*/ key) { + public /*value*/int/*value*/ remove(final /*key*/int/*key*/ key) { final Entry[] t = this.table; final int index = /*keyHash*/key/*keyHash*/ & mask; Entry prev = t[index]; Entry e = prev; while (e != null) { - Entry next = e.next; + final Entry next = e.next; if (e.key == key) { size--; if (prev == e) { @@ -358,8 +358,8 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, * @see #get * @see #put */ - public /*value*/int/*value*/ setKeyNotFoundValue(/*value*/int/*value*/ newKeyNotFoundValue) { - /*value*/int/*value*/ t = keyNotFoundValue; + public /*value*/int/*value*/ setKeyNotFoundValue(final /*value*/int/*value*/ newKeyNotFoundValue) { + final /*value*/int/*value*/ t = keyNotFoundValue; keyNotFoundValue = newKeyNotFoundValue; return t; } @@ -382,7 +382,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, sb = new StringBuilder(); } sb.append("{"); - Iterator<Entry> itr = iterator(); + final Iterator<Entry> itr = iterator(); while(itr.hasNext()) { itr.next().toString(sb); if(itr.hasNext()) { @@ -405,7 +405,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, private int index; private Entry next; - private EntryIterator(Entry[] entries){ + private EntryIterator(final Entry[] entries){ this.entries = entries; // load next next(); @@ -424,7 +424,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, next = current.next; }else{ while(index < entries.length) { - Entry e = entries[index++]; + final Entry e = entries[index++]; if(e != null) { next = e; return current; @@ -453,7 +453,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, private Entry next; - Entry(/*key*/int/*key*/ k, /*value*/int/*value*/ v, Entry n) { + Entry(final /*key*/int/*key*/ k, final /*value*/int/*value*/ v, final Entry n) { key = k; value = v; next = n; @@ -476,7 +476,7 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, /** * Sets the value for this entry. */ - public void setValue(/*value*/int/*value*/ value) { + public void setValue(final /*value*/int/*value*/ value) { this.value = value; } @@ -499,14 +499,14 @@ public class /*name*/IntIntHashMap/*name*/ implements Cloneable, } - private static Method getCloneMethod(Object obj) { + private static Method getCloneMethod(final Object obj) { final Class<?> clazz = obj.getClass(); return AccessController.doPrivileged(new PrivilegedAction<Method>() { @Override public Method run() { try { return clazz.getDeclaredMethod("clone"); - } catch (NoSuchMethodException ex) { + } catch (final NoSuchMethodException ex) { throw new JogampRuntimeException("Class "+clazz+" doesn't support clone()", ex); } } } ); diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java index 77f1a84..eeee82a 100644 --- a/src/java/com/jogamp/common/util/JarUtil.java +++ b/src/java/com/jogamp/common/util/JarUtil.java @@ -83,7 +83,7 @@ public class JarUtil { * @throws SecurityException if the security manager doesn't have the setFactory * permission */ - public static void setResolver(Resolver r) throws IllegalArgumentException, IllegalStateException, SecurityException { + public static void setResolver(final Resolver r) throws IllegalArgumentException, IllegalStateException, SecurityException { if(r == null) { throw new IllegalArgumentException("Null Resolver passed"); } @@ -113,10 +113,10 @@ public class JarUtil { * @return true if the class is loaded from a Jar file, otherwise false. * @see {@link #getJarURI(String, ClassLoader)} */ - public static boolean hasJarURI(String clazzBinName, ClassLoader cl) { + public static boolean hasJarURI(final String clazzBinName, final ClassLoader cl) { try { return null != getJarURI(clazzBinName, cl); - } catch (Exception e) { /* ignore */ } + } catch (final Exception e) { /* ignore */ } return false; } @@ -136,7 +136,7 @@ public class JarUtil { * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ - public static URI getJarURI(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { + public static URI getJarURI(final String clazzBinName, final ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { if(null == clazzBinName || null == cl) { throw new IllegalArgumentException("null arguments: clazzBinName "+clazzBinName+", cl "+cl); } @@ -187,7 +187,7 @@ public class JarUtil { * @throws IllegalArgumentException if the URI doesn't match the expected formatting or is null * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ - public static String getJarBasename(URI classJarURI) throws IllegalArgumentException { + public static String getJarBasename(final URI classJarURI) throws IllegalArgumentException { if(null == classJarURI) { throw new IllegalArgumentException("URI is null"); } @@ -246,7 +246,7 @@ public class JarUtil { * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ - public static String getJarBasename(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { + public static String getJarBasename(final String clazzBinName, final ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { return getJarBasename( getJarURI(clazzBinName, cl) ); } @@ -264,7 +264,7 @@ public class JarUtil { * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ - public static URI getJarSubURI(URI classJarURI) throws IllegalArgumentException, URISyntaxException { + public static URI getJarSubURI(final URI classJarURI) throws IllegalArgumentException, URISyntaxException { if(null == classJarURI) { throw new IllegalArgumentException("URI is null"); } @@ -277,7 +277,7 @@ public class JarUtil { // to // file:/some/path/gluegen-rt.jar final String uriS0 = classJarURI.getSchemeSpecificPart(); - int idx = uriS0.lastIndexOf(IOUtil.JAR_SCHEME_SEPARATOR); + final int idx = uriS0.lastIndexOf(IOUtil.JAR_SCHEME_SEPARATOR); final String uriS1; if (0 <= idx) { uriS1 = uriS0.substring(0, idx); // exclude '!/' @@ -303,7 +303,7 @@ public class JarUtil { * @return <code>/com/jogamp/common/GlueGenVersion.class</code> * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ - public static String getJarEntry(URI classJarURI) { + public static String getJarEntry(final URI classJarURI) { if(null == classJarURI) { throw new IllegalArgumentException("URI is null"); } @@ -345,7 +345,7 @@ public class JarUtil { * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ - public static URI getJarSubURI(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { + public static URI getJarSubURI(final String clazzBinName, final ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { return getJarSubURI( getJarURI(clazzBinName, cl) ); } @@ -365,7 +365,7 @@ public class JarUtil { * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link IOUtil#getClassURL(String, ClassLoader)} */ - public static URI getJarFileURI(String clazzBinName, ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { + public static URI getJarFileURI(final String clazzBinName, final ClassLoader cl) throws IllegalArgumentException, IOException, URISyntaxException { if(null == clazzBinName || null == cl) { throw new IllegalArgumentException("null arguments: clazzBinName "+clazzBinName+", cl "+cl); } @@ -383,7 +383,7 @@ public class JarUtil { * @throws URISyntaxException * @throws IllegalArgumentException null arguments */ - public static URI getJarFileURI(URI baseUri, String jarFileName) throws IllegalArgumentException, URISyntaxException { + public static URI getJarFileURI(final URI baseUri, final String jarFileName) throws IllegalArgumentException, URISyntaxException { if(null == baseUri || null == jarFileName) { throw new IllegalArgumentException("null arguments: baseURI "+baseUri+", jarFileName "+jarFileName); } @@ -396,7 +396,7 @@ public class JarUtil { * @throws IllegalArgumentException null arguments * @throws URISyntaxException */ - public static URI getJarFileURI(URI jarSubUri) throws IllegalArgumentException, URISyntaxException { + public static URI getJarFileURI(final URI jarSubUri) throws IllegalArgumentException, URISyntaxException { if(null == jarSubUri) { throw new IllegalArgumentException("jarSubURI is null"); } @@ -409,7 +409,7 @@ public class JarUtil { * @throws IllegalArgumentException null arguments * @throws URISyntaxException */ - public static URI getJarFileURI(String jarSubUriS) throws IllegalArgumentException, URISyntaxException { + public static URI getJarFileURI(final String jarSubUriS) throws IllegalArgumentException, URISyntaxException { if(null == jarSubUriS) { throw new IllegalArgumentException("jarSubURIS is null"); } @@ -423,7 +423,7 @@ public class JarUtil { * @throws IllegalArgumentException null arguments * @throws URISyntaxException */ - public static URI getJarEntryURI(URI jarFileURI, String jarEntry) throws IllegalArgumentException, URISyntaxException { + public static URI getJarEntryURI(final URI jarFileURI, final String jarEntry) throws IllegalArgumentException, URISyntaxException { if(null == jarEntry) { throw new IllegalArgumentException("jarEntry is null"); } @@ -439,7 +439,7 @@ public class JarUtil { * @throws URISyntaxException if the URI could not be translated into a RFC 2396 URI * @see {@link #getJarFileURI(String, ClassLoader)} */ - public static JarFile getJarFile(String clazzBinName, ClassLoader cl) throws IOException, IllegalArgumentException, URISyntaxException { + public static JarFile getJarFile(final String clazzBinName, final ClassLoader cl) throws IOException, IllegalArgumentException, URISyntaxException { return getJarFile( getJarFileURI(clazzBinName, cl) ); } @@ -450,7 +450,7 @@ public class JarUtil { * @throws IOException if the Jar file could not been found * @throws URISyntaxException */ - public static JarFile getJarFile(URI jarFileURI) throws IOException, IllegalArgumentException, URISyntaxException { + public static JarFile getJarFile(final URI jarFileURI) throws IOException, IllegalArgumentException, URISyntaxException { if(null == jarFileURI) { throw new IllegalArgumentException("null jarFileURI"); } @@ -464,8 +464,8 @@ public class JarUtil { // final URL jarFileURL = jarFileURI.toURL(); // doesn't work due to encoded path even w/ file schema! final URLConnection urlc = jarFileURL.openConnection(); if(urlc instanceof JarURLConnection) { - JarURLConnection jarConnection = (JarURLConnection)jarFileURL.openConnection(); - JarFile jarFile = jarConnection.getJarFile(); + final JarURLConnection jarConnection = (JarURLConnection)jarFileURL.openConnection(); + final JarFile jarFile = jarConnection.getJarFile(); if(DEBUG) { System.err.println("getJarFile res: "+jarFile.getName()); } @@ -509,7 +509,7 @@ public class JarUtil { * @throws IOException * @throws URISyntaxException */ - public static URI getRelativeOf(Class<?> classFromJavaJar, String cutOffInclSubDir, String relResPath) throws IllegalArgumentException, IOException, URISyntaxException { + public static URI getRelativeOf(final Class<?> classFromJavaJar, final String cutOffInclSubDir, final String relResPath) throws IllegalArgumentException, IOException, URISyntaxException { final ClassLoader cl = classFromJavaJar.getClassLoader(); final URI classJarURI = JarUtil.getJarURI(classFromJavaJar.getName(), cl); if( DEBUG ) { @@ -546,7 +546,7 @@ public class JarUtil { /** * Return a map from native-lib-base-name to entry-name. */ - public static Map<String, String> getNativeLibNames(JarFile jarFile) { + public static Map<String, String> getNativeLibNames(final JarFile jarFile) { if (DEBUG) { System.err.println("JarUtil: getNativeLibNames: "+jarFile); } @@ -602,11 +602,11 @@ public class JarUtil { * @return * @throws IOException */ - public static final int extract(File dest, Map<String, String> nativeLibMap, - JarFile jarFile, - String nativeLibraryPath, - boolean extractNativeLibraries, - boolean extractClassFiles, boolean extractOtherFiles) throws IOException { + public static final int extract(final File dest, final Map<String, String> nativeLibMap, + final JarFile jarFile, + final String nativeLibraryPath, + final boolean extractNativeLibraries, + final boolean extractClassFiles, final boolean extractOtherFiles) throws IOException { if (DEBUG) { System.err.println("JarUtil: extract: "+jarFile.getName()+" -> "+dest+ @@ -616,10 +616,10 @@ public class JarUtil { } int num = 0; - Enumeration<JarEntry> entries = jarFile.entries(); + final Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { - JarEntry entry = entries.nextElement(); - String entryName = entry.getName(); + final JarEntry entry = entries.nextElement(); + final String entryName = entry.getName(); // Match entries with correct prefix and suffix (ignoring case) final String libBaseName = NativeLibrary.isValidNativeLibraryName(entryName, false); @@ -637,7 +637,7 @@ public class JarUtil { try { nativeLibraryPathS = IOUtil.slashify(nativeLibraryPath, false /* startWithSlash */, true /* endWithSlash */); dirnameS = IOUtil.getDirname(entryName); - } catch (URISyntaxException e) { + } catch (final URISyntaxException e) { throw new IOException(e); } if( !nativeLibraryPathS.equals(dirnameS) ) { @@ -721,7 +721,7 @@ public class JarUtil { * <li>Bug 865: Safari >= 6.1 [OSX]: May employ xattr on 'com.apple.quarantine' on 'PluginProcess.app'</li> * </ul> */ - private final static void fixNativeLibAttribs(File file) { + private final static void fixNativeLibAttribs(final File file) { // We tolerate UnsatisfiedLinkError (and derived) to solve the chicken and egg problem // of loading gluegen's native library. // On Safari(OSX), Bug 865, we simply hope the destination folder is executable. @@ -732,7 +732,7 @@ public class JarUtil { if( DEBUG ) { System.err.println("JarUtil.fixNativeLibAttribs: "+fileAbsPath+" - OK"); } - } catch (Throwable t) { + } catch (final Throwable t) { if( DEBUG ) { System.err.println("JarUtil.fixNativeLibAttribs: "+fileAbsPath+" - "+t.getClass().getSimpleName()+": "+t.getMessage()); } @@ -749,7 +749,7 @@ public class JarUtil { getCodeSource().getCertificates(); </pre> */ - public static final void validateCertificates(Certificate[] rootCerts, JarFile jarFile) + public static final void validateCertificates(final Certificate[] rootCerts, final JarFile jarFile) throws IOException, SecurityException { if (DEBUG) { @@ -760,8 +760,8 @@ public class JarUtil { throw new IllegalArgumentException("Null certificates passed"); } - byte[] buf = new byte[1024]; - Enumeration<JarEntry> entries = jarFile.entries(); + final byte[] buf = new byte[1024]; + final Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { final JarEntry entry = entries.nextElement(); if( ! entry.isDirectory() && ! entry.getName().startsWith("META-INF/") ) { @@ -775,8 +775,8 @@ public class JarUtil { * Check the certificates with the ones in the jar file * (all must match). */ - private static final void validateCertificate(Certificate[] rootCerts, - JarFile jar, JarEntry entry, byte[] buf) throws IOException, SecurityException { + private static final void validateCertificate(final Certificate[] rootCerts, + final JarFile jar, final JarEntry entry, final byte[] buf) throws IOException, SecurityException { if (DEBUG) { System.err.println("JarUtil: validate JarEntry : " + entry.getName()); @@ -785,7 +785,7 @@ public class JarUtil { // API states that we must read all of the data from the entry's // InputStream in order to be able to get its certificates - InputStream is = jar.getInputStream(entry); + final InputStream is = jar.getInputStream(entry); try { while (is.read(buf) > 0) { } } finally { diff --git a/src/java/com/jogamp/common/util/JogampVersion.java b/src/java/com/jogamp/common/util/JogampVersion.java index 2789de7..2ff7d81 100644 --- a/src/java/com/jogamp/common/util/JogampVersion.java +++ b/src/java/com/jogamp/common/util/JogampVersion.java @@ -47,15 +47,15 @@ public class JogampVersion { /** See {@link #getImplementationCommit()} */ public static final Attributes.Name IMPLEMENTATION_COMMIT = new Attributes.Name("Implementation-Commit"); - private String packageName; - private Manifest mf; - private int hash; - private Attributes mainAttributes; - private Set<?>/*<Attributes.Name>*/ mainAttributeNames; + private final String packageName; + private final Manifest mf; + private final int hash; + private final Attributes mainAttributes; + private final Set<?>/*<Attributes.Name>*/ mainAttributeNames; private final String androidPackageVersionName; - protected JogampVersion(String packageName, Manifest mf) { + protected JogampVersion(final String packageName, final Manifest mf) { this.packageName = packageName; this.mf = ( null != mf ) ? mf : new Manifest(); this.hash = this.mf.hashCode(); @@ -70,7 +70,7 @@ public class JogampVersion { } @Override - public final boolean equals(Object o) { + public final boolean equals(final Object o) { if (o instanceof JogampVersion) { return mf.equals(((JogampVersion) o).getManifest()); } @@ -85,17 +85,17 @@ public class JogampVersion { return packageName; } - public final String getAttribute(Attributes.Name attributeName) { + public final String getAttribute(final Attributes.Name attributeName) { return (null != attributeName) ? (String) mainAttributes.get(attributeName) : null; } - public final String getAttribute(String attributeName) { + public final String getAttribute(final String attributeName) { return getAttribute(getAttributeName(attributeName)); } - public final Attributes.Name getAttributeName(String attributeName) { - for (Iterator<?> iter = mainAttributeNames.iterator(); iter.hasNext();) { - Attributes.Name an = (Attributes.Name) iter.next(); + public final Attributes.Name getAttributeName(final String attributeName) { + for (final Iterator<?> iter = mainAttributeNames.iterator(); iter.hasNext();) { + final Attributes.Name an = (Attributes.Name) iter.next(); if (an.toString().equals(attributeName)) { return an; } @@ -121,21 +121,21 @@ public class JogampVersion { * Returns the implementation build number, e.g. <code>2.0-b456-20130328</code>. */ public final String getImplementationBuild() { - return this.getAttribute(GlueGenVersion.IMPLEMENTATION_BUILD); + return this.getAttribute(JogampVersion.IMPLEMENTATION_BUILD); } /** * Returns the SCM branch name */ public final String getImplementationBranch() { - return this.getAttribute(GlueGenVersion.IMPLEMENTATION_BRANCH); + return this.getAttribute(JogampVersion.IMPLEMENTATION_BRANCH); } /** * Returns the SCM version of the last commit, e.g. git's sha1 */ public final String getImplementationCommit() { - return this.getAttribute(GlueGenVersion.IMPLEMENTATION_COMMIT); + return this.getAttribute(JogampVersion.IMPLEMENTATION_COMMIT); } public final String getImplementationTitle() { @@ -181,7 +181,7 @@ public class JogampVersion { return this.getAttribute(Attributes.Name.SPECIFICATION_VERSION); } - public final StringBuilder getFullManifestInfo(StringBuilder sb) { + public final StringBuilder getFullManifestInfo(final StringBuilder sb) { return VersionUtil.getFullManifestInfo(getManifest(), sb); } @@ -189,7 +189,7 @@ public class JogampVersion { if(null==sb) { sb = new StringBuilder(); } - String nl = Platform.getNewline(); + final String nl = Platform.getNewline(); sb.append("Package: ").append(getPackageName()).append(nl); sb.append("Extension Name: ").append(getExtensionName()).append(nl); sb.append("Specification Title: ").append(getSpecificationTitle()).append(nl); diff --git a/src/java/com/jogamp/common/util/LFRingbuffer.java b/src/java/com/jogamp/common/util/LFRingbuffer.java index a0418c5..685c529 100644 --- a/src/java/com/jogamp/common/util/LFRingbuffer.java +++ b/src/java/com/jogamp/common/util/LFRingbuffer.java @@ -87,7 +87,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } @Override - public final void dump(PrintStream stream, String prefix) { + public final void dump(final PrintStream stream, final String prefix) { stream.println(prefix+" "+toString()+" {"); for(int i=0; i<capacityPlusOne; i++) { stream.println("\t["+i+"]: "+array[i]); @@ -116,7 +116,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code> */ @SuppressWarnings("unchecked") - public LFRingbuffer(T[] copyFrom) throws IllegalArgumentException { + public LFRingbuffer(final T[] copyFrom) throws IllegalArgumentException { capacityPlusOne = copyFrom.length + 1; array = (T[]) newArray(copyFrom.getClass(), capacityPlusOne); resetImpl(true, copyFrom); @@ -139,9 +139,9 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { * @param arrayType the array type of the created empty internal array. * @param capacity the initial net capacity of the ring buffer */ - public LFRingbuffer(Class<? extends T[]> arrayType, int capacity) { + public LFRingbuffer(final Class<? extends T[]> arrayType, final int capacity) { capacityPlusOne = capacity+1; - array = (T[]) newArray(arrayType, capacityPlusOne); + array = newArray(arrayType, capacityPlusOne); resetImpl(false, null /* empty, nothing to copy */ ); } @@ -162,11 +162,11 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } @Override - public final void resetFull(T[] copyFrom) throws IllegalArgumentException { + public final void resetFull(final T[] copyFrom) throws IllegalArgumentException { resetImpl(true, copyFrom); } - private final void resetImpl(boolean full, T[] copyFrom) throws IllegalArgumentException { + private final void resetImpl(final boolean full, final T[] copyFrom) throws IllegalArgumentException { synchronized ( syncGlobal ) { if( null != copyFrom ) { if( copyFrom.length != capacityPlusOne-1 ) { @@ -210,7 +210,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { public final T get() { try { return getImpl(false, false); - } catch (InterruptedException ie) { throw new RuntimeException(ie); } + } catch (final InterruptedException ie) { throw new RuntimeException(ie); } } /** @@ -228,14 +228,14 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { public final T peek() { try { return getImpl(false, true); - } catch (InterruptedException ie) { throw new RuntimeException(ie); } + } catch (final InterruptedException ie) { throw new RuntimeException(ie); } } @Override public final T peekBlocking() throws InterruptedException { return getImpl(true, true); } - private final T getImpl(boolean blocking, boolean peek) throws InterruptedException { + private final T getImpl(final boolean blocking, final boolean peek) throws InterruptedException { int localReadPos = readPos; if( localReadPos == writePos ) { if( blocking ) { @@ -268,10 +268,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { * </p> */ @Override - public final boolean put(T e) { + public final boolean put(final T e) { try { return putImpl(e, false, false); - } catch (InterruptedException ie) { throw new RuntimeException(ie); } + } catch (final InterruptedException ie) { throw new RuntimeException(ie); } } /** @@ -281,7 +281,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { * </p> */ @Override - public final void putBlocking(T e) throws InterruptedException { + public final void putBlocking(final T e) throws InterruptedException { if( !putImpl(e, false, true) ) { throw new InternalError("Blocking put failed: "+this); } @@ -294,11 +294,11 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { * </p> */ @Override - public final boolean putSame(boolean blocking) throws InterruptedException { + public final boolean putSame(final boolean blocking) throws InterruptedException { return putImpl(null, true, blocking); } - private final boolean putImpl(T e, boolean sameRef, boolean blocking) throws InterruptedException { + private final boolean putImpl(final T e, final boolean sameRef, final boolean blocking) throws InterruptedException { int localWritePos = writePos; localWritePos = (localWritePos + 1) % capacityPlusOne; if( localWritePos == readPos ) { @@ -325,7 +325,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { @Override - public final void waitForFreeSlots(int count) throws InterruptedException { + public final void waitForFreeSlots(final int count) throws InterruptedException { synchronized ( syncRead ) { if( capacityPlusOne - 1 - size < count ) { while( capacityPlusOne - 1 - size < count ) { @@ -361,7 +361,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { final int growAmount = newElements.length; final int newCapacity = capacityPlusOne + growAmount; final T[] oldArray = array; - final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity); + final T[] newArray = newArray(arrayTypeInternal, newCapacity); // writePos == readPos writePos += growAmount; // warp writePos to the end of the new data location @@ -401,7 +401,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { final int newCapacity = capacityPlusOne + growAmount; final T[] oldArray = array; - final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity); + final T[] newArray = newArray(arrayTypeInternal, newCapacity); // writePos == readPos - 1 readPos = ( writePos + 1 + growAmount ) % newCapacity; // warp readPos to the end of the new data location @@ -420,7 +420,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> { } @SuppressWarnings("unchecked") - private static <T> T[] newArray(Class<? extends T[]> arrayType, int length) { + private static <T> T[] newArray(final Class<? extends T[]> arrayType, final int length) { return ((Object)arrayType == (Object)Object[].class) ? (T[]) new Object[length] : (T[]) Array.newInstance(arrayType.getComponentType(), length); diff --git a/src/java/com/jogamp/common/util/PropertyAccess.java b/src/java/com/jogamp/common/util/PropertyAccess.java index a2e3690..b6e9bdd 100644 --- a/src/java/com/jogamp/common/util/PropertyAccess.java +++ b/src/java/com/jogamp/common/util/PropertyAccess.java @@ -59,12 +59,12 @@ public class PropertyAccess { * @param prefix New prefix to be registered as trusted. * @throws AccessControlException as thrown by {@link SecurityUtil#checkAllPermissions()}. */ - protected static final void addTrustedPrefix(String prefix) throws AccessControlException { + protected static final void addTrustedPrefix(final String prefix) throws AccessControlException { SecurityUtil.checkAllPermissions(); trustedPrefixes.add(prefix); } - public static final boolean isTrusted(String propertyKey) { + public static final boolean isTrusted(final String propertyKey) { final int dot1 = propertyKey.indexOf('.'); if(0<=dot1) { return trustedPrefixes.contains(propertyKey.substring(0, dot1+1)) || trusted.contains(propertyKey); @@ -74,26 +74,26 @@ public class PropertyAccess { } /** @see #getProperty(String, boolean) */ - public static final int getIntProperty(final String property, final boolean jnlpAlias, int defaultValue) { + public static final int getIntProperty(final String property, final boolean jnlpAlias, final int defaultValue) { int i=defaultValue; try { final String sv = PropertyAccess.getProperty(property, jnlpAlias); if(null!=sv) { i = Integer.parseInt(sv); } - } catch (NumberFormatException nfe) {} + } catch (final NumberFormatException nfe) {} return i; } /** @see #getProperty(String, boolean) */ - public static final long getLongProperty(final String property, final boolean jnlpAlias, long defaultValue) { + public static final long getLongProperty(final String property, final boolean jnlpAlias, final long defaultValue) { long l=defaultValue; try { final String sv = PropertyAccess.getProperty(property, jnlpAlias); if(null!=sv) { l = Long.parseLong(sv); } - } catch (NumberFormatException nfe) {} + } catch (final NumberFormatException nfe) {} return l; } @@ -103,7 +103,7 @@ public class PropertyAccess { } /** @see #getProperty(String, boolean) */ - public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias, boolean defaultValue) { + public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias, final boolean defaultValue) { final String valueS = PropertyAccess.getProperty(property, jnlpAlias); if(null != valueS) { return Boolean.valueOf(valueS).booleanValue(); @@ -164,7 +164,7 @@ public class PropertyAccess { } /** See {@link #getProperty(String, boolean)}, additionally allows a <code>defaultValue</code> if property value is <code>null</code>. */ - public static final String getProperty(final String propertyKey, final boolean jnlpAlias, String defaultValue) + public static final String getProperty(final String propertyKey, final boolean jnlpAlias, final String defaultValue) throws SecurityException, NullPointerException, IllegalArgumentException { final String s = PropertyAccess.getProperty(propertyKey, jnlpAlias); if( null != s ) { @@ -180,7 +180,7 @@ public class PropertyAccess { public String run() { try { return System.getProperty(propertyKey); - } catch (SecurityException se) { + } catch (final SecurityException se) { throw new SecurityException("Could not access trusted property '"+propertyKey+"'", se); } } diff --git a/src/java/com/jogamp/common/util/ReflectionUtil.java b/src/java/com/jogamp/common/util/ReflectionUtil.java index 949df1d..7117f56 100644 --- a/src/java/com/jogamp/common/util/ReflectionUtil.java +++ b/src/java/com/jogamp/common/util/ReflectionUtil.java @@ -63,7 +63,7 @@ public final class ReflectionUtil { static { Debug.initSingleton(); DEBUG = Debug.debug("ReflectionUtil"); - DEBUG_STATS_FORNAME = Debug.isPropertyDefined("jogamp.debug.ReflectionUtil.forNameStats", true); + DEBUG_STATS_FORNAME = PropertyAccess.isPropertyDefined("jogamp.debug.ReflectionUtil.forNameStats", true); if(DEBUG_STATS_FORNAME) { forNameLock = new Object(); forNameStats = new HashMap<String, ClassNameLookup>(); @@ -81,7 +81,7 @@ public final class ReflectionUtil { private static final Class<?>[] zeroTypes = new Class[0]; private static class ClassNameLookup { - public ClassNameLookup(String name) { + public ClassNameLookup(final String name) { this.name = name; this.nanoCosts = 0; this.count = 0; @@ -111,7 +111,7 @@ public final class ReflectionUtil { sb.append(String.format("ReflectionUtil.forName: %8.3f ms, %03d invoc%n", forNameNanoCosts/1e6, forNameCount)); final Set<Entry<String, ClassNameLookup>> entries = forNameStats.entrySet(); int entryNum = 0; - for(Iterator<Entry<String, ClassNameLookup>> iter = entries.iterator(); iter.hasNext(); entryNum++) { + for(final Iterator<Entry<String, ClassNameLookup>> iter = entries.iterator(); iter.hasNext(); entryNum++) { final Entry<String, ClassNameLookup> entry = iter.next(); sb.append(String.format("ReflectionUtil.forName[%03d]: %s%n", entryNum, entry.getValue())); } @@ -120,7 +120,7 @@ public final class ReflectionUtil { return sb; } - private static Class<?> getClassImpl(String clazzName, boolean initializeClazz, ClassLoader cl) throws ClassNotFoundException { + private static Class<?> getClassImpl(final String clazzName, final boolean initializeClazz, final ClassLoader cl) throws ClassNotFoundException { if(DEBUG_STATS_FORNAME) { final long t0 = System.nanoTime(); final Class<?> res = Class.forName(clazzName, initializeClazz, cl); @@ -151,10 +151,10 @@ public final class ReflectionUtil { /** * Returns true only if the class could be loaded. */ - public static final boolean isClassAvailable(String clazzName, ClassLoader cl) { + public static final boolean isClassAvailable(final String clazzName, final ClassLoader cl) { try { return null != getClassImpl(clazzName, false, cl); - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { return false; } } @@ -163,11 +163,11 @@ public final class ReflectionUtil { * Loads and returns the class or null. * @see Class#forName(java.lang.String, boolean, java.lang.ClassLoader) */ - public static final Class<?> getClass(String clazzName, boolean initializeClazz, ClassLoader cl) + public static final Class<?> getClass(final String clazzName, final boolean initializeClazz, final ClassLoader cl) throws JogampRuntimeException { try { return getClassImpl(clazzName, initializeClazz, cl); - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { throw new JogampRuntimeException(clazzName + " not available", e); } } @@ -176,17 +176,17 @@ public final class ReflectionUtil { * @param initializeClazz TODO * @throws JogampRuntimeException if the constructor can not be delivered. */ - public static final Constructor<?> getConstructor(String clazzName, Class<?>[] cstrArgTypes, boolean initializeClazz, ClassLoader cl) + public static final Constructor<?> getConstructor(final String clazzName, final Class<?>[] cstrArgTypes, final boolean initializeClazz, final ClassLoader cl) throws JogampRuntimeException { try { return getConstructor(getClassImpl(clazzName, initializeClazz, cl), cstrArgTypes); - } catch (ClassNotFoundException ex) { + } catch (final ClassNotFoundException ex) { throw new JogampRuntimeException(clazzName + " not available", ex); } } - static final String asString(Class<?>[] argTypes) { - StringBuilder args = new StringBuilder(); + 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++) { @@ -213,7 +213,7 @@ public final class ReflectionUtil { * * @throws JogampRuntimeException if the constructor can not be delivered. */ - public static final Constructor<?> getConstructor(Class<?> clazz, Class<?> ... cstrArgTypes) + public static final Constructor<?> getConstructor(final Class<?> clazz, Class<?> ... cstrArgTypes) throws JogampRuntimeException { if(null == cstrArgTypes) { cstrArgTypes = zeroTypes; @@ -221,7 +221,7 @@ public final class ReflectionUtil { Constructor<?> cstr = null; try { cstr = clazz.getDeclaredConstructor(cstrArgTypes); - } catch (NoSuchMethodException ex) { + } catch (final NoSuchMethodException ex) { // ok, cont. w/ 'isAssignableFrom()' validation } if(null == cstr) { @@ -248,7 +248,7 @@ public final class ReflectionUtil { return cstr; } - public static final Constructor<?> getConstructor(String clazzName, ClassLoader cl) + public static final Constructor<?> getConstructor(final String clazzName, final ClassLoader cl) throws JogampRuntimeException { return getConstructor(clazzName, null, true, cl); } @@ -256,12 +256,12 @@ public final class ReflectionUtil { /** * @throws JogampRuntimeException if the instance can not be created. */ - public static final Object createInstance(Constructor<?> cstr, Object ... cstrArgs) + public static final Object createInstance(final Constructor<?> cstr, final Object ... cstrArgs) throws JogampRuntimeException, RuntimeException { try { return cstr.newInstance(cstrArgs); - } catch (Exception e) { + } catch (final Exception e) { Throwable t = e; if (t instanceof InvocationTargetException) { t = ((InvocationTargetException) t).getTargetException(); @@ -279,13 +279,13 @@ public final class ReflectionUtil { /** * @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 JogampRuntimeException, RuntimeException { return createInstance(getConstructor(clazz, cstrArgTypes), cstrArgs); } - public static final Object createInstance(Class<?> clazz, Object ... cstrArgs) + public static final Object createInstance(final Class<?> clazz, final Object ... cstrArgs) throws JogampRuntimeException, RuntimeException { Class<?>[] cstrArgTypes = null; @@ -298,17 +298,17 @@ public final class ReflectionUtil { return createInstance(clazz, cstrArgTypes, cstrArgs); } - public static final Object createInstance(String clazzName, Class<?>[] cstrArgTypes, Object[] cstrArgs, ClassLoader cl) + public static final Object createInstance(final String clazzName, final Class<?>[] cstrArgTypes, final Object[] cstrArgs, final ClassLoader cl) throws JogampRuntimeException, RuntimeException { try { return createInstance(getClassImpl(clazzName, true, cl), cstrArgTypes, cstrArgs); - } catch (ClassNotFoundException ex) { + } catch (final ClassNotFoundException ex) { throw new JogampRuntimeException(clazzName + " not available", ex); } } - public static final Object createInstance(String clazzName, Object[] cstrArgs, ClassLoader cl) + public static final Object createInstance(final String clazzName, final Object[] cstrArgs, final ClassLoader cl) throws JogampRuntimeException, RuntimeException { Class<?>[] cstrArgTypes = null; @@ -321,16 +321,16 @@ public final class ReflectionUtil { return createInstance(clazzName, cstrArgTypes, cstrArgs, cl); } - public static final Object createInstance(String clazzName, ClassLoader cl) + public static final Object createInstance(final String clazzName, final ClassLoader cl) throws JogampRuntimeException, RuntimeException { return createInstance(clazzName, null, null, cl); } - public static final boolean instanceOf(Object obj, String clazzName) { + public static final boolean instanceOf(final Object obj, final String clazzName) { return instanceOf(obj.getClass(), clazzName); } - public static final boolean instanceOf(Class<?> clazz, String clazzName) { + public static final boolean instanceOf(Class<?> clazz, final String clazzName) { do { if(clazz.getName().equals(clazzName)) { return true; @@ -340,14 +340,14 @@ public final class ReflectionUtil { return false; } - public static final boolean implementationOf(Object obj, String faceName) { + public static final boolean implementationOf(final Object obj, final String faceName) { return implementationOf(obj.getClass(), faceName); } - public static final boolean implementationOf(Class<?> clazz, String faceName) { + public static final boolean implementationOf(Class<?> clazz, final String faceName) { do { - Class<?>[] clazzes = clazz.getInterfaces(); + final Class<?>[] clazzes = clazz.getInterfaces(); for(int i=clazzes.length-1; i>=0; i--) { - Class<?> face = clazzes[i]; + final Class<?> face = clazzes[i]; if(face.getName().equals(faceName)) { return true; } @@ -357,27 +357,27 @@ public final class ReflectionUtil { return false; } - public static boolean isAWTComponent(Object target) { + public static boolean isAWTComponent(final Object target) { return instanceOf(target, AWTNames.ComponentClass); } - public static boolean isAWTComponent(Class<?> clazz) { + public static boolean isAWTComponent(final Class<?> clazz) { return instanceOf(clazz, AWTNames.ComponentClass); } /** * @throws JogampRuntimeException if the Method can not be found. */ - public static final Method getMethod(Class<?> clazz, String methodName, Class<?> ... argTypes) + public static final Method getMethod(final Class<?> clazz, final String methodName, final Class<?> ... argTypes) throws JogampRuntimeException, RuntimeException { Throwable t = null; Method m = null; try { m = clazz.getDeclaredMethod(methodName, argTypes); - } catch (NoClassDefFoundError ex0) { + } catch (final NoClassDefFoundError ex0) { t = ex0; - } catch (NoSuchMethodException ex1) { + } catch (final NoSuchMethodException ex1) { t = ex1; } if(null != t) { @@ -389,12 +389,12 @@ public final class ReflectionUtil { /** * @throws JogampRuntimeException if the Method can not be found. */ - public static final Method getMethod(String clazzName, String methodName, Class<?>[] argTypes, ClassLoader cl) + public static final Method getMethod(final String clazzName, final String methodName, final Class<?>[] argTypes, final ClassLoader cl) throws JogampRuntimeException, RuntimeException { try { return getMethod(getClassImpl(clazzName, true, cl), methodName, argTypes); - } catch (ClassNotFoundException ex) { + } catch (final ClassNotFoundException ex) { throw new JogampRuntimeException(clazzName + " not available", ex); } } @@ -407,12 +407,12 @@ public final class ReflectionUtil { * @throws JogampRuntimeException if call fails * @throws RuntimeException if call fails */ - public static final Object callMethod(Object instance, Method method, Object ... args) + public static final Object callMethod(final Object instance, final Method method, final Object ... args) throws JogampRuntimeException, 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(); @@ -430,7 +430,7 @@ public final class ReflectionUtil { /** * @throws JogampRuntimeException if the instance can not be created. */ - public static final Object callStaticMethod(String clazzName, String methodName, Class<?>[] argTypes, Object[] args, ClassLoader cl) + public static final Object callStaticMethod(final String clazzName, final String methodName, final Class<?>[] argTypes, final Object[] args, final ClassLoader cl) throws JogampRuntimeException, RuntimeException { return callMethod(null, getMethod(clazzName, methodName, argTypes, cl), args); @@ -441,10 +441,10 @@ public final class ReflectionUtil { Method m = null; /** Check {@link #available()} before using instance. */ - public MethodAccessor(Class<?> clazz, String methodName, Class<?> ... argTypes) { + public MethodAccessor(final Class<?> clazz, final String methodName, final Class<?> ... argTypes) { try { m = ReflectionUtil.getMethod(clazz, methodName, argTypes); - } catch (JogampRuntimeException jre) { /* method n/a */ } + } catch (final JogampRuntimeException jre) { /* method n/a */ } } /** Returns true if method is available, otherwise false. */ @@ -456,7 +456,7 @@ public final class ReflectionUtil { * Check {@link #available()} before calling to avoid throwing a JogampRuntimeException. * @throws JogampRuntimeException if method is not available */ - public Object callMethod(Object instance, Object ... args) { + public Object callMethod(final Object instance, final Object ... args) { if(null == m) { throw new JogampRuntimeException("Method not available. Instance: "+instance); } diff --git a/src/java/com/jogamp/common/util/RunnableExecutor.java b/src/java/com/jogamp/common/util/RunnableExecutor.java index 629bc8c..9358a06 100644 --- a/src/java/com/jogamp/common/util/RunnableExecutor.java +++ b/src/java/com/jogamp/common/util/RunnableExecutor.java @@ -43,7 +43,7 @@ public interface RunnableExecutor { private CurrentThreadExecutor() {} @Override - public void invoke(boolean wait, Runnable r) { + public void invoke(final boolean wait, final Runnable r) { r.run(); } } diff --git a/src/java/com/jogamp/common/util/RunnableTask.java b/src/java/com/jogamp/common/util/RunnableTask.java index 97adf04..6fb98de 100644 --- a/src/java/com/jogamp/common/util/RunnableTask.java +++ b/src/java/com/jogamp/common/util/RunnableTask.java @@ -42,7 +42,7 @@ public class RunnableTask extends TaskBase { * @param waitUntilDone if <code>true</code>, waits until <code>runnable</code> execution is completed, otherwise returns immediately. * @param runnable the {@link Runnable} to execute. */ - public static void invoke(boolean waitUntilDone, Runnable runnable) { + public static void invoke(final boolean waitUntilDone, final Runnable runnable) { Throwable throwable = null; final Object sync = new Object(); final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true, waitUntilDone ? null : System.err ); @@ -51,7 +51,7 @@ public class RunnableTask extends TaskBase { if( waitUntilDone ) { try { sync.wait(); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { throwable = ie; } if(null==throwable) { @@ -85,7 +85,7 @@ public class RunnableTask extends TaskBase { if( waitUntilDone ) { try { sync.wait(); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { throwable = ie; } if(null==throwable) { @@ -114,7 +114,7 @@ public class RunnableTask extends TaskBase { * otherwise the exception is thrown. * @param exceptionOut If not <code>null</code>, exceptions are written to this {@link PrintStream}. */ - public RunnableTask(Runnable runnable, Object syncObject, boolean catchExceptions, PrintStream exceptionOut) { + public RunnableTask(final Runnable runnable, final Object syncObject, final boolean catchExceptions, final PrintStream exceptionOut) { super(syncObject, catchExceptions, exceptionOut); this.runnable = runnable ; } @@ -131,7 +131,7 @@ public class RunnableTask extends TaskBase { if(null == syncObject) { try { runnable.run(); - } catch (Throwable t) { + } catch (final Throwable t) { runnableException = t; if(null != exceptionOut) { exceptionOut.println("RunnableTask.run(): "+getExceptionOutIntro()+" exception occured on thread "+Thread.currentThread().getName()+": "+toString()); @@ -148,7 +148,7 @@ public class RunnableTask extends TaskBase { synchronized (syncObject) { try { runnable.run(); - } catch (Throwable t) { + } catch (final Throwable t) { runnableException = t; if(null != exceptionOut) { exceptionOut.println("RunnableTask.run(): "+getExceptionOutIntro()+" exception occured on thread "+Thread.currentThread().getName()+": "+toString()); diff --git a/src/java/com/jogamp/common/util/SecurityUtil.java b/src/java/com/jogamp/common/util/SecurityUtil.java index 4586d22..1b8b7c2 100644 --- a/src/java/com/jogamp/common/util/SecurityUtil.java +++ b/src/java/com/jogamp/common/util/SecurityUtil.java @@ -56,7 +56,7 @@ public class SecurityUtil { try { insecPD.implies(allPermissions); _hasAllPermissions = true; - } catch( SecurityException ace ) { + } catch( final SecurityException ace ) { _hasAllPermissions = false; } hasAllPermissions = _hasAllPermissions; @@ -92,11 +92,11 @@ public class SecurityUtil { * or the installed {@link SecurityManager}'s <code>checkPermission(perm)</code> * passes. Otherwise method returns <code>false</code>. */ - public static final boolean hasPermission(Permission perm) { + public static final boolean hasPermission(final Permission perm) { try { checkPermission(perm); return true; - } catch( SecurityException ace ) { + } catch( final SecurityException ace ) { return false; } } @@ -113,7 +113,7 @@ public class SecurityUtil { * Throws an {@link SecurityException} if an installed {@link SecurityManager} * does not permit the requested {@link Permission}. */ - public static final void checkPermission(Permission perm) throws SecurityException { + public static final void checkPermission(final Permission perm) throws SecurityException { if( null != securityManager ) { securityManager.checkPermission(perm); } @@ -124,11 +124,11 @@ public class SecurityUtil { * or the installed {@link SecurityManager}'s <code>checkLink(libName)</code> * passes. Otherwise method returns <code>false</code>. */ - public static final boolean hasLinkPermission(String libName) { + public static final boolean hasLinkPermission(final String libName) { try { checkLinkPermission(libName); return true; - } catch( SecurityException ace ) { + } catch( final SecurityException ace ) { return false; } } @@ -137,7 +137,7 @@ public class SecurityUtil { * Throws an {@link SecurityException} if an installed {@link SecurityManager} * does not permit to dynamically link the given libName. */ - public static final void checkLinkPermission(String libName) throws SecurityException { + public static final void checkLinkPermission(final String libName) throws SecurityException { if( null != securityManager ) { securityManager.checkLink(libName); } @@ -166,7 +166,7 @@ public class SecurityUtil { return (null != certs && certs.length>0) ? certs : null; } - public static final boolean equals(Certificate[] a, Certificate[] b) { + public static final boolean equals(final Certificate[] a, final Certificate[] b) { if(a == b) { return true; } diff --git a/src/java/com/jogamp/common/util/SyncedRingbuffer.java b/src/java/com/jogamp/common/util/SyncedRingbuffer.java index 8ef2970..7f4a878 100644 --- a/src/java/com/jogamp/common/util/SyncedRingbuffer.java +++ b/src/java/com/jogamp/common/util/SyncedRingbuffer.java @@ -63,7 +63,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { } @Override - public final void dump(PrintStream stream, String prefix) { + public final void dump(final PrintStream stream, final String prefix) { stream.println(prefix+" "+toString()+" {"); for(int i=0; i<capacity; i++) { stream.println("\t["+i+"]: "+array[i]); @@ -92,7 +92,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { * @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code> */ @SuppressWarnings("unchecked") - public SyncedRingbuffer(T[] copyFrom) throws IllegalArgumentException { + public SyncedRingbuffer(final T[] copyFrom) throws IllegalArgumentException { capacity = copyFrom.length; array = (T[]) newArray(copyFrom.getClass(), capacity); resetImpl(true, copyFrom); @@ -115,9 +115,9 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { * @param arrayType the array type of the created empty internal array. * @param capacity the initial net capacity of the ring buffer */ - public SyncedRingbuffer(Class<? extends T[]> arrayType, int capacity) { + public SyncedRingbuffer(final Class<? extends T[]> arrayType, final int capacity) { this.capacity = capacity; - this.array = (T[]) newArray(arrayType, capacity); + this.array = newArray(arrayType, capacity); resetImpl(false, null /* empty, nothing to copy */ ); } @@ -144,11 +144,11 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { } @Override - public final void resetFull(T[] copyFrom) throws IllegalArgumentException { + public final void resetFull(final T[] copyFrom) throws IllegalArgumentException { resetImpl(true, copyFrom); } - private final void resetImpl(boolean full, T[] copyFrom) throws IllegalArgumentException { + private final void resetImpl(final boolean full, final T[] copyFrom) throws IllegalArgumentException { synchronized ( syncGlobal ) { if( null != copyFrom ) { if( copyFrom.length != capacity() ) { @@ -202,7 +202,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { public final T get() { try { return getImpl(false, false); - } catch (InterruptedException ie) { throw new RuntimeException(ie); } + } catch (final InterruptedException ie) { throw new RuntimeException(ie); } } /** @@ -220,14 +220,14 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { public final T peek() { try { return getImpl(false, true); - } catch (InterruptedException ie) { throw new RuntimeException(ie); } + } catch (final InterruptedException ie) { throw new RuntimeException(ie); } } @Override public final T peekBlocking() throws InterruptedException { return getImpl(true, true); } - private final T getImpl(boolean blocking, boolean peek) throws InterruptedException { + private final T getImpl(final boolean blocking, final boolean peek) throws InterruptedException { synchronized( syncGlobal ) { if( 0 == size ) { if( blocking ) { @@ -257,10 +257,10 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { * </p> */ @Override - public final boolean put(T e) { + public final boolean put(final T e) { try { return putImpl(e, false, false); - } catch (InterruptedException ie) { throw new RuntimeException(ie); } + } catch (final InterruptedException ie) { throw new RuntimeException(ie); } } /** @@ -270,7 +270,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { * </p> */ @Override - public final void putBlocking(T e) throws InterruptedException { + public final void putBlocking(final T e) throws InterruptedException { if( !putImpl(e, false, true) ) { throw new InternalError("Blocking put failed: "+this); } @@ -283,11 +283,11 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { * </p> */ @Override - public final boolean putSame(boolean blocking) throws InterruptedException { + public final boolean putSame(final boolean blocking) throws InterruptedException { return putImpl(null, true, blocking); } - private final boolean putImpl(T e, boolean sameRef, boolean blocking) throws InterruptedException { + private final boolean putImpl(final T e, final boolean sameRef, final boolean blocking) throws InterruptedException { synchronized( syncGlobal ) { if( capacity == size ) { if( blocking ) { @@ -310,7 +310,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { } @Override - public final void waitForFreeSlots(int count) throws InterruptedException { + public final void waitForFreeSlots(final int count) throws InterruptedException { synchronized ( syncGlobal ) { if( capacity - size < count ) { while( capacity - size < count ) { @@ -344,7 +344,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { final int growAmount = newElements.length; final int newCapacity = capacity + growAmount; final T[] oldArray = array; - final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity); + final T[] newArray = newArray(arrayTypeInternal, newCapacity); // writePos == readPos writePos += growAmount; // warp writePos to the end of the new data location @@ -383,7 +383,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { final int newCapacity = capacity + growAmount; final T[] oldArray = array; - final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity); + final T[] newArray = newArray(arrayTypeInternal, newCapacity); // writePos == readPos readPos += growAmount; // warp readPos to the end of the new data location @@ -402,7 +402,7 @@ public class SyncedRingbuffer<T> implements Ringbuffer<T> { } @SuppressWarnings("unchecked") - private static <T> T[] newArray(Class<? extends T[]> arrayType, int length) { + private static <T> T[] newArray(final Class<? extends T[]> arrayType, final int length) { return ((Object)arrayType == (Object)Object[].class) ? (T[]) new Object[length] : (T[]) Array.newInstance(arrayType.getComponentType(), length); diff --git a/src/java/com/jogamp/common/util/TaskBase.java b/src/java/com/jogamp/common/util/TaskBase.java index db437f8..b688ba6 100644 --- a/src/java/com/jogamp/common/util/TaskBase.java +++ b/src/java/com/jogamp/common/util/TaskBase.java @@ -42,7 +42,7 @@ public abstract class TaskBase implements Runnable { static { Debug.initSingleton(); - TRACE_SOURCE = Debug.isPropertyDefined("jogamp.debug.TaskBase.TraceSource", true); + TRACE_SOURCE = PropertyAccess.isPropertyDefined("jogamp.debug.TaskBase.TraceSource", true); } protected final Object syncObject; @@ -56,7 +56,7 @@ public abstract class TaskBase implements Runnable { protected volatile long tExecuted; protected volatile boolean isFlushed; - protected TaskBase(Object syncObject, boolean catchExceptions, PrintStream exceptionOut) { + protected TaskBase(final Object syncObject, final boolean catchExceptions, final PrintStream exceptionOut) { this.syncObject = syncObject; this.catchExceptions = catchExceptions; this.exceptionOut = exceptionOut; @@ -88,7 +88,7 @@ public abstract class TaskBase implements Runnable { * Attach a custom object to this task. * Useful to piggybag further information, ie tag a task final. */ - public final void setAttachment(Object o) { + public final void setAttachment(final Object o) { attachment = o; } @@ -113,7 +113,7 @@ public abstract class TaskBase implements Runnable { * @see #isFlushed() * @see #isInQueue() */ - public final void flush(Throwable t) { + public final void flush(final Throwable t) { if(!isExecuted() && hasWaiter()) { runnableException = t; synchronized (syncObject) { diff --git a/src/java/com/jogamp/common/util/ValueConv.java b/src/java/com/jogamp/common/util/ValueConv.java index 9a16b64..2ad002a 100644 --- a/src/java/com/jogamp/common/util/ValueConv.java +++ b/src/java/com/jogamp/common/util/ValueConv.java @@ -37,7 +37,7 @@ package com.jogamp.common.util; * </p> */ public class ValueConv { - public static final byte float_to_byte(float v, boolean dSigned) { + public static final byte float_to_byte(final float v, final boolean dSigned) { // lossy if( dSigned ) { return (byte) ( v * ( v > 0 ? 127.0f : 128.0f ) ); @@ -45,14 +45,14 @@ public class ValueConv { return (byte) ( v * 255.0f ); } } - public static final short float_to_short(float v, boolean dSigned) { + public static final short float_to_short(final float v, final boolean dSigned) { if( dSigned ) { return (short) ( v * ( v > 0 ? 32767.0f : 32768.0f ) ); } else { return (short) ( v * 65535.0f ); } } - public static final int float_to_int(float v, boolean dSigned) { + public static final int float_to_int(final float v, final boolean dSigned) { // float significand 0x007fffff // double significand 0x000fffffffffffffL // int min = 0x80000000 = -2147483648 @@ -64,7 +64,7 @@ public class ValueConv { } } - public static final byte double_to_byte(double v, boolean dSigned) { + public static final byte double_to_byte(final double v, final boolean dSigned) { // lossy if( dSigned ) { return (byte) ( v * ( v > 0 ? 127.0 : 128.0 ) ); @@ -72,7 +72,7 @@ public class ValueConv { return (byte) ( v * 255.0 ); } } - public static final short double_to_short(double v, boolean dSigned) { + public static final short double_to_short(final double v, final boolean dSigned) { // lossy if( dSigned ) { return (short) ( v * ( v > 0 ? 32767.0 : 32768.0 ) ); @@ -80,7 +80,7 @@ public class ValueConv { return (short) ( v * 65535.0 ); } } - public static final int double_to_int(double v, boolean dSigned) { + public static final int double_to_int(final double v, final boolean dSigned) { // lossy if( dSigned ) { return (int) ( v * ( v > 0 ? 2147483647.0 : 2147483648.0 ) ); @@ -89,28 +89,28 @@ public class ValueConv { } } - public static final float byte_to_float(byte v, boolean sSigned) { + public static final float byte_to_float(final byte v, final boolean sSigned) { if( sSigned ) { return (v & 0xff) / ( v > 0 ? 127.0f : -128.0f ) ; } else { return (v & 0xff) / 255.0f ; } } - public static final double byte_to_double(byte v, boolean sSigned) { + public static final double byte_to_double(final byte v, final boolean sSigned) { if( sSigned ) { return (v & 0xff) / ( v > 0 ? 127.0 : -128.0 ) ; } else { return (v & 0xff) / 255.0 ; } } - public static final float short_to_float(short v, boolean sSigned) { + public static final float short_to_float(final short v, final boolean sSigned) { if( sSigned ) { return (v & 0xffff) / ( v > 0 ? 32767.0f : -32768.0f ) ; } else { return (v & 0xffff) / 65535.0f ; } } - public static final double short_to_double(short v, boolean sSigned) { + public static final double short_to_double(final short v, final boolean sSigned) { // lossy if( sSigned ) { return (v & 0xffff) / ( v > 0 ? 32767.0 : -32768.0 ) ; @@ -118,7 +118,7 @@ public class ValueConv { return (v & 0xffff) / 65535.0 ; } } - public static final float int_to_float(int v, boolean sSigned) { + public static final float int_to_float(final int v, final boolean sSigned) { // lossy // float significand 0x007fffff // double significand 0x000fffffffffffffL @@ -127,35 +127,35 @@ public class ValueConv { if( sSigned ) { return (float) ( v / ( v > 0 ? 2147483647.0 : 2147483648.0 ) ); } else { - return (float) ( ((long)v & 0xffffffffL) / 4294967295.0 ); + return (float) ( (v & 0xffffffffL) / 4294967295.0 ); } } - public static final double int_to_double(int v, boolean sSigned) { + public static final double int_to_double(final int v, final boolean sSigned) { if( sSigned ) { return v / ( v > 0 ? 2147483647.0 : 2147483648.0 ) ; } else { - return ((long)v & 0xffffffffL) / 4294967295.0 ; + return (v & 0xffffffffL) / 4294967295.0 ; } } - public static final short byte_to_short(byte v, boolean sSigned, boolean dSigned) { + public static final short byte_to_short(final byte v, final boolean sSigned, final boolean dSigned) { return float_to_short(byte_to_float(v, sSigned), dSigned); } - public static final int byte_to_int(byte v, boolean sSigned, boolean dSigned) { + public static final int byte_to_int(final byte v, final boolean sSigned, final boolean dSigned) { return float_to_int(byte_to_float(v, sSigned), dSigned); } - public static final byte short_to_byte(short v, boolean sSigned, boolean dSigned) { + public static final byte short_to_byte(final short v, final boolean sSigned, final boolean dSigned) { return float_to_byte(short_to_float(v, sSigned), dSigned); } - public static final int short_to_int(short v, boolean sSigned, boolean dSigned) { + public static final int short_to_int(final short v, final boolean sSigned, final boolean dSigned) { return float_to_int(short_to_float(v, sSigned), dSigned); } - public static final byte int_to_byte(int v, boolean sSigned, boolean dSigned) { + public static final byte int_to_byte(final int v, final boolean sSigned, final boolean dSigned) { return float_to_byte(int_to_float(v, sSigned), dSigned); } - public static final short int_to_short(int v, boolean sSigned, boolean dSigned) { + public static final short int_to_short(final int v, final boolean sSigned, final boolean dSigned) { return float_to_short(int_to_float(v, sSigned), dSigned); } } diff --git a/src/java/com/jogamp/common/util/VersionNumber.java b/src/java/com/jogamp/common/util/VersionNumber.java index addc879..b212fd0 100644 --- a/src/java/com/jogamp/common/util/VersionNumber.java +++ b/src/java/com/jogamp/common/util/VersionNumber.java @@ -72,7 +72,7 @@ public class VersionNumber implements Comparable<Object> { * </p> * @param delim the delimiter, e.g. "." */ - public static java.util.regex.Pattern getVersionNumberPattern(String delim) { + public static java.util.regex.Pattern getVersionNumberPattern(final String delim) { return java.util.regex.Pattern.compile("\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+)[^\\"+delim+"\\s]*(?:\\"+delim+"\\D*(\\d+))?)?"); } @@ -102,7 +102,7 @@ public class VersionNumber implements Comparable<Object> { protected final static short HAS_MINOR = 1 << 1 ; protected final static short HAS_SUB = 1 << 2 ; - protected VersionNumber(int majorRev, int minorRev, int subMinorRev, int _strEnd, short _state) { + protected VersionNumber(final int majorRev, final int minorRev, final int subMinorRev, final int _strEnd, final short _state) { major = majorRev; minor = minorRev; sub = subMinorRev; @@ -116,7 +116,7 @@ public class VersionNumber implements Comparable<Object> { * @see #hasMinor() * @see #hasSub() */ - public VersionNumber(int majorRev, int minorRev, int subMinorRev) { + public VersionNumber(final int majorRev, final int minorRev, final int subMinorRev) { this(majorRev, minorRev, subMinorRev, -1, (short)(HAS_MAJOR | HAS_MINOR | HAS_SUB)); } @@ -197,7 +197,7 @@ public class VersionNumber implements Comparable<Object> { } } } - } catch (Exception e) { } + } catch (final Exception e) { } major = val[0]; minor = val[1]; @@ -233,7 +233,7 @@ public class VersionNumber implements Comparable<Object> { } @Override - public final boolean equals(Object o) { + public final boolean equals(final Object o) { if ( o instanceof VersionNumber ) { return 0 == compareTo( (VersionNumber) o ); } @@ -241,15 +241,15 @@ public class VersionNumber implements Comparable<Object> { } @Override - public final int compareTo(Object o) { + public final int compareTo(final Object o) { if ( ! ( o instanceof VersionNumber ) ) { - Class<?> c = (null != o) ? o.getClass() : null ; + final Class<?> c = (null != o) ? o.getClass() : null ; throw new ClassCastException("Not a VersionNumber object: " + c); } return compareTo( (VersionNumber) o ); } - public final int compareTo(VersionNumber vo) { + public final int compareTo(final VersionNumber vo) { if (major > vo.major) { return 1; } else if (major < vo.major) { diff --git a/src/java/com/jogamp/common/util/VersionNumberString.java b/src/java/com/jogamp/common/util/VersionNumberString.java index e23300c..6644f65 100644 --- a/src/java/com/jogamp/common/util/VersionNumberString.java +++ b/src/java/com/jogamp/common/util/VersionNumberString.java @@ -44,7 +44,7 @@ public class VersionNumberString extends VersionNumber { protected final String strVal; - protected VersionNumberString(int majorRev, int minorRev, int subMinorRev, int strEnd, short _state, String versionString) { + protected VersionNumberString(final int majorRev, final int minorRev, final int subMinorRev, final int strEnd, final short _state, final String versionString) { super(majorRev, minorRev, subMinorRev, strEnd, _state); strVal = versionString; } @@ -52,7 +52,7 @@ public class VersionNumberString extends VersionNumber { /** * See {@link VersionNumber#VersionNumber(int, int, int)}. */ - public VersionNumberString(int majorRev, int minorRev, int subMinorRev, String versionString) { + public VersionNumberString(final int majorRev, final int minorRev, final int subMinorRev, final String versionString) { this(majorRev, minorRev, subMinorRev, -1, (short)(HAS_MAJOR | HAS_MINOR | HAS_SUB), versionString); } diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java index c4451ac..6949d62 100644 --- a/src/java/com/jogamp/common/util/VersionUtil.java +++ b/src/java/com/jogamp/common/util/VersionUtil.java @@ -40,6 +40,8 @@ import java.util.Set; import java.util.jar.Attributes; import java.util.jar.Manifest; +import jogamp.common.os.PlatformPropsImpl; + public class VersionUtil { public static final String SEPERATOR = "-----------------------------------------------------------------------------------------------------"; @@ -68,7 +70,7 @@ public class VersionUtil { Platform.getMachineDescription().toString(sb).append(Platform.getNewline()); // JVM/JRE - sb.append("Platform: Java Version: ").append(Platform.getJavaVersion()).append(" (").append(Platform.getJavaVersionNumber()).append("u").append(Platform.JAVA_VERSION_UPDATE).append("), VM: ").append(Platform.getJavaVMName()); + sb.append("Platform: Java Version: ").append(Platform.getJavaVersion()).append(" (").append(Platform.getJavaVersionNumber()).append("u").append(PlatformPropsImpl.JAVA_VERSION_UPDATE).append("), VM: ").append(Platform.getJavaVMName()); sb.append(", Runtime: ").append(Platform.getJavaRuntimeName()).append(Platform.getNewline()); sb.append("Platform: Java Vendor: ").append(Platform.getJavaVendor()).append(", ").append(Platform.getJavaVendorURL()); sb.append(", JavaSE: ").append(Platform.isJavaSE()); @@ -94,7 +96,7 @@ public class VersionUtil { * @param extension The value of the 'Extension-Name' jar-manifest attribute; used to identify the manifest. * @return the requested manifest or null when not found. */ - public static Manifest getManifest(ClassLoader cl, String extension) { + public static Manifest getManifest(final ClassLoader cl, final String extension) { return getManifest(cl, new String[] { extension } ); } @@ -106,10 +108,10 @@ public class VersionUtil { * Matching is applied in decreasing order, i.e. first element is favored over the second, etc. * @return the requested manifest or null when not found. */ - public static Manifest getManifest(ClassLoader cl, String[] extensions) { + public static Manifest getManifest(final ClassLoader cl, final String[] extensions) { final Manifest[] extManifests = new Manifest[extensions.length]; try { - Enumeration<URL> resources = cl.getResources("META-INF/MANIFEST.MF"); + final Enumeration<URL> resources = cl.getResources("META-INF/MANIFEST.MF"); while (resources.hasMoreElements()) { final InputStream is = resources.nextElement().openStream(); final Manifest manifest; @@ -118,7 +120,7 @@ public class VersionUtil { } finally { IOUtil.close(is, false); } - Attributes attributes = manifest.getMainAttributes(); + final Attributes attributes = manifest.getMainAttributes(); if(attributes != null) { for(int i=0; i < extensions.length && null == extManifests[i]; i++) { final String extension = extensions[i]; @@ -131,7 +133,7 @@ public class VersionUtil { } } } - } catch (IOException ex) { + } catch (final IOException ex) { throw new RuntimeException("Unable to read manifest.", ex); } for(int i=1; i<extManifests.length; i++) { @@ -142,7 +144,7 @@ public class VersionUtil { return null; } - public static StringBuilder getFullManifestInfo(Manifest mf, StringBuilder sb) { + public static StringBuilder getFullManifestInfo(final Manifest mf, StringBuilder sb) { if(null==mf) { return sb; } @@ -151,11 +153,11 @@ public class VersionUtil { sb = new StringBuilder(); } - Attributes attr = mf.getMainAttributes(); - Set<Object> keys = attr.keySet(); - for(Iterator<Object> iter=keys.iterator(); iter.hasNext(); ) { - Attributes.Name key = (Attributes.Name) iter.next(); - String val = attr.getValue(key); + final Attributes attr = mf.getMainAttributes(); + final Set<Object> keys = attr.keySet(); + for(final Iterator<Object> iter=keys.iterator(); iter.hasNext(); ) { + final Attributes.Name key = (Attributes.Name) iter.next(); + final String val = attr.getValue(key); sb.append(" "); sb.append(key); sb.append(" = "); diff --git a/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java b/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java index e98478e..ec9348d 100644 --- a/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java +++ b/src/java/com/jogamp/common/util/awt/AWTEDTExecutor.java @@ -44,7 +44,7 @@ public class AWTEDTExecutor implements RunnableExecutor { private AWTEDTExecutor() {} @Override - public void invoke(boolean wait, Runnable r) { + public void invoke(final boolean wait, final Runnable r) { if(EventQueue.isDispatchThread()) { r.run(); } else { @@ -54,9 +54,9 @@ public class AWTEDTExecutor implements RunnableExecutor { } else { EventQueue.invokeLater(r); } - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new RuntimeException(e.getTargetException()); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RuntimeException(e); } } @@ -83,7 +83,7 @@ public class AWTEDTExecutor implements RunnableExecutor { * @param r the {@link Runnable} to be executed. * @return <code>true</code> if the {@link Runnable} has been issued for execution, otherwise <code>false</code> */ - public boolean invoke(Object treeLock, boolean allowOnNonEDT, boolean wait, Runnable r) { + public boolean invoke(final Object treeLock, final boolean allowOnNonEDT, final boolean wait, final Runnable r) { if( EventQueue.isDispatchThread() ) { r.run(); return true; @@ -94,9 +94,9 @@ public class AWTEDTExecutor implements RunnableExecutor { } else { EventQueue.invokeLater(r); } - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw new RuntimeException(e.getTargetException()); - } catch (InterruptedException e) { + } catch (final InterruptedException e) { throw new RuntimeException(e); } return true; 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"); } diff --git a/src/java/com/jogamp/common/util/locks/LockFactory.java b/src/java/com/jogamp/common/util/locks/LockFactory.java index e1ec2d7..dd8d25b 100644 --- a/src/java/com/jogamp/common/util/locks/LockFactory.java +++ b/src/java/com/jogamp/common/util/locks/LockFactory.java @@ -39,7 +39,7 @@ public class LockFactory { public final int id; - ImplType(int id){ + ImplType(final int id){ this.id = id; } } @@ -54,7 +54,7 @@ public class LockFactory { return new RecursiveThreadGroupLockImpl01Unfairish(); } - public static RecursiveLock createRecursiveLock(ImplType t, boolean fair) { + public static RecursiveLock createRecursiveLock(final ImplType t, final boolean fair) { switch(t) { case Int01: return fair ? new RecursiveLockImpl01CompleteFair() : new RecursiveLockImpl01Unfairish(); diff --git a/src/java/com/jogamp/common/util/locks/SingletonInstance.java b/src/java/com/jogamp/common/util/locks/SingletonInstance.java index f016d4b..ee703cd 100644 --- a/src/java/com/jogamp/common/util/locks/SingletonInstance.java +++ b/src/java/com/jogamp/common/util/locks/SingletonInstance.java @@ -37,11 +37,11 @@ public abstract class SingletonInstance implements Lock { protected static final boolean DEBUG = true; - public static SingletonInstance createFileLock(long poll_ms, String lockFileBasename) { + public static SingletonInstance createFileLock(final long poll_ms, final String lockFileBasename) { return new SingletonInstanceFileLock(poll_ms, lockFileBasename); } - public static SingletonInstance createFileLock(long poll_ms, File lockFile) { + public static SingletonInstance createFileLock(final long poll_ms, final File lockFile) { return new SingletonInstanceFileLock(poll_ms, lockFile); } @@ -58,11 +58,11 @@ public abstract class SingletonInstance implements Lock { * @param pollPeriod * @param portNumber to be used for this single instance server socket. */ - public static SingletonInstance createServerSocket(long poll_ms, int portNumber) { + public static SingletonInstance createServerSocket(final long poll_ms, final int portNumber) { return new SingletonInstanceServerSocket(poll_ms, portNumber); } - protected SingletonInstance(long poll_ms) { + protected SingletonInstance(final long poll_ms) { this.poll_ms = Math.max(10, poll_ms); } @@ -79,7 +79,7 @@ public abstract class SingletonInstance implements Lock { return; } } while ( true ) ; - } catch ( RuntimeException ie ) { + } catch ( final RuntimeException ie ) { throw new RuntimeException(ie); } } @@ -109,7 +109,7 @@ public abstract class SingletonInstance implements Lock { maxwait -= System.currentTimeMillis()-t1; i++; } while ( 0 < maxwait ) ; - } catch ( InterruptedException ie ) { + } catch ( final InterruptedException ie ) { final long t2 = System.currentTimeMillis(); throw new RuntimeException(infoPrefix(t2)+" EEE (1) "+getName()+" - couldn't get lock within "+(t2-t0)+" ms, "+i+" attempts", ie); } @@ -139,7 +139,7 @@ public abstract class SingletonInstance implements Lock { return locked; } - protected String infoPrefix(long currentMillis) { + protected String infoPrefix(final long currentMillis) { return "SLOCK [T "+Thread.currentThread().getName()+" @ "+currentMillis+" ms"; } protected String infoPrefix() { |