From de326e5e95b066bfae6905fee79c6fa3fd601eec Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 18 May 2010 08:49:09 +0000 Subject: [PATCH] ClassUtils recognizes "void" as primitive type name as well (SPR-7212) --- .../src/main/java/org/springframework/util/ClassUtils.java | 5 +++-- .../test/java/org/springframework/util/ClassUtilsTests.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java b/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java index aa3cee29fb..f771a5e921 100644 --- a/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java +++ b/org.springframework.core/src/main/java/org/springframework/util/ClassUtils.java @@ -89,7 +89,7 @@ public abstract class ClassUtils { * Map with primitive type name as key and corresponding primitive * type as value, for example: "int" -> "int.class". */ - private static final Map> primitiveTypeNameMap = new HashMap>(16); + private static final Map> primitiveTypeNameMap = new HashMap>(32); /** * Map with common "java.lang" class name as key and corresponding Class as value. @@ -113,11 +113,12 @@ public abstract class ClassUtils { registerCommonClasses(entry.getKey()); } - Set> primitiveTypes = new HashSet>(16); + Set> primitiveTypes = new HashSet>(32); primitiveTypes.addAll(primitiveWrapperTypeMap.values()); primitiveTypes.addAll(Arrays.asList( boolean[].class, byte[].class, char[].class, double[].class, float[].class, int[].class, long[].class, short[].class)); + primitiveTypes.add(void.class); for (Class primitiveType : primitiveTypes) { primitiveTypeNameMap.put(primitiveType.getName(), primitiveType); } diff --git a/org.springframework.core/src/test/java/org/springframework/util/ClassUtilsTests.java b/org.springframework.core/src/test/java/org/springframework/util/ClassUtilsTests.java index ccd443f506..60396f11a3 100644 --- a/org.springframework.core/src/test/java/org/springframework/util/ClassUtilsTests.java +++ b/org.springframework.core/src/test/java/org/springframework/util/ClassUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,6 @@ import java.util.List; import junit.framework.TestCase; -import org.junit.Ignore; import org.springframework.beans.DerivedTestBean; import org.springframework.beans.IOther; import org.springframework.beans.ITestBean; @@ -76,6 +75,7 @@ public class ClassUtilsTests extends TestCase { assertEquals(long.class, ClassUtils.forName("long")); assertEquals(float.class, ClassUtils.forName("float")); assertEquals(double.class, ClassUtils.forName("double")); + assertEquals(void.class, ClassUtils.forName("void")); } public void testForNameWithPrimitiveArrays() throws ClassNotFoundException {