From 1575e2a1d3587d7f28bb20b548b2b0bcf917c05a Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Fri, 21 Aug 2015 22:24:51 -0400 Subject: [PATCH] minor changes according to static analyzer --- .../src/main/java/com/jme3/light/PointLight.java | 4 ++-- .../main/java/com/jme3/system/AppSettings.java | 2 ++ .../src/main/java/com/jme3/util/BufferUtils.java | 15 ++++++++++----- .../src/main/java/com/jme3/util/LittleEndien.java | 4 +--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/light/PointLight.java b/jme3-core/src/main/java/com/jme3/light/PointLight.java index 55a129275..6548ee7fe 100644 --- a/jme3-core/src/main/java/com/jme3/light/PointLight.java +++ b/jme3-core/src/main/java/com/jme3/light/PointLight.java @@ -120,8 +120,8 @@ public class PointLight extends Light { throw new IllegalArgumentException("Light radius cannot be negative"); } this.radius = radius; - if (radius != 0) { - this.invRadius = 1 / radius; + if (radius != 0f) { + this.invRadius = 1f / radius; } else { this.invRadius = 0; } diff --git a/jme3-core/src/main/java/com/jme3/system/AppSettings.java b/jme3-core/src/main/java/com/jme3/system/AppSettings.java index 73b036f2f..484458929 100644 --- a/jme3-core/src/main/java/com/jme3/system/AppSettings.java +++ b/jme3-core/src/main/java/com/jme3/system/AppSettings.java @@ -54,6 +54,8 @@ import java.util.prefs.Preferences; */ public final class AppSettings extends HashMap { + private static final long serialVersionUID = 1L; + private static final AppSettings defaults = new AppSettings(false); /** diff --git a/jme3-core/src/main/java/com/jme3/util/BufferUtils.java b/jme3-core/src/main/java/com/jme3/util/BufferUtils.java index 84c6f6743..6fc0c50f0 100644 --- a/jme3-core/src/main/java/com/jme3/util/BufferUtils.java +++ b/jme3-core/src/main/java/com/jme3/util/BufferUtils.java @@ -36,6 +36,7 @@ import com.jme3.math.Quaternion; import com.jme3.math.Vector2f; import com.jme3.math.Vector3f; import com.jme3.math.Vector4f; +import java.io.UnsupportedEncodingException; import java.lang.ref.PhantomReference; import java.lang.ref.Reference; import java.lang.ref.ReferenceQueue; @@ -1010,11 +1011,15 @@ public final class BufferUtils { } public static ByteBuffer createByteBuffer(String data) { - byte[] bytes = data.getBytes(); - ByteBuffer bb = createByteBuffer(bytes.length); - bb.put(bytes); - bb.flip(); - return bb; + try { + byte[] bytes = data.getBytes("UTF-8"); + ByteBuffer bb = createByteBuffer(bytes.length); + bb.put(bytes); + bb.flip(); + return bb; + } catch (UnsupportedEncodingException ex) { + throw new UnsupportedOperationException(ex); + } } /** diff --git a/jme3-core/src/main/java/com/jme3/util/LittleEndien.java b/jme3-core/src/main/java/com/jme3/util/LittleEndien.java index 092f77018..6b15a7d45 100644 --- a/jme3-core/src/main/java/com/jme3/util/LittleEndien.java +++ b/jme3-core/src/main/java/com/jme3/util/LittleEndien.java @@ -42,7 +42,6 @@ import java.io.*; public class LittleEndien extends InputStream implements DataInput { protected BufferedInputStream in; - protected BufferedReader inRead; /** * Creates a new LittleEndien reader from the given input stream. The @@ -51,7 +50,6 @@ public class LittleEndien extends InputStream implements DataInput { */ public LittleEndien(InputStream in) { this.in = new BufferedInputStream(in); - inRead = new BufferedReader(new InputStreamReader(in)); } public int read() throws IOException { @@ -141,7 +139,7 @@ public class LittleEndien extends InputStream implements DataInput { } public String readLine() throws IOException { - return inRead.readLine(); + throw new IOException("Unsupported operation"); } public String readUTF() throws IOException {