Hi Joe, Might it not be better to modify testWriteRGB() to do something like this (code neither compiled nor tested):
ImageTypeSpecifier spec = new ImageTypeSpecifier(bi); Iterator<ImageWriter> writers = ImageIO.getImageWriters(spec, format).next(); File file = new File("BitDepth_" + biTypeNames[type] + "." + format); if (!writers.hasNext()) { System.out.println(“No writers available for type “ + biTypeNames[type] + " BufferedImage!"); } else { ImageWriter writer = writers.next(); try (ImageOutputStream out = ImageIO.createImageOutputStream(file)) { writer.setOutput(out); writer.write(bi); } catch (Exception e) { System.out.println("Can't write a type “ + biTypeNames[type] + " BufferedImage!"); } } return file; Thanks, Brian On Feb 15, 2016, at 9:35 AM, joe darcy <joe.da...@oracle.com> wrote: > Any comments on this? > > Thanks, > > -Joe > > On 2/11/2016 6:00 PM, joe darcy wrote: >> Hello, >> >> Please review a candidate fix for >> >> JDK-8148914: BitDepth.java test fails >> >> In brief, OpenJDK supports two fewer buffered image formats for jpg than the >> closed JDK does. I've modified the BitDepth test to allow for this >> difference. Patch below; webrev at >> >> http://cr.openjdk.java.net/~darcy/8148914.0/ >> >> Thanks, >> >> -Joe >> >> --- a/test/javax/imageio/plugins/shared/BitDepth.java Thu Feb 11 16:24:55 >> 2016 -0800 >> +++ b/test/javax/imageio/plugins/shared/BitDepth.java Thu Feb 11 17:26:23 >> 2016 -0800 >> @@ -130,11 +130,7 @@ >> >> boolean allOK = true; >> >> - for (int i = 0; i < biRGBTypes.length; i++) { >> - >> - int type = biRGBTypes[i]; >> - >> - >> + for (int type : biRGBTypes) { >> // TODO: remove the following 'if' block after the 8147448 fix >> if ( format.toLowerCase().equals("bmp") && ( >> (type == BufferedImage.TYPE_INT_ARGB ) || >> @@ -151,12 +147,23 @@ >> >> System.out.println("Testing " + format + >> " writer for type " + biTypeNames[type]); >> - File f = testWriteRGB(format, type); >> - boolean ok = testReadRGB(f); >> - if (ok) { >> - f.delete(); >> + boolean ok = false; >> + File f = null; >> + try { >> + f = testWriteRGB(format, type); >> + ok = testReadRGB(f); >> + } catch (javax.imageio.IIOException e) { >> + // The follow two formats are not supported on OpenJDK >> + if (format.toLowerCase().equals("jpg") && >> + (type == BufferedImage.TYPE_4BYTE_ABGR || >> + type == BufferedImage.TYPE_4BYTE_ABGR_PRE)) >> + continue; >> + } finally { >> + if (ok) { >> + f.delete(); >> + } >> + allOK = allOK && (ok || f == null); >> } >> - allOK = allOK && ok; >> } >> >> >