Skip to content

Commit

Permalink
Annotate java.awt.Window.
Browse files Browse the repository at this point in the history
adapted from
typetools/jdk@62877f0,
including to remove annotations on non-visible APIs
  • Loading branch information
jpschewe authored and cpovirk committed Oct 4, 2024
1 parent cbe846f commit c37135d
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/java.desktop/share/classes/java/awt/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

package java.awt;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -164,6 +167,7 @@
* @see java.awt.BorderLayout
* @since 1.0
*/
@NullMarked
public class Window extends Container implements Accessible {

/**
Expand Down Expand Up @@ -574,7 +578,7 @@ private void init(GraphicsConfiguration gc) {
* @see java.awt.GraphicsEnvironment#isHeadless
* @see #isShowing
*/
public Window(Frame owner) {
public Window(@Nullable Frame owner) {
this(owner == null ? (GraphicsConfiguration)null :
owner.getGraphicsConfiguration());
ownedInit(owner);
Expand Down Expand Up @@ -604,7 +608,7 @@ public Window(Frame owner) {
*
* @since 1.2
*/
public Window(Window owner) {
public Window(@Nullable Window owner) {
this(owner == null ? (GraphicsConfiguration)null :
owner.getGraphicsConfiguration());
ownedInit(owner);
Expand Down Expand Up @@ -638,7 +642,7 @@ public Window(Window owner) {
* @see #isShowing
* @since 1.3
*/
public Window(Window owner, GraphicsConfiguration gc) {
public Window(@Nullable Window owner, @Nullable GraphicsConfiguration gc) {
this(gc);
ownedInit(owner);
}
Expand Down Expand Up @@ -721,7 +725,7 @@ public java.util.List<Image> getIconImages() {
* @see #setIconImage(Image)
* @since 1.6
*/
public synchronized void setIconImages(java.util.List<? extends Image> icons) {
public synchronized void setIconImages(java.util.@Nullable List<? extends Image> icons) {
this.icons = (icons == null) ? new ArrayList<Image>() :
new ArrayList<Image>(icons);
WindowPeer peer = (WindowPeer)this.peer;
Expand Down Expand Up @@ -759,7 +763,7 @@ public synchronized void setIconImages(java.util.List<? extends Image> icons) {
* @see #getIconImages()
* @since 1.6
*/
public void setIconImage(Image image) {
public void setIconImage(@Nullable Image image) {
ArrayList<Image> imageList = new ArrayList<Image>();
if (image != null) {
imageList.add(image);
Expand Down Expand Up @@ -869,7 +873,7 @@ public void pack() {
* @see #pack
* @since 1.6
*/
public void setMinimumSize(Dimension minimumSize) {
public void setMinimumSize(@Nullable Dimension minimumSize) {
synchronized (getTreeLock()) {
super.setMinimumSize(minimumSize);
Dimension size = getSize();
Expand Down Expand Up @@ -1395,7 +1399,7 @@ public Toolkit getToolkit() {
* and returns the string value of that property.
* @return the warning string for this window.
*/
public final String getWarningString() {
public final @Nullable String getWarningString() {
return warningString;
}

Expand Down Expand Up @@ -1462,7 +1466,7 @@ public InputContext getInputContext() {
* @see Cursor
* @since 1.1
*/
public void setCursor(Cursor cursor) {
public void setCursor(@Nullable Cursor cursor) {
if (cursor == null) {
cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
}
Expand All @@ -1475,7 +1479,7 @@ public void setCursor(Cursor cursor) {
* @return the owner of this window
* @since 1.2
*/
public Window getOwner() {
public @Nullable Window getOwner() {
return getOwner_NoClientCode();
}
final Window getOwner_NoClientCode() {
Expand Down Expand Up @@ -2340,7 +2344,7 @@ public final boolean isAlwaysOnTop() {
* @see #getMostRecentFocusOwner
* @see #isFocused
*/
public Component getFocusOwner() {
public @Nullable Component getFocusOwner() {
return (isFocused())
? KeyboardFocusManager.getCurrentKeyboardFocusManager().
getFocusOwner()
Expand All @@ -2364,7 +2368,7 @@ public Component getFocusOwner() {
* @see #isFocusableWindow
* @since 1.4
*/
public Component getMostRecentFocusOwner() {
public @Nullable Component getMostRecentFocusOwner() {
if (isFocused()) {
return getFocusOwner();
} else {
Expand Down Expand Up @@ -2496,7 +2500,7 @@ public final boolean isFocusCycleRoot() {
* @see Container#isFocusCycleRoot()
* @since 1.4
*/
public final Container getFocusCycleRootAncestor() {
public final @Nullable Container getFocusCycleRootAncestor() {
return null;
}

Expand Down Expand Up @@ -3290,7 +3294,7 @@ void setGraphicsConfiguration(GraphicsConfiguration gc) {
* @see java.awt.GraphicsEnvironment#getCenterPoint
* @since 1.4
*/
public void setLocationRelativeTo(Component c) {
public void setLocationRelativeTo(@Nullable Component c) {
// target location
int dx = 0, dy = 0;
// target GC
Expand Down Expand Up @@ -3421,7 +3425,7 @@ public void createBufferStrategy(int numBuffers,
* @see #createBufferStrategy
* @since 1.4
*/
public BufferStrategy getBufferStrategy() {
public @Nullable BufferStrategy getBufferStrategy() {
return super.getBufferStrategy();
}

Expand Down Expand Up @@ -3709,7 +3713,7 @@ public void setOpacity(float opacity) {
*
* @since 1.7
*/
public Shape getShape() {
public @Nullable Shape getShape() {
synchronized (getTreeLock()) {
return shape == null ? null : new Path2D.Float(shape);
}
Expand Down Expand Up @@ -3764,7 +3768,7 @@ public Shape getShape() {
*
* @since 1.7
*/
public void setShape(Shape shape) {
public void setShape(@Nullable Shape shape) {
synchronized (getTreeLock()) {
if (shape != null) {
GraphicsConfiguration gc = getGraphicsConfiguration();
Expand Down Expand Up @@ -3801,7 +3805,7 @@ public void setShape(Shape shape) {
* @see GraphicsDevice.WindowTranslucency
*/
@Override
public Color getBackground() {
public @Nullable Color getBackground() {
return super.getBackground();
}

Expand Down Expand Up @@ -3881,7 +3885,7 @@ public Color getBackground() {
* @see GraphicsConfiguration#isTranslucencyCapable()
*/
@Override
public void setBackground(Color bgColor) {
public void setBackground(@Nullable Color bgColor) {
Color oldBg = getBackground();
super.setBackground(bgColor);
if (oldBg != null && oldBg.equals(bgColor)) {
Expand Down

0 comments on commit c37135d

Please sign in to comment.