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

@@ -31,9 +31,9 @@ import net.sf.ehcache.constructs.blocking.SelfPopulatingCache;
import net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory;
import net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache;
import net.sf.ehcache.event.CacheEventListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
@@ -85,6 +85,7 @@ public class EhCacheFactoryBean extends CacheConfiguration implements FactoryBea
private Ehcache cache;
@SuppressWarnings("deprecation")
public EhCacheFactoryBean() {
setMaxElementsInMemory(10000);
setMaxElementsOnDisk(10000000);

View File

@@ -101,7 +101,7 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage
protected Collection<Cache> loadCaches() {
Collection<Cache> caches = new LinkedHashSet<Cache>();
for (String cacheName : this.cacheManager.getCacheNames()) {
javax.cache.Cache jcache = this.cacheManager.getCache(cacheName);
javax.cache.Cache<Object, Object> jcache = this.cacheManager.getCache(cacheName);
caches.add(new JCacheCache(jcache, this.allowNullValues));
}
return caches;

View File

@@ -53,12 +53,12 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T
@Override
public ScheduledFuture schedule(Runnable task, Trigger trigger) {
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
return new ReschedulingTimerListener(errorHandlingTask(task, true), trigger).schedule();
}
@Override
public ScheduledFuture schedule(Runnable task, Date startTime) {
public ScheduledFuture<?> schedule(Runnable task, Date startTime) {
TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, false));
Timer timer = getTimerManager().schedule(futureTask, startTime);
futureTask.setTimer(timer);
@@ -66,7 +66,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T
}
@Override
public ScheduledFuture scheduleAtFixedRate(Runnable task, Date startTime, long period) {
public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, Date startTime, long period) {
TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true));
Timer timer = getTimerManager().scheduleAtFixedRate(futureTask, startTime, period);
futureTask.setTimer(timer);
@@ -74,7 +74,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T
}
@Override
public ScheduledFuture scheduleAtFixedRate(Runnable task, long period) {
public ScheduledFuture<?> scheduleAtFixedRate(Runnable task, long period) {
TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true));
Timer timer = getTimerManager().scheduleAtFixedRate(futureTask, 0, period);
futureTask.setTimer(timer);
@@ -82,7 +82,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T
}
@Override
public ScheduledFuture scheduleWithFixedDelay(Runnable task, Date startTime, long delay) {
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, Date startTime, long delay) {
TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true));
Timer timer = getTimerManager().schedule(futureTask, startTime, delay);
futureTask.setTimer(timer);
@@ -90,7 +90,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T
}
@Override
public ScheduledFuture scheduleWithFixedDelay(Runnable task, long delay) {
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable task, long delay) {
TimerScheduledFuture futureTask = new TimerScheduledFuture(errorHandlingTask(task, true));
Timer timer = getTimerManager().schedule(futureTask, 0, delay);
futureTask.setTimer(timer);
@@ -164,7 +164,7 @@ public class TimerManagerTaskScheduler extends TimerManagerAccessor implements T
this.trigger = trigger;
}
public ScheduledFuture schedule() {
public ScheduledFuture<?> schedule() {
this.scheduledExecutionTime = this.trigger.nextExecutionTime(this.triggerContext);
if (this.scheduledExecutionTime == null) {
return null;

View File

@@ -20,6 +20,7 @@ import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import javax.naming.NamingException;
import commonj.work.Work;
@@ -176,11 +177,13 @@ public class WorkManagerTaskExecutor extends JndiLocatorSupport
}
@Override
@SuppressWarnings("rawtypes")
public boolean waitForAll(Collection workItems, long timeout) throws InterruptedException {
return this.workManager.waitForAll(workItems, timeout);
}
@Override
@SuppressWarnings("rawtypes")
public Collection waitForAny(Collection workItems, long timeout) throws InterruptedException {
return this.workManager.waitForAny(workItems, timeout);
}

View File

@@ -74,7 +74,7 @@ public class AdaptableJobFactory implements JobFactory {
Method getJobDetail = bundle.getClass().getMethod("getJobDetail");
Object jobDetail = ReflectionUtils.invokeMethod(getJobDetail, bundle);
Method getJobClass = jobDetail.getClass().getMethod("getJobClass");
Class jobClass = (Class) ReflectionUtils.invokeMethod(getJobClass, jobDetail);
Class<?> jobClass = (Class<?>) ReflectionUtils.invokeMethod(getJobClass, jobDetail);
return jobClass.newInstance();
}

View File

@@ -232,7 +232,7 @@ public class CronTriggerFactoryBean implements FactoryBean<CronTrigger>, BeanNam
this.cronTrigger = cti;
*/
Class cronTriggerClass;
Class<?> cronTriggerClass;
Method jobKeyMethod;
try {
cronTriggerClass = getClass().getClassLoader().loadClass("org.quartz.impl.triggers.CronTriggerImpl");

View File

@@ -21,7 +21,6 @@ import java.util.Map;
import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
@@ -48,11 +47,11 @@ import org.springframework.context.ApplicationContextAware;
* @see org.springframework.beans.factory.BeanNameAware
* @see org.quartz.Scheduler#DEFAULT_GROUP
*/
@SuppressWarnings("serial")
@SuppressWarnings({ "serial", "rawtypes" })
public class JobDetailBean extends JobDetail
implements BeanNameAware, ApplicationContextAware, InitializingBean {
private Class actualJobClass;
private Class<?> actualJobClass;
private String beanName;

View File

@@ -56,7 +56,7 @@ public class JobDetailFactoryBean
private String group;
private Class jobClass;
private Class<?> jobClass;
private JobDataMap jobDataMap = new JobDataMap();
@@ -92,7 +92,7 @@ public class JobDetailFactoryBean
/**
* Specify the job's implementation class.
*/
public void setJobClass(Class jobClass) {
public void setJobClass(Class<?> jobClass) {
this.jobClass = jobClass;
}

View File

@@ -92,7 +92,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
jobDetailImplClass = null;
}
try {
Class jobExecutionContextClass =
Class<?> jobExecutionContextClass =
QuartzJobBean.class.getClassLoader().loadClass("org.quartz.JobExecutionContext");
setResultMethod = jobExecutionContextClass.getMethod("setResult", Object.class);
}
@@ -192,7 +192,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
}
@Override
protected Class resolveClassName(String className) throws ClassNotFoundException {
protected Class<?> resolveClassName(String className) throws ClassNotFoundException {
return ClassUtils.forName(className, this.beanClassLoader);
}
@@ -205,7 +205,7 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
String name = (this.name != null ? this.name : this.beanName);
// Consider the concurrent flag to choose between stateful and stateless job.
Class jobClass = (this.concurrent ? MethodInvokingJob.class : StatefulMethodInvokingJob.class);
Class<?> jobClass = (this.concurrent ? MethodInvokingJob.class : StatefulMethodInvokingJob.class);
// Build JobDetail instance.
if (jobDetailImplClass != null) {
@@ -253,8 +253,8 @@ public class MethodInvokingJobDetailFactoryBean extends ArgumentConvertingMethod
* Overridden to support the {@link #setTargetBeanName "targetBeanName"} feature.
*/
@Override
public Class getTargetClass() {
Class targetClass = super.getTargetClass();
public Class<?> getTargetClass() {
Class<?> targetClass = super.getTargetClass();
if (targetClass == null && this.targetBeanName != null) {
Assert.state(this.beanFactory != null, "BeanFactory must be set when using 'targetBeanName'");
targetClass = this.beanFactory.getType(this.targetBeanName);

View File

@@ -76,7 +76,7 @@ public abstract class QuartzJobBean implements Job {
static {
try {
Class jobExecutionContextClass =
Class<?> jobExecutionContextClass =
QuartzJobBean.class.getClassLoader().loadClass("org.quartz.JobExecutionContext");
getSchedulerMethod = jobExecutionContextClass.getMethod("getScheduler");
getMergedJobDataMapMethod = jobExecutionContextClass.getMethod("getMergedJobDataMap");
@@ -97,7 +97,7 @@ public abstract class QuartzJobBean implements Job {
try {
// Reflectively adapting to differences between Quartz 1.x and Quartz 2.0...
Scheduler scheduler = (Scheduler) ReflectionUtils.invokeMethod(getSchedulerMethod, context);
Map mergedJobDataMap = (Map) ReflectionUtils.invokeMethod(getMergedJobDataMapMethod, context);
Map<?, ?> mergedJobDataMap = (Map<?, ?>) ReflectionUtils.invokeMethod(getMergedJobDataMapMethod, context);
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
MutablePropertyValues pvs = new MutablePropertyValues();

View File

@@ -24,7 +24,6 @@ import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.spi.ClassLoadHelper;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
@@ -73,6 +72,7 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper {
}
@Override
@SuppressWarnings("rawtypes")
public Class loadClass(String name) throws ClassNotFoundException {
return this.resourceLoader.getClassLoader().loadClass(name);
}

View File

@@ -382,7 +382,7 @@ public abstract class SchedulerAccessor implements ResourceLoaderAware {
}
else {
try {
Map jobDataMap = (Map) ReflectionUtils.invokeMethod(Trigger.class.getMethod("getJobDataMap"), trigger);
Map<?, ?> jobDataMap = (Map<?, ?>) ReflectionUtils.invokeMethod(Trigger.class.getMethod("getJobDataMap"), trigger);
return (JobDetail) jobDataMap.remove(JobDetailAwareTrigger.JOB_DETAIL_KEY);
}
catch (NoSuchMethodException ex) {

View File

@@ -173,7 +173,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
private DataSource nonTransactionalDataSource;
private Map schedulerContextMap;
private Map<? ,?> schedulerContextMap;
private ApplicationContext applicationContext;
@@ -208,7 +208,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
* @see #setConfigLocation
* @see #setQuartzProperties
*/
public void setSchedulerFactoryClass(Class schedulerFactoryClass) {
public void setSchedulerFactoryClass(Class<?> schedulerFactoryClass) {
if (schedulerFactoryClass == null || !SchedulerFactory.class.isAssignableFrom(schedulerFactoryClass)) {
throw new IllegalArgumentException("schedulerFactoryClass must implement [org.quartz.SchedulerFactory]");
}
@@ -313,7 +313,7 @@ public class SchedulerFactoryBean extends SchedulerAccessor implements FactoryBe
* values (for example Spring-managed beans)
* @see JobDetailBean#setJobDataAsMap
*/
public void setSchedulerContextAsMap(Map schedulerContextAsMap) {
public void setSchedulerContextAsMap(Map<?, ?> schedulerContextAsMap) {
this.schedulerContextMap = schedulerContextAsMap;
}

View File

@@ -233,7 +233,7 @@ public class SimpleTriggerFactoryBean implements FactoryBean<SimpleTrigger>, Bea
this.simpleTrigger = sti;
*/
Class simpleTriggerClass;
Class<?> simpleTriggerClass;
Method jobKeyMethod;
try {
simpleTriggerClass = getClass().getClassLoader().loadClass("org.quartz.impl.triggers.SimpleTriggerImpl");

View File

@@ -63,7 +63,7 @@ public abstract class JasperReportsUtils {
return (JRDataSource) value;
}
else if (value instanceof Collection) {
return new JRBeanCollectionDataSource((Collection) value);
return new JRBeanCollectionDataSource((Collection<?>) value);
}
else if (value instanceof Object[]) {
return new JRBeanArrayDataSource((Object[]) value);