JDK-6755357 : Applet.getImage() and ImageObserver.imageUpdate() don't use same object types.
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2008-10-02
  • Updated: 2010-04-04
  • Resolved: 2008-10-13
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
1.6.0_10-rc2

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP3

EXTRA RELEVANT SYSTEM CONFIGURATION :
IE 7 or Firefox 3, using plugin2

A DESCRIPTION OF THE PROBLEM :
Since 1.6.0_10, Applet.getImage() returns a sun.plugin.util.ToolkitImageWrapper.
ImageObserver.imageUpdate still sends a sun.awt.image.ToolkitImage.

It is then impossible under 1.6.0-10-rc2 to know which image returned by Applet.getImage() is now ready.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Using the following applet (taken from http://forums.java.net/jive/thread.jspa?messageID=297683&tstart=0).
Add 2 JPEG images in the codebase called image1.jpg and image2.jpg.
Point your browser to the applet codebase.



EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The applet should return something along the lines of:

Preparing image1.jpg (sun.awt.image.ToolkitImage@1820dda)
Preparing image2.jpg (sun.awt.image.ToolkitImage@112f614)
image2.jpg is ready
image1.jpg is ready

(this output is taken from 1.6.0_07)
ACTUAL -
Preparing image1.jpg (sun.plugin.util.ToolkitImageWrapper@176c74b)
Preparing image2.jpg (sun.plugin.util.ToolkitImageWrapper@1ee3914)
sun.awt.image.ToolkitImage@1f14ceb is ready but it does not match any of the prepared images
sun.awt.image.ToolkitImage@f0eed6 is ready but it does not match any of the prepared images



REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
// ---------------------------------------------------------------------
import java.applet.*;
import java.awt.*;
import java.awt.image.*;

public class Java6Bug extends Applet implements ImageObserver
{
  Image image1, image2;
  String image1Name = "image1.jpg";
  String image2Name = "image2.jpg";

  public void init()
  {
    image1 = getImage(getCodeBase(), image1Name);
    image2 = getImage(getCodeBase(), image2Name);
    System.out.println("Preparing " + image1Name + " (" + image1 + ")");
    prepareImage(image1, this);
    System.out.println("Preparing " + image2Name + " (" + image2 + ")");
    prepareImage(image2, this);
  }

  public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height)
  {
    if ( (infoflags & ImageObserver.ALLBITS) != 0 )
    {
      if ( img == image1 )
        System.out.println(image1Name + " is ready");
      else if ( img == image2 )
         System.out.println(image2Name + " is ready");
      else
         System.out.println(img + " is ready but it does not match any of the prepared images");
      }
     return true;
   }
} 
---------- END SOURCE ----------

Release Regression From : 6u10
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Comments
EVALUATION This difference in behavior was deliberate and stems from the fix for 6582571. I don't think there is a way for us to revert to the old behavior and preserve the fix for 6582571, but reassigning to the RE for 6582571 for further evaluation. This might be closed as "Will not fix".
02-10-2008