Re: jvm crash
In article
<1b82a558-e1dd-43e9-9831-4f21bb1bf716@i8g2000pro.googlegroups.com>,
suru <suraj.hajare@gmail.com> wrote:
[...]
my observation is that, suddenly, my applet (& its child windows)are
gone, and i find jvm crash log file, explaining the details.
Can you supply an example that demonstrates your problem? Here is an
example of an applet crashing the Event Dispatching Thread:
<code>
//<applet code="Hello.class" width=400 height 0></applet>
import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class Hello extends JApplet {
private static final Font font = new Font("Serif", Font.BOLD, 24);
private static final String s = "Hello World!";
public void init() {
System.out.println("Initializing...");
}
public void paint(Graphics g) {
g.setFont(font);
int xx = this.getWidth();
int yy = this.getHeight();
int w2 = g.getFontMetrics().stringWidth(s) / 2;
int h2 = g.getFontMetrics().getDescent();
g.setColor(Color.lightGray);
g.fillRect(0, 0, xx, yy);
g.setColor(Color.black);
g.drawString(s, xx / 2 - w2, yy / 2 + h2);
int evil = 1/0; // line 22
}
public void destroy() {
System.out.println("That's all, folks...");
}
}
</code>
<console>
Java Plug-in 1.5.0
Using JRE version 1.5.0_19 Java HotSpot(TM) Client VM
User home directory = /Users/...
Initializing...
Exception in thread "AWT-EventQueue-2"
java.lang.ArithmeticException: / by zero
at Hello.paint(Hello.java:22)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
....
</console>
Here's is the same error in the debugger:
$ appletviewer -debug Hello.java
Initializing jdb ...
run
run sun.applet.Main Hello.java
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
VM Started: Warning: Temporarily overwriting system property at user's
request: key: http.proxyPort old value: 8118 new value: 8118
Warning: Temporarily overwriting system property at user's request: key:
http.proxyHost old value: 127.0.0.1 new value: 127.0.0.1
Initializing...
Exception in thread "AWT-EventQueue-1" java.lang.ArithmeticException: /
by zero
at Hello.paint(Hello.java:22)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:276)
....
evernthough i have log file, can u explain difference between app
crashing and the JVM crashing"?
<http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>