Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8259522: Apply java.io.Serial annotations in java.desktop #2020

Closed
wants to merge 9 commits into from
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, 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,24 @@

package com.sun.beans.editors;

import java.awt.*;
import java.beans.*;
import java.awt.Canvas;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Panel;
import java.awt.TextField;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyEditor;
import java.io.Serial;

public class ColorEditor extends Panel implements PropertyEditor {

/**
* Use serialVersionUID from JDK 1.7 for interoperability.
*/
@Serial
private static final long serialVersionUID = 1781257185164716054L;

@SuppressWarnings("deprecation")
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, 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,25 @@

package com.sun.beans.editors;

import java.awt.*;
import java.beans.*;
import java.awt.Choice;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Event;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Label;
import java.awt.Panel;
import java.awt.Toolkit;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serial;

public class FontEditor extends Panel implements java.beans.PropertyEditor {

/**
* Use serialVersionUID from JDK 1.7 for interoperability.
*/
@Serial
private static final long serialVersionUID = 6732704486002715933L;

@SuppressWarnings("deprecation")
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, 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
@@ -22,9 +22,17 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.sun.beans.finder;

import java.io.Serial;

final class SignatureException extends RuntimeException {

/**
* Use serialVersionUID from JDK 9 for interoperability.
*/
@Serial
private static final long serialVersionUID = 4536098341586118473L;

SignatureException(Throwable cause) {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2021, 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
@@ -22,15 +22,22 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package com.sun.imageio.plugins.common;

import java.awt.color.ColorSpace;
import java.io.Serial;

/**
* Singleton class representing a simple, mathematically defined CMYK
* color space.
*/
public final class SimpleCMYKColorSpace extends ColorSpace {

/**
* Use serialVersionUID from JDK 9 for interoperability.
*/
@Serial
private static final long serialVersionUID = 5387117338644522424L;

private static ColorSpace theInstance = null;
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, 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 com.sun.media.sound;

import java.io.IOException;
import java.io.Serial;

/**
* This exception is used when a file contains illegal or unexpected data.
@@ -34,6 +35,10 @@
*/
public class InvalidDataException extends IOException {

/**
* Use serialVersionUID from JDK 1.7 for interoperability.
*/
@Serial
private static final long serialVersionUID = 1L;
Comment on lines +38 to 42

This comment has been minimized.

@aivanov-jdk

aivanov-jdk Jan 12, 2021
Member

This is the standard wording, yet should it mention the serialization is between the same versions only because the value of serialVersionUID is not unique?

This comment has been minimized.

@mrserb

mrserb Jan 12, 2021
Author Member

I think it is "quite" unique, the "1L" is used from the beginning. It is just different from the value which could be generated by the "serialver" but still should work fine.

This comment has been minimized.

@aivanov-jdk

aivanov-jdk Jan 12, 2021
Member

Okay. There are several classes which extend this one, all of them use the same 1L value which makes it not "quite" unique.

Changing the values at this time presents more risks than benefits.


public InvalidDataException() {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, 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 com.sun.media.sound;

import java.io.Serial;

/**
* This exception is used when a reader is used to read file of a format
* it doesn't unterstand or support.
@@ -33,6 +35,10 @@
*/
public class InvalidFormatException extends InvalidDataException {

/**
* Use serialVersionUID from JDK 1.7 for interoperability.
*/
@Serial
private static final long serialVersionUID = 1L;

public InvalidFormatException() {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, 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,19 @@

package com.sun.media.sound;

import java.io.Serial;

/**
* This exception is used when a RIFF file contains illegal or unexpected data.
*
* @author Karl Helgason
*/
public final class RIFFInvalidDataException extends InvalidDataException {

/**
* Use serialVersionUID from JDK 1.7 for interoperability.
*/
@Serial
private static final long serialVersionUID = 1L;

public RIFFInvalidDataException() {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, 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 com.sun.media.sound;

import java.io.Serial;

/**
* This exception is used when a reader is used to read RIFF file of a format it
* doesn't unterstand or support.
@@ -33,6 +35,10 @@
*/
public final class RIFFInvalidFormatException extends InvalidFormatException {

/**
* Use serialVersionUID from JDK 1.7 for interoperability.
*/
@Serial
private static final long serialVersionUID = 1L;

public RIFFInvalidFormatException() {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, 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
@@ -34,6 +34,7 @@
import java.awt.event.ComponentEvent;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serial;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
@@ -94,6 +95,7 @@ public Applet() throws HeadlessException {
/**
* Use serialVersionUID from JDK 1.0 for interoperability.
*/
@Serial
private static final long serialVersionUID = -5836846270535785031L;

/**
@@ -109,6 +111,7 @@ public Applet() throws HeadlessException {
* @see java.awt.GraphicsEnvironment#isHeadless
* @since 1.4
*/
@Serial
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException, HeadlessException {
if (GraphicsEnvironment.isHeadless()) {
@@ -579,6 +582,7 @@ public AccessibleContext getAccessibleContext() {
/**
* Use serialVersionUID from JDK 1.3 for interoperability.
*/
@Serial
private static final long serialVersionUID = 8127374778187708896L;

/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, 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,16 +25,19 @@

package java.awt;

import java.io.Serial;

/**
* Thrown when a serious Abstract Window Toolkit error has occurred.
*
* @author Arthur van Hoff
*/
public class AWTError extends Error {

/*
* JDK 1.1 serialVersionUID
/**
* Use serialVersionUID from JDK 1.1 for interoperability.
*/
@Serial
private static final long serialVersionUID = -1819846354050686206L;

/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2021, 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
@@ -38,6 +38,7 @@
import java.awt.event.WindowEvent;
import java.awt.peer.ComponentPeer;
import java.awt.peer.LightweightPeer;
import java.io.Serial;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.util.EventObject;
@@ -252,9 +253,10 @@ final AccessControlContext getAccessControlContext() {
*/
public static final int RESERVED_ID_MAX = 1999;

/*
* JDK 1.1 serialVersionUID
/**
* Use serialVersionUID from JDK 1.1 for interoperability.
*/
@Serial
private static final long serialVersionUID = -1825314779160409405L;

static {
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2021, 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
@@ -22,8 +22,10 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package java.awt;

import java.io.Serial;

/**
* Signals that an Abstract Window Toolkit exception has occurred.
@@ -32,9 +34,10 @@
*/
public class AWTException extends Exception {

/*
* JDK 1.1 serialVersionUID
/**
* Use serialVersionUID from JDK 1.1 for interoperability.
*/
@Serial
private static final long serialVersionUID = -1900414231151323879L;

/**
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@@ -27,6 +27,7 @@

import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.Serial;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -64,7 +65,12 @@
* @since 1.4
*/
public class AWTKeyStroke implements Serializable {
static final long serialVersionUID = -6430539691155161871L;

/**
* Use serialVersionUID from JDK 1.4 for interoperability.
*/
@Serial
private static final long serialVersionUID = -6430539691155161871L;

private static Map<String, Integer> modifierKeywords;
/**
@@ -725,6 +731,7 @@ static String getVKText(int keyCode) {
* @return a cached instance which is equal to this instance
* @throws java.io.ObjectStreamException if a serialization problem occurs
*/
@Serial
protected Object readResolve() throws java.io.ObjectStreamException {
synchronized (AWTKeyStroke.class) {