jme3-core: fix minor issues pointed in static analysis
This commit is contained in:
parent
1076b489ab
commit
400c09a633
@ -69,7 +69,7 @@ public final class AssetConfig {
|
|||||||
public static void loadText(AssetManager assetManager, URL configUrl) throws IOException{
|
public static void loadText(AssetManager assetManager, URL configUrl) throws IOException{
|
||||||
InputStream in = configUrl.openStream();
|
InputStream in = configUrl.openStream();
|
||||||
try {
|
try {
|
||||||
Scanner scan = new Scanner(in);
|
Scanner scan = new Scanner(in, "UTF-8");
|
||||||
scan.useLocale(Locale.US); // Fix commas / periods ??
|
scan.useLocale(Locale.US); // Fix commas / periods ??
|
||||||
while (scan.hasNext()){
|
while (scan.hasNext()){
|
||||||
String cmd = scan.next();
|
String cmd = scan.next();
|
||||||
|
@ -312,13 +312,12 @@ public class DesktopAssetManager implements AssetManager {
|
|||||||
protected <T> T registerAndCloneSmartAsset(AssetKey<T> key, T obj, AssetProcessor proc, AssetCache cache) {
|
protected <T> T registerAndCloneSmartAsset(AssetKey<T> key, T obj, AssetProcessor proc, AssetCache cache) {
|
||||||
// object obj is the original asset
|
// object obj is the original asset
|
||||||
// create an instance for user
|
// create an instance for user
|
||||||
T clone = (T) obj;
|
|
||||||
if (proc == null) {
|
if (proc == null) {
|
||||||
throw new IllegalStateException("Asset implements "
|
throw new IllegalStateException("Asset implements "
|
||||||
+ "CloneableSmartAsset but doesn't "
|
+ "CloneableSmartAsset but doesn't "
|
||||||
+ "have processor to handle cloning");
|
+ "have processor to handle cloning");
|
||||||
} else {
|
} else {
|
||||||
clone = (T) proc.createClone(obj);
|
T clone = (T) proc.createClone(obj);
|
||||||
if (cache != null && clone != obj) {
|
if (cache != null && clone != obj) {
|
||||||
cache.registerAssetClone(key, clone);
|
cache.registerAssetClone(key, clone);
|
||||||
} else {
|
} else {
|
||||||
@ -326,9 +325,9 @@ public class DesktopAssetManager implements AssetManager {
|
|||||||
+ "CloneableSmartAsset but doesn't have cache or "
|
+ "CloneableSmartAsset but doesn't have cache or "
|
||||||
+ "was not cloned");
|
+ "was not cloned");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T> T loadAssetFromStream(AssetKey<T> key, InputStream inputStream) {
|
public <T> T loadAssetFromStream(AssetKey<T> key, InputStream inputStream) {
|
||||||
|
@ -47,7 +47,7 @@ import java.util.logging.Logger;
|
|||||||
* This is done by keeping an instance of each asset loader and asset
|
* This is done by keeping an instance of each asset loader and asset
|
||||||
* locator object in a thread local.
|
* locator object in a thread local.
|
||||||
*/
|
*/
|
||||||
public class ImplHandler {
|
final class ImplHandler {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(ImplHandler.class.getName());
|
private static final Logger logger = Logger.getLogger(ImplHandler.class.getName());
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class ImplHandler {
|
|||||||
this.assetManager = assetManager;
|
this.assetManager = assetManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class ImplThreadLocal<T> extends ThreadLocal {
|
protected static class ImplThreadLocal<T> extends ThreadLocal {
|
||||||
|
|
||||||
private final Class<T> type;
|
private final Class<T> type;
|
||||||
private final String path;
|
private final String path;
|
||||||
@ -83,7 +83,7 @@ public class ImplHandler {
|
|||||||
|
|
||||||
public ImplThreadLocal(Class<T> type, String[] extensions){
|
public ImplThreadLocal(Class<T> type, String[] extensions){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.extensions = extensions;
|
this.extensions = extensions.clone();
|
||||||
this.path = null;
|
this.path = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ import java.io.IOException;
|
|||||||
* the light intensity slowly decrease between the inner cone and the outer cone.
|
* the light intensity slowly decrease between the inner cone and the outer cone.
|
||||||
* @author Nehon
|
* @author Nehon
|
||||||
*/
|
*/
|
||||||
public class SpotLight extends Light implements Savable {
|
public class SpotLight extends Light {
|
||||||
|
|
||||||
protected Vector3f position = new Vector3f();
|
protected Vector3f position = new Vector3f();
|
||||||
protected Vector3f direction = new Vector3f(0,-1,0);
|
protected Vector3f direction = new Vector3f(0,-1,0);
|
||||||
|
@ -64,7 +64,7 @@ import java.util.logging.Logger;
|
|||||||
* TODO more automagic (batch when needed in the updateLogicalState)
|
* TODO more automagic (batch when needed in the updateLogicalState)
|
||||||
* @author Nehon
|
* @author Nehon
|
||||||
*/
|
*/
|
||||||
public class BatchNode extends GeometryGroupNode implements Savable {
|
public class BatchNode extends GeometryGroupNode {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(BatchNode.class.getName());
|
private static final Logger logger = Logger.getLogger(BatchNode.class.getName());
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +58,7 @@ import java.util.logging.Logger;
|
|||||||
* @author Gregg Patton
|
* @author Gregg Patton
|
||||||
* @author Joshua Slack
|
* @author Joshua Slack
|
||||||
*/
|
*/
|
||||||
public class Node extends Spatial implements Savable {
|
public class Node extends Spatial {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(Node.class.getName());
|
private static final Logger logger = Logger.getLogger(Node.class.getName());
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class InstancedNode extends GeometryGroupNode {
|
|||||||
setGeometryStartIndex(geom, startIndex);
|
setGeometryStartIndex(geom, startIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class InstanceTypeKey implements Cloneable {
|
private static final class InstanceTypeKey implements Cloneable {
|
||||||
|
|
||||||
Mesh mesh;
|
Mesh mesh;
|
||||||
Material material;
|
Material material;
|
||||||
|
@ -40,7 +40,7 @@ import java.io.IOException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
public class DefineList implements Savable, Cloneable {
|
public final class DefineList implements Savable, Cloneable {
|
||||||
|
|
||||||
private static final String ONE = "1";
|
private static final String ONE = "1";
|
||||||
|
|
||||||
|
@ -72,9 +72,10 @@ import java.util.ArrayList;
|
|||||||
* @author Kirill Vainer
|
* @author Kirill Vainer
|
||||||
*/
|
*/
|
||||||
public class FrameBuffer extends NativeObject {
|
public class FrameBuffer extends NativeObject {
|
||||||
public static int SLOT_UNDEF = -1;
|
|
||||||
public static int SLOT_DEPTH = -100;
|
public static final int SLOT_UNDEF = -1;
|
||||||
public static int SLOT_DEPTH_STENCIL = -101;
|
public static final int SLOT_DEPTH = -100;
|
||||||
|
public static final int SLOT_DEPTH_STENCIL = -101;
|
||||||
|
|
||||||
private int width = 0;
|
private int width = 0;
|
||||||
private int height = 0;
|
private int height = 0;
|
||||||
|
@ -34,6 +34,7 @@ package com.jme3.util;
|
|||||||
import com.jme3.util.IntMap.Entry;
|
import com.jme3.util.IntMap.Entry;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to a {@link Map} except that ints are used as keys.
|
* Similar to a {@link Map} except that ints are used as keys.
|
||||||
@ -234,7 +235,7 @@ public final class IntMap<T> implements Iterable<Entry<T>>, Cloneable {
|
|||||||
|
|
||||||
public Entry next() {
|
public Entry next() {
|
||||||
if (el >= size)
|
if (el >= size)
|
||||||
throw new IllegalStateException("No more elements!");
|
throw new NoSuchElementException("No more elements!");
|
||||||
|
|
||||||
if (cur != null){
|
if (cur != null){
|
||||||
Entry e = cur;
|
Entry e = cur;
|
||||||
|
@ -274,12 +274,10 @@ public class TangentBinormalGenerator {
|
|||||||
triData.setIndex(index);
|
triData.setIndex(index);
|
||||||
triData.triangleOffset = i * 3 ;
|
triData.triangleOffset = i * 3 ;
|
||||||
}
|
}
|
||||||
if (triData != null) {
|
|
||||||
vertices.get(index[0]).triangles.add(triData);
|
vertices.get(index[0]).triangles.add(triData);
|
||||||
vertices.get(index[1]).triangles.add(triData);
|
vertices.get(index[1]).triangles.add(triData);
|
||||||
vertices.get(index[2]).triangles.add(triData);
|
vertices.get(index[2]).triangles.add(triData);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return vertices;
|
return vertices;
|
||||||
}
|
}
|
||||||
@ -483,7 +481,7 @@ public class TangentBinormalGenerator {
|
|||||||
boolean isDegenerate = isDegenerateTriangle(v[0], v[1], v[2]);
|
boolean isDegenerate = isDegenerateTriangle(v[0], v[1], v[2]);
|
||||||
TriangleData triData = processTriangle(index, v, t);
|
TriangleData triData = processTriangle(index, v, t);
|
||||||
|
|
||||||
if (triData != null && !isDegenerate) {
|
if (!isDegenerate) {
|
||||||
vertices.get(index[0]).triangles.add(triData);
|
vertices.get(index[0]).triangles.add(triData);
|
||||||
vertices.get(index[1]).triangles.add(triData);
|
vertices.get(index[1]).triangles.add(triData);
|
||||||
vertices.get(index[2]).triangles.add(triData);
|
vertices.get(index[2]).triangles.add(triData);
|
||||||
@ -529,11 +527,9 @@ public class TangentBinormalGenerator {
|
|||||||
populateFromBuffer(t[2], textureBuffer, index[2]);
|
populateFromBuffer(t[2], textureBuffer, index[2]);
|
||||||
|
|
||||||
TriangleData triData = processTriangle(index, v, t);
|
TriangleData triData = processTriangle(index, v, t);
|
||||||
if (triData != null) {
|
|
||||||
vertices.get(index[0]).triangles.add(triData);
|
vertices.get(index[0]).triangles.add(triData);
|
||||||
vertices.get(index[1]).triangles.add(triData);
|
vertices.get(index[1]).triangles.add(triData);
|
||||||
vertices.get(index[2]).triangles.add(triData);
|
vertices.get(index[2]).triangles.add(triData);
|
||||||
}
|
|
||||||
|
|
||||||
Vector3f vTemp = v[1];
|
Vector3f vTemp = v[1];
|
||||||
v[1] = v[2];
|
v[1] = v[2];
|
||||||
|
@ -71,7 +71,7 @@ public class BlockLanguageParser {
|
|||||||
private void load(InputStream in) throws IOException{
|
private void load(InputStream in) throws IOException{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
reader = new InputStreamReader(in);
|
reader = new InputStreamReader(in, "UTF-8");
|
||||||
|
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
boolean insideComment = false;
|
boolean insideComment = false;
|
||||||
|
@ -196,7 +196,7 @@ public class WAVLoader implements AssetLoader {
|
|||||||
break;
|
break;
|
||||||
case i_data:
|
case i_data:
|
||||||
// Compute duration based on data chunk size
|
// Compute duration based on data chunk size
|
||||||
duration = len / bytesPerSec;
|
duration = (float)(len / bytesPerSec);
|
||||||
|
|
||||||
if (readStream) {
|
if (readStream) {
|
||||||
readDataChunkForStream(inOffset, len);
|
readDataChunkForStream(inOffset, len);
|
||||||
|
@ -270,11 +270,9 @@ public final class BinaryImporter implements JmeImporter {
|
|||||||
try {
|
try {
|
||||||
return load(fis, listener);
|
return load(fis, listener);
|
||||||
} finally {
|
} finally {
|
||||||
if (fis != null) {
|
|
||||||
fis.close();
|
fis.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Savable load(byte[] data) throws IOException {
|
public Savable load(byte[] data) throws IOException {
|
||||||
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user