diff --git a/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java b/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java index ef9016a157..68eb55c9c4 100644 --- a/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java +++ b/spring-aop/src/main/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -291,7 +291,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint, private void appendType(StringBuilder sb, Class type, boolean useLongTypeName) { if (type.isArray()) { - appendType(sb, type.getComponentType(), useLongTypeName); + appendType(sb, type.componentType(), useLongTypeName); sb.append("[]"); } else { diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java index 3b470e1701..26651f6200 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java @@ -266,7 +266,7 @@ public abstract class AopProxyUtils { if (varargArray instanceof Object[] && !varargType.isInstance(varargArray)) { Object[] newArguments = new Object[arguments.length]; System.arraycopy(arguments, 0, newArguments, 0, varargIndex); - Class targetElementType = varargType.getComponentType(); + Class targetElementType = varargType.componentType(); int varargLength = Array.getLength(varargArray); Object newVarargArray = Array.newInstance(targetElementType, varargLength); System.arraycopy(varargArray, 0, newVarargArray, 0, varargLength); diff --git a/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java b/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java index fa2bc7ea8e..38274e8c7f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java +++ b/spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java @@ -291,7 +291,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA String lastKey = tokens.keys[tokens.keys.length - 1]; if (propValue.getClass().isArray()) { - Class requiredType = propValue.getClass().getComponentType(); + Class requiredType = propValue.getClass().componentType(); int arrayIndex = Integer.parseInt(lastKey); Object oldValue = null; try { @@ -302,7 +302,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA requiredType, ph.nested(tokens.keys.length)); int length = Array.getLength(propValue); if (arrayIndex >= length && arrayIndex < this.autoGrowCollectionLimit) { - Class componentType = propValue.getClass().getComponentType(); + Class componentType = propValue.getClass().componentType(); Object newArray = Array.newInstance(componentType, arrayIndex + 1); System.arraycopy(propValue, 0, newArray, 0, length); int lastKeyIndex = tokens.canonicalName.lastIndexOf('['); @@ -769,7 +769,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA } int length = Array.getLength(array); if (index >= length && index < this.autoGrowCollectionLimit) { - Class componentType = array.getClass().getComponentType(); + Class componentType = array.getClass().componentType(); Object newArray = Array.newInstance(componentType, index + 1); System.arraycopy(array, 0, newArray, 0, length); for (int i = length; i < Array.getLength(newArray); i++) { @@ -900,11 +900,11 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA private Object newValue(Class type, @Nullable TypeDescriptor desc, String name) { try { if (type.isArray()) { - Class componentType = type.getComponentType(); + Class componentType = type.componentType(); // TODO - only handles 2-dimensional arrays if (componentType.isArray()) { Object array = Array.newInstance(componentType, 1); - Array.set(array, 0, Array.newInstance(componentType.getComponentType(), 0)); + Array.set(array, 0, Array.newInstance(componentType.componentType(), 0)); return array; } else { diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java index b1b77374e1..5fdc92ac39 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanUtils.java @@ -654,7 +654,7 @@ public abstract class BeanUtils { */ public static boolean isSimpleProperty(Class type) { Assert.notNull(type, "'type' must not be null"); - return isSimpleValueType(type) || (type.isArray() && isSimpleValueType(type.getComponentType())); + return isSimpleValueType(type) || (type.isArray() && isSimpleValueType(type.componentType())); } /** diff --git a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java index 43632a6651..76ef87f3fa 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java +++ b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java @@ -192,14 +192,14 @@ class ExtendedBeanInfo implements BeanInfo { if (pd instanceof IndexedPropertyDescriptor indexedPd) { candidateType = indexedPd.getIndexedPropertyType(); if (candidateName.equals(propertyName) && - (candidateType.equals(propertyType) || candidateType.equals(propertyType.getComponentType()))) { + (candidateType.equals(propertyType) || candidateType.equals(propertyType.componentType()))) { return pd; } } else { candidateType = pd.getPropertyType(); if (candidateName.equals(propertyName) && - (candidateType.equals(propertyType) || propertyType.equals(candidateType.getComponentType()))) { + (candidateType.equals(propertyType) || propertyType.equals(candidateType.componentType()))) { return pd; } } diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java index 2faf87e0e3..9eb05f99d8 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java @@ -233,7 +233,7 @@ abstract class PropertyDescriptorUtils { } if (propertyType != null && (!propertyType.isArray() || - propertyType.getComponentType() != indexedPropertyType)) { + propertyType.componentType() != indexedPropertyType)) { throw new IntrospectionException("Type mismatch between indexed and non-indexed methods: " + indexedReadMethod + " - " + indexedWriteMethod); } diff --git a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java index 11be228b43..a3bfd17bc1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/TypeConverterDelegate.java @@ -172,10 +172,10 @@ class TypeConverterDelegate { else if (requiredType.isArray()) { // Array required -> apply appropriate conversion of elements. if (convertedValue instanceof String text && - Enum.class.isAssignableFrom(requiredType.getComponentType())) { + Enum.class.isAssignableFrom(requiredType.componentType())) { convertedValue = StringUtils.commaDelimitedListToStringArray(text); } - return (T) convertToTypedArray(convertedValue, propertyName, requiredType.getComponentType()); + return (T) convertToTypedArray(convertedValue, propertyName, requiredType.componentType()); } else if (convertedValue.getClass().isArray()) { if (Array.getLength(convertedValue) == 1) { @@ -453,7 +453,7 @@ class TypeConverterDelegate { } else if (input.getClass().isArray()) { // Convert array elements, if necessary. - if (componentType.equals(input.getClass().getComponentType()) && + if (componentType.equals(input.getClass().componentType()) && !this.propertyEditorRegistry.hasCustomEditorForElement(componentType, propertyName)) { return input; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java index 6af615a320..1a32e7000b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java @@ -917,7 +917,7 @@ class ConstructorResolver { // Single constructor or factory method -> let's return an empty array/collection // for e.g. a vararg or a non-null List/Set/Map parameter. if (paramType.isArray()) { - return Array.newInstance(paramType.getComponentType(), 0); + return Array.newInstance(paramType.componentType(), 0); } else if (CollectionFactory.isApproximableCollectionType(paramType)) { return CollectionFactory.createCollection(paramType, 0); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index ffc402d8bc..f45a769477 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1464,7 +1464,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return stream; } else if (type.isArray()) { - Class componentType = type.getComponentType(); + Class componentType = type.componentType(); ResolvableType resolvableType = descriptor.getResolvableType(); Class resolvedArrayType = resolvableType.resolve(type); if (resolvedArrayType != type) { diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java index f10004a30f..75594b444e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java @@ -145,7 +145,7 @@ class BeanUtilsTests { for (PropertyDescriptor descriptor : descriptors) { if ("containedBeans".equals(descriptor.getName())) { assertThat(descriptor.getPropertyType().isArray()).as("Property should be an array").isTrue(); - assertThat(ContainedBean.class).isEqualTo(descriptor.getPropertyType().getComponentType()); + assertThat(ContainedBean.class).isEqualTo(descriptor.getPropertyType().componentType()); } } } diff --git a/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java b/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java index 13a10ecec1..1f41aaf60d 100644 --- a/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java +++ b/spring-context/src/main/java/org/springframework/jmx/access/MBeanClientInterceptor.java @@ -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 resultColl = CollectionFactory.createCollection(collectionType, Array.getLength(array)); for (Object element : array) { resultColl.add(ReflectionUtils.invokeMethod(fromMethod, null, element)); diff --git a/spring-core/src/main/java/org/springframework/aot/generate/AccessControl.java b/spring-core/src/main/java/org/springframework/aot/generate/AccessControl.java index 3f4cd40185..cb9cbd4ec1 100644 --- a/spring-core/src/main/java/org/springframework/aot/generate/AccessControl.java +++ b/spring-core/src/main/java/org/springframework/aot/generate/AccessControl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -215,7 +215,7 @@ public final class AccessControl { clazz = ClassUtils.getUserClass(clazz); Visibility visibility = forModifiers(clazz.getModifiers()); if (clazz.isArray()) { - visibility = lowest(visibility, forClass(clazz.getComponentType())); + visibility = lowest(visibility, forClass(clazz.componentType())); } Class enclosingClass = clazz.getEnclosingClass(); if (enclosingClass != null) { diff --git a/spring-core/src/main/java/org/springframework/aot/hint/ReflectionTypeReference.java b/spring-core/src/main/java/org/springframework/aot/hint/ReflectionTypeReference.java index 310f29512d..3e4a26557a 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/ReflectionTypeReference.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/ReflectionTypeReference.java @@ -37,7 +37,7 @@ final class ReflectionTypeReference extends AbstractTypeReference { @Nullable private static TypeReference getEnclosingClass(Class type) { - Class candidate = (type.isArray() ? type.getComponentType().getEnclosingClass() : + Class candidate = (type.isArray() ? type.componentType().getEnclosingClass() : type.getEnclosingClass()); return (candidate != null ? new ReflectionTypeReference(candidate) : null); } @@ -56,7 +56,7 @@ final class ReflectionTypeReference extends AbstractTypeReference { @Override protected boolean isPrimitive() { return this.type.isPrimitive() || - (this.type.isArray() && this.type.getComponentType().isPrimitive()); + (this.type.isArray() && this.type.componentType().isPrimitive()); } } diff --git a/spring-core/src/main/java/org/springframework/asm/Type.java b/spring-core/src/main/java/org/springframework/asm/Type.java index 36d69ab8b0..48cb1f2ea7 100644 --- a/spring-core/src/main/java/org/springframework/asm/Type.java +++ b/spring-core/src/main/java/org/springframework/asm/Type.java @@ -614,7 +614,7 @@ public final class Type { Class currentClass = clazz; while (currentClass.isArray()) { stringBuilder.append('['); - currentClass = currentClass.getComponentType(); + currentClass = currentClass.componentType(); } if (currentClass.isPrimitive()) { char descriptor; diff --git a/spring-core/src/main/java/org/springframework/cglib/core/EmitUtils.java b/spring-core/src/main/java/org/springframework/cglib/core/EmitUtils.java index a932f4f886..c1e157b722 100644 --- a/spring-core/src/main/java/org/springframework/cglib/core/EmitUtils.java +++ b/spring-core/src/main/java/org/springframework/cglib/core/EmitUtils.java @@ -347,7 +347,7 @@ public class EmitUtils { public static void push_array(CodeEmitter e, Object[] array) { e.push(array.length); - e.newarray(Type.getType(remapComponentType(array.getClass().getComponentType()))); + e.newarray(Type.getType(remapComponentType(array.getClass().componentType()))); for (int i = 0; i < array.length; i++) { e.dup(); e.push(i); diff --git a/spring-core/src/main/java/org/springframework/cglib/util/ParallelSorter.java b/spring-core/src/main/java/org/springframework/cglib/util/ParallelSorter.java index 11cdf02d82..42f60ac8c1 100644 --- a/spring-core/src/main/java/org/springframework/cglib/util/ParallelSorter.java +++ b/spring-core/src/main/java/org/springframework/cglib/util/ParallelSorter.java @@ -154,7 +154,7 @@ abstract public class ParallelSorter extends SorterTemplate { private void chooseComparer(int index, Comparator cmp) { Object array = a[index]; - Class type = array.getClass().getComponentType(); + Class type = array.getClass().componentType(); if (type.equals(Integer.TYPE)) { comparer = new IntComparer((int[])array); } else if (type.equals(Long.TYPE)) { diff --git a/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java b/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java index 8aa4380f87..70cddfd493 100644 --- a/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java +++ b/spring-core/src/main/java/org/springframework/core/BridgeMethodResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -158,7 +158,7 @@ public final class BridgeMethodResolver { Class candidateParameter = candidateParameters[i]; if (candidateParameter.isArray()) { // An array type: compare the component type. - if (!candidateParameter.getComponentType().equals(genericParameter.getComponentType().toClass())) { + if (!candidateParameter.componentType().equals(genericParameter.getComponentType().toClass())) { return false; } } diff --git a/spring-core/src/main/java/org/springframework/core/Conventions.java b/spring-core/src/main/java/org/springframework/core/Conventions.java index 7eac92ca0d..ba21b61158 100644 --- a/spring-core/src/main/java/org/springframework/core/Conventions.java +++ b/spring-core/src/main/java/org/springframework/core/Conventions.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -67,7 +67,7 @@ public final class Conventions { boolean pluralize = false; if (value.getClass().isArray()) { - valueClass = value.getClass().getComponentType(); + valueClass = value.getClass().componentType(); pluralize = true; } else if (value instanceof Collection collection) { @@ -104,7 +104,7 @@ public final class Conventions { String reactiveSuffix = ""; if (parameter.getParameterType().isArray()) { - valueClass = parameter.getParameterType().getComponentType(); + valueClass = parameter.getParameterType().componentType(); pluralize = true; } else if (Collection.class.isAssignableFrom(parameter.getParameterType())) { @@ -178,7 +178,7 @@ public final class Conventions { String reactiveSuffix = ""; if (resolvedType.isArray()) { - valueClass = resolvedType.getComponentType(); + valueClass = resolvedType.componentType(); pluralize = true; } else if (Collection.class.isAssignableFrom(resolvedType)) { diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index 7c0e4395fb..dd03fa8295 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -396,7 +396,7 @@ public class ResolvableType implements Serializable { return this.componentType; } if (this.type instanceof Class clazz) { - Class componentType = clazz.getComponentType(); + Class componentType = clazz.componentType(); return forType(componentType, this.variableResolver); } if (this.type instanceof GenericArrayType genericArrayType) { diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AbstractMergedAnnotation.java b/spring-core/src/main/java/org/springframework/core/annotation/AbstractMergedAnnotation.java index 779c763f39..978e9684c2 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AbstractMergedAnnotation.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AbstractMergedAnnotation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationAttributes.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationAttributes.java index 5ec7276ca8..fe7a49612a 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationAttributes.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -352,8 +352,8 @@ public class AnnotationAttributes extends LinkedHashMap { assertAttributePresence(attributeName, value); assertNotException(attributeName, value); if (!expectedType.isInstance(value) && expectedType.isArray() && - expectedType.getComponentType().isInstance(value)) { - Object array = Array.newInstance(expectedType.getComponentType(), 1); + expectedType.componentType().isInstance(value)) { + Object array = Array.newInstance(expectedType.componentType(), 1); Array.set(array, 0, value); value = array; } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java index 86c491b7db..528b649e88 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationTypeMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -217,7 +217,7 @@ final class AnnotationTypeMapping { } private boolean isCompatibleReturnType(Class attributeType, Class targetType) { - return (attributeType == targetType || attributeType == targetType.getComponentType()); + return (attributeType == targetType || attributeType == targetType.componentType()); } private void processAliases() { @@ -399,9 +399,9 @@ final class AnnotationTypeMapping { for (int i = 0; i < attributeMethods.size(); i++) { Method method = attributeMethods.get(i); Class type = method.getReturnType(); - if (type.isAnnotation() || (type.isArray() && type.getComponentType().isAnnotation())) { + if (type.isAnnotation() || (type.isArray() && type.componentType().isAnnotation())) { Class annotationType = - (Class) (type.isAnnotation() ? type : type.getComponentType()); + (Class) (type.isAnnotation() ? type : type.componentType()); AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(annotationType).get(0); if (mapping.isSynthesizable()) { return true; diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index a904f39d91..5ce041a138 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -1011,7 +1011,7 @@ public abstract class AnnotationUtils { } if (value instanceof Annotation[] annotations) { Annotation[] synthesized = (Annotation[]) Array.newInstance( - annotations.getClass().getComponentType(), annotations.length); + annotations.getClass().componentType(), annotations.length); for (int i = 0; i < annotations.length; i++) { synthesized[i] = MergedAnnotation.from(annotatedElement, annotations[i]).synthesize(); } @@ -1292,7 +1292,7 @@ public abstract class AnnotationUtils { return annotations; } Annotation[] synthesized = (Annotation[]) Array.newInstance( - annotations.getClass().getComponentType(), annotations.length); + annotations.getClass().componentType(), annotations.length); for (int i = 0; i < annotations.length; i++) { synthesized[i] = synthesizeAnnotation(annotations[i], annotatedElement); } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java b/spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java index dc122981aa..fe059f5241 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AttributeMethods.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ final class AttributeMethods { if (!foundDefaultValueMethod && (method.getDefaultValue() != null)) { foundDefaultValueMethod = true; } - if (!foundNestedAnnotation && (type.isAnnotation() || (type.isArray() && type.getComponentType().isAnnotation()))) { + if (!foundNestedAnnotation && (type.isAnnotation() || (type.isArray() && type.componentType().isAnnotation()))) { foundNestedAnnotation = true; } ReflectionUtils.makeAccessible(method); diff --git a/spring-core/src/main/java/org/springframework/core/annotation/RepeatableContainers.java b/spring-core/src/main/java/org/springframework/core/annotation/RepeatableContainers.java index 1b0293f05d..c1b2fffd86 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/RepeatableContainers.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/RepeatableContainers.java @@ -174,7 +174,7 @@ public abstract class RepeatableContainers { if (method != null) { Class returnType = method.getReturnType(); if (returnType.isArray()) { - Class componentType = returnType.getComponentType(); + Class componentType = returnType.componentType(); if (Annotation.class.isAssignableFrom(componentType) && componentType.isAnnotationPresent(Repeatable.class)) { return method; @@ -211,7 +211,7 @@ public abstract class RepeatableContainers { throw new NoSuchMethodException("No value method found"); } Class returnType = valueMethod.getReturnType(); - if (!returnType.isArray() || returnType.getComponentType() != repeatable) { + if (!returnType.isArray() || returnType.componentType() != repeatable) { throw new AnnotationConfigurationException( "Container type [%s] must declare a 'value' attribute for an array of type [%s]" .formatted(container.getName(), repeatable.getName())); diff --git a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java index 27ced8751c..85a0e52a96 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -228,7 +228,7 @@ final class TypeMappedAnnotation extends AbstractMergedAnn int attributeIndex = getAttributeIndex(attributeName, true); Method attribute = this.mapping.getAttributes().get(attributeIndex); - Class componentType = attribute.getReturnType().getComponentType(); + Class componentType = attribute.getReturnType().componentType(); Assert.notNull(type, "Type must not be null"); Assert.notNull(componentType, () -> "Attribute " + attributeName + " is not an array"); Assert.isAssignable(type, componentType, () -> "Attribute " + attributeName + " component type mismatch:"); @@ -286,7 +286,7 @@ final class TypeMappedAnnotation extends AbstractMergedAnn private Class getTypeForMapOptions(Method attribute, Adapt[] adaptations) { Class attributeType = attribute.getReturnType(); - Class componentType = (attributeType.isArray() ? attributeType.getComponentType() : attributeType); + Class componentType = (attributeType.isArray() ? attributeType.componentType() : attributeType); if (Adapt.CLASS_TO_STRING.isIn(adaptations) && componentType == Class.class) { return (attributeType.isArray() ? String[].class : String.class); } @@ -309,7 +309,7 @@ final class TypeMappedAnnotation extends AbstractMergedAnn return result; } Object result = Array.newInstance( - attribute.getReturnType().getComponentType(), annotations.length); + attribute.getReturnType().componentType(), annotations.length); for (int i = 0; i < annotations.length; i++) { Array.set(result, i, annotations[i].synthesize()); } @@ -470,8 +470,8 @@ final class TypeMappedAnnotation extends AbstractMergedAnn value = annotation.synthesize(); } else if (value instanceof MergedAnnotation[] annotations && - type.isArray() && type.getComponentType().isAnnotation()) { - Object array = Array.newInstance(type.getComponentType(), annotations.length); + type.isArray() && type.componentType().isAnnotation()) { + Object array = Array.newInstance(type.componentType(), annotations.length); for (int i = 0; i < annotations.length; i++) { Array.set(array, i, annotations[i].synthesize()); } @@ -495,11 +495,11 @@ final class TypeMappedAnnotation extends AbstractMergedAnn if (attributeType.isAnnotation()) { return adaptToMergedAnnotation(value, (Class) attributeType); } - if (attributeType.isArray() && attributeType.getComponentType().isAnnotation()) { + if (attributeType.isArray() && attributeType.componentType().isAnnotation()) { MergedAnnotation[] result = new MergedAnnotation[Array.getLength(value)]; for (int i = 0; i < result.length; i++) { result[i] = adaptToMergedAnnotation(Array.get(value, i), - (Class) attributeType.getComponentType()); + (Class) attributeType.componentType()); } return result; } @@ -510,7 +510,7 @@ final class TypeMappedAnnotation extends AbstractMergedAnn return value; } if (attributeType.isArray() && isEmptyObjectArray(value)) { - return emptyArray(attributeType.getComponentType()); + return emptyArray(attributeType.componentType()); } if (!attributeType.isInstance(value)) { throw new IllegalStateException("Attribute '" + attribute.getName() + @@ -561,7 +561,7 @@ final class TypeMappedAnnotation extends AbstractMergedAnn if (attributeType.isAnnotation()) { return (Class) MergedAnnotation.class; } - if (attributeType.isArray() && attributeType.getComponentType().isAnnotation()) { + if (attributeType.isArray() && attributeType.componentType().isAnnotation()) { return (Class) MergedAnnotation[].class; } return (Class) ClassUtils.resolvePrimitiveIfNecessary(attributeType); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java index 8b305589bb..0075400dfa 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/GenericConversionService.java @@ -551,7 +551,7 @@ public class GenericConversionService implements ConfigurableConversionService { int i = 0; while (i < hierarchy.size()) { Class candidate = hierarchy.get(i); - candidate = (array ? candidate.getComponentType() : ClassUtils.resolvePrimitiveIfNecessary(candidate)); + candidate = (array ? candidate.componentType() : ClassUtils.resolvePrimitiveIfNecessary(candidate)); Class superclass = candidate.getSuperclass(); if (superclass != null && superclass != Object.class && superclass != Enum.class) { addToClassHierarchy(i + 1, candidate.getSuperclass(), array, hierarchy, visited); diff --git a/spring-core/src/main/java/org/springframework/core/style/DefaultValueStyler.java b/spring-core/src/main/java/org/springframework/core/style/DefaultValueStyler.java index 126a58b2e0..3dd8891646 100644 --- a/spring-core/src/main/java/org/springframework/core/style/DefaultValueStyler.java +++ b/spring-core/src/main/java/org/springframework/core/style/DefaultValueStyler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -178,14 +178,14 @@ public class DefaultValueStyler implements ValueStyler { */ protected String styleArray(Object[] array) { if (array.length == 0) { - return ARRAY + '<' + ClassUtils.getShortName(array.getClass().getComponentType()) + '>' + EMPTY; + return ARRAY + '<' + ClassUtils.getShortName(array.getClass().componentType()) + '>' + EMPTY; } StringJoiner result = new StringJoiner(", ", "[", "]"); for (Object element : array) { result.add(style(element)); } - return ARRAY + '<' + ClassUtils.getShortName(array.getClass().getComponentType()) + '>' + result; + return ARRAY + '<' + ClassUtils.getShortName(array.getClass().componentType()) + '>' + result; } /** diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index 0b37101f42..1799dcfaf2 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -516,7 +516,7 @@ public abstract class ClassUtils { */ public static boolean isPrimitiveArray(Class clazz) { Assert.notNull(clazz, "Class must not be null"); - return (clazz.isArray() && clazz.getComponentType().isPrimitive()); + return (clazz.isArray() && clazz.componentType().isPrimitive()); } /** @@ -527,7 +527,7 @@ public abstract class ClassUtils { */ public static boolean isPrimitiveWrapperArray(Class clazz) { Assert.notNull(clazz, "Class must not be null"); - return (clazz.isArray() && isPrimitiveWrapper(clazz.getComponentType())); + return (clazz.isArray() && isPrimitiveWrapper(clazz.componentType())); } /** diff --git a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java index 02b7a14c2f..45da0adeac 100644 --- a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java @@ -244,7 +244,7 @@ public abstract class ObjectUtils { } } throw new IllegalArgumentException("Constant [" + constant + "] does not exist in enum type " + - enumValues.getClass().getComponentType().getName()); + enumValues.getClass().componentType().getName()); } /** @@ -270,7 +270,7 @@ public abstract class ObjectUtils { public static A[] addObjectToArray(@Nullable A[] array, @Nullable O obj, int position) { Class componentType = Object.class; if (array != null) { - componentType = array.getClass().getComponentType(); + componentType = array.getClass().componentType(); } else if (obj != null) { componentType = obj.getClass(); diff --git a/spring-core/src/main/java/org/springframework/util/TypeUtils.java b/spring-core/src/main/java/org/springframework/util/TypeUtils.java index 70e2e5a857..b118aa2eee 100644 --- a/spring-core/src/main/java/org/springframework/util/TypeUtils.java +++ b/spring-core/src/main/java/org/springframework/util/TypeUtils.java @@ -75,7 +75,7 @@ public abstract class TypeUtils { else if (lhsClass.isArray() && rhsType instanceof GenericArrayType rhsGenericArrayType) { Type rhsComponent = rhsGenericArrayType.getGenericComponentType(); - return isAssignable(lhsClass.getComponentType(), rhsComponent); + return isAssignable(lhsClass.componentType(), rhsComponent); } } @@ -97,7 +97,7 @@ public abstract class TypeUtils { Type lhsComponent = lhsGenericArrayType.getGenericComponentType(); if (rhsType instanceof Class rhsClass && rhsClass.isArray()) { - return isAssignable(lhsComponent, rhsClass.getComponentType()); + return isAssignable(lhsComponent, rhsClass.componentType()); } else if (rhsType instanceof GenericArrayType rhsGenericArrayType) { Type rhsComponent = rhsGenericArrayType.getGenericComponentType(); diff --git a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java index f1a439706a..e4f62a5c24 100644 --- a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java +++ b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java @@ -360,7 +360,7 @@ class ResolvableTypeTests { ResolvableType type = ResolvableType.forField(field); assertThat(type.isArray()).isTrue(); assertThat(type.getComponentType().getType()) - .isEqualTo(((Class) field.getGenericType()).getComponentType()); + .isEqualTo(((Class) field.getGenericType()).componentType()); } @Test diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java index 20f3d4cdd6..95e220f8e9 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/CodeFlow.java @@ -450,7 +450,7 @@ public class CodeFlow implements Opcodes { if (clazz.isArray()) { while (clazz.isArray()) { sb.append('['); - clazz = clazz.getComponentType(); + clazz = clazz.componentType(); } } if (clazz.isPrimitive()) { diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java index 7e80a576c1..438e582130 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java @@ -384,7 +384,7 @@ public class Indexer extends SpelNodeImpl { } private Object accessArrayElement(Object ctx, int idx) throws SpelEvaluationException { - Class arrayComponentType = ctx.getClass().getComponentType(); + Class arrayComponentType = ctx.getClass().componentType(); if (arrayComponentType == Boolean.TYPE) { boolean[] array = (boolean[]) ctx; checkAccess(array.length, idx); diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java index bbe55deccb..2292484494 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java @@ -373,7 +373,7 @@ public abstract class ReflectionHelper { conversionOccurred |= (argument != arguments[i]); } - final Class varArgClass = methodHandleArgumentTypes.lastParameterType().getComponentType(); + final Class varArgClass = methodHandleArgumentTypes.lastParameterType().componentType(); ResolvableType varArgResolvableType = ResolvableType.forClass(varArgClass); TypeDescriptor varArgContentType = new TypeDescriptor(varArgResolvableType, varArgClass, null); @@ -431,11 +431,11 @@ public abstract class ReflectionHelper { } Class type = possibleArray.getClass(); if (!type.isArray() || Array.getLength(possibleArray) == 0 || - !ClassUtils.isAssignableValue(type.getComponentType(), value)) { + !ClassUtils.isAssignableValue(type.componentType(), value)) { return false; } Object arrayValue = Array.get(possibleArray, 0); - return (type.getComponentType().isPrimitive() ? arrayValue.equals(value) : arrayValue == value); + return (type.componentType().isPrimitive() ? arrayValue.equals(value) : arrayValue == value); } /** @@ -468,7 +468,7 @@ public abstract class ReflectionHelper { if (argumentCount >= parameterCount) { varargsArraySize = argumentCount - (parameterCount - 1); } - Class componentType = requiredParameterTypes[parameterCount - 1].getComponentType(); + Class componentType = requiredParameterTypes[parameterCount - 1].componentType(); Object varargsArray = Array.newInstance(componentType, varargsArraySize); for (int i = 0; i < varargsArraySize; i++) { Array.set(varargsArray, i, args[parameterCount - 1 + i]); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java index e808aa661c..96c625493c 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/AbstractExpressionTests.java @@ -258,8 +258,8 @@ public abstract class AbstractExpressionTests { } if (value.getClass().isArray()) { StringBuilder sb = new StringBuilder(); - if (value.getClass().getComponentType().isPrimitive()) { - Class primitiveType = value.getClass().getComponentType(); + if (value.getClass().componentType().isPrimitive()) { + Class primitiveType = value.getClass().componentType(); if (primitiveType == Integer.TYPE) { int[] l = (int[]) value; sb.append("int[").append(l.length).append("]{"); @@ -287,10 +287,10 @@ public abstract class AbstractExpressionTests { " in ExpressionTestCase.stringValueOf()"); } } - else if (value.getClass().getComponentType().isArray()) { + else if (value.getClass().componentType().isArray()) { List l = Arrays.asList((Object[]) value); if (!isNested) { - sb.append(value.getClass().getComponentType().getName()); + sb.append(value.getClass().componentType().getName()); } sb.append('[').append(l.size()).append("]{"); int i = 0; @@ -306,7 +306,7 @@ public abstract class AbstractExpressionTests { else { List l = Arrays.asList((Object[]) value); if (!isNested) { - sb.append(value.getClass().getComponentType().getName()); + sb.append(value.getClass().componentType().getName()); } sb.append('[').append(l.size()).append("]{"); int i = 0; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java index 4c82d36e64..77b9b2ff9e 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java @@ -260,7 +260,7 @@ class ReflectionHelperTests extends AbstractExpressionTests { assertThat(newArray).hasSize(1); Object firstParam = newArray[0]; - assertThat(firstParam.getClass().getComponentType()).isEqualTo(String.class); + assertThat(firstParam.getClass().componentType()).isEqualTo(String.class); Object[] firstParamArray = (Object[]) firstParam; assertThat(firstParamArray).containsExactly("a", "b", "c"); } diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 2f69913413..28ecbaa0c8 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -619,7 +619,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi parameterizedType.getActualTypeArguments().length == 1) { Type typeArgument = parameterizedType.getActualTypeArguments()[0]; if (typeArgument instanceof Class classArgument) { - return ((classArgument.isArray() && Byte.TYPE == classArgument.getComponentType()) || + return ((classArgument.isArray() && Byte.TYPE == classArgument.componentType()) || isPrimitiveWrapper(classArgument) || isStandardClass(classArgument) || supportsInternal(classArgument, false)); } diff --git a/spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java b/spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java index 586f6c67c9..ada9ca0d79 100644 --- a/spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java +++ b/spring-web/src/main/java/org/springframework/web/bind/WebDataBinder.java @@ -344,7 +344,7 @@ public class WebDataBinder extends DataBinder { } else if (fieldType.isArray()) { // Special handling of array property. - return Array.newInstance(fieldType.getComponentType(), 0); + return Array.newInstance(fieldType.componentType(), 0); } else if (Collection.class.isAssignableFrom(fieldType)) { return CollectionFactory.createCollection(fieldType, 0); diff --git a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java index 6d480e8581..ac1418cc1a 100644 --- a/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java +++ b/spring-web/src/main/java/org/springframework/web/multipart/support/MultipartResolutionDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -157,7 +157,7 @@ public final class MultipartResolutionDelegate { } private static boolean isMultipartFileArray(MethodParameter methodParam) { - return (MultipartFile.class == methodParam.getNestedParameterType().getComponentType()); + return (MultipartFile.class == methodParam.getNestedParameterType().componentType()); } private static boolean isPartCollection(MethodParameter methodParam) { @@ -165,7 +165,7 @@ public final class MultipartResolutionDelegate { } private static boolean isPartArray(MethodParameter methodParam) { - return (Part.class == methodParam.getNestedParameterType().getComponentType()); + return (Part.class == methodParam.getNestedParameterType().componentType()); } @Nullable