Class identity comparisons wherever possible

Issue: SPR-12926
This commit is contained in:
Juergen Hoeller
2015-05-20 14:34:09 +02:00
parent 57e0c789a8
commit b4095c3e1d
108 changed files with 317 additions and 322 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@@ -381,7 +381,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
private boolean maybeBindJoinPoint(Class<?> candidateParameterType) {
if (candidateParameterType.equals(JoinPoint.class)) {
if (JoinPoint.class == candidateParameterType) {
this.joinPointArgumentIndex = 0;
return true;
}
@@ -391,7 +391,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
private boolean maybeBindProceedingJoinPoint(Class<?> candidateParameterType) {
if (candidateParameterType.equals(ProceedingJoinPoint.class)) {
if (ProceedingJoinPoint.class == candidateParameterType) {
if (!supportsProceedingJoinPoint()) {
throw new IllegalArgumentException("ProceedingJoinPoint is only supported for around advice");
}
@@ -408,7 +408,7 @@ public abstract class AbstractAspectJAdvice implements Advice, AspectJPrecedence
}
private boolean maybeBindJoinPointStaticPart(Class<?> candidateParameterType) {
if (candidateParameterType.equals(JoinPoint.StaticPart.class)) {
if (JoinPoint.StaticPart.class == candidateParameterType) {
this.joinPointStaticPartArgumentIndex = 0;
return true;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2015 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.
@@ -93,7 +93,7 @@ public class AspectJAfterReturningAdvice extends AbstractAspectJAdvice implement
if (returnValue != null) {
return ClassUtils.isAssignableValue(type, returnValue);
}
else if (type.equals(Object.class) && method.getReturnType().equals(void.class)) {
else if (Object.class == type && void.class == method.getReturnType()) {
return true;
}
else{

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@@ -72,7 +72,7 @@ public class AspectMetadata {
Class<?> currClass = aspectClass;
AjType<?> ajType = null;
while (!currClass.equals(Object.class)) {
while (currClass != Object.class) {
AjType<?> ajTypeToCheck = AjTypeSystem.getAjType(currClass);
if (ajTypeToCheck.isAspect()) {
ajType = ajTypeToCheck;

View File

@@ -157,7 +157,7 @@ public class ReflectiveAspectJAdvisorFactory extends AbstractAspectJAdvisorFacto
return null;
}
if (DeclareParents.class.equals(declareParents.defaultImpl())) {
if (DeclareParents.class == declareParents.defaultImpl()) {
// This is what comes back if it wasn't set. This seems bizarre...
// TODO this restriction possibly should be relaxed
throw new IllegalStateException("defaultImpl must be set on DeclareParents");

View File

@@ -255,7 +255,7 @@ class CglibAopProxy implements AopProxy, Serializable {
* methods across ClassLoaders, and writes warnings to the log for each one found.
*/
private void doValidateClass(Class<?> proxySuperClass, ClassLoader proxyClassLoader) {
if (!Object.class.equals(proxySuperClass)) {
if (Object.class != proxySuperClass) {
Method[] methods = proxySuperClass.getDeclaredMethods();
for (Method method : methods) {
int mod = method.getModifiers();

View File

@@ -71,7 +71,7 @@ public class DefaultAopProxyFactory implements AopProxyFactory, Serializable {
*/
private boolean hasNoUserSuppliedProxyInterfaces(AdvisedSupport config) {
Class<?>[] interfaces = config.getProxiedInterfaces();
return (interfaces.length == 0 || (interfaces.length == 1 && SpringProxy.class.equals(interfaces[0])));
return (interfaces.length == 0 || (interfaces.length == 1 && SpringProxy.class == interfaces[0]));
}
}

View File

@@ -126,7 +126,7 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
* @return whether the given interface is just a container callback
*/
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
return (ifc.equals(InitializingBean.class) || ifc.equals(DisposableBean.class) ||
return (InitializingBean.class == ifc || DisposableBean.class == ifc ||
ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2015 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.
@@ -109,7 +109,7 @@ public class ThrowsAdviceInterceptor implements MethodInterceptor, AfterAdvice {
logger.trace("Trying to find handler for exception of type [" + exceptionClass.getName() + "]");
}
Method handler = this.exceptionHandlerMap.get(exceptionClass);
while (handler == null && !exceptionClass.equals(Throwable.class)) {
while (handler == null && exceptionClass != Throwable.class) {
exceptionClass = exceptionClass.getSuperclass();
handler = this.exceptionHandlerMap.get(exceptionClass);
}