From 7b99419aead602bb7c6c9fc08a5556deaaf77d77 Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Wed, 3 Nov 2010 23:14:42 +0000 Subject: [PATCH] Removed compiler warnings. --- .../main/java/com/google/gson/JsonSyntaxException.java | 2 +- gson/src/main/java/com/google/gson/LruCache.java | 2 ++ gson/src/main/java/com/google/gson/Streams.java | 4 ++-- gson/src/main/java/com/google/gson/stream/JsonReader.java | 8 ++++++-- .../test/java/com/google/gson/stream/JsonReaderTest.java | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gson/src/main/java/com/google/gson/JsonSyntaxException.java b/gson/src/main/java/com/google/gson/JsonSyntaxException.java index 23447e40..ffd875c5 100644 --- a/gson/src/main/java/com/google/gson/JsonSyntaxException.java +++ b/gson/src/main/java/com/google/gson/JsonSyntaxException.java @@ -36,7 +36,7 @@ public final class JsonSyntaxException extends JsonParseException { /** * Creates exception with the specified cause. Consider using - * {@link #JsonIOException(String, Throwable)} instead if you can describe what happened. + * {@link #JsonSyntaxException(String, Throwable)} instead if you can describe what happened. * * @param cause root exception that caused this exception to be thrown. */ diff --git a/gson/src/main/java/com/google/gson/LruCache.java b/gson/src/main/java/com/google/gson/LruCache.java index 126f6ad6..947327e4 100644 --- a/gson/src/main/java/com/google/gson/LruCache.java +++ b/gson/src/main/java/com/google/gson/LruCache.java @@ -41,6 +41,7 @@ final class LruCache extends LinkedHashMap implements Cache { put(key, value); } + @Override public void clear() { super.clear(); } @@ -53,6 +54,7 @@ final class LruCache extends LinkedHashMap implements Cache { return remove(key); } + @Override public int size() { return super.size(); } diff --git a/gson/src/main/java/com/google/gson/Streams.java b/gson/src/main/java/com/google/gson/Streams.java index 73b00949..c1c54dab 100644 --- a/gson/src/main/java/com/google/gson/Streams.java +++ b/gson/src/main/java/com/google/gson/Streams.java @@ -154,8 +154,8 @@ final class Streams { appendable.append((char) i); } - @Override public void flush() throws IOException {} - @Override public void close() throws IOException {} + @Override public void flush() {} + @Override public void close() {} /** * A mutable char sequence pointing at a single char[]. diff --git a/gson/src/main/java/com/google/gson/stream/JsonReader.java b/gson/src/main/java/com/google/gson/stream/JsonReader.java index a136b3bb..46a2a521 100644 --- a/gson/src/main/java/com/google/gson/stream/JsonReader.java +++ b/gson/src/main/java/com/google/gson/stream/JsonReader.java @@ -564,7 +564,7 @@ public final class JsonReader implements Closeable { } catch (NumberFormatException ignored) { double asDouble = Double.parseDouble(value); // don't catch this NumberFormatException result = (long) asDouble; - if ((double) result != asDouble) { + if (result != asDouble) { throw new NumberFormatException(value); } } @@ -599,7 +599,7 @@ public final class JsonReader implements Closeable { } catch (NumberFormatException ignored) { double asDouble = Double.parseDouble(value); // don't catch this NumberFormatException result = (int) asDouble; - if ((double) result != asDouble) { + if (result != asDouble) { throw new NumberFormatException(value); } } @@ -665,6 +665,7 @@ public final class JsonReader implements Closeable { stack.set(stack.size() - 1, newTop); } + @SuppressWarnings("fallthrough") private JsonToken nextInArray(boolean firstElement) throws IOException { if (firstElement) { replaceTop(JsonScope.NONEMPTY_ARRAY); @@ -706,6 +707,7 @@ public final class JsonReader implements Closeable { } } + @SuppressWarnings("fallthrough") private JsonToken nextInObject(boolean firstElement) throws IOException { /* * Read delimiters. Either a comma/semicolon separating this and the @@ -780,6 +782,7 @@ public final class JsonReader implements Closeable { return nextValue(); } + @SuppressWarnings("fallthrough") private JsonToken nextValue() throws IOException { int c = nextNonWhitespace(); switch (c) { @@ -968,6 +971,7 @@ public final class JsonReader implements Closeable { * Returns the string up to but not including any delimiter characters. This * does not consume the delimiter character. */ + @SuppressWarnings("fallthrough") private String nextLiteral() throws IOException { StringBuilder builder = null; do { diff --git a/gson/src/test/java/com/google/gson/stream/JsonReaderTest.java b/gson/src/test/java/com/google/gson/stream/JsonReaderTest.java index 7ca13873..b7f76e9e 100644 --- a/gson/src/test/java/com/google/gson/stream/JsonReaderTest.java +++ b/gson/src/test/java/com/google/gson/stream/JsonReaderTest.java @@ -97,7 +97,7 @@ public final class JsonReaderTest extends TestCase { } } - public void testEmptyString() throws IOException { + public void testEmptyString() { try { new JsonReader(new StringReader("")).beginArray(); } catch (IOException expected) { @@ -108,7 +108,7 @@ public final class JsonReaderTest extends TestCase { } } - public void testNoTopLevelObject() throws IOException { + public void testNoTopLevelObject() { try { new JsonReader(new StringReader("true")).nextBoolean(); } catch (IOException expected) {