-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
6u10
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP version 2.07
A DESCRIPTION OF THE PROBLEM :
With the legacy_lifecycle param set to TRUE and using the next generation java plugin, if you refresh the applet too quickly (that is before the start() method has completed), the destroy() method will be called. If I disable the "next-generation Java Plug-in" from the Java Control Panel, this does not occur - only stop() is called.
Calling the destroy() method is causing grave problems for our applet with this 6u10 version because the ThreadGroup for the applet instance is being destroyed. With previous JREs we were able to inherit the same threadgroup when init() was called again. Granted this may not have been a wise practice, but it has worked fine for quite some time.
At any rate, now we must use the legacy_lifecycle option and one of the most basic user operations involves the applet being refreshed due to URL changes.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Using sample blink applet, add a sleep() call in the applet's start() method.
2. Add destroy() method that simply has a System.out.println statement and calls super.destroy().
3. In Blink.html add -- <param name="legacy_lifecycle" VALUE="TRUE">
4. Load Blink.html and wait for it to completely start
5. Then refresh/reload the page a couple times quickly (before the sleep() ends in start() method.
6. Should see the System.out statement from the destroy statement in Java Console.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect that only the stop() method is called. Not destroy() as well.
Here's the output running with the old plugin
--------------------------------------------------------------------------------------------------------
>> Start called - about to sleep...
basic: Stopping applet ...
basic: Applet supports legacy lifecycle model - add applet to lifecycle cache
>> sleep done!
basic: Found previous stopped applet from lifecycle cache
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@1c76c98, refcount=7
basic: Starting applet ...
basic: completed perf rollup
ACTUAL -
Here's the relevant trace from the Java Console when refreshing quickly.
Notice the statement from the destroy() method
--------------------------------------------------------------------------------------------------------
>> Start called - about to sleep...
WARNING -- destroy called for applet id: 2
>> sleep done!
basic: Applet started
basic: Skipped starting applet -- terminated abruptly
basic: Starting applet teardown
basic: Finished applet teardown
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@1b55f2
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 177437 us, pluginInit dt 71320370 us, TotalTime: 71497807 us
basic: Applet initialized
basic: Removed progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@1b55f2
basic: Applet made visible
basic: Starting applet
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.util.*;
public class Blink extends java.applet.Applet {
private Timer timer; // Schedules the blinking
private String labelString; // The label for the window
private int delay; // the delay time between blinks
private int appletID;
public static int appletConstructionCount = 0;
public Blink() {
appletConstructionCount++;
}
public void init() {
String blinkFrequency = getParameter("speed");
delay = (blinkFrequency == null) ? 400 :
(1000 / Integer.parseInt(blinkFrequency));
labelString = getParameter("lbl");
labelString += labelString;
if (labelString == null)
labelString = "Blink";
Font font = new java.awt.Font("Serif", Font.BOLD, 24);
setFont(font);
}
public void start() {
System.out.println("\n>> Start called - about to sleep...");
Thread th = Thread.currentThread();
try {
th.sleep(3000);
}
catch (Exception e) {
}
System.out.println(">> sleep done!");
timer = new Timer(); //creates a new timer to schedule the blinking
timer.schedule(new TimerTask() { //creates a timertask to schedule
// overrides the run method to provide functionality
public void run() {
repaint();
}
}
, delay, delay);
}
public void paint(Graphics g) {
int fontSize = g.getFont().getSize();
int x = 0, y = fontSize, space;
int red = (int) ( 50 * Math.random());
int green = (int) ( 50 * Math.random());
int blue = (int) (256 * Math.random());
Dimension d = getSize();
g.setColor(Color.black);
FontMetrics fm = g.getFontMetrics();
space = fm.stringWidth(" ");
for (StringTokenizer t = new StringTokenizer(labelString);
t.hasMoreTokens();) {
String word = t.nextToken();
int w = fm.stringWidth(word) + space;
if (x + w > d.width) {
x = 0;
y += fontSize; //move word to next line if it doesn't fit
}
if (Math.random() < 0.5)
g.setColor(new java.awt.Color((red + y*30) % 256,
(green + x/3) % 256, blue));
else
g.setColor(getBackground());
g.drawString(word, x, y);
x += w; //shift to the right to draw the next word
}
}
public void stop() {
timer.cancel(); //stops the timer
}
public void destroy() {
System.out.println("\nWARNING -- destroy called for applet id: " + appletConstructionCount);
super.destroy();
}
public String getAppletInfo() {
return "Title: Blinker\n"
+ "Author: Arthur van Hoff\n"
+ "Displays multicolored blinking text.";
}
public String[][] getParameterInfo() {
String pinfo[][] = {
{"speed", "string", "The blink frequency"},
{"lbl", "string", "The text to blink."},
};
return pinfo;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
For IE we can use the old plugin but since our applet also runs on Firefox, we would prefer to have the same set of instructions for both browsers. With Firefox we are broken with the old plugin due to some LiveConnect problems (bug id - 6603064).
Release Regression From : 6u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP version 2.07
A DESCRIPTION OF THE PROBLEM :
With the legacy_lifecycle param set to TRUE and using the next generation java plugin, if you refresh the applet too quickly (that is before the start() method has completed), the destroy() method will be called. If I disable the "next-generation Java Plug-in" from the Java Control Panel, this does not occur - only stop() is called.
Calling the destroy() method is causing grave problems for our applet with this 6u10 version because the ThreadGroup for the applet instance is being destroyed. With previous JREs we were able to inherit the same threadgroup when init() was called again. Granted this may not have been a wise practice, but it has worked fine for quite some time.
At any rate, now we must use the legacy_lifecycle option and one of the most basic user operations involves the applet being refreshed due to URL changes.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Using sample blink applet, add a sleep() call in the applet's start() method.
2. Add destroy() method that simply has a System.out.println statement and calls super.destroy().
3. In Blink.html add -- <param name="legacy_lifecycle" VALUE="TRUE">
4. Load Blink.html and wait for it to completely start
5. Then refresh/reload the page a couple times quickly (before the sleep() ends in start() method.
6. Should see the System.out statement from the destroy statement in Java Console.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect that only the stop() method is called. Not destroy() as well.
Here's the output running with the old plugin
--------------------------------------------------------------------------------------------------------
>> Start called - about to sleep...
basic: Stopping applet ...
basic: Applet supports legacy lifecycle model - add applet to lifecycle cache
>> sleep done!
basic: Found previous stopped applet from lifecycle cache
basic: Referencing classloader: sun.plugin.ClassLoaderInfo@1c76c98, refcount=7
basic: Starting applet ...
basic: completed perf rollup
ACTUAL -
Here's the relevant trace from the Java Console when refreshing quickly.
Notice the statement from the destroy() method
--------------------------------------------------------------------------------------------------------
>> Start called - about to sleep...
WARNING -- destroy called for applet id: 2
>> sleep done!
basic: Applet started
basic: Skipped starting applet -- terminated abruptly
basic: Starting applet teardown
basic: Finished applet teardown
basic: Added progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@1b55f2
basic: Applet loaded.
basic: Applet resized and added to parent container
basic: PERF: AppletExecutionRunnable - applet.init() BEGIN ; jvmLaunch dt 177437 us, pluginInit dt 71320370 us, TotalTime: 71497807 us
basic: Applet initialized
basic: Removed progress listener: sun.plugin.util.GrayBoxPainter$GrayBoxProgressListener@1b55f2
basic: Applet made visible
basic: Starting applet
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.util.*;
public class Blink extends java.applet.Applet {
private Timer timer; // Schedules the blinking
private String labelString; // The label for the window
private int delay; // the delay time between blinks
private int appletID;
public static int appletConstructionCount = 0;
public Blink() {
appletConstructionCount++;
}
public void init() {
String blinkFrequency = getParameter("speed");
delay = (blinkFrequency == null) ? 400 :
(1000 / Integer.parseInt(blinkFrequency));
labelString = getParameter("lbl");
labelString += labelString;
if (labelString == null)
labelString = "Blink";
Font font = new java.awt.Font("Serif", Font.BOLD, 24);
setFont(font);
}
public void start() {
System.out.println("\n>> Start called - about to sleep...");
Thread th = Thread.currentThread();
try {
th.sleep(3000);
}
catch (Exception e) {
}
System.out.println(">> sleep done!");
timer = new Timer(); //creates a new timer to schedule the blinking
timer.schedule(new TimerTask() { //creates a timertask to schedule
// overrides the run method to provide functionality
public void run() {
repaint();
}
}
, delay, delay);
}
public void paint(Graphics g) {
int fontSize = g.getFont().getSize();
int x = 0, y = fontSize, space;
int red = (int) ( 50 * Math.random());
int green = (int) ( 50 * Math.random());
int blue = (int) (256 * Math.random());
Dimension d = getSize();
g.setColor(Color.black);
FontMetrics fm = g.getFontMetrics();
space = fm.stringWidth(" ");
for (StringTokenizer t = new StringTokenizer(labelString);
t.hasMoreTokens();) {
String word = t.nextToken();
int w = fm.stringWidth(word) + space;
if (x + w > d.width) {
x = 0;
y += fontSize; //move word to next line if it doesn't fit
}
if (Math.random() < 0.5)
g.setColor(new java.awt.Color((red + y*30) % 256,
(green + x/3) % 256, blue));
else
g.setColor(getBackground());
g.drawString(word, x, y);
x += w; //shift to the right to draw the next word
}
}
public void stop() {
timer.cancel(); //stops the timer
}
public void destroy() {
System.out.println("\nWARNING -- destroy called for applet id: " + appletConstructionCount);
super.destroy();
}
public String getAppletInfo() {
return "Title: Blinker\n"
+ "Author: Arthur van Hoff\n"
+ "Displays multicolored blinking text.";
}
public String[][] getParameterInfo() {
String pinfo[][] = {
{"speed", "string", "The blink frequency"},
{"lbl", "string", "The text to blink."},
};
return pinfo;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
For IE we can use the old plugin but since our applet also runs on Firefox, we would prefer to have the same set of instructions for both browsers. With Firefox we are broken with the old plugin due to some LiveConnect problems (bug id - 6603064).
Release Regression From : 6u7
The above release value was the last known release where this
bug was not reproducible. Since then there has been a regression.