Use Class#componentType() for consistency with arrayType()
Java 12 introduced java.lang.Class#componentType() as a shortcut for
getComponentType().
Since we started using arrayType() in fe5560400c, this commit switches
to componentType() for consistent API usage style.
This commit is contained in:
@@ -605,8 +605,8 @@ public class MBeanClientInterceptor
|
||||
}
|
||||
|
||||
private Object convertDataArrayToTargetArray(Object[] array, Class<?> targetClass) throws NoSuchMethodException {
|
||||
Class<?> targetType = targetClass.getComponentType();
|
||||
Method fromMethod = targetType.getMethod("from", array.getClass().getComponentType());
|
||||
Class<?> targetType = targetClass.componentType();
|
||||
Method fromMethod = targetType.getMethod("from", array.getClass().componentType());
|
||||
Object resultArray = Array.newInstance(targetType, array.length);
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
Array.set(resultArray, i, ReflectionUtils.invokeMethod(fromMethod, null, array[i]));
|
||||
@@ -617,7 +617,7 @@ public class MBeanClientInterceptor
|
||||
private Collection<?> convertDataArrayToTargetCollection(Object[] array, Class<?> collectionType, Class<?> elementType)
|
||||
throws NoSuchMethodException {
|
||||
|
||||
Method fromMethod = elementType.getMethod("from", array.getClass().getComponentType());
|
||||
Method fromMethod = elementType.getMethod("from", array.getClass().componentType());
|
||||
Collection<Object> resultColl = CollectionFactory.createCollection(collectionType, Array.getLength(array));
|
||||
for (Object element : array) {
|
||||
resultColl.add(ReflectionUtils.invokeMethod(fromMethod, null, element));
|
||||
|
||||
Reference in New Issue
Block a user