diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
index 40940374d8..515f1621ad 100644
--- a/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
+++ b/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -234,7 +234,7 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
@Override
public Class>[] getProxiedInterfaces() {
- return this.interfaces.toArray(new Class>[this.interfaces.size()]);
+ return ClassUtils.toClassArray(this.interfaces);
}
@Override
diff --git a/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java b/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java
index 32af73dc7b..8219737a22 100644
--- a/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java
+++ b/spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -104,7 +104,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
@Override
public Class>[] getInterfaces() {
- return this.interfaces.toArray(new Class>[this.interfaces.size()]);
+ return ClassUtils.toClassArray(this.interfaces);
}
@Override
diff --git a/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java b/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java
index b91c897502..b0153f91bb 100644
--- a/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java
+++ b/spring-aop/src/main/java/org/springframework/aop/support/IntroductionInfoSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -53,15 +53,15 @@ public class IntroductionInfoSupport implements IntroductionInfo, Serializable {
* due to the delegate implementing it. Call this method to exclude
* internal interfaces from being visible at the proxy level.
*
Does nothing if the interface is not implemented by the delegate.
- * @param intf the interface to suppress
+ * @param ifc the interface to suppress
*/
- public void suppressInterface(Class> intf) {
- this.publishedInterfaces.remove(intf);
+ public void suppressInterface(Class> ifc) {
+ this.publishedInterfaces.remove(ifc);
}
@Override
public Class>[] getInterfaces() {
- return this.publishedInterfaces.toArray(new Class>[this.publishedInterfaces.size()]);
+ return ClassUtils.toClassArray(this.publishedInterfaces);
}
/**
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 cf7d8de329..4101865e3b 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
@@ -1742,7 +1742,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
if (targetType != null && targetType != obj.getClass()) {
sources.add(targetType);
}
- return sources.toArray(new Object[sources.size()]);
+ return sources.toArray();
}
private RootBeanDefinition getRootBeanDefinition(String beanName) {
diff --git a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/KeyGeneratorAdapter.java b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/KeyGeneratorAdapter.java
index 42db86cefd..4c6bccb2c1 100644
--- a/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/KeyGeneratorAdapter.java
+++ b/spring-context-support/src/main/java/org/springframework/cache/jcache/interceptor/KeyGeneratorAdapter.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2018 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.springframework.cache.jcache.interceptor;
import java.lang.annotation.Annotation;
@@ -13,10 +29,9 @@ import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
/**
- * Spring's {@link KeyGenerator} implementation that either delegates to a
- * standard JSR-107 {@link javax.cache.annotation.CacheKeyGenerator}, or
- * wrap a standard {@link KeyGenerator} so that only relevant parameters
- * are handled.
+ * Spring's {@link KeyGenerator} implementation that either delegates to a standard JSR-107
+ * {@link javax.cache.annotation.CacheKeyGenerator}, or wrap a standard {@link KeyGenerator}
+ * so that only relevant parameters are handled.
*
* @author Stephane Nicoll
* @since 4.1
@@ -29,12 +44,13 @@ class KeyGeneratorAdapter implements KeyGenerator {
private CacheKeyGenerator cacheKeyGenerator;
+
/**
* Create an instance with the given {@link KeyGenerator} so that {@link javax.cache.annotation.CacheKey}
* and {@link javax.cache.annotation.CacheValue} are handled according to the spec.
*/
public KeyGeneratorAdapter(JCacheOperationSource cacheOperationSource, KeyGenerator target) {
- Assert.notNull(cacheOperationSource, "cacheOperationSource must not be null.");
+ Assert.notNull(cacheOperationSource, "JCacheOperationSource must not be null");
Assert.notNull(target, "KeyGenerator must not be null");
this.cacheOperationSource = cacheOperationSource;
this.keyGenerator = target;
@@ -44,12 +60,13 @@ class KeyGeneratorAdapter implements KeyGenerator {
* Create an instance used to wrap the specified {@link javax.cache.annotation.CacheKeyGenerator}.
*/
public KeyGeneratorAdapter(JCacheOperationSource cacheOperationSource, CacheKeyGenerator target) {
- Assert.notNull(cacheOperationSource, "cacheOperationSource must not be null.");
- Assert.notNull(target, "KeyGenerator must not be null");
+ Assert.notNull(cacheOperationSource, "JCacheOperationSource must not be null");
+ Assert.notNull(target, "CacheKeyGenerator must not be null");
this.cacheOperationSource = cacheOperationSource;
this.cacheKeyGenerator = target;
}
+
/**
* Return the target key generator to use in the form of either a {@link KeyGenerator}
* or a {@link CacheKeyGenerator}.
@@ -58,7 +75,6 @@ class KeyGeneratorAdapter implements KeyGenerator {
return (this.keyGenerator != null ? this.keyGenerator : this.cacheKeyGenerator);
}
-
@Override
public Object generate(Object target, Method method, Object... params) {
JCacheOperation> operation = this.cacheOperationSource.getCacheOperation(method, target.getClass());
@@ -88,15 +104,14 @@ class KeyGeneratorAdapter implements KeyGenerator {
parameters.add(value);
}
}
- return keyGenerator.generate(context.getTarget(), context.getMethod(),
- parameters.toArray(new Object[parameters.size()]));
-
+ return keyGenerator.generate(context.getTarget(), context.getMethod(), parameters.toArray());
}
@SuppressWarnings("unchecked")
- private CacheKeyInvocationContext> createCacheKeyInvocationContext(Object target,
- JCacheOperation> operation, Object[] params) {
+ private CacheKeyInvocationContext> createCacheKeyInvocationContext(
+ Object target, JCacheOperation> operation, Object[] params) {
+
AbstractJCacheKeyOperation keyCacheOperation = (AbstractJCacheKeyOperation) operation;
return new DefaultCacheKeyInvocationContext(keyCacheOperation, target, params);
}
diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java
index 5e1414e074..53bf01e46f 100644
--- a/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java
+++ b/spring-context/src/main/java/org/springframework/context/support/AbstractMessageSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -330,7 +330,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
resolvedArgs.add(arg);
}
}
- return resolvedArgs.toArray(new Object[resolvedArgs.size()]);
+ return resolvedArgs.toArray();
}
/**
diff --git a/spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java b/spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java
index 7d6b8f759b..61561beb83 100644
--- a/spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java
+++ b/spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2017 the original author or authors.
+ * Copyright 2002-2018 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.
@@ -17,9 +17,9 @@
package org.springframework.validation.beanvalidation;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -34,6 +34,7 @@ import org.springframework.beans.NotReadablePropertyException;
import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.util.Assert;
+import org.springframework.util.ClassUtils;
import org.springframework.validation.BindingResult;
import org.springframework.validation.Errors;
import org.springframework.validation.FieldError;
@@ -115,7 +116,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
}
}
processConstraintViolations(
- this.targetValidator.validate(target, groups.toArray(new Class>[groups.size()])), errors);
+ this.targetValidator.validate(target, ClassUtils.toClassArray(groups)), errors);
}
}
@@ -215,7 +216,7 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
* @see org.springframework.validation.DefaultBindingErrorProcessor#getArgumentsForBindError
*/
protected Object[] getArgumentsForConstraint(String objectName, String field, ConstraintDescriptor> descriptor) {
- List