Fix remaining compiler warnings

Fix remaining Java compiler warnings, mainly around missing
generics or deprecated code.

Also add the `-Werror` compiler option to ensure that any future
warnings will fail the build.

Issue: SPR-11064
This commit is contained in:
Phillip Webb
2013-11-21 18:15:09 -08:00
parent 4de3291dc7
commit 59002f2456
540 changed files with 1943 additions and 1843 deletions

View File

@@ -172,7 +172,7 @@ public abstract class DataAccessUtils {
* @throws TypeMismatchDataAccessException if the unique object
* in the collection is not convertable to an int
*/
public static int intResult(Collection results)
public static int intResult(Collection<?> results)
throws IncorrectResultSizeDataAccessException, TypeMismatchDataAccessException {
return objectResult(results, Number.class).intValue();
@@ -191,7 +191,7 @@ public abstract class DataAccessUtils {
* @throws TypeMismatchDataAccessException if the unique object
* in the collection is not convertable to a long
*/
public static long longResult(Collection results)
public static long longResult(Collection<?> results)
throws IncorrectResultSizeDataAccessException, TypeMismatchDataAccessException {
return objectResult(results, Number.class).longValue();

View File

@@ -213,7 +213,7 @@ public class SingleConnectionFactory extends DelegatingConnectionFactory impleme
protected Connection getCloseSuppressingConnectionProxy(Connection target) {
return (Connection) Proxy.newProxyInstance(
Connection.class.getClassLoader(),
new Class[] {Connection.class},
new Class<?>[] {Connection.class},
new CloseSuppressingInvocationHandler(target));
}

View File

@@ -108,7 +108,7 @@ public class TransactionAwareConnectionFactoryProxy extends DelegatingConnection
protected Connection getTransactionAwareConnectionProxy(Connection target, ConnectionFactory cf) {
return (Connection) Proxy.newProxyInstance(
Connection.class.getClassLoader(),
new Class[] {Connection.class},
new Class<?>[] {Connection.class},
new TransactionAwareInvocationHandler(target, cf));
}

View File

@@ -140,7 +140,7 @@ public abstract class MappingRecordOperation extends EisOperation {
* Implementation of RecordExtractor that calls the enclosing
* class's {@code extractOutputData} method.
*/
protected class RecordExtractorImpl implements RecordExtractor {
protected class RecordExtractorImpl implements RecordExtractor<Object> {
@Override
public Object extractData(Record record) throws ResourceException, SQLException, DataAccessException {

View File

@@ -66,7 +66,7 @@ public class ResourceAdapterFactoryBean implements FactoryBean<ResourceAdapter>,
* through the "resourceAdapter" property.
* @see #setResourceAdapter
*/
public void setResourceAdapterClass(Class resourceAdapterClass) {
public void setResourceAdapterClass(Class<?> resourceAdapterClass) {
Assert.isAssignable(ResourceAdapter.class, resourceAdapterClass);
this.resourceAdapter = (ResourceAdapter) BeanUtils.instantiateClass(resourceAdapterClass);
}

View File

@@ -83,7 +83,7 @@ public class TransactionSystemException extends TransactionException {
}
@Override
public boolean contains(Class exType) {
public boolean contains(Class<?> exType) {
return super.contains(exType) || (exType != null && exType.isInstance(this.applicationException));
}

View File

@@ -57,13 +57,13 @@ public class JtaTransactionAnnotationParser implements TransactionAnnotationPars
rbta.setPropagationBehaviorName(
RuleBasedTransactionAttribute.PREFIX_PROPAGATION + attributes.getEnum("value").toString());
ArrayList<RollbackRuleAttribute> rollBackRules = new ArrayList<RollbackRuleAttribute>();
Class[] rbf = attributes.getClassArray("rollbackOn");
for (Class rbRule : rbf) {
Class<?>[] rbf = attributes.getClassArray("rollbackOn");
for (Class<?> rbRule : rbf) {
RollbackRuleAttribute rule = new RollbackRuleAttribute(rbRule);
rollBackRules.add(rule);
}
Class[] nrbf = attributes.getClassArray("dontRollbackOn");
for (Class rbRule : nrbf) {
Class<?>[] nrbf = attributes.getClassArray("dontRollbackOn");
for (Class<?> rbRule : nrbf) {
NoRollbackRuleAttribute rule = new NoRollbackRuleAttribute(rbRule);
rollBackRules.add(rule);
}

View File

@@ -62,8 +62,8 @@ public class SpringTransactionAnnotationParser implements TransactionAnnotationP
rbta.setReadOnly(attributes.getBoolean("readOnly"));
rbta.setQualifier(attributes.getString("value"));
ArrayList<RollbackRuleAttribute> rollBackRules = new ArrayList<RollbackRuleAttribute>();
Class[] rbf = attributes.getClassArray("rollbackFor");
for (Class rbRule : rbf) {
Class<?>[] rbf = attributes.getClassArray("rollbackFor");
for (Class<?> rbRule : rbf) {
RollbackRuleAttribute rule = new RollbackRuleAttribute(rbRule);
rollBackRules.add(rule);
}
@@ -72,8 +72,8 @@ public class SpringTransactionAnnotationParser implements TransactionAnnotationP
RollbackRuleAttribute rule = new RollbackRuleAttribute(rbRule);
rollBackRules.add(rule);
}
Class[] nrbf = attributes.getClassArray("noRollbackFor");
for (Class rbRule : nrbf) {
Class<?>[] nrbf = attributes.getClassArray("noRollbackFor");
for (Class<?> rbRule : nrbf) {
NoRollbackRuleAttribute rule = new NoRollbackRuleAttribute(rbRule);
rollBackRules.add(rule);
}

View File

@@ -203,9 +203,9 @@ public abstract class AbstractFallbackTransactionAttributeSource implements Tran
private final Method method;
private final Class targetClass;
private final Class<?> targetClass;
public DefaultCacheKey(Method method, Class targetClass) {
public DefaultCacheKey(Method method, Class<?> targetClass) {
this.method = method;
this.targetClass = targetClass;
}

View File

@@ -128,7 +128,7 @@ public class MethodMapTransactionAttributeSource
}
String className = name.substring(0, lastDotIndex);
String methodName = name.substring(lastDotIndex + 1);
Class clazz = ClassUtils.resolveClassName(className, this.beanClassLoader);
Class<?> clazz = ClassUtils.resolveClassName(className, this.beanClassLoader);
addTransactionalMethod(clazz, methodName, attr);
}

View File

@@ -74,7 +74,7 @@ public class NameMatchTransactionAttributeSource implements TransactionAttribute
*/
public void setProperties(Properties transactionAttributes) {
TransactionAttributeEditor tae = new TransactionAttributeEditor();
Enumeration propNames = transactionAttributes.propertyNames();
Enumeration<?> propNames = transactionAttributes.propertyNames();
while (propNames.hasMoreElements()) {
String methodName = (String) propNames.nextElement();
String value = transactionAttributes.getProperty(methodName);

View File

@@ -32,7 +32,7 @@ public class NoRollbackRuleAttribute extends RollbackRuleAttribute {
* @param clazz the {@code Throwable} class
* @see RollbackRuleAttribute#RollbackRuleAttribute(Class)
*/
public NoRollbackRuleAttribute(Class clazz) {
public NoRollbackRuleAttribute(Class<?> clazz) {
super(clazz);
}

View File

@@ -59,7 +59,7 @@ public class RollbackRuleAttribute implements Serializable{
* @throws IllegalArgumentException if the supplied {@code clazz} is
* not a {@code Throwable} type or is {@code null}
*/
public RollbackRuleAttribute(Class clazz) {
public RollbackRuleAttribute(Class<?> clazz) {
Assert.notNull(clazz, "'clazz' cannot be null.");
if (!Throwable.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(
@@ -110,7 +110,7 @@ public class RollbackRuleAttribute implements Serializable{
}
private int getDepth(Class exceptionClass, int depth) {
private int getDepth(Class<?> exceptionClass, int depth) {
if (exceptionClass.getName().indexOf(this.exceptionName) != -1) {
// Found it!
return depth;

View File

@@ -244,7 +244,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
* @return the return value of the method, if any
* @throws Throwable propagated from the target invocation
*/
protected Object invokeWithinTransaction(Method method, Class targetClass, final InvocationCallback invocation)
protected Object invokeWithinTransaction(Method method, Class<?> targetClass, final InvocationCallback invocation)
throws Throwable {
// If the transaction attribute is null, the method is non-transactional.
@@ -347,7 +347,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
* @return a String representation identifying this method
* @see org.springframework.util.ClassUtils#getQualifiedMethodName
*/
protected String methodIdentification(Method method, Class targetClass) {
protected String methodIdentification(Method method, Class<?> targetClass) {
String simpleMethodId = methodIdentification(method);
if (simpleMethodId != null) {
return simpleMethodId;
@@ -381,7 +381,7 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
* {@link #createTransactionIfNecessary(PlatformTransactionManager, TransactionAttribute, String)}
*/
@Deprecated
protected TransactionInfo createTransactionIfNecessary(Method method, Class targetClass) {
protected TransactionInfo createTransactionIfNecessary(Method method, Class<?> targetClass) {
// If the transaction attribute is null, the method is non-transactional.
TransactionAttribute txAttr = getTransactionAttributeSource().getTransactionAttribute(method, targetClass);
PlatformTransactionManager tm = determineTransactionManager(txAttr);

View File

@@ -59,7 +59,7 @@ public class TransactionAttributeSourceEditor extends PropertyEditorSupport {
// Now we have properties, process each one individually.
TransactionAttributeEditor tae = new TransactionAttributeEditor();
Enumeration propNames = props.propertyNames();
Enumeration<?> propNames = props.propertyNames();
while (propNames.hasMoreElements()) {
String name = (String) propNames.nextElement();
String value = props.getProperty(name);

View File

@@ -33,7 +33,7 @@ import org.springframework.util.ObjectUtils;
abstract class TransactionAttributeSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
@Override
public boolean matches(Method method, Class targetClass) {
public boolean matches(Method method, Class<?> targetClass) {
TransactionAttributeSource tas = getTransactionAttributeSource();
return (tas == null || tas.getTransactionAttribute(method, targetClass) != null);
}