From b51ffc1060103ab27cfc6a6f107f04111ba098f6 Mon Sep 17 00:00:00 2001 From: Inderjeet Singh Date: Thu, 24 Mar 2011 20:08:56 +0000 Subject: [PATCH] Removed eclipse warnings about missing overrides and declared exceptions that are never thrown. --- .../main/java/com/google/gson/internal/UnsafeAllocator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java b/gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java index 00bb411b..ec6c355e 100644 --- a/gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java +++ b/gson/src/main/java/com/google/gson/internal/UnsafeAllocator.java @@ -42,6 +42,7 @@ public abstract class UnsafeAllocator { final Object unsafe = f.get(null); final Method allocateInstance = unsafeClass.getMethod("allocateInstance", Class.class); return new UnsafeAllocator() { + @Override @SuppressWarnings("unchecked") public T newInstance(Class c) throws Exception { return (T) allocateInstance.invoke(unsafe, c); @@ -60,6 +61,7 @@ public abstract class UnsafeAllocator { .getDeclaredMethod("newInstance", Class.class, Class.class); newInstance.setAccessible(true); return new UnsafeAllocator() { + @Override @SuppressWarnings("unchecked") public T newInstance(Class c) throws Exception { return (T) newInstance.invoke(null, c, Object.class); @@ -82,6 +84,7 @@ public abstract class UnsafeAllocator { .getDeclaredMethod("newInstance", Class.class, int.class); newInstance.setAccessible(true); return new UnsafeAllocator() { + @Override @SuppressWarnings("unchecked") public T newInstance(Class c) throws Exception { return (T) newInstance.invoke(null, c, constructorId); @@ -92,7 +95,8 @@ public abstract class UnsafeAllocator { // give up return new UnsafeAllocator() { - public T newInstance(Class c) throws InstantiationException { + @Override + public T newInstance(Class c) { throw new UnsupportedOperationException("Cannot allocate " + c); } };