Name: dk106046 Date: 08/18/2003
OPERATING SYSTEM(S):
--------------------
Turbo Linux 8
FULL JDK VERSION(S):
-------------------
This test fails with Sunjdk1.4.1 (build 1.4.1_01-b01),
------------
java -jar Font2DTest.jar
modify something (such as the font size), then
use "save as JPEG" from the menu.
There is a classcast exception:
java.lang.ClassCastException: sun.awt.image.DataBufferNative
at sun.awt.image.codec.JPEGImageEncoderImpl.encode(JPEGImageEncoderImpl.java:436)
at sun.awt.image.codec.JPEGImageEncoderImpl.encode(JPEGImageEncoderImpl.java:259)
at FontPanel$FontCanvas.writeJPEG(FontPanel.java:1060)
This appears to be because the field db is a DataBufferNative, which inherits from DataBuffer,
as do DataBufferInt and DataBufferByte, so a class cast between them would fail.
Whilst I dont fully understand the problem (I.E why a DataBufferNative is being supplied in this
case), I have altered the code such that it goes down the alternative path if it is given a
DataBufferNative, and that "seems to work" - Here are the modifications:
>>>> import sun.awt.image.DataBufferNative;
pack = false;
>>>> if (cmok && useGiven(ras) && !(db instanceof DataBufferNative) ) { /*ibm@63210*/
ComponentSampleModel csm =(ComponentSampleModel)sm;
start = (int)(db.getOffset()+
csm.getOffset(
ras.getMinX() - ras.getSampleModelTranslateX(),
ras.getMinY() - ras.getSampleModelTranslateY()
));
line = (int)csm.getScanlineStride();
data = ((DataBufferByte)db).getData();
>>>> } else if (cmok && canPack(ras) && !(db instanceof DataBufferNative) ) { /*ibm@63210*/
SinglePixelPackedSampleModel sppsm;
sppsm = (SinglePixelPackedSampleModel)sm;
start = (int)(db.getOffset()+
sppsm.getOffset(
ras.getMinX() - ras.getSampleModelTranslateX(),
ras.getMinY() - ras.getSampleModelTranslateY()
));
line = (int)sppsm.getScanlineStride();
data = ((DataBufferInt)db).getData();
pack = true;
} else {
[This bug is being submitted as a courtesy, in order to maintain uniformity between Sun & IBM JDKs. It has been fixed in IBM JDKs.
Please contact ###@###.### if you have questions.]
======================================================================
This is reproducible on WinXP with JPEGFlip program (which is part of Java2Demo) when executed with OpenGL flag. This is not reproducible with JPEGFlip on DDRAW, NODDRAW. I have attached the code to this bug report.
###@###.### 2004-07-27