|
44 | 44 | import org.slf4j.Logger; |
45 | 45 | import org.slf4j.LoggerFactory; |
46 | 46 |
|
| 47 | +import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl; |
| 48 | + |
47 | 49 | public class ParamsFlattener { |
48 | 50 |
|
49 | 51 | private static final String MODULE_PROPERTY = "__module__"; |
@@ -442,15 +444,26 @@ private boolean isPrimitiveClass(Class<?> clazz) { |
442 | 444 | private Object unflattedComplexType(Class<?> clazz, Props props, ObjectRefsManager manager) { |
443 | 445 |
|
444 | 446 | Constructor<?> constructor = clazz.getConstructors()[0]; |
445 | | - |
446 | | - Object[] constParams = new Object[constructor.getParameterTypes().length]; |
447 | | - |
| 447 | + |
| 448 | + List<Type> constClasses = new ArrayList<>(); |
| 449 | + Class<?>[] parameterTypes = constructor.getParameterTypes(); |
| 450 | + Type[] parameterGenericTypes = constructor.getGenericParameterTypes(); |
| 451 | + for (int i = 0; i < parameterGenericTypes.length; i++) { |
| 452 | + if (parameterGenericTypes[i] instanceof ParameterizedTypeImpl) { |
| 453 | + // This is a class with a generic type |
| 454 | + // (for example, a java.util.List<java.lang.String>) |
| 455 | + constClasses.add(parameterGenericTypes[i]); |
| 456 | + } else { |
| 457 | + constClasses.add(parameterTypes[i]); |
| 458 | + } |
| 459 | + } |
| 460 | + |
| 461 | + Object[] constParams = new Object[parameterTypes.length]; |
448 | 462 | List<String> paramNames = ParamAnnotationUtils.getParamNames(constructor); |
449 | | - Class<?>[] constClasses = constructor.getParameterTypes(); |
450 | 463 |
|
451 | 464 | for (int i = 0; i < constParams.length; i++) { |
452 | 465 | String paramName = paramNames.get(i); |
453 | | - constParams[i] = unflattenValue(paramName, constClasses[i], props.getProp(paramName), |
| 466 | + constParams[i] = unflattenValue(paramName, constClasses.get(i), props.getProp(paramName), |
454 | 467 | manager); |
455 | 468 | } |
456 | 469 |
|
|
0 commit comments