RFR: 8370368: Apply java.io.Serial annotations in java.security.jgss

Sean Mullan mullan at openjdk.org
Thu Oct 23 18:44:29 UTC 2025


On Wed, 22 Oct 2025 01:10:00 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> Please review the application of the `@Serial` annotation ([JDK-8202385](https://bugs.openjdk.org/browse/JDK-8202385)) to types in the java.security.jgss module to enable stricter compile-time checking of serialization-related declarations.
> 
> Example of a similar change https://github.com/openjdk/jdk/pull/24891.

src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Context.java line 1:

> 1: /*

The `majorMessage` field of `GSSExceptionImpl` should have `@Serial` too.

src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Context.java line 1:

> 1: /*

Change `java.io.Serial` annotation on `readObject` method to `@Serial`.

src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Context.java line 1:

> 1: /*

The `state` field should also have `@Serial`.

src/java.security.jgss/share/classes/sun/security/krb5/KrbException.java line 45:

> 43:     private static final long serialVersionUID = -4993302876451928596L;
> 44: 
> 45:     private int returnCode;

I think these two fields should also be marked with `@Serial` since they are not `transient`.

src/java.security.jgss/share/classes/sun/security/krb5/internal/KRBError.java line 128:

> 126:     }
> 127: 
> 128:     @Serial

Can you also change `java.io.Serial` to `Serial` on the `readObject` method?

src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Ktab.java line 87:

> 85:         @java.io.Serial
> 86:         private static final long serialVersionUID = 0L;
> 87:         private final int errorCode;

`errorCode` should have `@Serial` too.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/27925#discussion_r2456655753
PR Review Comment: https://git.openjdk.org/jdk/pull/27925#discussion_r2456663954
PR Review Comment: https://git.openjdk.org/jdk/pull/27925#discussion_r2456672452
PR Review Comment: https://git.openjdk.org/jdk/pull/27925#discussion_r2456638167
PR Review Comment: https://git.openjdk.org/jdk/pull/27925#discussion_r2456621785
PR Review Comment: https://git.openjdk.org/jdk/pull/27925#discussion_r2456694847


More information about the security-dev mailing list