8355004: Apply java.io.Serial annotations in java.compiler

Reviewed-by: liach, darcy
This commit is contained in:
Sergey Bylokhov 2025-05-31 00:16:40 +00:00
parent 2926435d22
commit 5ad02c98f1
8 changed files with 43 additions and 18 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,6 +26,7 @@
package javax.annotation.processing;
import java.io.IOException;
import java.io.Serial;
/**
* Indicates a {@link Filer} detected an attempt to open a file that
@ -38,7 +39,10 @@ import java.io.IOException;
* @since 1.6
*/
public class FilerException extends IOException {
static final long serialVersionUID = 8426423106453163293L;
@Serial
private static final long serialVersionUID = 8426423106453163293L;
/**
* Constructs an exception with the specified detail message.
* @param s the detail message, which should include the name of

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,8 @@
package javax.lang.model;
import java.io.Serial;
/**
* Superclass of exceptions which indicate that an unknown kind of
* entity was encountered. This situation can occur if the language
@ -39,6 +41,7 @@ package javax.lang.model;
*/
public class UnknownEntityException extends RuntimeException {
@Serial
private static final long serialVersionUID = 269L;
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,8 @@
package javax.lang.model.element;
import java.io.Serial;
import javax.lang.model.UnknownEntityException;
/**
@ -40,6 +42,7 @@ import javax.lang.model.UnknownEntityException;
*/
public class UnknownAnnotationValueException extends UnknownEntityException {
@Serial
private static final long serialVersionUID = 269L;
private transient AnnotationValue av;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,8 @@
package javax.lang.model.element;
import java.io.Serial;
import javax.lang.model.UnknownEntityException;
/**
@ -39,6 +41,7 @@ import javax.lang.model.UnknownEntityException;
*/
public class UnknownDirectiveException extends UnknownEntityException {
@Serial
private static final long serialVersionUID = 269L;
private final transient ModuleElement.Directive directive;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,8 @@
package javax.lang.model.element;
import java.io.Serial;
import javax.lang.model.UnknownEntityException;
/**
@ -39,6 +41,7 @@ import javax.lang.model.UnknownEntityException;
*/
public class UnknownElementException extends UnknownEntityException {
@Serial
private static final long serialVersionUID = 269L;
private transient Element element;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,10 +25,11 @@
package javax.lang.model.type;
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.lang.model.element.Element;
import java.io.ObjectInputStream;
import java.io.Serial;
import javax.lang.model.element.Element;
/**
* Thrown when an application attempts to access the {@link Class} object
@ -40,7 +41,8 @@ import javax.lang.model.element.Element;
*/
public class MirroredTypeException extends MirroredTypesException {
private static final long serialVersionUID = 269;
@Serial
private static final long serialVersionUID = 269L;
private transient TypeMirror type; // cannot be serialized
@ -72,6 +74,7 @@ public class MirroredTypeException extends MirroredTypesException {
* deserialization
* @throws IOException for an IO problem during deserialization
*/
@Serial
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,13 +25,14 @@
package javax.lang.model.type;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.io.ObjectInputStream;
import java.io.IOException;
import javax.lang.model.element.Element;
import java.io.ObjectInputStream;
import java.io.Serial;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.lang.model.element.Element;
/**
* Thrown when an application attempts to access a sequence of {@link
@ -43,7 +44,8 @@ import javax.lang.model.element.Element;
*/
public class MirroredTypesException extends RuntimeException {
private static final long serialVersionUID = 269;
@Serial
private static final long serialVersionUID = 269L;
transient List<? extends TypeMirror> types; // cannot be serialized
@ -87,6 +89,7 @@ public class MirroredTypesException extends RuntimeException {
* deserialization
* @throws IOException for an IO problem during deserialization
*/
@Serial
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
s.defaultReadObject();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,8 @@
package javax.lang.model.type;
import java.io.Serial;
import javax.lang.model.UnknownEntityException;
/**
@ -39,6 +41,7 @@ import javax.lang.model.UnknownEntityException;
*/
public class UnknownTypeException extends UnknownEntityException {
@Serial
private static final long serialVersionUID = 269L;
private transient TypeMirror type;