Skip to content

Commit

Permalink
8297515: serialVersionUID fields are not annotated with @serial
Browse files Browse the repository at this point in the history
Reviewed-by: rriggs, lancea
  • Loading branch information
minborg authored and TheShermanTanker committed Nov 30, 2022
1 parent 22f5d01 commit f05bfb1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,7 @@ private void parseHandleStartupErrors(String keyword) throws IOException {
}

class ConfigurationException extends IOException {
@Serial
private static final long serialVersionUID = 254492758807673194L;
ConfigurationException(String msg) {
super(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
*/
abstract class P11Key implements Key, Length {

@Serial
private static final long serialVersionUID = -2575874101938349339L;

private static final String PUBLIC = "public";
Expand Down Expand Up @@ -421,6 +422,7 @@ static PrivateKey privateKey(Session session, long keyID, String algorithm,
// base class for all PKCS11 private keys
private static abstract class P11PrivateKey extends P11Key implements
PrivateKey {
@Serial
private static final long serialVersionUID = -2138581185214187615L;

protected byte[] encoded; // guard by synchronized
Expand All @@ -441,6 +443,7 @@ byte[] getEncodedInternal() {
}

private static class P11SecretKey extends P11Key implements SecretKey {
@Serial
private static final long serialVersionUID = -7828241727014329084L;

private volatile byte[] encoded; // guard by double-checked locking
Expand Down Expand Up @@ -484,6 +487,7 @@ byte[] getEncodedInternal() {
// base class for all PKCS11 public keys
private static abstract class P11PublicKey extends P11Key implements
PublicKey {
@Serial
private static final long serialVersionUID = 1L;

protected byte[] encoded; // guard by synchronized
Expand All @@ -497,6 +501,7 @@ private static abstract class P11PublicKey extends P11Key implements
@SuppressWarnings("deprecation")
private static class P11TlsMasterSecretKey extends P11SecretKey
implements TlsMasterSecret {
@Serial
private static final long serialVersionUID = -1318560923770573441L;

private final int majorVersion, minorVersion;
Expand All @@ -517,6 +522,7 @@ public int getMinorVersion() {

// impl class for sensitive/unextractable RSA private keys
static class P11RSAPrivateKeyInternal extends P11PrivateKey {
@Serial
private static final long serialVersionUID = -2138581185214187615L;

static P11RSAPrivateKeyInternal of(Session session, long keyID,
Expand Down Expand Up @@ -590,6 +596,7 @@ public BigInteger getModulus() {
// RSA CRT private key
private static final class P11RSAPrivateKey extends P11RSAPrivateKeyInternal
implements RSAPrivateCrtKey {
@Serial
private static final long serialVersionUID = 9215872438913515220L;

private transient BigInteger e, d, p, q, pe, qe, coeff;
Expand Down Expand Up @@ -667,6 +674,7 @@ public BigInteger getCrtCoefficient() {
// RSA non-CRT private key
private static final class P11RSAPrivateNonCRTKey extends
P11RSAPrivateKeyInternal implements RSAPrivateKey {
@Serial
private static final long serialVersionUID = 1137764983777411481L;

private transient BigInteger d;
Expand Down Expand Up @@ -712,6 +720,7 @@ public BigInteger getPrivateExponent() {

private static final class P11RSAPublicKey extends P11PublicKey
implements RSAPublicKey {
@Serial
private static final long serialVersionUID = -826726289023854455L;
private transient BigInteger n, e;

Expand Down Expand Up @@ -768,6 +777,7 @@ public String toString() {

private static final class P11DSAPublicKey extends P11PublicKey
implements DSAPublicKey {
@Serial
private static final long serialVersionUID = 5989753793316396637L;

private transient BigInteger y;
Expand Down Expand Up @@ -823,6 +833,7 @@ public String toString() {
}

static class P11DSAPrivateKeyInternal extends P11PrivateKey {
@Serial
private static final long serialVersionUID = 3119629997181999389L;

protected transient DSAParams params;
Expand Down Expand Up @@ -864,6 +875,7 @@ protected DSAParams getParams() {

private static final class P11DSAPrivateKey extends P11DSAPrivateKeyInternal
implements DSAPrivateKey {
@Serial
private static final long serialVersionUID = 3119629997181999389L;

private transient BigInteger x; // params inside P11DSAPrivateKeyInternal
Expand Down Expand Up @@ -916,6 +928,7 @@ public DSAParams getParams() {
}

static class P11DHPrivateKeyInternal extends P11PrivateKey {
@Serial
private static final long serialVersionUID = 1L;

protected transient DHParameterSpec params;
Expand Down Expand Up @@ -956,6 +969,7 @@ public DHParameterSpec getParams() {

private static final class P11DHPrivateKey extends P11DHPrivateKeyInternal
implements DHPrivateKey {
@Serial
private static final long serialVersionUID = -1698576167364928838L;

private transient BigInteger x; // params in P11DHPrivateKeyInternal
Expand Down Expand Up @@ -1120,6 +1134,7 @@ public boolean equals(Object obj) {

static class P11ECPrivateKeyInternal extends P11PrivateKey {

@Serial
private static final long serialVersionUID = 1L;

protected transient ECParameterSpec params;
Expand Down Expand Up @@ -1164,6 +1179,7 @@ protected ECParameterSpec getParams() {

private static final class P11ECPrivateKey extends P11ECPrivateKeyInternal
implements ECPrivateKey {
@Serial
private static final long serialVersionUID = -7786054399510515515L;

private transient BigInteger s; // params in P11ECPrivateKeyInternal
Expand Down Expand Up @@ -1222,6 +1238,7 @@ public ECParameterSpec getParams() {

private static final class P11ECPublicKey extends P11PublicKey
implements ECPublicKey {
@Serial
private static final long serialVersionUID = -6371481375154806089L;

private transient ECPoint w;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
*/
final class P11SecureRandom extends SecureRandomSpi {

@Serial
private static final long serialVersionUID = -8939510236124553291L;

// token instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
*/
public final class SunPKCS11 extends AuthProvider {

@Serial
private static final long serialVersionUID = -1354835039035306505L;

static final Debug debug = Debug.getInstance("sunpkcs11");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
class Token implements Serializable {

// need to be serializable to allow SecureRandom to be serialized
@Serial
private static final long serialVersionUID = 2541527649100571747L;

// how often to check if the token is still present (in ms)
Expand Down Expand Up @@ -441,6 +442,7 @@ private Object writeReplace() throws ObjectStreamException {
// and if the token has not been removed in the meantime
private static class TokenRep implements Serializable {

@Serial
private static final long serialVersionUID = 3503721168218219807L;

private final byte[] tokenId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

package sun.security.pkcs11.wrapper;

import java.io.Serial;
import java.util.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;

Expand All @@ -63,6 +64,7 @@
* @invariants
*/
public class PKCS11Exception extends Exception {
@Serial
private static final long serialVersionUID = 4077027363729192L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
package sun.security.pkcs11.wrapper;


import java.io.Serial;

/**
* This is the superclass of all runtime exception used by this library.
* For instance, Runtime exceptions occur, if an internal error in the native
Expand All @@ -57,6 +59,7 @@
* @invariants
*/
public class PKCS11RuntimeException extends RuntimeException {
@Serial
private static final long serialVersionUID = 7889842162743590564L;

/**
Expand Down

1 comment on commit f05bfb1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.