Merge
authorprr
Wed, 17 Jan 2018 09:08:44 -0800
changeset 48646 36a1966132aa
parent 48645 6cfee3ad7a76 (diff)
parent 48543 7067fe4e054e (current diff)
child 48647 e4b03365ddbf
Merge
src/java.compiler/share/classes/javax/lang/model/overview.html
src/java.compiler/share/classes/javax/tools/FileManagerUtils.java
src/java.compiler/share/classes/javax/tools/overview.html
src/jdk.jdeps/share/classes/com/sun/tools/javap/overview.html
src/jdk.unsupported/share/classes/sun/reflect/Reflection.java
test/jdk/jdk/internal/reflect/Reflection/GetCallerClassWithDepth.java
test/jdk/sun/reflect/Reflection/GetCallerClassWithDepth.java
test/langtools/tools/javac/T8192885/AddGotoAfterForLoopToLNTTest.java
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Tue Jan 16 08:48:34 2018 +0100
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m	Wed Jan 17 09:08:44 2018 -0800
@@ -954,11 +954,6 @@
     return lastKeyWindow;
 }
 
-- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame {
-    return !NSEqualSizes(self.nsWindow.frame.size, newFrame.size);
-}
-
-
 @end // AWTWindow
 
 
--- a/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java	Tue Jan 16 08:48:34 2018 +0100
+++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java	Wed Jan 17 09:08:44 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, 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
@@ -374,7 +374,10 @@
             // And set current image since we've read it now
             currentImage = 0;
         }
-        if (seekForwardOnly) {
+        // If the image positions list is empty as in the case of a tables-only
+        // stream, then attempting to access the element at index
+        // imagePositions.size() - 1 will cause an IndexOutOfBoundsException.
+        if (seekForwardOnly && !imagePositions.isEmpty()) {
             Long pos = imagePositions.get(imagePositions.size()-1);
             iis.flushBefore(pos.longValue());
         }
@@ -492,6 +495,11 @@
         if (!tablesOnlyChecked) {
             checkTablesOnly();
         }
+        // If the image positions list is empty as in the case of a tables-only
+        // stream, then no image data can be read.
+        if (imagePositions.isEmpty()) {
+            throw new IIOException("No image data present to read");
+        }
         if (imageIndex < imagePositions.size()) {
             iis.seek(imagePositions.get(imageIndex).longValue());
         } else {
--- a/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java	Tue Jan 16 08:48:34 2018 +0100
+++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java	Wed Jan 17 09:08:44 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2018, 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
@@ -739,6 +739,17 @@
                     // If chunk type is 'IDAT', we've reached the image data.
                     if (imageStartPosition == -1L) {
                         /*
+                         * The PNG specification mandates that if colorType is
+                         * PNG_COLOR_PALETTE then the PLTE chunk should appear
+                         * before the first IDAT chunk.
+                         */
+                        if (colorType == PNG_COLOR_PALETTE &&
+                            !(metadata.PLTE_present))
+                        {
+                            throw new IIOException("Required PLTE chunk"
+                                    + " missing");
+                        }
+                        /*
                          * PNGs may contain multiple IDAT chunks containing
                          * a portion of image data. We store the position of
                          * the first IDAT chunk and continue with iteration
@@ -986,7 +997,9 @@
         }
 
         int inputBands = inputBandsForColorType[metadata.IHDR_colorType];
-        int bytesPerRow = (inputBands*passWidth*metadata.IHDR_bitDepth + 7)/8;
+        int bitsPerRow = Math.
+                multiplyExact((inputBands * metadata.IHDR_bitDepth), passWidth);
+        int bytesPerRow = (bitsPerRow + 7) / 8;
 
         // Read the image row-by-row
         for (int srcY = 0; srcY < passHeight; srcY++) {
@@ -1037,7 +1050,8 @@
         int bytesPerPixel = (bitDepth == 16) ? 2 : 1;
         bytesPerPixel *= inputBands;
 
-        int bytesPerRow = (inputBands*passWidth*bitDepth + 7)/8;
+        int bitsPerRow = Math.multiplyExact((inputBands * bitDepth), passWidth);
+        int bytesPerRow = (bitsPerRow + 7) / 8;
         int eltsPerRow = (bitDepth == 16) ? bytesPerRow/2 : bytesPerRow;
 
         // If no pixels need updating, just skip the input data
--- a/src/java.desktop/share/classes/java/awt/image/BandedSampleModel.java	Tue Jan 16 08:48:34 2018 +0100
+++ b/src/java.desktop/share/classes/java/awt/image/BandedSampleModel.java	Wed Jan 17 09:08:44 2018 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, 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
@@ -185,7 +185,33 @@
     public DataBuffer createDataBuffer() {
         DataBuffer dataBuffer = null;
 
+        // The minimum size required to store samples of one band
         int size = scanlineStride * height;
+
+        if (numBanks == 1) {
+            /*
+             * The sample model contains a single bank of data buffer. Hence
+             * we need to compute the size required to store samples of all
+             * bands including the respective offsets.
+             */
+            int sizePerBand = size;
+            size += bandOffsets[0];
+            for (int index = 1; index < bandOffsets.length; index++) {
+                size += (bandOffsets[index] - size) + sizePerBand;
+            }
+        } else {
+            /*
+             * The sample model contains multiple banks of data buffer where
+             * each bank would correspond to a particular band. Hence we need
+             * to compute only the additional space required for band offsets.
+             */
+            int maxBandOffset = bandOffsets[0];
+            for (int index = 1; index < bandOffsets.length; index++) {
+                maxBandOffset = Math.max(maxBandOffset, bandOffsets[index]);
+            }
+            size += maxBandOffset;
+        }
+
         switch (dataType) {
         case DataBuffer.TYPE_BYTE:
             dataBuffer = new DataBufferByte(size, numBanks);
--- a/src/java.desktop/share/classes/javax/swing/tree/VariableHeightLayoutCache.java	Tue Jan 16 08:48:34 2018 +0100
+++ b/src/java.desktop/share/classes/javax/swing/tree/VariableHeightLayoutCache.java	Wed Jan 17 09:08:44 2018 -0800
@@ -409,11 +409,10 @@
      */
     public void treeNodesChanged(TreeModelEvent e) {
         if(e != null) {
-            int               changedIndexs[];
-            TreeStateNode     changedNode;
+            int               changedIndexs[]  = e.getChildIndices();
+            TreeStateNode     changedNode = getNodeForPath(
+                    SwingUtilities2.getTreePath(e, getModel()), false, false);
 
-            changedIndexs = e.getChildIndices();
-            changedNode = getNodeForPath(SwingUtilities2.getTreePath(e, getModel()), false, false);
             if(changedNode != null) {
                 Object            changedValue = changedNode.getValue();
 
@@ -421,17 +420,12 @@
                    child indexs that are passed in. */
                 changedNode.updatePreferredSize();
                 if(changedNode.hasBeenExpanded() && changedIndexs != null) {
-                    int                counter;
-                    TreeStateNode      changedChildNode;
-
-                    for(counter = 0; counter < changedIndexs.length;
-                        counter++) {
-                        changedChildNode = (TreeStateNode)changedNode
-                                    .getChildAt(changedIndexs[counter]);
+                    for(int index : changedIndexs) {
+                        TreeStateNode changedChildNode = (TreeStateNode)changedNode
+                                    .getChildAt(index);
                         /* Reset the user object. */
                         changedChildNode.setUserObject
-                                    (treeModel.getChild(changedValue,
-                                                     changedIndexs[counter]));
+                                    (treeModel.getChild(changedValue, index));
                         changedChildNode.updatePreferredSize();
                     }
                 }
@@ -462,34 +456,26 @@
      */
     public void treeNodesInserted(TreeModelEvent e) {
         if(e != null) {
-            int               changedIndexs[];
-            TreeStateNode     changedParentNode;
-
-            changedIndexs = e.getChildIndices();
-            changedParentNode = getNodeForPath(SwingUtilities2.getTreePath(e, getModel()), false, false);
+            int               changedIndexs[] = e.getChildIndices();
+            TreeStateNode     changedParentNode = getNodeForPath(
+                    SwingUtilities2.getTreePath(e, getModel()), false, false);
             /* Only need to update the children if the node has been
                expanded once. */
             // PENDING(scott): make sure childIndexs is sorted!
             if(changedParentNode != null && changedIndexs != null &&
                changedIndexs.length > 0) {
                 if(changedParentNode.hasBeenExpanded()) {
-                    boolean            makeVisible;
-                    int                counter;
-                    Object             changedParent;
-                    TreeStateNode      newNode;
-                    int                oldChildCount = changedParentNode.
-                                          getChildCount();
+                    boolean   makeVisible =((changedParentNode == root &&
+                                            !rootVisible) ||
+                                            (changedParentNode.getRow() != -1 &&
+                                               changedParentNode.isExpanded()));
+                    int  oldChildCount = changedParentNode.getChildCount();
 
-                    changedParent = changedParentNode.getValue();
-                    makeVisible = ((changedParentNode == root &&
-                                    !rootVisible) ||
-                                   (changedParentNode.getRow() != -1 &&
-                                    changedParentNode.isExpanded()));
-                    for(counter = 0;counter < changedIndexs.length;counter++)
+                    for(int index : changedIndexs)
                     {
-                        newNode = this.createNodeAt(changedParentNode,
-                                                    changedIndexs[counter]);
+                        this.createNodeAt(changedParentNode, index);
                     }
+
                     if(oldChildCount == 0) {
                         // Update the size of the parent.
                         changedParentNode.updatePreferredSize();
@@ -643,7 +629,7 @@
                 rebuild(true);
             }
             else if(changedNode != null) {
-                int                              nodeIndex, oldRow;
+                int                              nodeIndex;
                 TreeStateNode                    newNode, parent;
                 boolean                          wasExpanded, wasVisible;
                 int                              newIndex;
@@ -925,24 +911,22 @@
       * row index, the last row index is returned.
       */
     private int getRowContainingYLocation(int location) {
+        final int rows = getRowCount();
+
+        if(rows <= 0)
+            return -1;
         if(isFixedRowHeight()) {
-            if(getRowCount() == 0)
-                return -1;
-            return Math.max(0, Math.min(getRowCount() - 1,
+            return Math.max(0, Math.min(rows - 1,
                                         location / getRowHeight()));
         }
 
-        int                    max, maxY, mid, min, minY;
-        TreeStateNode          node;
+        int max = rows, min = 0, mid = 0;
 
-        if((max = getRowCount()) <= 0)
-            return -1;
-        mid = min = 0;
         while(min < max) {
             mid = (max - min) / 2 + min;
-            node = (TreeStateNode)visibleNodes.elementAt(mid);
-            minY = node.getYOrigin();
-            maxY = minY + node.getPreferredHeight();
+            TreeStateNode node = (TreeStateNode)visibleNodes.elementAt(mid);
+            int minY = node.getYOrigin();
+            int maxY = minY + node.getPreferredHeight();
             if(location < minY) {
                 max = mid - 1;
             }
@@ -954,8 +938,8 @@
         }
         if(min == max) {
             mid = min;
-            if(mid >= getRowCount())
-                mid = getRowCount() - 1;
+            if(mid >= rows)
+                mid = rows - 1;
         }
         return mid;
     }
@@ -1008,9 +992,9 @@
             if(nodeWidth > maxWidth)
                 maxWidth = nodeWidth;
         }
+
         return maxWidth;
     }
-
     /**
       * Responsible for creating a TreeStateNode that will be used
       * to track display information about value.
@@ -1362,17 +1346,11 @@
                                                        isExpanded(),
                                                        boundsBuffer);
 
-            if(bounds == null) {
+            if(bounds == null || bounds.height == 0) {
                 xOrigin = 0;
                 preferredWidth = preferredHeight = 0;
                 updateNodeSizes = true;
-            }
-            else if(bounds.height == 0) {
-                xOrigin = 0;
-                preferredWidth = preferredHeight = 0;
-                updateNodeSizes = true;
-            }
-            else {
+            } else {
                 xOrigin = bounds.x;
                 preferredWidth = bounds.width;
                 if(isFixedRowHeight())
@@ -1477,24 +1455,14 @@
                     Object         realNode = getValue();
                     TreeModel      treeModel = getModel();
                     int            count = treeModel.getChildCount(realNode);
-
+                    int offset = originalRow == -1 ? -1 : originalRow + 1;
                     hasBeenExpanded = true;
-                    if(originalRow == -1) {
-                        for (int i = 0; i < count; i++) {
-                            newNode = createNodeForValue(treeModel.getChild
-                                                            (realNode, i));
-                            this.add(newNode);
-                            newNode.updatePreferredSize(-1);
-                        }
-                    }
-                    else {
-                        int offset = originalRow + 1;
-                        for (int i = 0; i < count; i++) {
-                            newNode = createNodeForValue(treeModel.getChild
-                                                       (realNode, i));
-                            this.add(newNode);
-                            newNode.updatePreferredSize(offset);
-                        }
+
+                    for (int i = 0; i < count; i++) {
+                        newNode = createNodeForValue(treeModel.getChild
+                                                        (realNode, i));
+                        this.add(newNode);
+                        newNode.updatePreferredSize(offset);
                     }
                 }
 
@@ -1502,14 +1470,9 @@
                 Enumeration<TreeNode> cursor = preorderEnumeration();
                 cursor.nextElement(); // don't add me, I'm already in
 
-                int newYOrigin;
+                int newYOrigin = isFixed || (this == root && !isRootVisible()) ?
+                                    0 : getYOrigin() + this.getPreferredHeight();
 
-                if(isFixed)
-                    newYOrigin = 0;
-                else if(this == root && !isRootVisible())
-                    newYOrigin = 0;
-                else
-                    newYOrigin = getYOrigin() + this.getPreferredHeight();
                 TreeStateNode   aNode;
                 if(!isFixed) {
                     while (cursor.hasMoreElements()) {
@@ -1744,14 +1707,10 @@
         protected boolean updateNextIndex() {
             // nextIndex == -1 identifies receiver, make sure is expanded
             // before descend.
-            if(nextIndex == -1 && !parent.isExpanded())
-                return false;
-
-            // Check that it can have kids
-            if(childCount == 0)
-                return false;
-            // Make sure next index not beyond child count.
-            else if(++nextIndex >= childCount)
+            if((nextIndex == -1 && !parent.isExpanded()) ||
+                childCount == 0 || // Check that it can have kids
+                ++nextIndex >= childCount) // Make sure next index not beyond
+                                             // child count.
                 return false;
 
             TreeStateNode       child = (TreeStateNode)parent.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/Window/WindowResizing/DoubleClickTitleBarTest.java	Wed Jan 17 09:08:44 2018 -0800
@@ -0,0 +1,138 @@
+/*
+ * 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
+ * @key headful
+ * @bug 8190192
+ * @requires os.family=="mac"
+ * @summary Double click on the title bar no longer repositions the window
+ * @run main DoubleClickTitleBarTest
+ */
+
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+import java.awt.Robot;
+import java.awt.Point;
+import java.awt.event.InputEvent;
+import java.awt.AWTException;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowStateListener;
+
+public class DoubleClickTitleBarTest {
+    private static Point position = null;
+    private static JFrame frame = null;
+    private static boolean windowMinimizedState = false, windowMaximizedState = false;
+    //offset from top left to some place on title bar
+    final private static int X_OFFSET = 100, Y_OFFSET = 7;
+
+    public static void main(String[] args) throws Exception {
+        try {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                @Override
+                public void run() {
+                    doTest();
+                }
+            });
+
+            Robot robot = new Robot();
+            robot.delay(500);
+
+            SwingUtilities.invokeAndWait(new Runnable() {
+                @Override
+                public void run() {
+                    position = frame.getLocationOnScreen();
+                }
+            });
+
+            //offset from the top left
+            robot.mouseMove(position.x + X_OFFSET,
+                                position.y + Y_OFFSET);
+
+            //do resize
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            robot.mouseMove(frame.getLocationOnScreen().x + 200,
+                                frame.getLocationOnScreen().y + 200);
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+            robot.delay(500);
+
+            SwingUtilities.invokeAndWait(new Runnable() {
+                @Override
+                public void run() {
+                    position = frame.getLocationOnScreen();
+                }
+            });
+
+            //after resize, do offset from top left
+            robot.mouseMove(position.x + X_OFFSET,
+                                position.y + Y_OFFSET);
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+
+            //wait till maximizing the window
+            robot.delay(1000);
+
+            if(!(windowMinimizedState && windowMaximizedState)) {
+                throw new RuntimeException("Test failed:");
+            }
+        } finally {
+            if(frame != null) {
+                frame.dispose();
+            }
+        }
+    }
+
+    private static void doTest() {
+        frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.pack();
+
+        WindowStateListener listener = new WindowAdapter() {
+            public void windowStateChanged(WindowEvent evt) {
+                int oldState = evt.getOldState();
+                int newState = evt.getNewState();
+
+                if((oldState & JFrame.MAXIMIZED_BOTH) != 0 &&
+                    (newState & JFrame.MAXIMIZED_BOTH) == 0) {
+                    windowMinimizedState = true;
+                }
+                else if(windowMinimizedState &&
+                         (oldState & JFrame.MAXIMIZED_BOTH) == 0 &&
+                         (newState & JFrame.MAXIMIZED_BOTH) != 0) {
+                    windowMaximizedState = true;
+                }
+            }
+        };
+
+        frame.addWindowStateListener(listener);
+        frame.setSize(200, 200);
+        frame.setLocation(100, 100);
+        frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
+        frame.setResizable(true);
+        frame.setVisible(true);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/image/BandedSampleModel/BandedSampleModelSizeTest.java	Wed Jan 17 09:08:44 2018 -0800
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2018, 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 8194489
+ * @summary The test checks whether BandedSampleModel computes appropriate
+ *          size for allocating memory in DataBuffer.
+ * @run main BandedSampleModelSizeTest
+ */
+import java.awt.image.BandedSampleModel;
+import java.awt.image.DataBuffer;
+import java.util.Arrays;
+
+public class BandedSampleModelSizeTest {
+    // Constants
+    private static final int TEST_NUM_BANDS = 3;
+    private static final int TEST_SRC_IMG_DIM = 10;
+
+    // Required sample models
+    private static BandedSampleModel singleBankModel = null;
+    private static BandedSampleModel multiBankModel = null;
+
+    private static void initTest() {
+        int[] bandOffsets = new int[TEST_NUM_BANDS];
+        int[] bankIndices = new int[TEST_NUM_BANDS];
+
+        /*
+         * Create a BandedSampleModel to store samples of all bands in one
+         * bank of DataBuffer.
+         */
+        bandOffsets[0] = 0;
+        bandOffsets[1] = 120;
+        bandOffsets[2] = 240;
+        bankIndices[0] = 0;
+        bankIndices[1] = 0;
+        bankIndices[2] = 0;
+
+        singleBankModel = new BandedSampleModel(DataBuffer.TYPE_BYTE,
+                TEST_SRC_IMG_DIM, TEST_SRC_IMG_DIM, TEST_SRC_IMG_DIM,
+                bankIndices, bandOffsets);
+
+        /*
+         * Create a BandedSampleModel to store samples of all bands in
+         * different banks of DataBuffer.
+         */
+        bandOffsets[0] = 0;
+        bandOffsets[1] = 20;
+        bandOffsets[2] = 40;
+        bankIndices[0] = 0;
+        bankIndices[1] = 1;
+        bankIndices[2] = 2;
+
+        multiBankModel = new BandedSampleModel(DataBuffer.TYPE_BYTE,
+                TEST_SRC_IMG_DIM, TEST_SRC_IMG_DIM, TEST_SRC_IMG_DIM,
+                bankIndices, bandOffsets);
+    }
+
+    private static void testSingleBankModel() {
+        int[] srcSamples = new int[TEST_NUM_BANDS];
+        int[] resSamples = new int[TEST_NUM_BANDS];
+
+        // Create image buffer for the requried sample model
+        DataBuffer imgBuffer = singleBankModel.createDataBuffer();
+
+        // Test the sample model by setting a pixel value & inspecting the same.
+        Arrays.fill(srcSamples, 125);
+        singleBankModel.setPixel(0, 0, srcSamples, imgBuffer);
+        singleBankModel.getPixel(0, 0, resSamples, imgBuffer);
+        if (!Arrays.equals(srcSamples, resSamples)) {
+            throw new RuntimeException("Test Failed. Incorrect samples found"
+                    + " in the image");
+        }
+
+        Arrays.fill(srcSamples, 250);
+        singleBankModel.setPixel(9, 9, srcSamples, imgBuffer);
+        singleBankModel.getPixel(9, 9, resSamples, imgBuffer);
+        if (!Arrays.equals(srcSamples, resSamples)) {
+            throw new RuntimeException("Test Failed. Incorrect samples found"
+                    + " in the image");
+        }
+    }
+
+    private static void testMultiBankModel() {
+        int[] srcSamples = new int[TEST_NUM_BANDS];
+        int[] resSamples = new int[TEST_NUM_BANDS];
+
+        // Create image buffer for the required sample model
+        DataBuffer imgBuffer = multiBankModel.createDataBuffer();
+
+        // Test the sample model by setting a pixel value & inspecting the same.
+        Arrays.fill(srcSamples, 125);
+        multiBankModel.setPixel(0, 0, srcSamples, imgBuffer);
+        multiBankModel.getPixel(0, 0, resSamples, imgBuffer);
+        if (!Arrays.equals(srcSamples, resSamples)) {
+            throw new RuntimeException("Test Failed. Incorrect samples found"
+                    + " in the image");
+        }
+
+        Arrays.fill(srcSamples, 250);
+        multiBankModel.setPixel(9, 9, srcSamples, imgBuffer);
+        multiBankModel.getPixel(9, 9, resSamples, imgBuffer);
+        if (!Arrays.equals(srcSamples, resSamples)) {
+            throw new RuntimeException("Test Failed. Incorrect samples found"
+                    + " in the image");
+        }
+    }
+
+    public static void main(String args[]) {
+        // Initialize the test
+        initTest();
+
+        // Test banded sample model with single bank of data buffer
+        testSingleBankModel();
+
+        // Test banded sample model with multiple banks of data buffer
+        testMultiBankModel();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/imageio/plugins/jpeg/JpegTablesOnlyReadTest.java	Wed Jan 17 09:08:44 2018 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2018, 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     8191073
+ * @summary Test verifies that when user tries to read image data from a
+ *          tables-only image input stream it should through IIOException
+ *          instead of throwing any other exception as per specification.
+ * @run     main JpegTablesOnlyReadTest
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Base64;
+import javax.imageio.IIOException;
+import javax.imageio.ImageIO;
+
+public class JpegTablesOnlyReadTest {
+    // JPEG input stream containing tables-only image
+    private static String inputImageBase64 = "/9j/4IAQSkZJRgABAQEASABIAAD"
+            + "/2wBDAFA3PEY8MlBGQUZaVVBfeMiCeG5uePWvuZHI//////////////////////"
+            + "//////////////////////////////2wBDAVVaWnhpeOuCguv//////////////"
+            + "///////////////////////////////////////////////////////////wAAR"
+            + "CAAgACADASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAECA//EACUQAQA"
+            + "CAAUDBAMAAAAAAAAAAAEAAhESITGxQXKSA2Fi0SIyUf/EABYBAQEBAAAAAAAAAA"
+            + "AAAAAAAAABA//EABcRAQEBAQAAAAAAAAAAAAAAAAEAESH/2gAMAwEAAhEDEQA/A"
+            + "Nf2VW2OKaWTqnRhl97eb9wrs91uWPEBUX+EtmrssvvbzfuJWjVG2tg1svLLtgJ0"
+            + "Uxwmd96d5zE7tVdnutyxm5JVoo0u6rpXHdWLP8PU8WIjtRuvVZN96d5zDP8AD1P"
+            + "Fhre1Apc/Ida4RAdv/9k=";
+
+    public static void main(String[] args) throws IOException {
+        byte[] inputBytes = Base64.getDecoder().decode(inputImageBase64);
+        InputStream in = new ByteArrayInputStream(inputBytes);
+
+        // Read tables-only JPEG image
+        try {
+            ImageIO.read(in);
+        } catch (IIOException e) {
+            // do nothing we expect it to throw IIOException if it throws
+            // any other exception test will fail.
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/imageio/plugins/png/PngPLTEChunkMissingTest.java	Wed Jan 17 09:08:44 2018 -0800
@@ -0,0 +1,71 @@
+/*
+ * 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     8190997
+ * @summary Test verifies that ImageIO.read() throws proper IIOException
+ *          when we have a PNG image with color type PNG_COLOR_PALETTE but
+ *          missing the required PLTE chunk.
+ * @run     main PngPLTEChunkMissingTest
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Base64;
+import javax.imageio.IIOException;
+import javax.imageio.ImageIO;
+
+public class PngPLTEChunkMissingTest {
+
+    // PNG image stream missing the required PLTE chunk
+    private static String inputImageBase64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB"
+            + "CAMAAAA6fptVAAAACklEQVQYV2P4DwABAQEAWk1v8QAAAABJRU5ErkJgggo=";
+
+    public static void main(String[] args) throws Exception {
+
+        byte[] inputBytes = Base64.getDecoder().decode(inputImageBase64);
+        InputStream in = new ByteArrayInputStream(inputBytes);
+
+        /*
+         * Attempt to read a PNG image of color type PNG_COLOR_PALETTE
+         * but missing the required PLTE chunk.
+         */
+        try {
+            ImageIO.read(in);
+        } catch (IIOException e) {
+            /*
+             * We expect ImageIO to throw IIOException with proper message
+             * instead of throwing NullPointerException.
+             */
+            Throwable cause = e.getCause();
+            if (cause == null ||
+                (!(cause.getMessage().
+                 equals("Required PLTE chunk missing"))))
+            {
+                throw e;
+            }
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/javax/imageio/plugins/png/PngReaderLargeWidthStrideTest.java	Wed Jan 17 09:08:44 2018 -0800
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2018, 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     8191174
+ * @summary Test verifies that PNGImageReader doesn't throw any undocumented
+ *          Exception because of faulty calculation of scanline stride in
+ *          PNGImageReader.
+ * @run     main PngReaderLargeWidthStrideTest
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Base64;
+import javax.imageio.IIOException;
+import javax.imageio.ImageIO;
+
+public class PngReaderLargeWidthStrideTest {
+
+    private static String inputImageBase64 = "iVBORw0KGgoAAAANSUhEUk////8AAAA"
+            + "BCAAAAAA6fptVAAAACklEQVQYV2P4DwABAQEAWk1v8QAAAABJRU5ErkJgggo=";
+
+    public static void main(String[] args) throws Exception {
+
+        byte[] inputBytes = Base64.getDecoder().decode(inputImageBase64);
+        InputStream in = new ByteArrayInputStream(inputBytes);
+
+        try {
+            ImageIO.read(in);
+        } catch (IIOException e) {
+            // Do nothing we expect it to throw IIOException, but if it throws
+            // any other exception test will fail.
+        }
+    }
+}
+