提交 78d56dc6 编写于 作者: S stsypanov 提交者: Sam Brannen

Use Arrays.copyOf and Arrays.copyOfRange where possible

Closes gh-23393
上级 216ffcfe
......@@ -180,8 +180,7 @@ public abstract class AopProxyUtils {
if (proxy instanceof DecoratingProxy) {
nonUserIfcCount++;
}
Class<?>[] userInterfaces = new Class<?>[proxyInterfaces.length - nonUserIfcCount];
System.arraycopy(proxyInterfaces, 0, userInterfaces, 0, userInterfaces.length);
Class<?>[] userInterfaces = Arrays.copyOf(proxyInterfaces, proxyInterfaces.length - nonUserIfcCount);
Assert.notEmpty(userInterfaces, "JDK proxy must implement one or more interfaces");
return userInterfaces;
}
......
......@@ -395,9 +395,7 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
logger.debug("Bean with name '" + finalName + "' concluding interceptor chain " +
"is not an advisor class: treating it as a target or TargetSource");
}
String[] newNames = new String[this.interceptorNames.length - 1];
System.arraycopy(this.interceptorNames, 0, newNames, 0, newNames.length);
this.interceptorNames = newNames;
this.interceptorNames = Arrays.copyOf(this.interceptorNames, this.interceptorNames.length - 1);
}
}
}
......
......@@ -25,6 +25,7 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
......@@ -721,8 +722,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
synchronized (this) {
if (!this.cached) {
if (arguments != null) {
Object[] cachedMethodArguments = new Object[paramTypes.length];
System.arraycopy(descriptors, 0, cachedMethodArguments, 0, arguments.length);
DependencyDescriptor[] cachedMethodArguments = Arrays.copyOf(descriptors, arguments.length);
registerDependentBeans(beanName, autowiredBeans);
if (autowiredBeans.size() == paramTypes.length) {
Iterator<String> it = autowiredBeans.iterator();
......
......@@ -268,8 +268,7 @@ final class AttributeMethods {
return NONE;
}
Arrays.sort(methods, methodComparator);
Method[] attributeMethods = new Method[size];
System.arraycopy(methods, 0, attributeMethods, 0, size);
Method[] attributeMethods = Arrays.copyOf(methods, size);
return new AttributeMethods(annotationType, attributeMethods);
}
......
......@@ -501,9 +501,7 @@ class Tokenizer {
}
private char[] subarray(int start, int end) {
char[] result = new char[end - start];
System.arraycopy(this.charsToProcess, start, result, 0, end - start);
return result;
return Arrays.copyOfRange(this.charsToProcess, start, end);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册