# HG changeset patch # User Jiri Vanek # Date 1539793000 -7200 # Node ID 5b3e94efb41c534a17e161bea2d2e11092239e2e # Parent e19639f572c4ff1456f1c208a22a1f27f45a5110 Removed EDT_DAEMON_THREAD_POOL diff -r e19639f572c4 -r 5b3e94efb41c ChangeLog --- a/ChangeLog Fri Oct 12 15:37:59 2018 +0200 +++ b/ChangeLog Wed Oct 17 18:16:40 2018 +0200 @@ -1,3 +1,22 @@ +2018-10-17 Laurent Bourgès + + * netx/net/sourceforge/jnlp/controlpanel/CachePane.java: using SwingUtils.invokeLater instead of + * netx/net/sourceforge/jnlp/controlpanel/CommandLine.java: same + calling SwingUtils.setup + * netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java: same + * netx/net/sourceforge/jnlp/controlpanel/PolicyPanel.java: same + * netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java: same + * netx/net/sourceforge/jnlp/controlpanel/desktopintegrationeditor/Blinker.java: same + * netx/net/sourceforge/jnlp/controlpanel/desktopintegrationeditor/FreeDesktopIntegrationEditorFrame.java: same + * netx/net/sourceforge/jnlp/runtime/Boot.java: same + calling SwingUtils.setup + * netx/net/sourceforge/jnlp/security/appletextendedsecurity/ExtendedAppletSecurityHelp.java: same + * netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java: same + calling SwingUtils.setup + * netx/net/sourceforge/jnlp/splashscreen/parts/BasicComponentErrorSplashScreen.java: same + * netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java: same + * netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java: same + * netx/net/sourceforge/jnlp/util/ImageResources.java: added check for null in stream + * netx/net/sourceforge/swing/SwingUtils.java: added setup-able. removed EDT_DAEMON_THREAD_POOL (thus currently not + working properly in jdk11+, but fix for JDK itself is on the way) + 2018-10-12 Jiri Vanek reworked showDocument logic diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/controlpanel/CachePane.java --- a/netx/net/sourceforge/jnlp/controlpanel/CachePane.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/controlpanel/CachePane.java Wed Oct 17 18:16:40 2018 +0200 @@ -21,7 +21,6 @@ import java.awt.Component; import java.awt.Cursor; import java.awt.Dimension; -import java.awt.EventQueue; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; @@ -67,6 +66,7 @@ import net.sourceforge.jnlp.util.PropertiesFile; import net.sourceforge.jnlp.util.logging.OutputController; import net.sourceforge.jnlp.util.ui.NonEditableTableModel; +import net.sourceforge.swing.SwingUtils; public class CachePane extends JPanel { final JDialog parent; @@ -267,7 +267,7 @@ * @see CachePane#cacheTable */ private void invokeLaterDelete() { - EventQueue.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { try { @@ -339,8 +339,7 @@ } private void invokeLaterDeleteAll() { - EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { @Override public void run() { try { @@ -362,7 +361,7 @@ * @see CachePane#populateTable */ final void invokeLaterPopulateTable() { - EventQueue.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { try { diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/controlpanel/CommandLine.java --- a/netx/net/sourceforge/jnlp/controlpanel/CommandLine.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/controlpanel/CommandLine.java Wed Oct 17 18:16:40 2018 +0200 @@ -37,6 +37,7 @@ import net.sourceforge.jnlp.util.docprovider.formatters.formatters.PlainTextFormatter; import net.sourceforge.jnlp.util.logging.OutputController; import net.sourceforge.jnlp.util.optionparser.OptionParser; +import net.sourceforge.swing.SwingUtils; /** * Encapsulates a command line interface to the deployment configuration. @@ -495,6 +496,9 @@ * @throws java.lang.Exception when it goes wrong */ public static void main(String[] args) throws Exception { + // setup Swing EDT tracing: + SwingUtils.setup(); + try { OptionParser optionParser = new OptionParser(args, OptionsDefinitions.getItwsettingsCommands()); if (optionParser.hasOption(OptionsDefinitions.OPTIONS.DETAILS) || optionParser.hasOption(OptionsDefinitions.OPTIONS.VERBOSE)){ diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java --- a/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java Wed Oct 17 18:16:40 2018 +0200 @@ -30,13 +30,13 @@ import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; -import javax.swing.SwingUtilities; import net.sourceforge.jnlp.ShortcutDesc; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.controlpanel.desktopintegrationeditor.FreeDesktopIntegrationEditorFrame; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.runtime.Translator; +import net.sourceforge.swing.SwingUtils; /** * This class provides the panel that allows the user to set whether they want @@ -79,7 +79,7 @@ @Override public void actionPerformed(ActionEvent e) { - SwingUtilities.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/controlpanel/PolicyPanel.java --- a/netx/net/sourceforge/jnlp/controlpanel/PolicyPanel.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/controlpanel/PolicyPanel.java Wed Oct 17 18:16:40 2018 +0200 @@ -55,7 +55,6 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; -import javax.swing.SwingUtilities; import net.sourceforge.jnlp.config.DeploymentConfiguration; import net.sourceforge.jnlp.config.PathsAndFiles; @@ -64,6 +63,7 @@ import net.sourceforge.jnlp.util.FileUtils; import net.sourceforge.jnlp.util.FileUtils.OpenFileResult; import net.sourceforge.jnlp.util.logging.OutputController; +import net.sourceforge.swing.SwingUtils; /** * Implements a Policy Settings panel for the itweb-settings control panel. @@ -264,7 +264,7 @@ public void actionPerformed(final ActionEvent event) { try { final URL fileUrl = new URL(fileUrlString); - SwingUtilities.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { launchPolicyTool(frame, fileUrl.getPath()); @@ -290,7 +290,7 @@ public void actionPerformed(final ActionEvent event) { try { final URL fileUrl = new URL(fileUrlString); - SwingUtilities.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { launchSimplePolicyEditor(fileUrl.getPath()); diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java --- a/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/controlpanel/UnsignedAppletsTrustingListPanel.java Wed Oct 17 18:16:40 2018 +0200 @@ -44,7 +44,6 @@ import java.awt.event.KeyListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.WindowEvent; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; @@ -101,6 +100,7 @@ import net.sourceforge.jnlp.security.dialogs.remember.ExecuteAppletAction; import net.sourceforge.jnlp.util.ScreenFinder; import net.sourceforge.jnlp.util.logging.OutputController; +import net.sourceforge.swing.SwingUtils; public class UnsignedAppletsTrustingListPanel extends JPanel { @@ -146,7 +146,7 @@ final String defaultFileName2 = "terrorList2"; final String defaultFile1 = defaultDir + defaultFileName1; final String defaultFile2 = defaultDir + defaultFileName2; - java.awt.EventQueue.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { try { diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/controlpanel/desktopintegrationeditor/Blinker.java --- a/netx/net/sourceforge/jnlp/controlpanel/desktopintegrationeditor/Blinker.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/controlpanel/desktopintegrationeditor/Blinker.java Wed Oct 17 18:16:40 2018 +0200 @@ -39,8 +39,8 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JComponent; -import javax.swing.SwingUtilities; import javax.swing.Timer; +import net.sourceforge.swing.SwingUtils; public class Blinker { @@ -76,7 +76,7 @@ } if (counter == 5) { ((Timer) e.getSource()).stop(); - SwingUtilities.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { @@ -86,7 +86,7 @@ }); return; } - SwingUtilities.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/controlpanel/desktopintegrationeditor/FreeDesktopIntegrationEditorFrame.java --- a/netx/net/sourceforge/jnlp/controlpanel/desktopintegrationeditor/FreeDesktopIntegrationEditorFrame.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/controlpanel/desktopintegrationeditor/FreeDesktopIntegrationEditorFrame.java Wed Oct 17 18:16:40 2018 +0200 @@ -63,6 +63,7 @@ import net.sourceforge.jnlp.util.logging.ConsoleOutputPaneModel; import static net.sourceforge.jnlp.runtime.Translator.R; +import net.sourceforge.swing.SwingUtils; public class FreeDesktopIntegrationEditorFrame extends JFrame { @@ -213,8 +214,7 @@ } public static void main(String args[]) { - - java.awt.EventQueue.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { new FreeDesktopIntegrationEditorFrame().setVisible(true); diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/runtime/Boot.java --- a/netx/net/sourceforge/jnlp/runtime/Boot.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/runtime/Boot.java Wed Oct 17 18:16:40 2018 +0200 @@ -96,6 +96,9 @@ * @param argsIn launching arguments */ public static void main(String[] argsIn) throws UnevenParameterException { + // setup Swing EDT tracing: + SwingUtils.setup(); + optionParser = new OptionParser(argsIn, OptionsDefinitions.getJavaWsOptions()); if (optionParser.hasOption(OptionsDefinitions.OPTIONS.VERBOSE)) { @@ -117,7 +120,7 @@ } catch (Exception e) { OutputController.getLogger().log(OutputController.Level.ERROR_ALL, e); } finally { - //no metter what happens, terminate + //no matter what happens, terminate return; } } diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/security/appletextendedsecurity/ExtendedAppletSecurityHelp.java --- a/netx/net/sourceforge/jnlp/security/appletextendedsecurity/ExtendedAppletSecurityHelp.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/security/appletextendedsecurity/ExtendedAppletSecurityHelp.java Wed Oct 17 18:16:40 2018 +0200 @@ -47,6 +47,7 @@ import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.util.docprovider.TextsProvider; import net.sourceforge.jnlp.util.logging.OutputController; +import net.sourceforge.swing.SwingUtils; public class ExtendedAppletSecurityHelp extends javax.swing.JDialog implements HyperlinkListener { @@ -162,7 +163,7 @@ } public static void main(String args[]) { - java.awt.EventQueue.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { public void run() { ExtendedAppletSecurityHelp dialog = new ExtendedAppletSecurityHelp(null, false); dialog.setVisible(true); diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java --- a/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/security/policyeditor/PolicyEditor.java Wed Oct 17 18:16:40 2018 +0200 @@ -57,7 +57,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.lang.ref.WeakReference; -import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; @@ -96,7 +95,6 @@ import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; import javax.swing.ScrollPaneConstants; -import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import javax.swing.UIManager; import javax.swing.WindowConstants; @@ -120,6 +118,7 @@ import net.sourceforge.jnlp.util.docprovider.formatters.formatters.PlainTextFormatter; import net.sourceforge.jnlp.util.logging.OutputController; import net.sourceforge.jnlp.util.optionparser.OptionParser; +import net.sourceforge.swing.SwingUtils; import sun.security.provider.PolicyParser; /** @@ -460,7 +459,7 @@ viewCustomButtonAction = new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { final PolicyIdentifier policyIdentifier = getSelectedPolicyIdentifier(); @@ -505,7 +504,7 @@ closeButtonAction = new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { - final Window parentWindow = SwingUtilities.getWindowAncestor(PolicyEditor.this); + final Window parentWindow = SwingUtils.getWindowAncestor(PolicyEditor.this); if (parentWindow instanceof PolicyEditorWindow) { ((PolicyEditorWindow) parentWindow).quit(); } @@ -587,10 +586,10 @@ } private void setParentWindowTitle(final String title) { - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { - final Window parent = SwingUtilities.getWindowAncestor(PolicyEditor.this); + final Window parent = SwingUtils.getWindowAncestor(PolicyEditor.this); if (!(parent instanceof PolicyEditorWindow)) { return; } @@ -839,7 +838,7 @@ return; } policyEditorController.addIdentifier(identifier); - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { listModel.clear(); @@ -880,7 +879,7 @@ * or when the user presses cancel. */ public void addNewIdentifierInteractive() { - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { final PolicyIdentifier identifier = promptForPolicyIdentifier(PolicyIdentifier.ALL_APPLETS_IDENTIFIER); @@ -936,7 +935,7 @@ } policyEditorController.removeIdentifier(identifier); final int fIndex = previousIndex; - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { listModel.removeElement(identifier); @@ -1047,37 +1046,17 @@ policyEditorController.clearCustomIdentifier(identifier); } - private void invokeRunnableOrEnqueueLater(final Runnable runnable) { - if (SwingUtilities.isEventDispatchThread()) { - runnable.run(); - } else { - SwingUtilities.invokeLater(runnable); - } - } - - private void invokeRunnableOrEnqueueAndWait(final Runnable runnable) throws InvocationTargetException, InterruptedException { - if (SwingUtilities.isEventDispatchThread()) { - runnable.run(); - } else { - SwingUtilities.invokeAndWait(runnable); - } - } - /** * Update the checkboxes to show the permissions granted to the specified identifier * @param identifier whose permissions to display */ private void updateCheckboxes(final PolicyIdentifier identifier) { - try { - invokeRunnableOrEnqueueAndWait(new Runnable() { - @Override - public void run() { - updateCheckboxesImpl(identifier); - } - }); - } catch (final InterruptedException | InvocationTargetException ex) { - OutputController.getLogger().log(ex); - } + SwingUtils.invokeAndWait(new Runnable() { + @Override + public void run() { + updateCheckboxesImpl(identifier); + } + }); } private void updateCheckboxesImpl(final PolicyIdentifier identifier) { @@ -1461,7 +1440,7 @@ void setChangesMade(final boolean b) { policyEditorController.setChangesMade(b); - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { setParentWindowTitle(getWindowTitleForStatus()); @@ -1529,14 +1508,14 @@ FileUtils.showReadOnlyDialog(PolicyEditor.this); } - final Window parentWindow = SwingUtilities.getWindowAncestor(this); + final Window parentWindow = SwingUtils.getWindowAncestor(this); final JDialog progressIndicator = new IndeterminateProgressDialog(parentWindow, "Loading..."); final SwingWorker openPolicyFileWorker = new SwingWorker() { @Override protected Void doInBackground() throws Exception { try { if (parentWindow != null) { - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { progressIndicator.setLocationRelativeTo(parentWindow); @@ -1590,14 +1569,14 @@ break; } - final Window parentWindow = SwingUtilities.getWindowAncestor(this); + final Window parentWindow = SwingUtils.getWindowAncestor(this); final JDialog progressIndicator = new IndeterminateProgressDialog(parentWindow, "Saving..."); final SwingWorker savePolicyFileWorker = new SwingWorker() { @Override public Void doInBackground() throws Exception { try { if (parentWindow != null) { - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { progressIndicator.setLocationRelativeTo(parentWindow); @@ -1631,7 +1610,7 @@ // This dialog is often displayed when closing the editor, and so PolicyEditor // may already be disposed when this dialog appears. Give a weak reference so // that this dialog doesn't prevent the JVM from exiting - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PEChangesSaved")); @@ -1646,7 +1625,7 @@ // This dialog is often displayed when closing the editor, and so PolicyEditor // may already be disposed when this dialog appears. Give a weak reference so // that this dialog doesn't prevent the JVM from exiting - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PECouldNotSave"), R("Error"), JOptionPane.ERROR_MESSAGE); @@ -1655,7 +1634,7 @@ } private void showClipboardErrorDialog() { - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PEClipboardError"), R("Error"), JOptionPane.ERROR_MESSAGE); @@ -1664,7 +1643,7 @@ } private void showInvalidPolicyExceptionDialog(final PolicyIdentifier identifier) { - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PEInvalidPolicy", identifier.toString()), R("Error"), JOptionPane.ERROR_MESSAGE); @@ -1673,7 +1652,7 @@ } private void showCouldNotAccessClipboardDialog() { - invokeRunnableOrEnqueueLater(new Runnable() { + SwingUtils.invokeRunnableOrEnqueueLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(parentPolicyEditor.get(), R("PEClipboardAccessError"), R("Error"), JOptionPane.ERROR_MESSAGE); @@ -1720,7 +1699,7 @@ private void toggleExpandedCheckboxGroupPanel(final JPanel groupPanel) { groupPanel.setVisible(!groupPanel.isVisible()); PolicyEditor.this.validate(); - final Window w = SwingUtilities.getWindowAncestor(PolicyEditor.this); + final Window w = SwingUtils.getWindowAncestor(PolicyEditor.this); if (w != null) { w.pack(); } @@ -1734,6 +1713,9 @@ * -help will print a help message and immediately return (no editor instance opens) */ public static void main(final String[] args) { + // setup Swing EDT tracing: + SwingUtils.setup(); + final OptionParser optionParser = new OptionParser(args, OptionsDefinitions.getPolicyEditorOptions()); if (optionParser.hasOption(OptionsDefinitions.OPTIONS.VERBOSE)) { @@ -1767,7 +1749,7 @@ final String signedBy = getSignedByArgument(optionParser); final Set principals = getPrincipalsArgument(optionParser); - SwingUtilities.invokeLater(new Runnable() { + SwingUtils.invokeLater(new Runnable() { @Override public void run() { final PolicyEditorWindow frame = getPolicyEditorFrame(filepath); diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/splashscreen/parts/BasicComponentErrorSplashScreen.java --- a/netx/net/sourceforge/jnlp/splashscreen/parts/BasicComponentErrorSplashScreen.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/splashscreen/parts/BasicComponentErrorSplashScreen.java Wed Oct 17 18:16:40 2018 +0200 @@ -37,6 +37,7 @@ package net.sourceforge.jnlp.splashscreen.parts; import net.sourceforge.jnlp.splashscreen.SplashErrorPanel; +import net.sourceforge.swing.SwingUtils; public abstract class BasicComponentErrorSplashScreen extends BasicComponentSplashScreen implements SplashErrorPanel { @@ -70,8 +71,7 @@ } protected void raiseExceptionDialogQUEUED() { - java.awt.EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { @Override public void run() { raiseExceptionDialogNOW(); diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java --- a/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/splashscreen/parts/JEditorPaneBasedExceptionDialog.java Wed Oct 17 18:16:40 2018 +0200 @@ -66,6 +66,7 @@ import net.sourceforge.jnlp.util.BasicExceptionDialog; import net.sourceforge.jnlp.util.docprovider.TextsProvider; import net.sourceforge.jnlp.util.logging.OutputController; +import net.sourceforge.swing.SwingUtils; public class JEditorPaneBasedExceptionDialog extends JDialog implements HyperlinkListener { @@ -276,8 +277,7 @@ * @param args the command line arguments */ public static void main(String args[]) { - java.awt.EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { public void run() { Exception ex = new RuntimeException("dsgsfdg"); JEditorPaneBasedExceptionDialog dialog = new JEditorPaneBasedExceptionDialog(new JFrame(), true, ex, null, "uaaa: aaa\nwqdeweq:sdsds"); diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/util/ImageResources.java --- a/netx/net/sourceforge/jnlp/util/ImageResources.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/util/ImageResources.java Wed Oct 17 18:16:40 2018 +0200 @@ -77,14 +77,16 @@ } InputStream in = cl.getResourceAsStream(APPLICATION_ICON_PATH); - try { - Image image = ImageIO.read(in); - cache.put(APPLICATION_ICON_PATH, image); - return image; - } catch (IOException ioe) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ioe); - return null; + if (in != null) { + try { + Image image = ImageIO.read(in); + cache.put(APPLICATION_ICON_PATH, image); + return image; + } catch (IOException ioe) { + OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ioe); + } } + return null; } /** diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java --- a/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/jnlp/util/logging/ConsoleOutputPane.java Wed Oct 17 18:16:40 2018 +0200 @@ -46,6 +46,7 @@ import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.util.logging.headers.ObservableMessagesProvider; +import net.sourceforge.swing.SwingUtils; public class ConsoleOutputPane extends JPanel implements Observer { @@ -188,8 +189,7 @@ @Override public final void mouseClicked(final MouseEvent e) { - EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { @Override public final void run() { try { @@ -213,8 +213,7 @@ if (e.getKeyCode() != KeyEvent.VK_CONTEXT_MENU) { return; } - EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { @Override public final void run() { try { @@ -283,8 +282,7 @@ return; } done.set(false); - EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { @Override public final void run() { try { @@ -683,8 +681,7 @@ @Override public final void actionPerformed(final ActionEvent e) { - EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { @Override public final void run() { try { @@ -706,8 +703,7 @@ @Override public final void actionPerformed(final ActionEvent e) { - EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { @Override public final void run() { try { @@ -730,8 +726,7 @@ @Override public final void actionPerformed(final ActionEvent e) { - EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { @Override public final void run() { try { @@ -903,8 +898,7 @@ } public static final void main(final String args[]) { - EventQueue.invokeLater(new Runnable() { - + SwingUtils.invokeLater(new Runnable() { @Override public final void run() { final JFrame dialog = new JFrame(); diff -r e19639f572c4 -r 5b3e94efb41c netx/net/sourceforge/swing/SwingUtils.java --- a/netx/net/sourceforge/swing/SwingUtils.java Fri Oct 12 15:37:59 2018 +0200 +++ b/netx/net/sourceforge/swing/SwingUtils.java Wed Oct 17 18:16:40 2018 +0200 @@ -36,18 +36,12 @@ exception statement from your version. */ package net.sourceforge.swing; +import java.awt.Component; +import java.awt.EventQueue; import java.awt.Window; import java.lang.reflect.InvocationTargetException; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; import javax.swing.JWindow; +import javax.swing.RepaintManager; import javax.swing.SwingUtilities; import net.sourceforge.jnlp.runtime.Translator; import net.sourceforge.jnlp.util.logging.OutputController; @@ -57,18 +51,37 @@ */ public final class SwingUtils { + private static final boolean DEBUG_EDT = System.getProperty("icedtea-web.edt.debug", "false").equalsIgnoreCase("true"); + // debugging flags: private static final boolean INFO_DIALOG = false; private static final boolean TRACE_INVOKE_EDT = false; private static final boolean TRACE_TG = false; + // internals: + private static boolean DO_SETUP = true; + /** main thread group (initialized at startup) */ - static final ThreadGroup MAIN_GROUP = Thread.currentThread().getThreadGroup(); + private static final ThreadGroup MAIN_GROUP = Thread.currentThread().getThreadGroup(); + + /* shared Window owner */ + private static Window window = null; private SwingUtils() { // forbidden } + public static void setup() { + if (DO_SETUP) { + DO_SETUP = false; // avoid reentrance + + if (DEBUG_EDT) { + trace("Using ThreadCheckingRepaintManager"); + RepaintManager.setCurrentManager(new ThreadCheckingRepaintManager()); + } + } + } + static void trace(final String msg) { // Use System.err directly for debuging EDT without any conflict with console / logging system System.err.println(msg); @@ -93,72 +106,6 @@ } } - // --- SwingUtilities wrapper --- - public static boolean isEventDispatchThread() { - return SwingUtilities.isEventDispatchThread(); - } - - public static void invokeLater(final Runnable doRun) { - if (isMainThreadGroup()) { - if (isEventDispatchThread()) { - if (TRACE_INVOKE_EDT) { - traceWithStack("invokeLater() from EDT: MAY be fixed ?"); - } - } - SwingUtilities.invokeLater(doRun); - } else { - EDT_DAEMON_THREAD_POOL.submit(new Runnable() { - @Override - public void run() { - SwingUtilities.invokeLater(doRun); - } - }); - } - } - - public static void callOnAppContext(final Runnable doRun) throws InterruptedException, InvocationTargetException { - SwingUtilities.invokeAndWait(doRun); - } - - public static void invokeAndWait(final Runnable doRun) { - if (isMainThreadGroup()) { - if (isEventDispatchThread()) { - if (TRACE_INVOKE_EDT) { - traceWithStack("invokeAndWait() from EDT: MAY be fixed ?"); - } - doRun.run(); - } else { - try { - callOnAppContext(doRun); - } catch (InterruptedException ie) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ie); - } catch (InvocationTargetException ite) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ite); - } - } - } else { - final Future future = EDT_DAEMON_THREAD_POOL.submit(new Callable() { - @Override - public Void call() throws Exception { - callOnAppContext(doRun); - return null; - } - }); - try { - // Wait on Future: - future.get(); - } catch (InterruptedException ie) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ie); - } catch (ExecutionException ee) { - if (ee.getCause() != null) { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ee.getCause()); - } else { - OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ee); - } - } - } - } - private static boolean isMainThreadGroup() { final Thread t = Thread.currentThread(); final ThreadGroup g = t.getThreadGroup(); @@ -172,35 +119,53 @@ return true; } - private static final class MainAppContextDaemonThreadFactory implements ThreadFactory { + // --- SwingUtilities wrapper --- + public static Window getWindowAncestor(Component c) { + return SwingUtilities.getWindowAncestor(c); + } - private final AtomicInteger threadNumber = new AtomicInteger(1); - private final String namePrefix = "itw-edt-thread-"; + public static boolean isEventDispatchThread() { + return EventQueue.isDispatchThread(); + } - @Override - public Thread newThread(Runnable r) { - final Thread t = new Thread(MAIN_GROUP, r, - namePrefix + threadNumber.getAndIncrement() - ); - if (!t.isDaemon()) { - t.setDaemon(true); + public static void invokeLater(final Runnable doRun) { + if (isMainThreadGroup()) { + if (TRACE_INVOKE_EDT && isEventDispatchThread()) { + traceWithStack("invokeLater() from EDT: MAY be fixed (useless) ?"); } - if (t.getPriority() != Thread.NORM_PRIORITY) { - t.setPriority(Thread.NORM_PRIORITY); - } - return t; + } + EventQueue.invokeLater(doRun); + } + + public static void invokeRunnableOrEnqueueLater(final Runnable runnable) { + if (isEventDispatchThread()) { + runnable.run(); + } else { + invokeLater(runnable); } } - /** single thread pool with max 1 live daemon thread */ - private static final ExecutorService EDT_DAEMON_THREAD_POOL = new ThreadPoolExecutor(0, 1, - 60L, TimeUnit.SECONDS, - new LinkedBlockingQueue(), - new MainAppContextDaemonThreadFactory() - ); + public static void callOnAppContext(final Runnable doRun) throws InterruptedException, InvocationTargetException { + EventQueue.invokeAndWait(doRun); + } - /* shared Window owner */ - private static Window window = null; + public static void invokeAndWait(final Runnable doRun) { + if (isEventDispatchThread()) { + if (TRACE_INVOKE_EDT) { + traceWithStack("invokeAndWait() from EDT: to be fixed (illegal) ?"); + } + // Direct invocation: + doRun.run(); + } else { + try { + callOnAppContext(doRun); + } catch (InterruptedException ie) { + OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ie); + } catch (InvocationTargetException ite) { + OutputController.getLogger().log(OutputController.Level.ERROR_ALL, ite); + } + } + } public static synchronized Window getOrCreateWindowOwner() { if (window == null) {