diff --git a/gson/src/main/java/com/google/gson/DefaultConstructorAllocator.java b/gson/src/main/java/com/google/gson/DefaultConstructorAllocator.java index b8df6407..5837fcc8 100644 --- a/gson/src/main/java/com/google/gson/DefaultConstructorAllocator.java +++ b/gson/src/main/java/com/google/gson/DefaultConstructorAllocator.java @@ -38,8 +38,8 @@ final class DefaultConstructorAllocator { } // for testing purpose - final Cache, Constructor> getConstructorCache() { - return constructorCache; + final boolean isInCache(Class cacheKey) { + return constructorCache.getElement(cacheKey) != null; } private static final Constructor createNullConstructor() { diff --git a/gson/src/test/java/com/google/gson/DefaultConstructorAllocatorTest.java b/gson/src/test/java/com/google/gson/DefaultConstructorAllocatorTest.java index 820e79dc..c20443b8 100644 --- a/gson/src/test/java/com/google/gson/DefaultConstructorAllocatorTest.java +++ b/gson/src/test/java/com/google/gson/DefaultConstructorAllocatorTest.java @@ -16,8 +16,6 @@ package com.google.gson; -import com.google.gson.DefaultConstructorAllocator; - import junit.framework.TestCase; import java.util.ArrayList; @@ -41,20 +39,16 @@ public class DefaultConstructorAllocatorTest extends TestCase { public void testObjectConstructor() throws Exception { ArrayList arrayList = allocator.newInstance(ArrayList.class); assertTrue(arrayList.isEmpty()); - assertInCache(ArrayList.class); + assertTrue(allocator.isInCache(ArrayList.class)); LinkedList linkedList = allocator.newInstance(LinkedList.class); assertTrue(linkedList.isEmpty()); - assertInCache(LinkedList.class); + assertTrue(allocator.isInCache(LinkedList.class)); } public void testMissingDefaultConstructor() throws Exception { assertNull(allocator.newInstance(NoDefaultConstructor.class)); - assertInCache(NoDefaultConstructor.class); - } - - private void assertInCache(Class clazz) { - assertNotNull(allocator.getConstructorCache().getElement(clazz)); + assertTrue(allocator.isInCache(NoDefaultConstructor.class)); } private static class NoDefaultConstructor {