JDK-6668439 : D3D: Illegal argument exception when setting window size to {0,0}
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u10
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2008-02-27
  • Updated: 2011-02-16
  • Resolved: 2008-04-12
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
6u10 b22Fixed
Description
happens on 1.6.0_10-ea-b11 and previous u10 builds
When you try to set window size to {0,0} an exeption appears. It works without problem on all JDK versions prior to u10

[java] SEVERE [global]
[java] java.lang.IllegalArgumentException: Width (0) and height (0) cannot
be <= 0
[java] at
java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)
[java] at
sun.awt.image.SunVolatileImage.getBackupImage(SunVolatileImage.java:225)
[java] at
sun.awt.image.VolatileSurfaceManager.getBackupSurface(VolatileSurfaceManager.java:252)
[java] at
sun.awt.image.VolatileSurfaceManager.initialize(VolatileSurfaceManager.java:108)
[java] at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:72)
[java] at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:82)
[java] at sun.awt.image.SunVolatileImage.<init>(SunVolatileImage.java:93)
[java] at
sun.java2d.d3d.D3DGraphicsConfig.createBackBuffer(D3DGraphicsConfig.java:148)
[java] at
sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:400)
[java] at
sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:367)
[java] at sun.awt.windows.WComponentPeer.setBounds(WComponentPeer.java:149)
[java] at sun.awt.windows.WWindowPeer.setBounds(WWindowPeer.java:514)
[java] at java.awt.Component.reshapeNativePeer(Component.java:2059)
[java] at java.awt.Component.reshape(Component.java:2007)
[java] at java.awt.Window.reshape(Window.java:776)
[java] at java.awt.Component.setBounds(Component.java:1973)
[java] at java.awt.Window.setBounds(Window.java:3114)


This code cause the exception

public static void main(String[] args) {
        // TODO code application logic here
        JFrame f = new JFrame();
        f.setUndecorated(true);
        f.setBounds(100, 100, 320, 240);
        f.setVisible(true);
        try { Thread.sleep(1000); } catch (Exception z) {}
        f.setBounds(0, 0, 0, 0);
        try { Thread.sleep(1000); } catch (Exception z) {}
        f.dispose();
    }

Comments
SUGGESTED FIX http://sa.sfbay.sun.com/projects/java2d_data/6u10/6668439.0
26-03-2008

EVALUATION The creation of 0x0 d3d surface fails, so we attempt to create a backup buffered image the size of 0x0, which fails with IAE. We should adjust the size of the back buffer to be at leat 1x1. The surface creation would still fail (there are minimum dimension restrictions on backbuffers), but a 1x1 backup surface will be successfully created. The software pipeline doesn't have this issue because the size of the backbuffers is adjusted in BltBufferStrategy. And this didn't happen in previous releases because apparently DirectDraw was happy to create a 0x0 surface.
25-03-2008

EVALUATION The exception occurs in WComponentPeer.replaceSurfaceData() method. According to the file history, this method is called from setBounds() since at least a couple of JDK releases ago, so the problem seems to be caused by some changes in Java2D.
11-03-2008

EVALUATION The problem is reproducible since at least JDK6u4-b01 and not reproducible with JDK6u1.
11-03-2008

EVALUATION This code cause the exception public static void main(String[] args) { // TODO code application logic here JFrame f = new JFrame(); f.setUndecorated(true); f.setBounds(100, 100, 320, 240); f.setVisible(true); try { Thread.sleep(1000); } catch (Exception z) {} f.setBounds(0, 0, 0, 0); try { Thread.sleep(1000); } catch (Exception z) {} f.dispose(); }
06-03-2008

EVALUATION I don't see any exceptions when running a simple test with JDK 6u10-b12: import java.awt.*; public class Test { public static void main(String[] args) { Frame f = new Frame(); f.setBounds(100, 100, 320, 240); f.setVisible(true); try { Thread.sleep(1000); } catch (Exception z) {} f.setBounds(0, 0, 0, 0); try { Thread.sleep(1000); } catch (Exception z) {} f.dispose(); } } Please, provide a test which can be used to reproduce the bug.
06-03-2008