Fix [serial] compiler warnings

Fix serialization warnings by applying @SuppressWarnings("serial")
when appropriate.

In certain cases and for unknown reasons, a correctly-placed
@SuppressWarnings("serial") annotation will fix the warning at the
javac level (i.e. the Gradle command-line), but will produce an
"unnecessary @SuppressWarnings" warning within Eclipse. In these
cases, a private static final serialVersionUID field has been added
with the default value of 1L.
This commit is contained in:
Phillip Webb
2012-12-19 14:35:57 -08:00
committed by Chris Beams
parent 7f0aa5cfb2
commit b0986049a3
550 changed files with 705 additions and 36 deletions

View File

@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
* @author Juergen Hoeller
* @since 2.0
*/
@SuppressWarnings("serial")
public abstract class AttributeAccessorSupport implements AttributeAccessor, Serializable {
/** Map with String keys and Object values */

View File

@@ -334,6 +334,7 @@ public abstract class CollectionFactory {
* ConcurrentMap adapter for the JDK ConcurrentHashMap class.
*/
@Deprecated
@SuppressWarnings("serial")
private static class JdkConcurrentHashMap extends ConcurrentHashMap implements ConcurrentMap {
private JdkConcurrentHashMap(int initialCapacity) {

View File

@@ -24,6 +24,7 @@ package org.springframework.core;
* @since 28.04.2003
* @see org.springframework.core.Constants
*/
@SuppressWarnings("serial")
public class ConstantException extends IllegalArgumentException {
/**

View File

@@ -35,6 +35,7 @@ import java.io.IOException;
* @see org.springframework.core.NestedCheckedException
* @see org.springframework.core.NestedRuntimeException
*/
@SuppressWarnings("serial")
public class NestedIOException extends IOException {
static {

View File

@@ -99,6 +99,7 @@ public abstract class AbstractCachingLabeledEnumResolver implements LabeledEnumR
/**
* Inner cache class that implements lazy building of LabeledEnum Maps.
*/
@SuppressWarnings("serial")
private class LabeledEnumCache extends CachingMapDecorator<Class, Map<Comparable, LabeledEnum>> {
public LabeledEnumCache() {

View File

@@ -23,6 +23,7 @@ package org.springframework.core.enums;
* @since 1.2.6
* @deprecated as of Spring 3.0, in favor of Java 5 enums.
*/
@SuppressWarnings("serial")
public abstract class AbstractGenericLabeledEnum extends AbstractLabeledEnum {
/**

View File

@@ -26,6 +26,7 @@ package org.springframework.core.enums;
* @deprecated as of Spring 3.0, in favor of Java 5 enums.
*/
@Deprecated
@SuppressWarnings("serial")
public abstract class AbstractLabeledEnum implements LabeledEnum {
/**

View File

@@ -30,6 +30,7 @@ import org.springframework.util.Assert;
* @deprecated as of Spring 3.0, in favor of Java 5 enums.
*/
@Deprecated
@SuppressWarnings("serial")
public class LetterCodedLabeledEnum extends AbstractGenericLabeledEnum {
/**

View File

@@ -30,6 +30,8 @@ package org.springframework.core.enums;
@Deprecated
public class ShortCodedLabeledEnum extends AbstractGenericLabeledEnum {
private static final long serialVersionUID = 1L;
/**
* The unique code of this enum.
*/

View File

@@ -44,6 +44,7 @@ package org.springframework.core.enums;
* @deprecated as of Spring 3.0, in favor of Java 5 enums.
*/
@Deprecated
@SuppressWarnings("serial")
public abstract class StaticLabeledEnum extends AbstractLabeledEnum {
/**

View File

@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
* @deprecated as of Spring 3.0, in favor of Java 5 enums.
*/
@Deprecated
@SuppressWarnings("serial")
public class StringCodedLabeledEnum extends AbstractGenericLabeledEnum {
/**

View File

@@ -28,6 +28,7 @@ import org.springframework.core.NestedRuntimeException;
* @author Juergen Hoeller
* @since 3.0.5
*/
@SuppressWarnings("serial")
public class SerializationFailedException extends NestedRuntimeException {
/**

View File

@@ -44,6 +44,7 @@ import org.springframework.util.CustomizableThreadCreator;
* @see org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
* @see org.springframework.scheduling.commonj.WorkManagerTaskExecutor
*/
@SuppressWarnings("serial")
public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator implements AsyncTaskExecutor, Serializable {
/**

View File

@@ -36,6 +36,7 @@ import org.springframework.util.Assert;
* @since 2.0
* @see SimpleAsyncTaskExecutor
*/
@SuppressWarnings("serial")
public class SyncTaskExecutor implements TaskExecutor, Serializable {
/**

View File

@@ -27,6 +27,7 @@ import java.util.concurrent.RejectedExecutionException;
* @see TaskExecutor#execute(Runnable)
* @see TaskTimeoutException
*/
@SuppressWarnings("serial")
public class TaskRejectedException extends RejectedExecutionException {
/**

View File

@@ -25,6 +25,7 @@ package org.springframework.core.task;
* @see AsyncTaskExecutor#execute(Runnable, long)
* @see TaskRejectedException
*/
@SuppressWarnings("serial")
public class TaskTimeoutException extends TaskRejectedException {
/**

View File

@@ -40,6 +40,7 @@ public class CachingMetadataReaderFactory extends SimpleMetadataReaderFactory {
private volatile int cacheLimit = DEFAULT_CACHE_LIMIT;
@SuppressWarnings("serial")
private final Map<Resource, MetadataReader> metadataReaderCache =
new LinkedHashMap<Resource, MetadataReader>(DEFAULT_CACHE_LIMIT, 0.75f, true) {
@Override

View File

@@ -39,6 +39,7 @@ import java.util.ListIterator;
* @author Juergen Hoeller
* @since 2.0
*/
@SuppressWarnings("serial")
public class AutoPopulatingList<E> implements List<E>, Serializable {
/**

View File

@@ -44,6 +44,7 @@ import java.util.WeakHashMap;
* @deprecated as of Spring 3.2, to be removed along with LabeledEnum support
*/
@Deprecated
@SuppressWarnings("serial")
public abstract class CachingMapDecorator<K, V> implements Map<K, V>, Serializable {
private static Object NULL_VALUE = new Object();

View File

@@ -386,6 +386,7 @@ public abstract class CollectionUtils {
/**
* Adapts a Map to the MultiValueMap contract.
*/
@SuppressWarnings("serial")
private static class MultiValueMapAdapter<K, V> implements MultiValueMap<K, V>, Serializable {
private final Map<K, List<V>> map;

View File

@@ -43,6 +43,7 @@ import org.apache.commons.logging.LogFactory;
* @see org.springframework.aop.interceptor.ConcurrencyThrottleInterceptor
* @see java.io.Serializable
*/
@SuppressWarnings("serial")
public abstract class ConcurrencyThrottleSupport implements Serializable {
/**

View File

@@ -29,6 +29,7 @@ import java.io.Serializable;
* @since 2.0.3
* @see org.springframework.scheduling.concurrent.CustomizableThreadFactory
*/
@SuppressWarnings("serial")
public class CustomizableThreadCreator implements Serializable {
private String threadNamePrefix;

View File

@@ -33,6 +33,7 @@ import java.util.Map;
* @author Juergen Hoeller
* @since 3.0
*/
@SuppressWarnings("serial")
public class LinkedCaseInsensitiveMap<V> extends LinkedHashMap<String, V> {
private final Map<String, String> caseInsensitiveKeys;

View File

@@ -25,6 +25,7 @@ import java.util.Comparator;
* @author Keith Donald
* @since 1.2.2
*/
@SuppressWarnings("serial")
public final class BooleanComparator implements Comparator<Boolean>, Serializable {
/**

View File

@@ -21,6 +21,7 @@ import org.springframework.core.enums.ShortCodedLabeledEnum;
/**
* @author Rob Harrop
*/
@SuppressWarnings("serial")
public class Colour extends ShortCodedLabeledEnum {
public static final Colour RED = new Colour(0, "RED");
@@ -32,4 +33,4 @@ public class Colour extends ShortCodedLabeledEnum {
super(code, label);
}
}
}

View File

@@ -22,6 +22,7 @@ import java.io.Serializable;
* @author Juergen Hoeller
* @since 21.08.2003
*/
@SuppressWarnings("serial")
public class DerivedTestBean extends TestBean implements Serializable {
private String beanName;
@@ -79,4 +80,4 @@ public class DerivedTestBean extends TestBean implements Serializable {
return destroyed;
}
}
}

View File

@@ -32,6 +32,7 @@ public class AttributeAccessorSupportTests extends TestCase {
private AttributeAccessor attributeAccessor;
@SuppressWarnings("serial")
protected void setUp() throws Exception {
this.attributeAccessor = new AttributeAccessorSupport() {
};

View File

@@ -87,18 +87,23 @@ public class ExceptionDepthComparatorTests {
return ExceptionDepthComparator.findClosestMatch(Arrays.asList(classes), new TargetException());
}
@SuppressWarnings("serial")
public class HighestDepthException extends Throwable {
}
@SuppressWarnings("serial")
public class LowestDepthException extends HighestDepthException {
}
@SuppressWarnings("serial")
public class TargetException extends LowestDepthException {
}
@SuppressWarnings("serial")
public class SameDepthException extends LowestDepthException {
}
@SuppressWarnings("serial")
public class NoDepthException extends TargetException {
}

View File

@@ -28,6 +28,7 @@ import junit.framework.Assert;
*/
public class NestedExceptionTests extends TestCase {
@SuppressWarnings("serial")
public void testNestedRuntimeExceptionWithNoRootCause() {
String mesg = "mesg of mine";
// Making a class abstract doesn't _really_ prevent instantiation :-)
@@ -44,6 +45,7 @@ public class NestedExceptionTests extends TestCase {
assertFalse(stackTrace.indexOf(mesg) == -1);
}
@SuppressWarnings("serial")
public void testNestedRuntimeExceptionWithRootCause() {
String myMessage = "mesg for this exception";
String rootCauseMesg = "this is the obscure message of the root cause";
@@ -64,6 +66,7 @@ public class NestedExceptionTests extends TestCase {
assertFalse(stackTrace.indexOf(rootCauseMesg) == -1);
}
@SuppressWarnings("serial")
public void testNestedCheckedExceptionWithNoRootCause() {
String mesg = "mesg of mine";
// Making a class abstract doesn't _really_ prevent instantiation :-)
@@ -80,6 +83,7 @@ public class NestedExceptionTests extends TestCase {
assertFalse(stackTrace.indexOf(mesg) == -1);
}
@SuppressWarnings("serial")
public void testNestedCheckedExceptionWithRootCause() {
String myMessage = "mesg for this exception";
String rootCauseMesg = "this is the obscure message of the root cause";

View File

@@ -240,6 +240,7 @@ public class DefaultConversionTests {
conversionService.convert(Integer.valueOf(1), CustomNumber.class);
}
@SuppressWarnings("serial")
public static class CustomNumber extends Number {
@Override

View File

@@ -217,6 +217,7 @@ public class MapToMapConverterTests {
assertEquals(NoDefaultConstructorMap.class, result.getClass());
}
@SuppressWarnings("serial")
public static class NoDefaultConstructorMap<K, V> extends HashMap<K, V> {
public NoDefaultConstructorMap(Map<? extends K, ? extends V> m) {
super(m);

View File

@@ -118,6 +118,7 @@ public class LabeledEnumTests extends TestCase {
}
@SuppressWarnings("serial")
private static class Other extends StaticLabeledEnum {
public static final Other THING1 = new Other(1, "Thing1");
@@ -130,6 +131,7 @@ public class LabeledEnumTests extends TestCase {
}
@SuppressWarnings("serial")
private static class Dog extends StaticLabeledEnum {
public static final Dog GOLDEN_RETRIEVER = new Dog(11, null) {
@@ -159,6 +161,7 @@ public class LabeledEnumTests extends TestCase {
}
@SuppressWarnings("serial")
private static abstract class ValuedEnum extends StaticLabeledEnum {
public static final ValuedEnum ONE = new ValuedEnum(1, "one") {

View File

@@ -94,6 +94,7 @@ public class CachingMapDecoratorTests extends TestCase {
}
@SuppressWarnings("serial")
private static class MyCachingMap extends CachingMapDecorator<String, String> {
private boolean createCalled;

View File

@@ -144,6 +144,7 @@ public abstract class AbstractStaxXMLReaderTestCase {
protected abstract AbstractStaxXMLReader createStaxXmlReader(InputStream inputStream) throws XMLStreamException;
/** Easymock {@code AbstractMatcher} implementation that matches SAX arguments. */
@SuppressWarnings("serial")
protected static class SaxArgumentMatcher extends AbstractMatcher {
@Override