Fix compiler warnings
This patch fixes several compiler warnings that do not point to code
problems. Two kinds of warnings are fixed. First in a lot of cases
@SuppressWarnings("unchecked") is used although there are no unchecked
casts happening. This seems to be a leftover from when the code base
was on Java 1.4, now that the code base was moved to Java 1.5 these are
no longer necessary. Secondly there some places where the raw types of
List and Class are used where there wildcard types (List<?> and
Class<?>) would work just as well without causing any raw type warnings.
These changes are beneficial particularly when working in Eclipse or
other IDEs because it reduces 'noise', helping to isolate actual
potential problems in the code.
The following changes have been made:
- remove @SuppressWarnings where no longer needed
- use wildcard types instead of raw types where possible
This commit is contained in:
committed by
Chris Beams
parent
e68b563626
commit
13239a0c3d
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2012 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,6 @@ public class ProxyFactory extends ProxyCreatorSupport {
|
||||
* (if necessary for proxy creation).
|
||||
* @return the proxy object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getProxy() {
|
||||
return createAopProxy().getProxy();
|
||||
}
|
||||
@@ -107,7 +106,6 @@ public class ProxyFactory extends ProxyCreatorSupport {
|
||||
* (or <code>null</code> for the low-level proxy facility's default)
|
||||
* @return the proxy object
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getProxy(ClassLoader classLoader) {
|
||||
return createAopProxy().getProxy(classLoader);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -59,7 +59,6 @@ public class DestructionAwareAttributeHolder implements Serializable {
|
||||
* the name of the attribute to be returned
|
||||
* @return the attribute value or <code>null</code> if not available
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object getAttribute(String name) {
|
||||
return attributes.get(name);
|
||||
}
|
||||
@@ -75,7 +74,6 @@ public class DestructionAwareAttributeHolder implements Serializable {
|
||||
* @return any previously object stored under the same name, if any,
|
||||
* <code>null</code> otherwise
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object setAttribute(String name, Object value) {
|
||||
return attributes.put(name, value);
|
||||
}
|
||||
@@ -101,7 +99,6 @@ public class DestructionAwareAttributeHolder implements Serializable {
|
||||
* @return the removed object, or <code>null</code> if no object was present
|
||||
* @see #registerDestructionCallback
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object removeAttribute(String name) {
|
||||
Object value = attributes.remove(name);
|
||||
|
||||
|
||||
@@ -168,7 +168,6 @@ public class JobDetailFactoryBean
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void afterPropertiesSet() {
|
||||
if (this.name == null) {
|
||||
this.name = this.beanName;
|
||||
@@ -196,7 +195,7 @@ public class JobDetailFactoryBean
|
||||
this.jobDetail = jdi;
|
||||
*/
|
||||
|
||||
Class jobDetailClass;
|
||||
Class<?> jobDetailClass;
|
||||
try {
|
||||
jobDetailClass = getClass().getClassLoader().loadClass("org.quartz.impl.JobDetailImpl");
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -88,7 +88,6 @@ public class SourceFilteringListener implements SmartApplicationListener {
|
||||
* <p>The default implementation invokes the specified delegate, if any.
|
||||
* @param event the event to process (matching the specified source)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void onApplicationEventInternal(ApplicationEvent event) {
|
||||
if (this.delegate == null) {
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -91,12 +91,11 @@ class WebSphereClassLoaderAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ClassLoader getThrowawayClassLoader() {
|
||||
try {
|
||||
ClassLoader loader = (ClassLoader) cloneConstructor.newInstance(getClassLoader());
|
||||
// clear out the transformers (copied as well)
|
||||
List list = (List) transformerList.get(loader);
|
||||
List<?> list = (List<?>) transformerList.get(loader);
|
||||
list.clear();
|
||||
return loader;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -20,7 +20,7 @@ import org.springframework.aop.framework.AbstractSingletonProxyFactoryBean;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
|
||||
@SuppressWarnings({ "serial", "deprecation" })
|
||||
@SuppressWarnings("serial")
|
||||
public class TestProxyFactoryBean extends AbstractSingletonProxyFactoryBean implements BeanFactoryAware {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -77,7 +77,6 @@ public class LocalVariableTableParameterNameDiscoverer implements ParameterNameD
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String[] getParameterNames(Constructor ctor) {
|
||||
Class<?> declaringClass = ctor.getDeclaringClass();
|
||||
Map<Member, String[]> map = this.parameterNamesCache.get(declaringClass);
|
||||
|
||||
@@ -281,7 +281,6 @@ public class MethodParameter {
|
||||
* @param annotationType the annotation type to look for
|
||||
* @return the annotation object, or <code>null</code> if not found
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Annotation> T getMethodAnnotation(Class<T> annotationType) {
|
||||
return getAnnotatedElement().getAnnotation(annotationType);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2012 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,6 @@ public class ColumnMapRowMapper implements RowMapper<Map<String, Object>> {
|
||||
* @return the new Map instance
|
||||
* @see org.springframework.util.LinkedCaseInsensitiveMap
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Map<String, Object> createColumnMap(int columnCount) {
|
||||
return new LinkedCaseInsensitiveMap<Object>(columnCount);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -159,7 +159,6 @@ public class ServletRequestAttributes extends AbstractRequestAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String[] getAttributeNames(int scope) {
|
||||
if (scope == SCOPE_REQUEST) {
|
||||
if (!isRequestActive()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -87,12 +87,10 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
|
||||
return getResponse();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getNativeRequest(Class<T> requiredType) {
|
||||
return WebUtils.getNativeRequest(getRequest(), requiredType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getNativeResponse(Class<T> requiredType) {
|
||||
return WebUtils.getNativeResponse(getResponse(), requiredType);
|
||||
}
|
||||
@@ -102,13 +100,11 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
|
||||
return getRequest().getHeader(headerName);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String[] getHeaderValues(String headerName) {
|
||||
String[] headerValues = StringUtils.toStringArray(getRequest().getHeaders(headerName));
|
||||
return (!ObjectUtils.isEmpty(headerValues) ? headerValues : null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterator<String> getHeaderNames() {
|
||||
return CollectionUtils.toIterator(getRequest().getHeaderNames());
|
||||
}
|
||||
@@ -121,12 +117,10 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
|
||||
return getRequest().getParameterValues(paramName);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Iterator<String> getParameterNames() {
|
||||
return CollectionUtils.toIterator(getRequest().getParameterNames());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<String, String[]> getParameterMap() {
|
||||
return getRequest().getParameterMap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user