diff options
author | Sven Gothel <[email protected]> | 2014-07-08 21:13:15 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-07-08 21:13:15 +0200 |
commit | 815776c5760e42c8b3c858a9bab982b203c59c24 (patch) | |
tree | 3f8ecd7e905b0f431f5472565fce837b24f922ab /src | |
parent | a41db57df54863566b0e286cd100bbbc5518eb7f (diff) |
Findbugs: Remove branches where reference cannot be null
Diffstat (limited to 'src')
10 files changed, 37 insertions, 34 deletions
diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index f082f358f..af7694ce1 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -186,8 +186,10 @@ public class BuildComposablePipeline { } try { + // Keep assignment w/ null comparison for clarification. + // If no exception is thrown, return value is always non-null; hasImmediateMode = - (classToComposeAround.getMethod("glBegin", new Class<?>[]{Integer.TYPE}) != null); + null != classToComposeAround.getMethod("glBegin", new Class<?>[]{Integer.TYPE}); } catch (final Exception e) { } @@ -388,7 +390,7 @@ public class BuildComposablePipeline { } } - if (null != baseInterfaceClass && !clazzList.contains(baseInterfaceClass)) { + if ( !clazzList.contains(baseInterfaceClass) ) { ifNames[i++] = baseInterfaceClass.getName(); clazzList.add(baseInterfaceClass); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 4a3e5b2e1..29dce40f5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -551,7 +551,7 @@ public class ShaderCode { out.println("<no shader source>"); return; } - final int sourceCount = (null!=shaderSource)?shaderSource.length:0; + final int sourceCount = shaderSource.length; final int shaderCount = (null!=shader)?shader.capacity():0; for(int i=0; i<shaderCount; i++) { out.println(""); @@ -601,7 +601,7 @@ public class ShaderCode { if(0>shaderIdx || shaderIdx>=shaderCount) { throw new IndexOutOfBoundsException("shaderIdx not within shader bounds [0.."+(shaderCount-1)+"]: "+shaderIdx); } - final int sourceCount = (null!=shaderSource)?shaderSource.length:0; + final int sourceCount = shaderSource.length; if(shaderIdx>=sourceCount) { throw new IndexOutOfBoundsException("shaderIdx not within source bounds [0.."+(sourceCount-1)+"]: "+shaderIdx); } @@ -660,7 +660,7 @@ public class ShaderCode { final int oldNameLen = oldName.length(); final int newNameLen = newName.length(); int num = 0; - final int sourceCount = (null!=shaderSource)?shaderSource.length:0; + final int sourceCount = shaderSource.length; for(int shaderIdx = 0; shaderIdx<sourceCount; shaderIdx++) { final CharSequence[] src = shaderSource[shaderIdx]; for(int j=0; j<src.length; j++) { @@ -706,7 +706,7 @@ public class ShaderCode { if(0>shaderIdx || shaderIdx>=shaderCount) { throw new IndexOutOfBoundsException("shaderIdx not within shader bounds [0.."+(shaderCount-1)+"]: "+shaderIdx); } - final int sourceCount = (null!=shaderSource)?shaderSource.length:0; + final int sourceCount = shaderSource.length; if(shaderIdx>=sourceCount) { throw new IndexOutOfBoundsException("shaderIdx not within source bounds [0.."+(sourceCount-1)+"]: "+shaderIdx); } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java index 118c9b136..b9b61e704 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PMSAAES2.java @@ -384,7 +384,7 @@ public class VBORegion2PMSAAES2 extends GLRegion { System.err.printf("XXX.Scale %d * [%f x %f]: %d x %d%n", sampleCount[0], winWidth, winHeight, targetFboWidth, targetFboHeight); } - if( hasDelta || fboDirty || isShapeDirty() || null == fbo || ( fbo != null && fbo.getNumSamples() != sampleCount[0] ) ) { + if( hasDelta || fboDirty || isShapeDirty() || null == fbo || fbo.getNumSamples() != sampleCount[0] ) { // FIXME: rescale final float minX = box.getMinX()-diffObjBorderWidth; final float minY = box.getMinY()-diffObjBorderHeight; diff --git a/src/jogl/classes/jogamp/opengl/glu/tessellator/GLUtessellatorImpl.java b/src/jogl/classes/jogamp/opengl/glu/tessellator/GLUtessellatorImpl.java index 6f89a95f2..f2a9c78fa 100644 --- a/src/jogl/classes/jogamp/opengl/glu/tessellator/GLUtessellatorImpl.java +++ b/src/jogl/classes/jogamp/opengl/glu/tessellator/GLUtessellatorImpl.java @@ -354,7 +354,7 @@ public class GLUtessellatorImpl implements GLUtessellator { /* Create a new vertex and edge which immediately follow e * in the ordering around the left face. */ - if (Mesh.__gl_meshSplitEdge(e) == null) return false; + Mesh.__gl_meshSplitEdge(e); e = e.Lnext; } @@ -396,11 +396,12 @@ public class GLUtessellatorImpl implements GLUtessellator { final CachedVertex[] v = cache; mesh = Mesh.__gl_meshNewMesh(); - if (mesh == null) return false; for (int i = 0; i < cacheCount; i++) { final CachedVertex vertex = v[i]; - if (!addVertex(vertex.coords, vertex.data)) return false; + if (!addVertex(vertex.coords, vertex.data)) { + return false; + } } cacheCount = 0; flushCacheOnNextVertex = false; diff --git a/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQHeap.java b/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQHeap.java index 74d981907..fa29db8dc 100644 --- a/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQHeap.java +++ b/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQHeap.java @@ -173,10 +173,11 @@ class PriorityQHeap extends jogamp.opengl.glu.tessellator.PriorityQ { pqNodes[i] = new PQnode(); } nodes = pqNodes; + /** Cannot be null if (nodes == null) { - nodes = saveNodes; /* restore ptr to free upon return */ + nodes = saveNodes; // restore ptr to free upon return return Integer.MAX_VALUE; - } + } */ // pq->handles = (PQhandleElem *)memRealloc( pq->handles,(size_t)((pq->max + 1) * sizeof( pq->handles[0] ))); final PriorityQ.PQhandleElem[] pqHandles = new PriorityQ.PQhandleElem[max + 1]; @@ -185,10 +186,11 @@ class PriorityQHeap extends jogamp.opengl.glu.tessellator.PriorityQ { pqHandles[i] = new PQhandleElem(); } handles = pqHandles; + /** cannot be null if (handles == null) { - handles = saveHandles; /* restore ptr to free upon return */ + handles = saveHandles; // restore ptr to free upon return return Integer.MAX_VALUE; - } + } */ } if (freeList == 0) { diff --git a/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQSort.java b/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQSort.java index 45e994b67..d88f584cf 100644 --- a/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQSort.java +++ b/src/jogl/classes/jogamp/opengl/glu/tessellator/PriorityQSort.java @@ -202,7 +202,7 @@ class PriorityQSort extends jogamp.opengl.glu.tessellator.PriorityQ { } curr = size; if (++size >= max) { - final Object[] saveKey = keys; + // final Object[] saveKey = keys; /* If the heap overflows, double its size. */ max <<= 1; @@ -210,10 +210,11 @@ class PriorityQSort extends jogamp.opengl.glu.tessellator.PriorityQ { final Object[] pqKeys = new Object[max]; System.arraycopy( keys, 0, pqKeys, 0, keys.length ); keys = pqKeys; + /** Cannot be null if (keys == null) { - keys = saveKey; /* restore ptr to free upon return */ + keys = saveKey; // restore ptr to free upon return return Integer.MAX_VALUE; - } + } */ } assert curr != Integer.MAX_VALUE; keys[curr] = keyNew; diff --git a/src/jogl/classes/jogamp/opengl/glu/tessellator/Sweep.java b/src/jogl/classes/jogamp/opengl/glu/tessellator/Sweep.java index 9cf05378c..b6c60058f 100644 --- a/src/jogl/classes/jogamp/opengl/glu/tessellator/Sweep.java +++ b/src/jogl/classes/jogamp/opengl/glu/tessellator/Sweep.java @@ -1237,7 +1237,6 @@ class Sweep { return Geom.VertLeq(((GLUvertex) key1), (GLUvertex) key2); } }); - if (pq == null) return false; vHead = tess.mesh.vHead; for (v = vHead.next; v != vHead; v = v.next) { diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 6aa753ac1..05e192bbc 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -571,19 +571,17 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.vid = vid; this.aid = aid; - if ( this.streamLoc != null ) { - new Thread() { - public void run() { - try { - // StreamWorker may be used, see API-doc of StreamWorker - initStreamImpl(vid, aid); - } catch (final Throwable t) { - streamErr = new StreamException(t.getClass().getSimpleName()+" while initializing: "+GLMediaPlayerImpl.this.toString(), t); - changeState(GLMediaEventListener.EVENT_CHANGE_ERR, GLMediaPlayer.State.Uninitialized); - } // also initializes width, height, .. etc - } - }.start(); - } + new Thread() { + public void run() { + try { + // StreamWorker may be used, see API-doc of StreamWorker + initStreamImpl(vid, aid); + } catch (final Throwable t) { + streamErr = new StreamException(t.getClass().getSimpleName()+" while initializing: "+GLMediaPlayerImpl.this.toString(), t); + changeState(GLMediaEventListener.EVENT_CHANGE_ERR, GLMediaPlayer.State.Uninitialized); + } // also initializes width, height, .. etc + } + }.start(); } } /** diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AppContextInfo.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AppContextInfo.java index c637ec59e..2026ada0f 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AppContextInfo.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AppContextInfo.java @@ -160,8 +160,8 @@ public class AppContextInfo { } else { // old info is OK if( DEBUG ) { - final int mainThreadAppContextHash = null != mainThreadAppContext ? mainThreadAppContext.hashCode() : 0; - final int thisThreadAppContextHash = null != thisThreadAppContext ? thisThreadAppContext.hashCode() : 0; + final int mainThreadAppContextHash = mainThreadAppContext.hashCode(); + final int thisThreadAppContextHash = thisThreadAppContext.hashCode(); System.err.println("Bug 1004[TGMapped "+tgMapped+"]: OK AppContext @ "+info+" on thread "+thread.getName()+" "+toHexString(thread.hashCode())+ ": tg "+threadGroup.getName()+" "+toHexString(threadGroup.hashCode())+ " : appCtx [ this "+thisThreadAppContext+" "+toHexString(thisThreadAppContextHash)+ diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 4a3b9442d..afa9786e2 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -298,7 +298,7 @@ public class WindowDriver extends WindowImpl { final PointerIconImpl pi = (PointerIconImpl)getPointerIcon(); final boolean res; if( pointerVisible && null != pi ) { - setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.validatedHandle() : 0); + setPointerIcon0(dpy, getWindowHandle(), pi.validatedHandle()); res = true; } else { res = setPointerVisible0(dpy, getWindowHandle(), pointerVisible); |