JDK-6222850 : Java 2D throws Exception when launched through browser
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: jds3,5.0u1,6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux,windows
  • CPU: x86
  • Submitted: 2005-01-28
  • Updated: 2010-05-08
  • Resolved: 2007-04-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b43Fixed
Related Reports
Duplicate :  
Relates :  
Description
Java 2D throws Exception when launched through browser

Tested OS : Solaris 9 sparc
Tested browser : Mozilla 1.7
Steps to reproduce :

1. Install Mozilla 1.7
2. Install Mustang build 20
3. Register mustang plugin with mozilla
4. Launch mozilla
5. Launch Java2D which is under jdk1.6.0/demo/plugin/jfc/Java2D folder
6. Click on each tab
7. Close the browser

Following message is getting displayed in the terminal

"Java process: caught exception from sun.plugin.navig.motif.Plugin.start
Exception in thread "main""

Under mozilla folder, the file named plugin_stack.trace got created with the following contents :

"java.lang.IllegalThreadStateException
        at java.lang.ThreadGroup.add(ThreadGroup.java:856)
        at java.lang.Thread.start(Thread.java:573)
        at java.lang.Shutdown.runHooks(Shutdown.java:128)
        at java.lang.Shutdown.sequence(Shutdown.java:173)
        at java.lang.Shutdown.exit(Shutdown.java:218)
        at java.lang.Runtime.exit(Runtime.java:90)
        at java.lang.System.exit(System.java:868)
        at sun.plugin.navig.motif.Plugin.doit(Plugin.java:178)
        at sun.plugin.navig.motif.Plugin.start(Plugin.java:104)"

plugin_stack.trace file attached
###@###.### 2005-1-28 12:40:32 GMT

Comments
EVALUATION The bug is not reproduciable using current mustang build. ###@###.### 2005-04-27 07:27:45 GMT The problem exists in Java2D codes. GraphicsPrimitive.java: public synchronized static void tracePrimitive(Object prim) { ... TraceReporter.setShutdownHook(); ... Refer to: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread) ... Once the shutdown sequence has begun it is impossible to register a new shutdown hook or de-register a previously-registered hook. Attempting either of these operations will cause an IllegalStateException to be thrown. ... In many classes of Java2d, they will try to call tracePrimitive method which will try to add a shutdown hook. It's unsafe method when shutdown has been started. Java2D should only call this method once at the begin time. reassign to java2d. ###@###.### 2005-05-20 08:32:41 GMT From Jim(member of java2d)'s evaluation, the problem might not exist in java2d code. I checked the awt/java2d code again, and wrote some test codes. The problem might exist in FontManager.createFont of awt code. Attachment is the email with java2d and test code. Need awt team for further evaluation. ###@###.### 2005-05-23 02:33:26 GMT FontManager's addShutdownHook looks like it could potentially be registered during a typical lifecycle of an applet. I'd note, though, that the stack trace doesn't look like it is coming from an errant "addShutdownHook", but from running a validly registered shutdown hook. It is specifically coming from the line that checks if the ThreadGroup of a Thread being started has been deleted or not. That would seem to me to be the potential issue - if Plugin deletes the Applet's ThreadGroup before calling exit(), then the Shutdown hook registered by FontManager (and likely any other Shutdown hooks in the JVM) will fail because they will have been registered under the default ThreadGroup of the caller. The fix would then be to have the FontManager make sure that it's ShutdownHook is given a System ThreadGroup before registering it. jim.a.graham 2005-05-23 ###@###.### 2005-05-23 20:47:07 GMT As noted above this ought to be a member of the top level thread group. There are a number of shutdown hooks at various places in the JRE. Some of them look similarly vulnerable but are much more likely to be created in the VM initialisation phase rather than in the course of running an applet. ###@###.### 2005-05-24 18:09:51 GMT
27-04-2005