Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 13239a0

Browse files
marschallcbeams
authored andcommitted
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
1 parent e68b563 commit 13239a0

File tree

11 files changed

+12
-30
lines changed

11 files changed

+12
-30
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactory.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -93,7 +93,6 @@ public ProxyFactory(Class proxyInterface, TargetSource targetSource) {
9393
* (if necessary for proxy creation).
9494
* @return the proxy object
9595
*/
96-
@SuppressWarnings("unchecked")
9796
public Object getProxy() {
9897
return createAopProxy().getProxy();
9998
}
@@ -107,7 +106,6 @@ public Object getProxy() {
107106
* (or <code>null</code> for the low-level proxy facility's default)
108107
* @return the proxy object
109108
*/
110-
@SuppressWarnings("unchecked")
111109
public Object getProxy(ClassLoader classLoader) {
112110
return createAopProxy().getProxy(classLoader);
113111
}

spring-beans/src/main/java/org/springframework/beans/factory/config/DestructionAwareAttributeHolder.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -59,7 +59,6 @@ public Map<String, Object> getAttributeMap() {
5959
* the name of the attribute to be returned
6060
* @return the attribute value or <code>null</code> if not available
6161
*/
62-
@SuppressWarnings("unchecked")
6362
public Object getAttribute(String name) {
6463
return attributes.get(name);
6564
}
@@ -75,7 +74,6 @@ public Object getAttribute(String name) {
7574
* @return any previously object stored under the same name, if any,
7675
* <code>null</code> otherwise
7776
*/
78-
@SuppressWarnings("unchecked")
7977
public Object setAttribute(String name, Object value) {
8078
return attributes.put(name, value);
8179
}
@@ -101,7 +99,6 @@ public Object setAttribute(String name, Object value) {
10199
* @return the removed object, or <code>null</code> if no object was present
102100
* @see #registerDestructionCallback
103101
*/
104-
@SuppressWarnings("unchecked")
105102
public Object removeAttribute(String name) {
106103
Object value = attributes.remove(name);
107104

spring-context-support/src/main/java/org/springframework/scheduling/quartz/JobDetailFactoryBean.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ public void setApplicationContextJobDataKey(String applicationContextJobDataKey)
168168
}
169169

170170

171-
@SuppressWarnings("unchecked")
172171
public void afterPropertiesSet() {
173172
if (this.name == null) {
174173
this.name = this.beanName;
@@ -196,7 +195,7 @@ public void afterPropertiesSet() {
196195
this.jobDetail = jdi;
197196
*/
198197

199-
Class jobDetailClass;
198+
Class<?> jobDetailClass;
200199
try {
201200
jobDetailClass = getClass().getClassLoader().loadClass("org.quartz.impl.JobDetailImpl");
202201
}

spring-context/src/main/java/org/springframework/context/event/SourceFilteringListener.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -88,7 +88,6 @@ public int getOrder() {
8888
* <p>The default implementation invokes the specified delegate, if any.
8989
* @param event the event to process (matching the specified source)
9090
*/
91-
@SuppressWarnings("unchecked")
9291
protected void onApplicationEventInternal(ApplicationEvent event) {
9392
if (this.delegate == null) {
9493
throw new IllegalStateException(

spring-context/src/main/java/org/springframework/instrument/classloading/websphere/WebSphereClassLoaderAdapter.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -91,12 +91,11 @@ public void addTransformer(ClassFileTransformer transformer) {
9191
}
9292
}
9393

94-
@SuppressWarnings("unchecked")
9594
public ClassLoader getThrowawayClassLoader() {
9695
try {
9796
ClassLoader loader = (ClassLoader) cloneConstructor.newInstance(getClassLoader());
9897
// clear out the transformers (copied as well)
99-
List list = (List) transformerList.get(loader);
98+
List<?> list = (List<?>) transformerList.get(loader);
10099
list.clear();
101100
return loader;
102101
}

spring-context/src/test/java/org/springframework/context/support/TestProxyFactoryBean.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020
import org.springframework.beans.factory.BeanFactory;
2121
import org.springframework.beans.factory.BeanFactoryAware;
2222

23-
@SuppressWarnings({ "serial", "deprecation" })
23+
@SuppressWarnings("serial")
2424
public class TestProxyFactoryBean extends AbstractSingletonProxyFactoryBean implements BeanFactoryAware {
2525

2626
@Override

spring-core/src/main/java/org/springframework/core/LocalVariableTableParameterNameDiscoverer.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,7 +77,6 @@ public String[] getParameterNames(Method method) {
7777
return null;
7878
}
7979

80-
@SuppressWarnings("unchecked")
8180
public String[] getParameterNames(Constructor ctor) {
8281
Class<?> declaringClass = ctor.getDeclaringClass();
8382
Map<Member, String[]> map = this.parameterNamesCache.get(declaringClass);

spring-core/src/main/java/org/springframework/core/MethodParameter.java

-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ public Annotation[] getMethodAnnotations() {
281281
* @param annotationType the annotation type to look for
282282
* @return the annotation object, or <code>null</code> if not found
283283
*/
284-
@SuppressWarnings("unchecked")
285284
public <T extends Annotation> T getMethodAnnotation(Class<T> annotationType) {
286285
return getAnnotatedElement().getAnnotation(annotationType);
287286
}

spring-jdbc/src/main/java/org/springframework/jdbc/core/ColumnMapRowMapper.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -67,7 +67,6 @@ public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException
6767
* @return the new Map instance
6868
* @see org.springframework.util.LinkedCaseInsensitiveMap
6969
*/
70-
@SuppressWarnings("unchecked")
7170
protected Map<String, Object> createColumnMap(int columnCount) {
7271
return new LinkedCaseInsensitiveMap<Object>(columnCount);
7372
}

spring-web/src/main/java/org/springframework/web/context/request/ServletRequestAttributes.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -159,7 +159,6 @@ public void removeAttribute(String name, int scope) {
159159
}
160160
}
161161

162-
@SuppressWarnings("unchecked")
163162
public String[] getAttributeNames(int scope) {
164163
if (scope == SCOPE_REQUEST) {
165164
if (!isRequestActive()) {

spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2011 the original author or authors.
2+
* Copyright 2002-2012 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -87,12 +87,10 @@ public Object getNativeResponse() {
8787
return getResponse();
8888
}
8989

90-
@SuppressWarnings("unchecked")
9190
public <T> T getNativeRequest(Class<T> requiredType) {
9291
return WebUtils.getNativeRequest(getRequest(), requiredType);
9392
}
9493

95-
@SuppressWarnings("unchecked")
9694
public <T> T getNativeResponse(Class<T> requiredType) {
9795
return WebUtils.getNativeResponse(getResponse(), requiredType);
9896
}
@@ -102,13 +100,11 @@ public String getHeader(String headerName) {
102100
return getRequest().getHeader(headerName);
103101
}
104102

105-
@SuppressWarnings("unchecked")
106103
public String[] getHeaderValues(String headerName) {
107104
String[] headerValues = StringUtils.toStringArray(getRequest().getHeaders(headerName));
108105
return (!ObjectUtils.isEmpty(headerValues) ? headerValues : null);
109106
}
110107

111-
@SuppressWarnings("unchecked")
112108
public Iterator<String> getHeaderNames() {
113109
return CollectionUtils.toIterator(getRequest().getHeaderNames());
114110
}
@@ -121,12 +117,10 @@ public String[] getParameterValues(String paramName) {
121117
return getRequest().getParameterValues(paramName);
122118
}
123119

124-
@SuppressWarnings("unchecked")
125120
public Iterator<String> getParameterNames() {
126121
return CollectionUtils.toIterator(getRequest().getParameterNames());
127122
}
128123

129-
@SuppressWarnings("unchecked")
130124
public Map<String, String[]> getParameterMap() {
131125
return getRequest().getParameterMap();
132126
}

0 commit comments

Comments
 (0)