--- old/test/javax/swing/JPopupMenu/6583251/bug6583251.java 2015-08-27 03:08:04.870081848 -0700 +++ new/test/javax/swing/JPopupMenu/6583251/bug6583251.java 2015-08-27 03:08:04.677080205 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, 2015 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 @@ -25,7 +25,7 @@ /* @test -@bug 6583251 +@bug 6583251 8130481 @summary One more ClassCastException in Swing with TrayIcon @author Alexander Potochkin @run main bug6583251 @@ -56,7 +56,7 @@ } public static void main(String[] args) throws Exception { - + if (SystemTray.isSupported()) { SwingUtilities.invokeAndWait(new Runnable() { public void run() { createGui(); @@ -65,13 +65,24 @@ Robot robot = new Robot(); robot.waitForIdle(); - menu.show(frame, 0, 0); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + menu.show(frame, 0, 0); + } + }); robot.waitForIdle(); - TrayIcon trayIcon = new TrayIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)); - MouseEvent ev = new MouseEvent( - new JButton(), MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, 0, 0, 1, false); - ev.setSource(trayIcon); - Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ev); + try { + TrayIcon trayIcon = new TrayIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)); + MouseEvent ev = new MouseEvent( + new JButton(), MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), 0, 0, 0, 1, false); + ev.setSource(trayIcon); + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(ev); + } catch(UnsupportedOperationException e) { + throw new Error("Tray icon unsupported"); + } + } else { + System.out.println("SystemTray not supported. " + "Test is skipped."); + } } }