[OpenJDK 2D-Dev] RFR: 7183828: Invalid Image Variant when using anything other than BufferedImage

Sergey Bylokhov serb at openjdk.java.net
Tue Sep 8 21:22:26 UTC 2020

It is intended that our draw machinery works only on specific image formats that we know we support.
But the user still able to create some image subclasses for their purpose and according to our spec of
Graphics2D.drawImage() we should not throw any exceptions.

I suggest handling this situation in a similar way as we handle some errors during rendering when
the pipeline is in the wrong state, or the ToolkitImage is not loaded yet, just ignore the request and
return false.

All our pipelines have a special meaning of InvalidPipeException, if the pipeline found that it cannot complete the draw
operation throws this exception which is handled by all methods in the SunGraphics2D class.

So as a fix I suggest changing the IllegalArgumentException to the InvalidPipeException.
Also, we need to add a try/catch block to the drawHiDPIImage(it uses the SurfaceManager.getManager method directly)

Old review request:


Commit messages:
 - 7183828: Invalid Image Variant when using anything other than BufferedImage

Changes: https://git.openjdk.java.net/jdk/pull/85/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=85&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-7183828
  Stats: 413 lines in 3 files changed: 268 ins; 100 del; 45 mod
  Patch: https://git.openjdk.java.net/jdk/pull/85.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/85/head:pull/85

PR: https://git.openjdk.java.net/jdk/pull/85

More information about the 2d-dev mailing list