8283700: Add final or sealed modifier to appropriate java.awt API classes

Reviewed-by: darcy, aivanov, serb, psadhukhan
This commit is contained in:
Phil Race 2022-03-30 17:26:03 +00:00
parent ec9ab558a3
commit e85fa2f04b
12 changed files with 29 additions and 12 deletions

View File

@ -36,7 +36,7 @@ import java.io.Serial;
* @see java.awt.GridBagConstraints
* @since 1.6
*/
public class GridBagLayoutInfo implements java.io.Serializable {
public final class GridBagLayoutInfo implements java.io.Serializable {
/**
* Use serialVersionUID from JDK 1.6 for interoperability.

View File

@ -41,7 +41,7 @@ package java.awt;
* @author Roman Poborchiy
* @since 1.5
*/
public class PointerInfo {
public final class PointerInfo {
private final GraphicsDevice device;
private final Point location;

View File

@ -40,7 +40,7 @@ import sun.awt.AWTAccessor;
*
* @since 1.4
*/
public class ScrollPaneAdjustable implements Adjustable, Serializable {
public final class ScrollPaneAdjustable implements Adjustable, Serializable {
/**
* The {@code ScrollPane} this object is a scrollbar of.

View File

@ -55,7 +55,7 @@ import javax.accessibility.AccessibleStateSet;
* @author Sami Shaio
* @since 1.0
*/
public class TextArea extends TextComponent {
public non-sealed class TextArea extends TextComponent {
/**
* The number of rows in the {@code TextArea}.

View File

@ -67,7 +67,9 @@ import sun.awt.InputMethodSupport;
* @author Arthur van Hoff
* @since 1.0
*/
public class TextComponent extends Component implements Accessible {
public sealed class TextComponent extends Component implements Accessible
permits TextArea,
TextField {
/**
* The value of the text.

View File

@ -99,7 +99,7 @@ import javax.accessibility.AccessibleStateSet;
* @see java.awt.TextField#addActionListener
* @since 1.0
*/
public class TextField extends TextComponent {
public non-sealed class TextField extends TextComponent {
/**
* The number of columns in the text field.

View File

@ -37,7 +37,18 @@ import java.util.EventObject;
*
* @since 9
*/
public class AppEvent extends EventObject {
public sealed class AppEvent extends EventObject
permits AboutEvent,
AppForegroundEvent,
AppHiddenEvent,
AppReopenedEvent,
FilesEvent,
OpenURIEvent,
PreferencesEvent,
QuitEvent,
ScreenSleepEvent,
SystemSleepEvent,
UserSessionEvent {
/**
* Use serialVersionUID from JDK 9 for interoperability.

View File

@ -38,7 +38,9 @@ import java.util.List;
*
* @since 9
*/
public class FilesEvent extends AppEvent {
public sealed class FilesEvent extends AppEvent
permits OpenFilesEvent,
PrintFilesEvent {
/**
* Use serialVersionUID from JDK 9 for interoperability.

View File

@ -53,7 +53,7 @@ import sun.awt.AWTAccessor.DropTargetContextAccessor;
* @since 1.2
*/
public class DropTargetContext implements Serializable {
public final class DropTargetContext implements Serializable {
/**
* Use serialVersionUID from JDK 1.4 for interoperability.

View File

@ -57,7 +57,9 @@ import sun.util.logging.PlatformLogger;
*
* @since 1.1
*/
public abstract class InputEvent extends ComponentEvent {
public abstract sealed class InputEvent extends ComponentEvent
permits KeyEvent,
MouseEvent {
private static final PlatformLogger logger = PlatformLogger.getLogger("java.awt.event.InputEvent");

View File

@ -151,7 +151,7 @@ import sun.awt.AWTAccessor;
*
* @since 1.1
*/
public class KeyEvent extends InputEvent {
public non-sealed class KeyEvent extends InputEvent {
/**
* Stores the state of native event dispatching system

View File

@ -189,7 +189,7 @@ import sun.awt.SunToolkit;
*
* @since 1.1
*/
public class MouseEvent extends InputEvent {
public non-sealed class MouseEvent extends InputEvent {
/**
* The first number in the range of ids used for mouse events.