A few small missing-code/code-changes? for jme3 rev.7239

Hello, I hope you (reading this) don’t mind if I make a few corrections to the jme3 rev.7239 code such as missing @Override or missing switch cases and so on… :wink: and maybe possibly some developer would have the time to implement them, if the changes are really worth the time

I’ll group them by type:

1. missing @Override annotation in the following places:

ignored

2. Boxed/Unboxed

ie. The expression of type Float is unboxed into float

ignored

3. ie. “The serializable class AssetLoadException does not declare a static final serialVersionUID field of type long”

ignored

4. Missing case statements

ie. “The enum constant SetEnvParams needs a corresponding case label in this enum switch on QueuedAudioRenderer.CmdType”

a) line 138 “switch (cmd.type){”

in com.jme3.audio.QueuedAudioRenderer.java

is missing the following cases:

pre type="java"
case Cleanup:


break;


case PlaySourceInstance:


break;


case SetEnvParams:


break;
/pre

b) line 190 in com.jme3.renderer.queue.RenderQueue.java in method renderShadowQueue(ShadowMode, RenderManager, Camera, boolean)

“switch (shadBucket){”

is missing the following cases:

pre type="java"
case CastAndReceive:


break;


case Inherit:


break;


case Off:


break;
/pre

c) line 310 in com.jme3.scene.Mesh.java in setInterleaved() method

“The enum constant Double needs a corresponding case label in this enum switch on VertexBuffer.Format”

in other words the following case is missing:

pre type="java"
case Double:


break;
/pre

d) line 15 in com.jme3.scene.mesh.VirtualIndexBuffer.java in method VirtualIndexBuffer(int, Mode)

missing case:

pre type="java"
case Hybrid:


break;
/pre

e) line 80 in com.jme3.shader.Uniform.java in method write(JmeExporter)

“switch (varType){” missing the following cases:

pre type="java"
case Texture2D:


break;


case Texture3D:


break;


case TextureArray:


break;


case TextureBuffer:


break;


case TextureCubeMap:


break;
/pre

f) line 137 (after prev modif) in com.jme3.shader.Uniform.java in method read(JmeImporter)

another “switch (varType){” missing these cases:

pre type="java"
case Matrix3Array:


break;


case Matrix4Array:


break;


case Texture2D:


break;


case Texture3D:


break;


case TextureArray:


break;


case TextureBuffer:


break;


case TextureCubeMap:


break;


case Vector2Array:


break;
/pre

g) line 263 (after prev 2 modifs) in com.jme3.shader.Uniform.java in method clearValue()

yet another “switch (varType){” missing these cases:

pre type="java"
case FloatArray:


break;


case Matrix3:


break;


case Matrix3Array:


break;


case Matrix4:


break;


case Matrix4Array:


break;


case Texture2D:


break;


case Texture3D:


break;


case TextureArray:


break;


case TextureBuffer:


break;


case TextureCubeMap:


break;


case Vector2Array:


break;


case Vector3Array:


break;


case Vector4Array:


break;
/pre

h) line 130 in com.jme3.texture.Texture2D.java in method setWrap(WrapAxis, WrapMode)

“switch (axis) {” missing case:

pre type="java"
case R:


break;
/pre

i) on line 169 (after above modif) in same file com.jme3.texture.Texture2D.java in method getWrap(WrapAxis)

“switch (axis) {” missing case:

pre type="java"
case R:


break;
/pre

j) line 149 in com.jme3.system.Natives.java in method extractNativeLibs(Platform, AppSettings)

“switch (platform){”

“The enum constant Android needs a corresponding case label in this enum switch on JmeSystem.Platform”

missing cases:

pre type="java"
case Android:


break;
/pre

k) line 529(after some modifs) in com.jme3.shadow.PssmShadowRenderer.java in method setPcfFilter(FILTERING)

missing cases:

pre type="java"
case PCF10X10:


break;


case PCF16X16:


break;


case PCF20X20:


break;
/pre

l) line 141 in com.jme3.renderer.lwjgl.LwjglGL1Renderer.java in method setFixedFuncBinding(FixedFuncBinding, Object)

The enum constant MaterialSpecular needs a corresponding case label in this enum switch on FixedFuncBinding

missing cases:

pre type="java"
case MaterialAmbient:


break;


case MaterialDiffuse:


break;


case MaterialSpecular:


break;
/pre

m) line 691 (after above modif) in same file com.jme3.renderer.lwjgl.LwjglGL1Renderer.java in method setVertexAttrib(VertexBuffer, VertexBuffer)

“switch (vb.getBufferType()) {”

The enum constant TexCoord8 needs a corresponding case label in this enum switch on VertexBuffer.Type

The enum constant TexCoord7 needs a corresponding case label in this enum switch on VertexBuffer.Type

The enum constant TexCoord6 needs a corresponding case label in this enum switch on VertexBuffer.Type

hmm I have a feeling these other types are not valid for this switch though… maybe a “default:” and throw would be useful then?

anyway missing cases:

pre type="java"
case TexCoord8:


break;


case TexCoord7:


break;


case TexCoord6:


break;


case TexCoord5:


break;


case TexCoord4:


break;


case TexCoord3:


break;


case TexCoord2:


break;


case Tangent:


break;


case Size:


break;


case MiscAttrib:


break;


case InterleavedData:


break;


case Index:


break;


case BoneWeight:


break;


case BoneIndex:


break;


case Binormal:


break;


case BindPosePosition:


break;


case BindPoseNormal:


break;
/pre

n) line 136 in com.jme3.terrain.geomipmap.picking.BresenhamTerrainPicker.java in method getTerrainIntersection(Ray, CollisionResults)

“switch (d) {”

missing cases:

pre type="java"
case NegativeY:


break;


case None:


break;


case PositiveY:


break;
/pre

5. ie. “The static field LoopMode.DontLoop should be accessed in a static way”

ignored

6. Empty control-flow statement

ignored, “while (emitParticle(min, max));” it’s good in ParticleEmitter.java

7. overriden equals() but not hashCode()

ie. “The type MatParam should also implement hashCode() since it overrides Object.equals()”

a) this class com.jme3.material.MatParam.java

b) this class com.jme3.texture.Image.java

c) this class com.jme3.texture.Texture2D.java

d) com.jme3.texture.TextureCubeMap.java

e) this file com.jme3.export.binary.BinaryOutputCapsule.java

f) com.jme3.network.connection.Client.java

8. switch case fall though

ie. “Switch case may be entered by falling through previous case. If intended, add a new comment //$FALL-THROUGH$ on the line above”

a) line 181 and 187, in com.jme3.math.Matrix3f.java in get(int, int) method

this is what it looks like:

pre type="java"
public float get(int i, int j) {


switch (i) {


case 0:


switch (j) {


case 0: return m00;


case 1: return m01;


case 2: return m02;


}


//$FALL-THROUGH$


case 1:


switch (j) {


case 0: return m10;


case 1: return m11;


case 2: return m12;


}


//$FALL-THROUGH$


case 2:


switch (j) {


case 0: return m20;


case 1: return m21;


case 2: return m22;


}


}





logger.warning(“Invalid matrix index.”);


throw new IllegalArgumentException(“Invalid indices into matrix.”);


}
/pre

I know it’s good, but maybe insert “//$FALL-THROUGH$” before both “case 1:” and “case 2:” or not whatever :slight_smile:

b) same for lines 502,508

c) same for lines 296, 307, 318 in com.jme3.math.Matrix4f.java in get(int, int)

d) also lines 470, 485, 500 in the same com.jme3.math.Matrix4f.java

e) in com.jme3.shadow.PssmShadowRenderer.java in method postQueue(RenderQueue)

line 348, 350, 352 this is the code there:

pre type="java"
PssmShadowUtil.updateFrustumSplits(splitsArray, viewCam.getFrustumNear(), zFar, lambda);


switch (splitsArray.length){


case 5:


splits.a = splitsArray[4];


case 4:


splits.b = splitsArray[3];


case 3:


splits.g = splitsArray[2];


case 2:


case 1:


splits.r = splitsArray[1];


break;


}





Renderer r = renderManager.getRenderer();


renderManager.setForcedMaterial(preshadowMat);


renderManager.setForcedTechnique(“PreShadow”);
/pre

f) line 222,226,228,230,232,234 com.jme3.renderer.lwjgl.LwjglRenderer.java in method initialize()

it does say “fall through intentional” but I wonder if it’s only meant for the first 3 cases? this is the code:

pre type="java"
float version = Float.parseFloat(versionStr);


glslVer = (int) (version * 100);





switch (glslVer) {


default:


if (glslVer < 400) {


break;


}





// so that future OpenGL revisions wont break jme3





// fall through intentional


case 400:


case 330:


case 150:


caps.add(Caps.GLSL150);


case 140:


caps.add(Caps.GLSL140);


case 130:


caps.add(Caps.GLSL130);


case 120:


caps.add(Caps.GLSL120);


case 110:


caps.add(Caps.GLSL110);


case 100:


caps.add(Caps.GLSL100);


break;


}





if (!caps.contains(Caps.GLSL100)) {


logger.log(Level.WARNING, “Force-adding GLSL100 support, since OpenGL2 is supported.”);


caps.add(Caps.GLSL100);


}
/pre

there is another one below which is marked as intentional fallthru so I don’t report it though it would prevent my eclipse from complaining if it looked like this:

“//$FALL-THROUGH$

case TwoDimensional:

case TwoDimensionalArray:”

g) line 232 in jme3tools.navigation.Coordinate.java in method buildCoOrdinate(int, float, int, int)

“case LNG:” this is the code:

pre type="java"
/


* Populate this object by parsing the arguments to the function


* Placed here to allow multiple constructors to use it


* @since 1.0


*/


private void buildCoOrdinate(int deg, float minsDecMins, int coOrdinate,


int quad) {


NumUtil nu = new NumUtil();





switch (coOrdinate) {


case LAT:


switch (quad) {


case N:


this.deg = deg;


this.minsDecMins = minsDecMins;


this.coOrdinate = coOrdinate;


decCoordinate = nu.Round(this.deg + (float) this.minsDecMins / 60, Coordinate.MINPRECISION);


break;





case S:


this.deg = -deg;


this.minsDecMins = minsDecMins;


this.coOrdinate = coOrdinate;


decCoordinate = nu.Round(this.deg - ((float) this.minsDecMins / 60), Coordinate.MINPRECISION);


}





case LNG:


switch (quad) {


case E:


this.deg = deg;


this.minsDecMins = minsDecMins;


this.coOrdinate = coOrdinate;


decCoordinate = nu.Round(this.deg + ((float) this.minsDecMins / 60), Coordinate.MINPRECISION);


break;





case W:


this.deg = -deg;


this.minsDecMins = minsDecMins;


this.coOrdinate = coOrdinate;


decCoordinate = nu.Round(this.deg - ((float) this.minsDecMins / 60), Coordinate.MINPRECISION);


}


}


}
/pre

h) line 51 in jme3tools.navigation.NavCalculator.java in method NavCalculator(Position, Position, int)

“case GC:”

9) missing @Deprecated annotation

ie. “The deprecated method (Spatial, Camera, CameraControl.ControlDirection) of type CameraControl should be annotated with @Deprecated

a) line 95 in file com.jme3.scene.control.CameraControl.java on method CameraControl(Spatial, Camera, ControlDirection)

b) line 224 in com.jme3.scene.shape.Cylinder.java on method setRadius2(float)

c) lines 77,79,81,83,85,87 in com.jme3.post.filters.BloomFilter.java

ie. I added on the first one

pre type="java"
/
@deprecated use {@link GlowMode} enum /


@Deprecated public static final int GLOW_SCENE = 0;


/@deprecated use {@link GlowMode} enum */


public static final int GLOW_OBJECTS = 1;


/
@deprecated use {@link GlowMode} enum /


public static final int GLOW_BOTH = 2;


/**@deprecated use GLOW_SCENE instead
/


public static final int GLOW_MODE_ONLY_EXTRACTED_LIGHTS = 0;


/**@deprecated use GLOW_OBJECTS instead
/


public static final int GLOW_MODE_ONLY_GLOW_OBJECTS = 1;


/**@deprecated use GLOW_BOTH instead*/


public static final int GLOW_MODE_BOTH = 2;
/pre

10) dead code

a) line 160/161 in com.jme3.scene.shape.Torus.java in method setGeometryData()

pre type="java"
if (true)


fnb.put(tempNormal.x).put(tempNormal.y).put(


tempNormal.z);


else


fnb.put(-tempNormal.x).put(-tempNormal.y)


.put(-tempNormal.z);
/pre

11) field hiding another field

a) line 102 in com.jme3.shader.Shader.java in subclass ShaderSource

“boolean usable = false;”

“The field Shader.ShaderSource.usable is hiding a field from type Shader”

it’s probably ok (?), I renamed it to usable1 though

b) line 53 in com.jme3.texture.FrameBuffer.java in inner class RenderBuffer

“int id = -1;”

“The field FrameBuffer.RenderBuffer.id is hiding a field from type GLObject”

I renamed it to id1 though this also seemed ok as it were

c) line 489, 490 two fields, in com.jme3.water.SimpleWaterProcessor.java of inner class RefractionProcessor

The field SimpleWaterProcessor.RefractionProcessor.rm is hiding a field from type SimpleWaterProcessor

The field SimpleWaterProcessor.RefractionProcessor.vp is hiding a field from type SimpleWaterProcessor


this is again most likely ok :slight_smile: should’ve probably ignored this (11)

d) line 75 in jme3game.cubefield.CubeField.java

The field CubeField.speed is hiding a field from type Application

e) line 76 in jme3test.bullet.TestBoneRagdoll.java

The field TestBoneRagdoll.timer is hiding a field from type Application

f) line 379, 380 in com.jme3.network.base.DefaultServer.java in inner class Connection

The field DefaultServer.Connection.reliable is hiding a field from type DefaultServer

The field DefaultServer.Connection.fast is hiding a field from type DefaultServer

12) The method is overriding a synchronized method without being synchronized

a) line 302 in com.jme3.network.connection.SSLTCPConnection.java the method write(SelectableChannel)

ie. add “synchronized”

phew, this took a while :slight_smile:

Thanks! I think I fixed most of them. Some I decided to leave out however.


line 136 in com.jme3.terrain.geomipmap.picking.BresenhamTerrainPicker.java in method getTerrainIntersection(Ray, CollisionResults)
“switch (d) {”
missing cases:

I will leave this to @Brent to figure out

“Switch case may be entered by falling through previous case. If intended, add a new comment //$FALL-THROUGH$ on the line above”

I don't know what IDE you're using, but mine doesn't accept those kinds of comments to remove the warnings.
I have to use the Java appropriate @SuppressWarnings("fallthrough")
1 Like

I’m using eclipse-SDK-3.7M6-win32-x86_64.zip aka Eclipse 3.7 Indigo M6

The @SuppressWarnings("fallthrough") seems to have no effect on my IDE "Unnecessary @SuppressWarnings(“fallthrough”) ", silly eclipse :)) j/k

no biggie as long as it’s stated as intentional

Oh disregard that, that does work in Eclipse, I just had to enable one option here and now I don’t need to use the ugly //$FALL-THROUGH$ comment (though it was usable on a per case basis while @SW is for entire method) because the @SW one is now recognized

http://i.imgur.com/0wR19.png



Thank you for the fixes and consideration