|
| 1 | +/* |
| 2 | + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | +import java.awt.Dimension; |
| 25 | +import java.awt.FlowLayout; |
| 26 | +import java.awt.Graphics; |
| 27 | +import java.util.concurrent.CountDownLatch; |
| 28 | +import java.util.concurrent.TimeUnit; |
| 29 | + |
| 30 | +import javax.swing.JFrame; |
| 31 | +import javax.swing.JList; |
| 32 | +import javax.swing.JPanel; |
| 33 | +import javax.swing.JTable; |
| 34 | +import javax.swing.JTree; |
| 35 | +import javax.swing.SwingUtilities; |
| 36 | + |
| 37 | +/** |
| 38 | + * @test |
| 39 | + * @bug 6847157 |
| 40 | + * @key headful |
| 41 | + * @summary the java2D/AWT should die silently without exceptions |
| 42 | + * @run main/othervm RepaintOnAWTShutdown |
| 43 | + * @run main/othervm -Dsun.java2d.uiScale=1 RepaintOnAWTShutdown |
| 44 | + * @run main/othervm -Dsun.java2d.uiScale=1.2 RepaintOnAWTShutdown |
| 45 | + * @run main/othervm -Dsun.java2d.uiScale=1.25 RepaintOnAWTShutdown |
| 46 | + * @run main/othervm -Dsun.java2d.uiScale=1.5 RepaintOnAWTShutdown |
| 47 | + * @run main/othervm -Dsun.java2d.uiScale=1.75 RepaintOnAWTShutdown |
| 48 | + * @run main/othervm -Dsun.java2d.uiScale=2 RepaintOnAWTShutdown |
| 49 | + * @run main/othervm -Dsun.java2d.uiScale=2.25 RepaintOnAWTShutdown |
| 50 | + * @run main/othervm -Dsun.java2d.uiScale=5 RepaintOnAWTShutdown |
| 51 | + * @run main/othervm -Dsun.java2d.uiScale=10 RepaintOnAWTShutdown |
| 52 | + */ |
| 53 | +public final class RepaintOnAWTShutdown implements Runnable { |
| 54 | + |
| 55 | + private static final CountDownLatch go = new CountDownLatch(1); |
| 56 | + |
| 57 | + public static void main(String[] args) throws Exception { |
| 58 | + SwingUtilities.invokeLater(new RepaintOnAWTShutdown()); |
| 59 | + go.await(5, TimeUnit.SECONDS); |
| 60 | + // The test will check that no exception is thrown when the jtreg will |
| 61 | + // kill this test at the moment the frame will be painted |
| 62 | + } |
| 63 | + |
| 64 | + public void run() { |
| 65 | + JFrame frame = new JFrame(); |
| 66 | + JPanel panel = new MyPanel(); |
| 67 | + panel.setPreferredSize(new Dimension(100, 100)); |
| 68 | + panel.setLayout(new FlowLayout()); |
| 69 | + panel.add(new JTree()); |
| 70 | + panel.add(new JList(new String[]{"one", "two"})); |
| 71 | + panel.add(new JTable(new String[][]{{"one", "two"}}, |
| 72 | + new String[]{"one", "two"})); |
| 73 | + frame.add(panel); |
| 74 | + frame.pack(); |
| 75 | + frame.setLocationRelativeTo(null); |
| 76 | + frame.setVisible(true); |
| 77 | + // the frame is not disposed intentionally |
| 78 | + } |
| 79 | + |
| 80 | + |
| 81 | + private final class MyPanel extends JPanel { |
| 82 | + |
| 83 | + public void paint(Graphics g) { |
| 84 | + super.paint(g); |
| 85 | + go.countDown(); |
| 86 | + } |
| 87 | + } |
| 88 | +} |
0 commit comments