You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by oh...@apache.org on 2013/10/27 21:32:17 UTC

svn commit: r1536196 - in /commons/proper/beanutils/branches/java5/src: main/java/org/apache/commons/beanutils/ test/java/org/apache/commons/beanutils/

Author: oheger
Date: Sun Oct 27 20:32:16 2013
New Revision: 1536196

URL: http://svn.apache.org/r1536196
Log:
Generified PropertyUtilsBean and PropertyUtils.

Modified:
    commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtils.java
    commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java
    commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java

Modified: commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtils.java?rev=1536196&r1=1536195&r2=1536196&view=diff
==============================================================================
--- commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtils.java (original)
+++ commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtils.java Sun Oct 27 20:32:16 2013
@@ -203,7 +203,7 @@ public class PropertyUtils {
      *  propety cannot be found
      * @see PropertyUtilsBean#describe
      */
-    public static Map describe(Object bean)
+    public static Map<String, Object> describe(Object bean)
             throws IllegalAccessException, InvocationTargetException,
             NoSuchMethodException {
 
@@ -344,7 +344,7 @@ public class PropertyUtils {
      * @deprecated This method should not be exposed
      */
     @Deprecated
-    public static FastHashMap getMappedPropertyDescriptors(Class beanClass) {
+    public static FastHashMap getMappedPropertyDescriptors(Class<?> beanClass) {
 
         return PropertyUtilsBean.getInstance().getMappedPropertyDescriptors(beanClass);
 
@@ -478,7 +478,7 @@ public class PropertyUtils {
      * @see PropertyUtilsBean#getPropertyDescriptors(Class)
      */
     public static PropertyDescriptor[]
-            getPropertyDescriptors(Class beanClass) {
+            getPropertyDescriptors(Class<?> beanClass) {
 
         return PropertyUtilsBean.getInstance().getPropertyDescriptors(beanClass);
 
@@ -527,7 +527,7 @@ public class PropertyUtils {
      *  propety cannot be found
      * @see PropertyUtilsBean#getPropertyEditorClass(Object,String)
      */
-    public static Class getPropertyEditorClass(Object bean, String name)
+    public static Class<?> getPropertyEditorClass(Object bean, String name)
             throws IllegalAccessException, InvocationTargetException,
             NoSuchMethodException {
 
@@ -560,7 +560,7 @@ public class PropertyUtils {
      *  propety cannot be found
      * @see PropertyUtilsBean#getPropertyType(Object, String)
      */
-    public static Class getPropertyType(Object bean, String name)
+    public static Class<?> getPropertyType(Object bean, String name)
             throws IllegalAccessException, InvocationTargetException,
             NoSuchMethodException {
 

Modified: commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java?rev=1536196&r1=1536195&r2=1536196&view=diff
==============================================================================
--- commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java (original)
+++ commons/proper/beanutils/branches/java5/src/main/java/org/apache/commons/beanutils/PropertyUtilsBean.java Sun Oct 27 20:32:16 2013
@@ -30,6 +30,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.commons.beanutils.expression.DefaultResolver;
 import org.apache.commons.beanutils.expression.Resolver;
@@ -112,10 +113,10 @@ public class PropertyUtilsBean {
      * The cache of PropertyDescriptor arrays for beans we have already
      * introspected, keyed by the java.lang.Class of this object.
      */
-    private WeakFastHashMap descriptorsCache = null;
-    private WeakFastHashMap mappedDescriptorsCache = null;
-    private static final Class[] EMPTY_CLASS_PARAMETERS = new Class[0];
-    private static final Class[] LIST_CLASS_PARAMETER = new Class[] {java.util.List.class};
+    private WeakFastHashMap<Class<?>, PropertyDescriptor[]> descriptorsCache = null;
+    private WeakFastHashMap<Class<?>, FastHashMap> mappedDescriptorsCache = null;
+    private static final Class<?>[] EMPTY_CLASS_PARAMETERS = new Class[0];
+    private static final Class<?>[] LIST_CLASS_PARAMETER = new Class[] {java.util.List.class};
 
     /** An empty object array */
     private static final Object[] EMPTY_OBJECT_ARRAY = new Object[0];
@@ -127,9 +128,9 @@ public class PropertyUtilsBean {
 
     /** Base constructor */
     public PropertyUtilsBean() {
-        descriptorsCache = new WeakFastHashMap();
+        descriptorsCache = new WeakFastHashMap<Class<?>, PropertyDescriptor[]>();
         descriptorsCache.setFast(true);
-        mappedDescriptorsCache = new WeakFastHashMap();
+        mappedDescriptorsCache = new WeakFastHashMap<Class<?>, FastHashMap>();
         mappedDescriptorsCache.setFast(true);
     }
 
@@ -253,9 +254,9 @@ public class PropertyUtilsBean {
                 }
             }
         } else if (orig instanceof Map) {
-            Iterator entries = ((Map) orig).entrySet().iterator();
+            Iterator<?> entries = ((Map<?, ?>) orig).entrySet().iterator();
             while (entries.hasNext()) {
-                Map.Entry entry = (Map.Entry) entries.next();
+                Map.Entry<?, ?> entry = (Entry<?, ?>) entries.next();
                 String name = (String)entry.getKey();
                 if (isWriteable(dest, name)) {
                     try {
@@ -315,14 +316,14 @@ public class PropertyUtilsBean {
      * @exception NoSuchMethodException if an accessor method for this
      *  propety cannot be found
      */
-    public Map describe(Object bean)
+    public Map<String, Object> describe(Object bean)
             throws IllegalAccessException, InvocationTargetException,
             NoSuchMethodException {
 
         if (bean == null) {
             throw new IllegalArgumentException("No bean specified");
         }
-        Map description = new HashMap();
+        Map<String, Object> description = new HashMap<String, Object>();
         if (bean instanceof DynaBean) {
             DynaProperty[] descriptors =
                 ((DynaBean) bean).getDynaClass().getDynaProperties();
@@ -438,7 +439,7 @@ public class PropertyUtilsBean {
             if (bean.getClass().isArray()) {
                 return Array.get(bean, index);
             } else if (bean instanceof List) {
-                return ((List)bean).get(index);
+                return ((List<?>)bean).get(index);
             }
         }
         if (name == null) {
@@ -502,7 +503,7 @@ public class PropertyUtilsBean {
                         "' is not indexed on bean class '" + bean.getClass() + "'");
             } else {
                 //get the List's value
-                return ((java.util.List) value).get(index);
+                return ((java.util.List<?>) value).get(index);
             }
         } else {
             //get the array's value
@@ -646,7 +647,7 @@ public class PropertyUtilsBean {
             Object invokeResult = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
             /* test and fetch from the map */
             if (invokeResult instanceof java.util.Map) {
-              result = ((java.util.Map)invokeResult).get(key);
+              result = ((java.util.Map<?, ?>)invokeResult).get(key);
             }
           } else {
             throw new NoSuchMethodException("Property '" + name +
@@ -669,14 +670,14 @@ public class PropertyUtilsBean {
      * @deprecated This method should not be exposed
      */
     @Deprecated
-    public FastHashMap getMappedPropertyDescriptors(Class beanClass) {
+    public FastHashMap getMappedPropertyDescriptors(Class<?> beanClass) {
 
         if (beanClass == null) {
             return null;
         }
 
         // Look up any cached descriptors for this bean class
-        return (FastHashMap) mappedDescriptorsCache.get(beanClass);
+        return mappedDescriptorsCache.get(beanClass);
 
     }
 
@@ -737,7 +738,7 @@ public class PropertyUtilsBean {
             String next = resolver.next(name);
             Object nestedBean = null;
             if (bean instanceof Map) {
-                nestedBean = getPropertyOfMapBean((Map) bean, next);
+                nestedBean = getPropertyOfMapBean((Map<?, ?>) bean, next);
             } else if (resolver.isMapped(next)) {
                 nestedBean = getMappedProperty(bean, next);
             } else if (resolver.isIndexed(next)) {
@@ -755,7 +756,7 @@ public class PropertyUtilsBean {
         }
 
         if (bean instanceof Map) {
-            bean = getPropertyOfMapBean((Map) bean, name);
+            bean = getPropertyOfMapBean((Map<?, ?>) bean, name);
         } else if (resolver.isMapped(name)) {
             bean = getMappedProperty(bean, name);
         } else if (resolver.isIndexed(name)) {
@@ -791,7 +792,7 @@ public class PropertyUtilsBean {
      * no simple method is available.
      * @since 1.8.0
      */
-    protected Object getPropertyOfMapBean(Map bean, String propertyName)
+    protected Object getPropertyOfMapBean(Map<?, ?> bean, String propertyName)
         throws IllegalArgumentException, IllegalAccessException,
         InvocationTargetException, NoSuchMethodException {
 
@@ -954,7 +955,7 @@ public class PropertyUtilsBean {
      * @exception IllegalArgumentException if <code>beanClass</code> is null
      */
     public PropertyDescriptor[]
-            getPropertyDescriptors(Class beanClass) {
+            getPropertyDescriptors(Class<?> beanClass) {
 
         if (beanClass == null) {
             throw new IllegalArgumentException("No bean class specified");
@@ -963,7 +964,7 @@ public class PropertyUtilsBean {
         // Look up any cached descriptors for this bean class
         PropertyDescriptor[] descriptors = null;
         descriptors =
-                (PropertyDescriptor[]) descriptorsCache.get(beanClass);
+                descriptorsCache.get(beanClass);
         if (descriptors != null) {
             return (descriptors);
         }
@@ -1031,7 +1032,7 @@ public class PropertyUtilsBean {
                         Method[] methods = beanClass.getMethods();
                         for (int j = 0; j < methods.length; j++) {
                             if (methods[j].getName().equals(methodName)) {
-                                Class[] parameterTypes = methods[j].getParameterTypes();
+                                Class<?>[] parameterTypes = methods[j].getParameterTypes();
                                 if (parameterTypes.length == 1 &&
                                     List.class.isAssignableFrom(parameterTypes[0])) {
                                     writeMethod = methods[j];
@@ -1110,7 +1111,7 @@ public class PropertyUtilsBean {
      * @exception NoSuchMethodException if an accessor method for this
      *  propety cannot be found
      */
-    public Class getPropertyEditorClass(Object bean, String name)
+    public Class<?> getPropertyEditorClass(Object bean, String name)
             throws IllegalAccessException, InvocationTargetException,
             NoSuchMethodException {
 
@@ -1158,7 +1159,7 @@ public class PropertyUtilsBean {
      * @exception NoSuchMethodException if an accessor method for this
      *  propety cannot be found
      */
-    public Class getPropertyType(Object bean, String name)
+    public Class<?> getPropertyType(Object bean, String name)
             throws IllegalAccessException, InvocationTargetException,
             NoSuchMethodException {
 
@@ -1193,7 +1194,7 @@ public class PropertyUtilsBean {
             if (descriptor == null) {
                 return (null);
             }
-            Class type = descriptor.getType();
+            Class<?> type = descriptor.getType();
             if (type == null) {
                 return (null);
             } else if (type.isArray()) {
@@ -1246,7 +1247,7 @@ public class PropertyUtilsBean {
      * @param descriptor Property descriptor to return a getter for
      * @return The read method
      */
-    Method getReadMethod(Class clazz, PropertyDescriptor descriptor) {
+    Method getReadMethod(Class<?> clazz, PropertyDescriptor descriptor) {
         return (MethodUtils.getAccessibleMethod(clazz, descriptor.getReadMethod()));
     }
 
@@ -1355,7 +1356,7 @@ public class PropertyUtilsBean {
      * @param descriptor Property descriptor to return a setter for
      * @return The write method
      */
-    Method getWriteMethod(Class clazz, PropertyDescriptor descriptor) {
+    Method getWriteMethod(Class<?> clazz, PropertyDescriptor descriptor) {
         return (MethodUtils.getAccessibleMethod(clazz, descriptor.getWriteMethod()));
     }
 
@@ -1637,7 +1638,8 @@ public class PropertyUtilsBean {
                 Array.set(bean, index, value);
                 return;
             } else if (bean instanceof List) {
-                ((List)bean).set(index, value);
+                List<Object> list = toObjectList(bean);
+                list.set(index, value);
                 return;
             }
         }
@@ -1711,7 +1713,8 @@ public class PropertyUtilsBean {
         if (!array.getClass().isArray()) {
             if (array instanceof List) {
                 // Modify the specified value in the List
-                ((List) array).set(index, value);
+                List<Object> list = toObjectList(array);
+                list.set(index, value);
             } else {
                 throw new IllegalArgumentException("Property '" + name +
                         "' is not indexed on bean class '" + bean.getClass() + "'");
@@ -1864,7 +1867,8 @@ public class PropertyUtilsBean {
             Object invokeResult = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
             /* test and fetch from the map */
             if (invokeResult instanceof java.util.Map) {
-              ((java.util.Map)invokeResult).put(key, value);
+              java.util.Map<String, Object> map = toPropertyMap(invokeResult);
+              map.put(key, value);
             }
           } else {
             throw new NoSuchMethodException("Property '" + name +
@@ -1924,7 +1928,7 @@ public class PropertyUtilsBean {
             String next = resolver.next(name);
             Object nestedBean = null;
             if (bean instanceof Map) {
-                nestedBean = getPropertyOfMapBean((Map)bean, next);
+                nestedBean = getPropertyOfMapBean((Map<?, ?>)bean, next);
             } else if (resolver.isMapped(next)) {
                 nestedBean = getMappedProperty(bean, next);
             } else if (resolver.isIndexed(next)) {
@@ -1942,7 +1946,7 @@ public class PropertyUtilsBean {
         }
 
         if (bean instanceof Map) {
-            setPropertyOfMapBean((Map) bean, name, value);
+            setPropertyOfMapBean(toPropertyMap(bean), name, value);
         } else if (resolver.isMapped(name)) {
             setMappedProperty(bean, name, value);
         } else if (resolver.isIndexed(name)) {
@@ -2009,7 +2013,7 @@ public class PropertyUtilsBean {
      * no simple method is available.
      * @since 1.8.0
      */
-    protected void setPropertyOfMapBean(Map bean, String propertyName, Object value)
+    protected void setPropertyOfMapBean(Map<String, Object> bean, String propertyName, Object value)
         throws IllegalArgumentException, IllegalAccessException,
         InvocationTargetException, NoSuchMethodException {
 
@@ -2180,7 +2184,7 @@ public class PropertyUtilsBean {
                 }
             }
             String expectedString = "";
-            Class[] parTypes = method.getParameterTypes();
+            Class<?>[] parTypes = method.getParameterTypes();
             if (parTypes != null) {
                 for (int i = 0; i < parTypes.length; i++) {
                     if (i > 0) {
@@ -2217,7 +2221,7 @@ public class PropertyUtilsBean {
                 }
             }
             String expectedString = "";
-            Class[] parTypes = method.getParameterTypes();
+            Class<?>[] parTypes = method.getParameterTypes();
             if (parTypes != null) {
                 for (int i = 0; i < parTypes.length; i++) {
                     if (i > 0) {
@@ -2242,4 +2246,34 @@ public class PropertyUtilsBean {
 
         }
     }
+
+    /**
+     * Converts an object to a list of objects. This method is used when dealing
+     * with indexed properties. It assumes that indexed properties are stored as
+     * lists of objects.
+     *
+     * @param obj the object to be converted
+     * @return the resulting list of objects
+     */
+    private static List<Object> toObjectList(Object obj) {
+        @SuppressWarnings("unchecked")
+        // indexed properties are stored in lists of objects
+        List<Object> list = (List<Object>) obj;
+        return list;
+    }
+
+    /**
+     * Converts an object to a map with property values. This method is used
+     * when dealing with mapped properties. It assumes that mapped properties
+     * are stored in a Map&lt;String, Object&gt;.
+     *
+     * @param obj the object to be converted
+     * @return the resulting properties map
+     */
+    private static Map<String, Object> toPropertyMap(Object obj) {
+        @SuppressWarnings("unchecked")
+        // mapped properties are stores in maps of type <String, Object>
+        Map<String, Object> map = (Map<String, Object>) obj;
+        return map;
+    }
 }

Modified: commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java?rev=1536196&r1=1536195&r2=1536196&view=diff
==============================================================================
--- commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java (original)
+++ commons/proper/beanutils/branches/java5/src/test/java/org/apache/commons/beanutils/PropertyUtilsTestCase.java Sun Oct 27 20:32:16 2013
@@ -253,7 +253,7 @@ public class PropertyUtilsTestCase exten
      */
     public void testCopyPropertiesMap() {
 
-        Map map = new HashMap();
+        Map<String, Object> map = new HashMap<String, Object>();
         map.put("booleanProperty", Boolean.FALSE);
         map.put("doubleProperty", new Double(333.0));
         map.put("dupProperty", new String[] { "New 0", "New 1", "New 2" });
@@ -308,7 +308,7 @@ public class PropertyUtilsTestCase exten
      */
     public void testDescribe() {
 
-        Map map = null;
+        Map<String, Object> map = null;
         try {
             map = PropertyUtils.describe(bean);
         } catch (Exception e) {
@@ -1044,7 +1044,7 @@ public class PropertyUtilsTestCase exten
     public void testGetIndexedList() {
         String[] firstArray = new String[] {"FIRST-1", "FIRST-2", "FIRST-3"};
         String[] secondArray = new String[] {"SECOND-1", "SECOND-2", "SECOND-3",  "SECOND-4"};
-        List mainList   = new ArrayList();
+        List<Object> mainList = new ArrayList<Object>();
         mainList.add(Arrays.asList(firstArray));
         mainList.add(Arrays.asList(secondArray));
         TestBean bean = new TestBean(mainList);
@@ -1065,14 +1065,14 @@ public class PropertyUtilsTestCase exten
      * Test getting a value out of a mapped Map
      */
     public void testGetIndexedMap() {
-        Map firstMap  = new HashMap();
+        Map<String, Object> firstMap  = new HashMap<String, Object>();
         firstMap.put("FIRST-KEY-1", "FIRST-VALUE-1");
         firstMap.put("FIRST-KEY-2", "FIRST-VALUE-2");
-        Map secondMap  = new HashMap();
+        Map<String, Object> secondMap  = new HashMap<String, Object>();
         secondMap.put("SECOND-KEY-1", "SECOND-VALUE-1");
         secondMap.put("SECOND-KEY-2", "SECOND-VALUE-2");
 
-        List mainList   = new ArrayList();
+        List<Object> mainList   = new ArrayList<Object>();
         mainList.add(firstMap);
         mainList.add(secondMap);
         TestBean bean = new TestBean(mainList);
@@ -1174,7 +1174,7 @@ public class PropertyUtilsTestCase exten
      */
     public void testGetMappedList() {
         TestBean bean = new TestBean();
-        List list = new ArrayList();
+        List<Object> list = new ArrayList<Object>();
         list.add("klm");
         list.add("nop");
         list.add("qrs");
@@ -1193,7 +1193,7 @@ public class PropertyUtilsTestCase exten
      */
     public void testGetMappedMap() {
         TestBean bean = new TestBean();
-        Map map = new HashMap();
+        Map<String, Object> map = new HashMap<String, Object>();
         map.put("sub-key-1", "sub-value-1");
         map.put("sub-key-2", "sub-value-2");
         map.put("sub-key-3", "sub-value-3");
@@ -1669,7 +1669,7 @@ public class PropertyUtilsTestCase exten
         // don't init!
 
         try {
-            NestedTestBean value = (NestedTestBean) PropertyUtils.getProperty(
+            PropertyUtils.getProperty(
                                 nestedBean,
                                 "simpleBeanProperty.indexedProperty[0]");
             fail("NestedNullException not thrown");
@@ -1704,7 +1704,7 @@ public class PropertyUtilsTestCase exten
      */
     public void testGetPropertyType() {
 
-        Class clazz = null;
+        Class<?> clazz = null;
         int intArray[] = new int[0];
         String stringArray[] = new String[0];
 
@@ -1906,9 +1906,8 @@ public class PropertyUtilsTestCase exten
         assertTrue("Found foo descriptor", n >= 0);
         Method reader = pd[n].getReadMethod();
         assertNotNull("Found foo read method", reader);
-        Object value = null;
         try {
-            value = reader.invoke(beanPrivate, new Class[0]);
+            reader.invoke(beanPrivate, (Object[]) new Class<?>[0]);
             fail("Foo reader did throw IllegalAccessException");
         } catch (IllegalAccessException e) {
             // Expected result for this test
@@ -2043,9 +2042,8 @@ public class PropertyUtilsTestCase exten
      */
     public void testGetSimpleIndexed() {
 
-        Object value = null;
         try {
-            value = PropertyUtils.getSimpleProperty(bean,
+            PropertyUtils.getSimpleProperty(bean,
                     "intIndexed[0]");
             fail("Should have thrown IllegalArgumentException");
         } catch (IllegalAccessException e) {
@@ -2120,9 +2118,8 @@ public class PropertyUtilsTestCase exten
      */
     public void testGetSimpleNested() {
 
-        Object value = null;
         try {
-            value = PropertyUtils.getSimpleProperty(bean,
+            PropertyUtils.getSimpleProperty(bean,
                     "nested.stringProperty");
             fail("Should have thrown IllegaArgumentException");
         } catch (IllegalAccessException e) {
@@ -2616,45 +2613,45 @@ public class PropertyUtilsTestCase exten
     public void testSetIndexedList() {
         String[] firstArray = new String[] {"FIRST-1", "FIRST-2", "FIRST-3"};
         String[] secondArray = new String[] {"SECOND-1", "SECOND-2", "SECOND-3",  "SECOND-4"};
-        List mainList   = new ArrayList();
+        List<Object> mainList   = new ArrayList<Object>();
         mainList.add(Arrays.asList(firstArray));
         mainList.add(Arrays.asList(secondArray));
         TestBean bean = new TestBean(mainList);
-        assertEquals("BEFORE", "SECOND-4", ((List)bean.getListIndexed().get(1)).get(3));
+        assertEquals("BEFORE", "SECOND-4", ((List<?>)bean.getListIndexed().get(1)).get(3));
         try {
             PropertyUtils.setProperty(bean, "listIndexed[1][3]", "SECOND-4-UPDATED");
         } catch (Throwable t) {
             fail("Threw " + t + "");
         }
-        assertEquals("AFTER", "SECOND-4-UPDATED", ((List)bean.getListIndexed().get(1)).get(3));
+        assertEquals("AFTER", "SECOND-4-UPDATED", ((List<?>)bean.getListIndexed().get(1)).get(3));
     }
 
     /**
      * Test setting a value out of a mapped Map
      */
     public void testSetIndexedMap() {
-        Map firstMap  = new HashMap();
+        Map<String, Object> firstMap  = new HashMap<String, Object>();
         firstMap.put("FIRST-KEY-1", "FIRST-VALUE-1");
         firstMap.put("FIRST-KEY-2", "FIRST-VALUE-2");
-        Map secondMap  = new HashMap();
+        Map<String, Object> secondMap  = new HashMap<String, Object>();
         secondMap.put("SECOND-KEY-1", "SECOND-VALUE-1");
         secondMap.put("SECOND-KEY-2", "SECOND-VALUE-2");
 
-        List mainList = new ArrayList();
+        List<Object> mainList = new ArrayList<Object>();
         mainList.add(firstMap);
         mainList.add(secondMap);
         TestBean bean = new TestBean(mainList);
 
-        assertEquals("BEFORE",  null,              ((Map)bean.getListIndexed().get(0)).get("FIRST-NEW-KEY"));
-        assertEquals("BEFORE",  "SECOND-VALUE-1",  ((Map)bean.getListIndexed().get(1)).get("SECOND-KEY-1"));
+        assertEquals("BEFORE",  null,              ((Map<?, ?>)bean.getListIndexed().get(0)).get("FIRST-NEW-KEY"));
+        assertEquals("BEFORE",  "SECOND-VALUE-1",  ((Map<?, ?>)bean.getListIndexed().get(1)).get("SECOND-KEY-1"));
         try {
             PropertyUtils.setProperty(bean, "listIndexed[0](FIRST-NEW-KEY)", "FIRST-NEW-VALUE");
             PropertyUtils.setProperty(bean, "listIndexed[1](SECOND-KEY-1)",  "SECOND-VALUE-1-UPDATED");
         } catch (Throwable t) {
             fail("Threw " + t + "");
         }
-        assertEquals("BEFORE", "FIRST-NEW-VALUE",         ((Map)bean.getListIndexed().get(0)).get("FIRST-NEW-KEY"));
-        assertEquals("AFTER",  "SECOND-VALUE-1-UPDATED",  ((Map)bean.getListIndexed().get(1)).get("SECOND-KEY-1"));
+        assertEquals("BEFORE", "FIRST-NEW-VALUE",         ((Map<?, ?>)bean.getListIndexed().get(0)).get("FIRST-NEW-KEY"));
+        assertEquals("AFTER",  "SECOND-VALUE-1-UPDATED",  ((Map<?, ?>)bean.getListIndexed().get(1)).get("SECOND-KEY-1"));
     }
 
 
@@ -3093,19 +3090,19 @@ public class PropertyUtilsTestCase exten
      */
     public void testSetMappedList() {
         TestBean bean = new TestBean();
-        List list = new ArrayList();
+        List<Object> list = new ArrayList<Object>();
         list.add("klm");
         list.add("nop");
         list.add("qrs");
         bean.getMapProperty().put("mappedList", list);
 
-        assertEquals("BEFORE", "klm", ((List)bean.getMapProperty().get("mappedList")).get(0));
+        assertEquals("BEFORE", "klm", ((List<?>)bean.getMapProperty().get("mappedList")).get(0));
         try {
             PropertyUtils.setProperty(bean, "mapProperty(mappedList)[0]", "KLM-UPDATED");
         } catch (Throwable t) {
             fail("Threw " + t + "");
         }
-        assertEquals("AFTER", "KLM-UPDATED", ((List)bean.getMapProperty().get("mappedList")).get(0));
+        assertEquals("AFTER", "KLM-UPDATED", ((List<?>)bean.getMapProperty().get("mappedList")).get(0));
     }
 
     /**
@@ -3113,19 +3110,19 @@ public class PropertyUtilsTestCase exten
      */
     public void testSetMappedMap() {
         TestBean bean = new TestBean();
-        Map map = new HashMap();
+        Map<String, Object> map = new HashMap<String, Object>();
         map.put("sub-key-1", "sub-value-1");
         map.put("sub-key-2", "sub-value-2");
         map.put("sub-key-3", "sub-value-3");
         bean.getMapProperty().put("mappedMap", map);
 
-        assertEquals("BEFORE", "sub-value-3", ((Map)bean.getMapProperty().get("mappedMap")).get("sub-key-3"));
+        assertEquals("BEFORE", "sub-value-3", ((Map<?, ?>)bean.getMapProperty().get("mappedMap")).get("sub-key-3"));
         try {
             PropertyUtils.setProperty(bean, "mapProperty(mappedMap)(sub-key-3)", "SUB-KEY-3-UPDATED");
         } catch (Throwable t) {
             fail("Threw " + t + "");
         }
-        assertEquals("AFTER", "SUB-KEY-3-UPDATED", ((Map)bean.getMapProperty().get("mappedMap")).get("sub-key-3"));
+        assertEquals("AFTER", "SUB-KEY-3-UPDATED", ((Map<?, ?>)bean.getMapProperty().get("mappedMap")).get("sub-key-3"));
     }
 
     /**
@@ -4011,7 +4008,7 @@ public class PropertyUtilsTestCase exten
             Method reader = PropertyUtils.getReadMethod(pd[n]);
             assertNotNull("Reader for " + properties[i],
                     reader);
-            Class clazz = reader.getDeclaringClass();
+            Class<?> clazz = reader.getDeclaringClass();
             assertNotNull("Declaring class for " + properties[i],
                     clazz);
             assertEquals("Correct declaring class for " + properties[i],
@@ -4020,7 +4017,7 @@ public class PropertyUtilsTestCase exten
 
             // Actually call the reader method we received
             try {
-                reader.invoke(bean, new Class[0]);
+                reader.invoke(bean, (Object[]) new Class<?>[0]);
             } catch (Throwable t) {
                 fail("Call for " + properties[i] + ": " + t);
             }
@@ -4070,7 +4067,7 @@ public class PropertyUtilsTestCase exten
             Method writer = PropertyUtils.getWriteMethod(pd[n]);
             assertNotNull("Writer for " + properties[i],
                     writer);
-            Class clazz = writer.getDeclaringClass();
+            Class<?> clazz = writer.getDeclaringClass();
             assertNotNull("Declaring class for " + properties[i],
                     clazz);
             assertEquals("Correct declaring class for " + properties[i],
@@ -4208,9 +4205,6 @@ public class PropertyUtilsTestCase exten
         assertEquals("Cannot set no-getter property", "Omega", bean.getSecret());
 
         // test mapped no getter descriptor
-        MappedPropertyDescriptor descriptor
-            = new MappedPropertyDescriptor("noGetterMappedProperty", BetaBean.class);
-
         assertNotNull("Map Descriptor is null", PropertyUtils.getPropertyDescriptor(bean, "noGetterMappedProperty"));
 
         PropertyUtils.setMappedProperty(bean, "noGetterMappedProperty",  "Epsilon", "Epsilon");
@@ -4268,8 +4262,8 @@ public class PropertyUtilsTestCase exten
      * mistake.
      */
     public void testNestedPropertyKeyOrIndexOnBeanImplementingMap() throws Exception {
-        HashMap map = new HashMap();
-        HashMap submap = new HashMap();
+        HashMap<String, Object> map = new HashMap<String, Object>();
+        HashMap<String, Object> submap = new HashMap<String, Object>();
         BetaBean betaBean1 = new BetaBean("test1");
         BetaBean betaBean2 = new BetaBean("test2");
 
@@ -4312,7 +4306,7 @@ public class PropertyUtilsTestCase exten
             // However this isn't how javabeans property methods work. A map
             // only effectively has "simple" properties, even when the
             // returned object is a Map or Array.
-            Object o = PropertyUtils.getNestedProperty(map, "submap[3]");
+            PropertyUtils.getNestedProperty(map, "submap[3]");
 
             // What, no exception? In that case, getNestedProperties has
             // probably just tried to do
@@ -4336,10 +4330,10 @@ public class PropertyUtilsTestCase exten
      * <p>
      * If there are no keys, an empty string is returned.
      */
-    private String keysToString(Map map) {
+    private String keysToString(Map<?, ?> map) {
         Object[] mapKeys = map.keySet().toArray();
         java.util.Arrays.sort(mapKeys);
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         for(int i=0; i<mapKeys.length; ++i) {
             if (i != 0)
                 buf.append(", ");
@@ -4416,7 +4410,7 @@ public class PropertyUtilsTestCase exten
         assertEquals("setNestedProperty on non-simple property failed",
                 "value1", utilsBean.getNestedProperty(bean, "mapProperty"));
 
-        HashMap myMap = new HashMap();
+        HashMap<String, Object> myMap = new HashMap<String, Object>();
         myMap.put("thebean", bean);
         utilsBean.getNestedProperty(myMap, "thebean.mapitem");
         utilsBean.getNestedProperty(myMap, "thebean(mapitem)");