JDK-8130737 : [macosx] AffineTransformOp can't handle child raster with non-zero x-offset
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8u40,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2015-07-05
  • Updated: 2020-06-09
  • Resolved: 2016-12-20
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 8 JDK 9 Other
8u261Fixed 9 b153Fixed openjdk8u262Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

A DESCRIPTION OF THE PROBLEM :
Create a child raster by createWritableChild with an x-offset and contains the bottom-right pixel. Then AffineTransformOp filter produce an ImagingOpException.

If x-offset is 0 or the child raster doesn't contains the bottom-right pixel, the filter works well.



ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.awt.image.ImagingOpException: Unable to transform src image
	at java.awt.image.AffineTransformOp.filter(AffineTransformOp.java:358)
	at TestAffineOp3.main(TestAffineOp3.java:42)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.geom.AffineTransform;
import java.awt.image.*;

public class TestAffineOp3 {
    public static void main(String args[])
    {
        WritableRaster srcRaster, dstRaster;
        DataBuffer db;
        AffineTransform at = new AffineTransform();
        at.setToScale(4.0, 4.0);
        AffineTransformOp ato =
                new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);

        // UShort pixels
        short[] shortPixels =
                { 1001, 1002, 1003, 1004,
                        2001, 2002, 2003, 2004,
                        3001, 3002, 3003, 3004,
                        4001, 4002, 4003, 4004 };

        System.out.println(shortPixels.length);
        for (int j = 0, k = 0; j < 4; j++)
        {
            for (int i = 0; i < 4; i++, k++)
                System.out.print(shortPixels[k] + "\t");
            System.out.println();
        }

        // source raster
        db = new DataBufferUShort(shortPixels, shortPixels.length);
        int[] offsets = {0};
        srcRaster = Raster.createInterleavedRaster(db, 4, 4, 4, 1,
                offsets, null);

        // writable child raster
        srcRaster = srcRaster.createWritableChild(1, 1, 3, 3, 0, 0, null);

        // destination raster
        dstRaster = ato.filter(srcRaster, null);

        db = dstRaster.getDataBuffer();
        shortPixels = ((DataBufferUShort)db).getData();
        System.out.println(shortPixels.length);
        for (int j = 0, k = 0; j < 12; j++)
        {
            for (int i = 0; i < 12; i++, k++)
                System.out.print(shortPixels[k] + "\t");
            System.out.println();
        }
    }

}

---------- END SOURCE ----------


Comments
Fix request I would like to backport this fix to 8u, because the problem is not confined to macOS, and for Oracle JDK parity. I have confirmed that the patch applies as-is, modulo the usual path name changes. The test included in the patch will not run until JDK-8172559 has also been backported. Once JDK-8172559 has been applied (it should apply cleanly; it's just a line swap in the test), the test will pass. With JDK-8172559 but without the fixes in this test, 8u will fail the test included in this patch.
31-03-2020

To run the test with jtreg, @test should be the first annotation in the file; it's updated by JDK-8172559.
24-02-2020

1. Run the attached test case (TestAffineOp3.java) in MAC OS X. 2. Checked this for JDK 8u45, 8u60 ea b21, and 9 ea b71. 8u45: FAIL 8u60 ea b21: FAIL 9 ea b71: FAIL 3. Output with JDK 8u45: $ java TestAffineOp3 16 1001 1002 1003 1004 2001 2002 2003 2004 3001 3002 3003 3004 4001 4002 4003 4004 Exception in thread "main" java.awt.image.ImagingOpException: Unable to transform src image at java.awt.image.AffineTransformOp.filter(AffineTransformOp.java:360) at TestAffineOp3.main(TestAffineOp3.java:39) 4. Result: This issue is reproducible with JDK 8-all and 9 ea. Moving this up for further evaluation.
08-07-2015