Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Modal/NpeOnClose/NpeOnCloseTest.java
38828 views
/*1* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24@test25@bug 654788126@summary NPE when closing modal dialog27@author Oleg Sukhodolsky: area=awt.modal28@library ../../regtesthelpers29@build Util30@run main NpeOnCloseTest31*/32import java.awt.Dialog;33import java.awt.EventQueue;34import java.awt.Frame;3536import java.lang.reflect.InvocationTargetException;3738import test.java.awt.regtesthelpers.Util;3940public class NpeOnCloseTest {41public static void main(String[] args)42{43Frame frame1 = new Frame("frame 1");44frame1.setBounds(0, 0, 100, 100);45frame1.setVisible(true);46Util.waitForIdle(null);4748Frame frame2 = new Frame("frame 2");49frame2.setBounds(150, 0, 100, 100);50frame2.setVisible(true);51Util.waitForIdle(null);5253Frame frame3 = new Frame("frame 3");54final Dialog dialog = new Dialog(frame3, "dialog", true);55dialog.setBounds(300, 0, 100, 100);56EventQueue.invokeLater(new Runnable() {57public void run() {58dialog.setVisible(true);59}60});61try {62EventQueue.invokeAndWait(new Runnable() { public void run() {} });63Util.waitForIdle(null);64EventQueue.invokeAndWait(new Runnable() {65public void run() {66dialog.dispose();67}68});69}70catch (InterruptedException ie) {71throw new RuntimeException(ie);72}73catch (InvocationTargetException ite) {74throw new RuntimeException(ite);75}7677frame1.dispose();78frame2.dispose();79frame3.dispose();80}81}828384