Path: blob/master/test/jdk/java/awt/Modal/NpeOnClose/NpeOnCloseTest.java
41153 views
/*1* Copyright (c) 2007, 2016, 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@key headful26@bug 654788127@summary NPE when closing modal dialog28@author Oleg Sukhodolsky: area=awt.modal29@library ../../regtesthelpers30@build Util31@run main NpeOnCloseTest32*/33import java.awt.Dialog;34import java.awt.EventQueue;35import java.awt.Frame;3637import java.lang.reflect.InvocationTargetException;3839import test.java.awt.regtesthelpers.Util;4041public class NpeOnCloseTest {42public static void main(String[] args)43{44Frame frame1 = new Frame("frame 1");45frame1.setBounds(0, 0, 100, 100);46frame1.setVisible(true);47Util.waitForIdle(null);4849Frame frame2 = new Frame("frame 2");50frame2.setBounds(150, 0, 100, 100);51frame2.setVisible(true);52Util.waitForIdle(null);5354Frame frame3 = new Frame("frame 3");55final Dialog dialog = new Dialog(frame3, "dialog", true);56dialog.setBounds(300, 0, 100, 100);57EventQueue.invokeLater(new Runnable() {58public void run() {59dialog.setVisible(true);60}61});62try {63EventQueue.invokeAndWait(new Runnable() { public void run() {} });64Util.waitForIdle(null);65EventQueue.invokeAndWait(new Runnable() {66public void run() {67dialog.dispose();68}69});70}71catch (InterruptedException ie) {72throw new RuntimeException(ie);73}74catch (InvocationTargetException ite) {75throw new RuntimeException(ite);76}7778frame1.dispose();79frame2.dispose();80frame3.dispose();81}82}838485