FELIX-4832: ClassCastException with autoconfig Iterable fields.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1667672 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FieldUtil.java b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FieldUtil.java
index dbaa123..55cfb24 100644
--- a/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FieldUtil.java
+++ b/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FieldUtil.java
@@ -289,12 +289,15 @@
     private static boolean mayInjectToIterable(Class<?> clazz, Field field, boolean strictClassEquality) {
         Class<?> fieldType = field.getType();
         if (Iterable.class.isAssignableFrom(fieldType)) {
-            ParameterizedType parameterType = (ParameterizedType) field.getGenericType();
-            if (parameterType == null) {
+            Type type = field.getGenericType();
+            
+            // The field must be a parameterized map (generics).
+            if (! (type instanceof ParameterizedType)) {
                 return false;
             }
+            ParameterizedType parameterType = (ParameterizedType) type;
             Type[] types = parameterType.getActualTypeArguments();
-            if (types == null || types.length == 0) {
+            if (types == null || types.length != 1) {
             	return false;
             }
             if (types[0] instanceof Class<?>) {
@@ -309,17 +312,15 @@
     private static boolean mayInjectToMap(Class<?> clazz, Field field, boolean strictClassEquality) {
         Class<?> fieldType = field.getType();
         if (Map.class.isAssignableFrom(fieldType)) {
-            // The field must be a parameterized map (generics).
-            if (! (field.getGenericType() instanceof ParameterizedType)) {
-                return false;
-            }
-            ParameterizedType parameterType = (ParameterizedType) field.getGenericType();
-            if (parameterType == null) {
-                return false;
-            }
+            Type type = field.getGenericType();
             
+            // The field must be a parameterized map (generics).
+            if (! (type instanceof ParameterizedType)) {
+                return false;
+            }
+            ParameterizedType parameterType = (ParameterizedType) type;
             Type[] types = parameterType.getActualTypeArguments();
-            if (types == null || types.length < 2) {
+            if (types == null || types.length != 2) {
             	return false;
             }