Skip to content

Commit

Permalink
add try/finally
Browse files Browse the repository at this point in the history
  • Loading branch information
mrserb committed Sep 5, 2024
1 parent 94b798e commit a026bd4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
26 changes: 16 additions & 10 deletions test/jdk/java/awt/Paint/ButtonRepaint.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, 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
Expand Down Expand Up @@ -34,15 +34,21 @@ public final class ButtonRepaint extends Button {

public static void main(final String[] args) {
for (int i = 0; i < 10; ++i) {
final Frame frame = new Frame();
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
ButtonRepaint button = new ButtonRepaint();
frame.add(button);
frame.setVisible(true);
sleep();
button.test();
frame.dispose();
Frame frame = null;
try {
frame = new Frame();
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
ButtonRepaint button = new ButtonRepaint();
frame.add(button);
frame.setVisible(true);
sleep();
button.test();
} finally {
if (frame != null) {
frame.dispose();
}
}
}
}

Expand Down
26 changes: 16 additions & 10 deletions test/jdk/java/awt/Paint/CheckboxRepaint.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2024, 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
Expand Down Expand Up @@ -33,15 +33,21 @@ public final class CheckboxRepaint extends Checkbox {

public static void main(final String[] args) {
for (int i = 0; i < 10; ++i) {
final Frame frame = new Frame();
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
CheckboxRepaint checkbox = new CheckboxRepaint();
frame.add(checkbox);
frame.setVisible(true);
sleep();
checkbox.test();
frame.dispose();
Frame frame = null;
try {
frame = new Frame();
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
CheckboxRepaint checkbox = new CheckboxRepaint();
frame.add(checkbox);
frame.setVisible(true);
sleep();
checkbox.test();
} finally {
if (frame != null) {
frame.dispose();
}
}
}
}

Expand Down
24 changes: 15 additions & 9 deletions test/jdk/java/awt/Paint/LabelRepaint.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,21 @@ public final class LabelRepaint extends Label {

public static void main(final String[] args) {
for (int i = 0; i < 10; ++i) {
final Frame frame = new Frame();
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
LabelRepaint label = new LabelRepaint();
frame.add(label);
frame.setVisible(true);
sleep();
label.test();
frame.dispose();
Frame frame = null;
try {
frame = new Frame();
frame.setSize(300, 300);
frame.setLocationRelativeTo(null);
LabelRepaint label = new LabelRepaint();
frame.add(label);
frame.setVisible(true);
sleep();
label.test();
} finally {
if (frame != null) {
frame.dispose();
}
}
}
}

Expand Down

0 comments on commit a026bd4

Please sign in to comment.