# HG changeset patch # User ddehaven # Date 1486138555 28800 # Node ID 7b7f79ae8f296d1cec8fa40acd39215e8c5a3ae7 # Parent fd1cea12b2c602b2efc4d74592f9b6e79b4f82c6# Parent 362db50cabe6a2b02bfa7e9d4c9957c31531038c Merge diff -r fd1cea12b2c6 -r 7b7f79ae8f29 jdk/src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java --- a/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java Fri Feb 03 09:48:29 2017 -0800 +++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/OSXOffScreenSurfaceData.java Fri Feb 03 08:15:55 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -608,6 +608,13 @@ fImageInfoInt.put(kNeedToSyncFromJavaPixelsIndex, 1); // the pixels will change } + private void syncFromCustom() { + + } + + private void syncToCustom() { + + } // /** // * Invoked when the raster's contents will be taken (via the Raster.getDataBuffer() method) // */ diff -r fd1cea12b2c6 -r 7b7f79ae8f29 jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m Fri Feb 03 09:48:29 2017 -0800 +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/ImageSurfaceData.m Fri Feb 03 08:15:55 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,9 +34,6 @@ #import #import "BufImgSurfaceData.h" -#import "ThreadUtilities.h" - - //#define DEBUG 1 #if defined DEBUG @@ -195,10 +192,9 @@ PRINT(" customPixelsFromJava") SurfaceDataOps *sdo = (SurfaceDataOps*)isdo; - JNFCallVoidMethod([ThreadUtilities getJNIEnv], sdo->sdObject, jm_syncFromCustom); // AWT_THREADING Safe (known object) + JNFCallVoidMethod(env, sdo->sdObject, jm_syncFromCustom); // AWT_THREADING Safe (known object) } - IMAGE_SURFACE_INLINE void copyBits(jint w, jint h, jint javaPixelsBytesPerRow, Pixel8bit *pixelsSrc, jint dstPixelsBytesPerRow, Pixel8bit *pixelsDst) { PRINT(" copyBits") @@ -427,7 +423,7 @@ PRINT(" customPixelsToJava") SurfaceDataOps *sdo = (SurfaceDataOps*)isdo; - JNFCallVoidMethod([ThreadUtilities getJNIEnv], sdo->sdObject, jm_syncToCustom); // AWT_THREADING Safe (known object) + JNFCallVoidMethod(env, sdo->sdObject, jm_syncToCustom); // AWT_THREADING Safe (known object) } IMAGE_SURFACE_INLINE void removeAlphaPre_32bit(jint w, jint h, jint javaPixelsBytesPerRow, jint javaPixelBytes, Pixel32bit *pixelsSrc) @@ -995,9 +991,9 @@ { PRINT("imageDataProvider_UnholdJavaPixels") - ImageSDOps* isdo = (ImageSDOps*)info; - unholdJavaPixels([ThreadUtilities getJNIEnv], isdo); + // Currently do nothing } + static void imageDataProvider_FreeTempPixels(void *info, const void *data, size_t size) { PRINT("imageDataProvider_FreeTempPixels") diff -r fd1cea12b2c6 -r 7b7f79ae8f29 jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java Fri Feb 03 09:48:29 2017 -0800 +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java Fri Feb 03 08:15:55 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1559,6 +1559,59 @@ decodeRLE4(imSize, padding, values, bdata); } + private boolean copyRLE4ScanlineToDst(int lineNo, + byte[] val, + byte[] bdata) throws IOException { + // Return value + boolean isSuccess = false; + + // Reusing the code to copy 1 row of pixels or scanline to required + // destination buffer. + if (lineNo >= sourceRegion.y && + lineNo < sourceRegion.y + sourceRegion.height) { + if (noTransform) { + int pos = lineNo * (width + 1 >> 1); + for(int i = 0, j = 0; i < width >> 1; i++) + bdata[pos++] = + (byte)((val[j++] << 4) | val[j++]); + if ((width & 1) == 1) + bdata[pos] |= val[width - 1] << 4; + + processImageUpdate(bi, 0, lineNo, + destinationRegion.width, 1, 1, 1, + new int[]{0}); + isSuccess = true; + } else if ((lineNo - sourceRegion.y) % scaleY == 0) { + int lineStride = + ((MultiPixelPackedSampleModel)sampleModel).getScanlineStride(); + int currentLine = (lineNo - sourceRegion.y) / scaleY + + destinationRegion.y; + int pos = currentLine * lineStride; + pos += destinationRegion.x >> 1; + int shift = (1 - (destinationRegion.x & 1)) << 2; + for (int i = sourceRegion.x; + i < sourceRegion.x + sourceRegion.width; + i += scaleX) { + bdata[pos] |= val[i] << shift; + shift += 4; + if (shift == 4) { + pos++; + } + shift &= 7; + } + processImageUpdate(bi, 0, currentLine, + destinationRegion.width, 1, 1, 1, + new int[]{0}); + isSuccess = true; + } + // Ensure to reset the scanline buffer once the copy is complete. + for(int scIndex = 0; scIndex < width; scIndex++) { + val[scIndex] = 0; + } + } + return isSuccess; + } + private void decodeRLE4(int imSize, int padding, byte[] values, @@ -1568,57 +1621,22 @@ int value; boolean flag = false; int lineNo = isBottomUp ? height - 1 : 0; - int lineStride = - ((MultiPixelPackedSampleModel)sampleModel).getScanlineStride(); int finished = 0; - while (count != imSize) { + // Ensure the image has sufficient data before proceeding to decode + while ((count + 1) < imSize) { value = values[count++] & 0xFF; if (value == 0) { - // Absolute mode switch(values[count++] & 0xFF) { case 0: // End-of-scanline marker - // End-of-scanline marker - if (lineNo >= sourceRegion.y && - lineNo < sourceRegion.y + sourceRegion.height) { - if (noTransform) { - int pos = lineNo * (width + 1 >> 1); - for(int i = 0, j = 0; i < width >> 1; i++) - bdata[pos++] = - (byte)((val[j++] << 4) | val[j++]); - if ((width & 1) == 1) - bdata[pos] |= val[width - 1] << 4; - - processImageUpdate(bi, 0, lineNo, - destinationRegion.width, 1, 1, 1, - new int[]{0}); - finished++; - } else if ((lineNo - sourceRegion.y) % scaleY == 0) { - int currentLine = (lineNo - sourceRegion.y) / scaleY + - destinationRegion.y; - int pos = currentLine * lineStride; - pos += destinationRegion.x >> 1; - int shift = (1 - (destinationRegion.x & 1)) << 2; - for (int i = sourceRegion.x; - i < sourceRegion.x + sourceRegion.width; - i += scaleX) { - bdata[pos] |= val[i] << shift; - shift += 4; - if (shift == 4) { - pos++; - } - shift &= 7; - } - processImageUpdate(bi, 0, currentLine, - destinationRegion.width, 1, 1, 1, - new int[]{0}); - finished++; - } + // Copy the decoded scanline to destination + if (copyRLE4ScanlineToDst(lineNo, val, bdata)) { + finished++; } processImageProgress(100.0F * finished / destinationRegion.height); lineNo += isBottomUp ? -1 : 1; @@ -1633,21 +1651,61 @@ case 1: // End-of-RLE marker flag = true; + + // Check if the last decoded scanline was copied to + // destination bitmap + if (l != 0) { + // Copy the decoded scanline to destination + if (copyRLE4ScanlineToDst(lineNo, val, bdata)) { + finished++; + } + processImageProgress(100.0F * finished / destinationRegion.height); + lineNo += isBottomUp ? -1 : 1; + l = 0; + } break; case 2: // delta or vector marker - int xoff = values[count++] & 0xFF; - int yoff = values[count] & 0xFF; - // Move to the position xoff, yoff down - l += xoff + yoff*width; + if ((count + 1) < imSize) { + int xoff = values[count++] & 0xFF; + int yoff = values[count++] & 0xFF; + + // Check if the yOffset shifts the decoding to another + // row. In such cases, the decoded pixels in scanline + // buffer-val must be copied to the destination image. + if (yoff != 0) { + // Copy the decoded scanline to destination + if (copyRLE4ScanlineToDst(lineNo, val, bdata)) { + finished++; + } + processImageProgress(100.0F * finished + / destinationRegion.height); + lineNo += isBottomUp ? -yoff : yoff; + } + + // Move to the position (xoff, yoff). Since l-is used + // to index into the scanline buffer, the accumulated + // offset is limited to the width of the scanline + l += xoff + yoff*width; + l %= width; + } break; default: int end = values[count-1] & 0xFF; - for (int i=0; i> 4 - : (values[count++] & 0x0f)); + byte readByte = 0; + // Ensure to check if the source index-count, does not + // exceed the source image size + for (int i = 0; (i < end) && (count < imSize); i++) { + readByte = (byte)(((i & 1) == 0) ? + (values[count] & 0xf0) >> 4 : + (values[count++] & 0x0f)); + // Ensure to check if scanline index-l, does not + // exceed the scanline buffer size (width of image) + if (l < width) { + val[l++] = readByte; + } } // When end is odd, the above for loop does not @@ -1665,10 +1723,14 @@ } } else { // Encoded mode - int alternate[] = { (values[count] & 0xf0) >> 4, - values[count] & 0x0f }; - for (int i=0; (i < value) && (l < width); i++) { - val[l++] = (byte)alternate[i & 1]; + // Ensure to check if the source index-count, does not + // exceed the source image size + if (count < imSize) { + int alternate[] = { (values[count] & 0xf0) >> 4, + values[count] & 0x0f }; + for (int i=0; (i < value) && (l < width); i++) { + val[l++] = (byte)alternate[i & 1]; + } } count++; diff -r fd1cea12b2c6 -r 7b7f79ae8f29 jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java Fri Feb 03 09:48:29 2017 -0800 +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java Fri Feb 03 08:15:55 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -567,7 +567,7 @@ ("Type is TIFF_RATIONAL or TIFF_SRATIONAL and count < 1"); } else if (type == TIFFTag.TIFF_IFD_POINTER && count != 1) { throw new IllegalArgumentException - ("Type is TIFF_IFD_POINTER count != 1"); + ("Type is TIFF_IFD_POINTER and count != 1"); } else if(data == null) { throw new NullPointerException("data == null!"); } @@ -698,6 +698,11 @@ * data type for the supplied {@code TIFFTag}. * @throws IllegalArgumentException if {@code count < 0}. * @see #TIFFField(TIFFTag,int,int,Object) + * @throws IllegalArgumentException if {@code count < 1} + * and {@code type} is {@code TIFF_RATIONAL} or + * {@code TIFF_SRATIONAL}. + * @throws IllegalArgumentException if {@code count != 1} + * and {@code type} is {@code TIFF_IFD_POINTER}. */ public TIFFField(TIFFTag tag, int type, int count) { this(tag, type, count, createArrayForType(type, count)); @@ -885,11 +890,26 @@ * @throws IllegalArgumentException if {@code dataType} is not * one of the {@code TIFFTag.TIFF_*} data type constants. * @throws IllegalArgumentException if {@code count < 0}. + * @throws IllegalArgumentException if {@code count < 1} + * and {@code type} is {@code TIFF_RATIONAL} or + * {@code TIFF_SRATIONAL}. + * @throws IllegalArgumentException if {@code count != 1} + * and {@code type} is {@code TIFF_IFD_POINTER}. */ public static Object createArrayForType(int dataType, int count) { + if(count < 0) { throw new IllegalArgumentException("count < 0!"); + } else if ((dataType == TIFFTag.TIFF_RATIONAL + || dataType == TIFFTag.TIFF_SRATIONAL) + && count < 1) { + throw new IllegalArgumentException + ("Type is TIFF_RATIONAL or TIFF_SRATIONAL and count < 1"); + } else if (dataType == TIFFTag.TIFF_IFD_POINTER && count != 1) { + throw new IllegalArgumentException + ("Type is TIFF_IFD_POINTER and count != 1"); } + switch (dataType) { case TIFFTag.TIFF_BYTE: case TIFFTag.TIFF_SBYTE: diff -r fd1cea12b2c6 -r 7b7f79ae8f29 jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java Fri Feb 03 09:48:29 2017 -0800 +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java Fri Feb 03 08:15:55 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,13 +48,13 @@ * Keys to use for forward focus traversal when the JComponent is * managing focus. */ - private static Set managingFocusForwardTraversalKeys; + private Set managingFocusForwardTraversalKeys; /** * Keys to use for backward focus traversal when the JComponent is * managing focus. */ - private static Set managingFocusBackwardTraversalKeys; + private Set managingFocusBackwardTraversalKeys; /** * Style for the JSplitPane. diff -r fd1cea12b2c6 -r 7b7f79ae8f29 jdk/test/java/awt/print/PrinterJob/PrintCrashTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/awt/print/PrinterJob/PrintCrashTest.java Fri Feb 03 08:15:55 2017 -0800 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8163889 + * @summary Printing crashes on OSX. + * @run main PrintCrashTest + */ + +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.standard.Destination; + +import java.awt.GraphicsEnvironment; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.awt.print.Printable; +import java.awt.print.PrinterJob; + +import java.io.File; + +public class PrintCrashTest { + public static void main(String[] args) throws Exception { + PrinterJob printerJob = PrinterJob.getPrinterJob(); + printerJob.setPrintable((graphics, pageFormat, pageIndex) -> { + if (pageIndex != 0) { + return Printable.NO_SUCH_PAGE; + } else { + Shape shape = new Rectangle(110, 110, 10, 10); + Rectangle rect = shape.getBounds(); + + BufferedImage image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() + .getDefaultConfiguration().createCompatibleImage(rect.width, rect.height, Transparency.BITMASK); + graphics.drawImage(image, rect.x, rect.y, rect.width, rect.height, null); + + return Printable.PAGE_EXISTS; + } + }); + + File file = null; + try { + HashPrintRequestAttributeSet hashPrintRequestAttributeSet = new HashPrintRequestAttributeSet(); + file = File.createTempFile("out", "ps"); + file.deleteOnExit(); + Destination destination = new Destination(file.toURI()); + hashPrintRequestAttributeSet.add(destination); + printerJob.print(hashPrintRequestAttributeSet); + } finally { + if (file != null) { + file.delete(); + } + } + } +} + diff -r fd1cea12b2c6 -r 7b7f79ae8f29 jdk/test/javax/imageio/plugins/tiff/TIFFCreateArrayForTypeTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/imageio/plugins/tiff/TIFFCreateArrayForTypeTest.java Fri Feb 03 08:15:55 2017 -0800 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8152561 + * @summary Test verifies whether all boundary conditions are checked + * properly in TIFFField.createArrayForType(). + * @run main TIFFCreateArrayForTypeTest + */ + +import javax.imageio.plugins.tiff.TIFFField; +import javax.imageio.plugins.tiff.TIFFTag; + +public class TIFFCreateArrayForTypeTest { + + static int count = 0; + static boolean unknownDataType, negativeCount, zeroCount, countNotOne; + static String errorMsg = ""; + + private static void testCase1() { + // check passing unknown data type to createArrayForType() + count = 2; + int dataType = 15; + try { + TIFFField.createArrayForType(dataType, count); + } catch (IllegalArgumentException e) { + unknownDataType = true; + } catch (Exception e) { + // just consume if it throws any other exception. + } + if (!unknownDataType) { + errorMsg = errorMsg + "testCase1 "; + } + } + + private static void testCase2() { + // check passing negative count value for createArrayForType() + count = -1; + try { + TIFFField.createArrayForType(TIFFTag.TIFF_LONG, count); + } catch (IllegalArgumentException e) { + negativeCount = true; + } catch (Exception e) { + // just consume if it throws any other exception. + } + if (!negativeCount) { + errorMsg = errorMsg + "testCase2 "; + } + } + + private static void testCase3() { + /* + * check passing zero count value for createArrayForType() with + * TIFFTag.TIFF_RATIONAL or TIFFTag.TIFF_SRATIONAL data type. + */ + count = 0; + try { + TIFFField.createArrayForType(TIFFTag.TIFF_RATIONAL, count); + } catch (IllegalArgumentException e) { + zeroCount = true; + } catch (Exception e) { + // just consume if it throws any other exception. + } + if (!zeroCount) { + errorMsg = errorMsg + "testCase3 "; + } + } + + private static void testCase4() { + /* + * check passing count value other than 1 for createArrayForType() with + * TIFFTag.TIFF_IFD_POINTER data type. + */ + count = 2; + try { + TIFFField.createArrayForType(TIFFTag.TIFF_IFD_POINTER, count); + } catch (IllegalArgumentException e) { + countNotOne = true; + } catch (Exception e) { + // just consume if it throws any other exception. + } + if (!countNotOne) { + errorMsg = errorMsg + "testCase4 "; + } + } + + public static void main(String[] args) { + /* + * test different scenarios where TIFFField.createArrayForType() + * is required to throw IllegalArgumentException. + */ + testCase1(); + testCase2(); + testCase3(); + testCase4(); + if ((!unknownDataType) || + (!negativeCount) || + (!zeroCount) || + (!countNotOne)) + { + throw new RuntimeException(errorMsg + "is/are not throwing" + + " required IllegalArgumentException"); + } + } +} + diff -r fd1cea12b2c6 -r 7b7f79ae8f29 jdk/test/javax/swing/plaf/basic/BasicSplitPaneUI/Test6657026.java --- a/jdk/test/javax/swing/plaf/basic/BasicSplitPaneUI/Test6657026.java Fri Feb 03 09:48:29 2017 -0800 +++ b/jdk/test/javax/swing/plaf/basic/BasicSplitPaneUI/Test6657026.java Fri Feb 03 08:15:55 2017 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 6657026 + * @bug 6657026 7190595 * @summary Tests shared BasicSplitPaneUI in different application contexts * @author Sergey Malenkov * @modules java.desktop/sun.awt