aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--netx/net/sourceforge/jnlp/NetxPanel.java2
-rw-r--r--plugin/icedteanp/java/sun/applet/PluginAppletViewer.java7
-rw-r--r--tests/reproducers/simple/AppletTest/resources/errorAppletAutoTests.html43
-rw-r--r--tests/reproducers/simple/AppletTest/srcs/AppletErrorTest.java269
5 files changed, 330 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5f2364e..9228a0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2012-11-27 Jiri Vanek <[email protected]>
+ Better error reporting from applets
+ * netx/net/sourceforge/jnlp/NetxPanel.java: (init) ErrorSplash is shown
+ if fatal exception is cough
+ * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java: (replaceSpalsh)
+ is rather removing all then just its previous version
+ * tests/reproducers/simple/AppletTest/srcs/AppletErrorTest.java:
+ * tests/reproducers/simple/AppletTest/resources/errorAppletAutoTests.html
+ Testcase for manual testing of various exceptions from applet
+
+2012-11-27 Jiri Vanek <[email protected]>
+
* AUTHORS: added Jan Kmetko as current SplashScreen artwork author
2012-11-27 Jiri Vanek <[email protected]>
diff --git a/netx/net/sourceforge/jnlp/NetxPanel.java b/netx/net/sourceforge/jnlp/NetxPanel.java
index f6496b6..ce20d5c 100644
--- a/netx/net/sourceforge/jnlp/NetxPanel.java
+++ b/netx/net/sourceforge/jnlp/NetxPanel.java
@@ -33,6 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import net.sourceforge.jnlp.splashscreen.SplashController;
import net.sourceforge.jnlp.splashscreen.SplashPanel;
+import net.sourceforge.jnlp.splashscreen.SplashUtils;
import sun.applet.AppletViewerPanel;
import sun.awt.SunToolkit;
@@ -178,6 +179,7 @@ public class NetxPanel extends AppletViewerPanel implements SplashController {
} catch (Exception e) {
this.appletAlive = false;
e.printStackTrace();
+ replaceSplash(SplashUtils.getErrorSplashScreen(getWidth(), getHeight(), e));
}
}
diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
index 974c2e4..f9d9422 100644
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
+++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
@@ -114,6 +114,7 @@ import sun.awt.X11.XEmbeddedFrame;
import sun.misc.Ref;
import com.sun.jndi.toolkit.url.UrlUtil;
+import java.awt.BorderLayout;
import java.util.Hashtable;
import java.util.Vector;
import net.sourceforge.jnlp.splashscreen.SplashController;
@@ -453,9 +454,11 @@ public class PluginAppletViewer extends XEmbeddedFrame
public void run() {
splashPanel.getSplashComponent().setVisible(false);
splashPanel.stopAnimation();
- remove(splashPanel.getSplashComponent());
+ removeAll();
+ setLayout(new BorderLayout());
+ //remove(splashPanel.getSplashComponent());
splashPanel = null;
- remove(panel);
+ //remove(panel);
// Re-add the applet to notify container
add(panel);
panel.setVisible(true);
diff --git a/tests/reproducers/simple/AppletTest/resources/errorAppletAutoTests.html b/tests/reproducers/simple/AppletTest/resources/errorAppletAutoTests.html
new file mode 100644
index 0000000..bfc6434
--- /dev/null
+++ b/tests/reproducers/simple/AppletTest/resources/errorAppletAutoTests.html
@@ -0,0 +1,43 @@
+<!--
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+
+ -->
+<html><head></head><body bgcolor="blue">
+<p><applet code="AppletErrorTest.class" archive="AppletTest.jar" codebase="." width="800" height="600">
+ <param name="levelOfDeath" value="BEHIND_GUI_THREAD">
+</applet></p>
+</body>
+</html>
diff --git a/tests/reproducers/simple/AppletTest/srcs/AppletErrorTest.java b/tests/reproducers/simple/AppletTest/srcs/AppletErrorTest.java
new file mode 100644
index 0000000..22a0f37
--- /dev/null
+++ b/tests/reproducers/simple/AppletTest/srcs/AppletErrorTest.java
@@ -0,0 +1,269 @@
+/* AppletErrorTest.java
+Copyright (C) 2011 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+ *
+ */
+
+import java.applet.Applet;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.GridLayout;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.Random;
+import javax.swing.JApplet;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+public class AppletErrorTest extends JApplet {
+
+ private class Killer extends Thread {
+
+ public int n = 20000;
+
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(n);
+ System.out.println("Error Applet killing himself after " + n + " ms of life");
+ System.exit(0);
+ } catch (Exception ex) {
+ }
+ }
+ }
+ private volatile boolean waiting = true;
+ private boolean isApplet = true;
+ private Killer killer;
+ private final String IN_GUI_THREAD = "IN_GUI_THREAD";
+ private final String BEHIND_GUI_THREAD = "BEHIND_GUI_THREAD";
+ private final String IN_GUI = "IN_GUI";
+ private final String IN_INIT = "IN_INIT";
+ private final String IN_START = "IN_START";
+ private final String IN_STOP = "IN_STOP";
+ private final String IN_DESTROY = "IN_DESTROY";
+ private String levelOfDeath = BEHIND_GUI_THREAD;
+
+ @Override
+ public void init() {
+ if (isApplet) {
+ String s = getParameter("levelOfDeath");
+ if (s != null) {
+ levelOfDeath = s;
+ }
+ }
+ System.out.println("Error applet was initialised");
+ killer = new Killer();
+ if (levelOfDeath.equals(IN_INIT)) {
+ throw new RuntimeException("Intentional exception from init");
+ }
+ }
+
+ public static void main(String[] args) {
+ final JFrame f = new JFrame();
+ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ f.setSize(899, 600);
+ f.setLayout(new BorderLayout());
+ AppletErrorTest ae = new AppletErrorTest();
+ ae.isApplet=false;
+ ae.init();
+ f.add(ae);
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ f.setVisible(true);
+ }
+ });
+ ae.start();
+
+
+ }
+
+ @Override
+ public void start() {
+ final AppletErrorTest aSelf = this;
+ final JPanel self = new JPanel();
+ aSelf.setLayout(new BorderLayout());
+ aSelf.add(self);
+ self.setLayout(new GridLayout(0, 4));
+ final Random r = new Random();
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ new Colorer(self, r).run();
+ }
+ }).start();
+
+
+ System.out.println("Error applet was started");
+ killer.start();
+ System.out.println("killer was started");
+ if (levelOfDeath.equals(IN_GUI_THREAD) || levelOfDeath.equals(IN_GUI) || levelOfDeath.equals(BEHIND_GUI_THREAD)) {
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+
+ for (int i = 0; i < 15; i++) {
+ try {
+ System.out.println("Rainbow is shining");
+ new GuiRainbow(self, r, i).run();
+ if (levelOfDeath.equals(BEHIND_GUI_THREAD) && i >= 12) {
+ throw new RuntimeException("Intentional error from start (gui is running)- " + levelOfDeath);
+ }
+ Thread.sleep(200);
+ } catch (InterruptedException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ } finally {
+ waiting = false;
+ }
+
+
+
+ }
+ }).start();
+ }
+ if (!isApplet) {
+ if (levelOfDeath.equals(IN_GUI)) {
+ while (waiting) {
+ try {
+ Thread.sleep(100);
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ aSelf.repaint();
+ aSelf.validate();
+ aSelf.repaint();
+ }
+ });
+
+ } catch (InterruptedException ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ throw new RuntimeException("Intentional error from start (gui was running)- " + levelOfDeath);
+ }
+ }
+ if (levelOfDeath.equals(IN_START)) {
+ throw new RuntimeException("Intentional error from start (gui was not running)- " + levelOfDeath);
+ }
+ }
+
+ @Override
+ public void stop() {
+ System.out.println("Error applet was stopped");
+ if (levelOfDeath.equals(IN_STOP)) {
+ throw new RuntimeException("Intentional exception from stop" + levelOfDeath);
+ }
+ }
+
+ @Override
+ public void destroy() {
+ System.out.println("Error applet will be destroyed");
+ if (levelOfDeath.equals(IN_DESTROY)) {
+ throw new RuntimeException("Intentional exception from destroy" + levelOfDeath);
+ }
+ }
+
+ private class GuiRainbow implements Runnable {
+
+ private final JComponent self;
+ private final Random r;
+ private final int i;
+
+ public GuiRainbow(JComponent self, Random r, int i) {
+ this.self = self;
+ this.r = r;
+ this.i = i;
+ }
+
+ @Override
+ public void run() {
+ if (self.getComponentCount() > 1 && r.nextInt(2) == 0) {
+ int x = r.nextInt(self.getComponentCount());
+ self.remove(x);
+ self.validate();
+ } else {
+ JLabel ll=new JLabel("Hi, its error applet here " + i);
+ self.add(ll);
+ self.validate();
+ ll.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ throw new RuntimeException("Intentional exception by click to "+i);
+ }
+ });
+ }
+ System.out.println("Components are handled");
+ if (levelOfDeath.equals(IN_GUI_THREAD) && i >= 8) {
+ throw new RuntimeException("Intentional error from swing thread (gui is running)- " + levelOfDeath);
+ }
+
+ }
+ }
+
+ class Colorer implements Runnable {
+
+ private final JComponent self;
+ private final Random r;
+
+ public Colorer(JComponent self, Random r) {
+ this.self = self;
+ this.r = r;
+ }
+
+ @Override
+ public void run() {
+ int i = 0;
+ while (true) {
+ i++;
+ try {
+ self.setBackground(new Color(r.nextInt()));
+ System.out.println("Applet is coloring " + i);
+ Thread.sleep(200);
+ } catch (Exception ex) {
+ //intentionally silenced
+ }
+ }
+ }
+ }
+}