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:
Sam Brannen
2023-08-07 12:43:40 +03:00
parent 96fd3c10fb
commit 526fc391ee
40 changed files with 88 additions and 88 deletions

View File

@@ -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));