Fix serialization compiler warnings with Java 18
As of Java 18, the serial lint warning in javac has been expanded to check for class fields that are not marked as `Serializable`. See https://www.oracle.com/java/technologies/javase/18all-relnotes.html#JDK-8202056 In the Spring Framework codebase, this can happen with `Map`, `Set` or `List` attributes which are often assigned with an unmodifiable implementation variant. Such implementations are `Serializable` but cannot be used as field types. This commit ensures that the following changes are applied: * fields are marked as transient if they can't be serialized * classes are marked as `Serializable` if this was missing * `@SuppressWarnings("serial")` is applied where relevant
This commit is contained in:
@@ -84,6 +84,7 @@ public class MergedContextConfiguration implements Serializable {
|
||||
|
||||
private final Class<?>[] classes;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final Set<Class<? extends ApplicationContextInitializer<?>>> contextInitializerClasses;
|
||||
|
||||
private final String[] activeProfiles;
|
||||
@@ -92,11 +93,14 @@ public class MergedContextConfiguration implements Serializable {
|
||||
|
||||
private final String[] propertySourceProperties;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final Set<ContextCustomizer> contextCustomizers;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private final ContextLoader contextLoader;
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("serial")
|
||||
private final CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate;
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Rob Harrop
|
||||
* @since 4.0
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class DefaultTestContext implements TestContext {
|
||||
|
||||
private static final long serialVersionUID = -5827157174866681233L;
|
||||
|
||||
Reference in New Issue
Block a user