Merge
authorlana
Mon, 04 Oct 2010 14:36:45 -0700
changeset 6646 a7518af86b7a
parent 6633 824e11bd7035 (diff)
parent 6645 63ea2d282026 (current diff)
child 6663 bd462b0c169c
Merge
--- a/.hgtags	Mon Oct 04 16:21:26 2010 +0400
+++ b/.hgtags	Mon Oct 04 14:36:45 2010 -0700
@@ -86,3 +86,4 @@
 e02b4d709e177d08d56130a4bc68061e4bbacc7d jdk7-b109
 a6442d6bc38a44152e0662688213ce4d2701f42a jdk7-b110
 69f3edf083477955b5bd2f754252c7504167d8e1 jdk7-b111
+f960f117f1623629f64203e2b09a92a8f6f14ff5 jdk7-b112
--- a/.hgtags-top-repo	Mon Oct 04 16:21:26 2010 +0400
+++ b/.hgtags-top-repo	Mon Oct 04 14:36:45 2010 -0700
@@ -86,3 +86,4 @@
 81dfc728d7bb7e1fff4a4dc6d0f7cea5a3315667 jdk7-b109
 2a02d4a6955c7c078aee9a604cb3be409800d82c jdk7-b110
 9702d6fef68e17533ee7fcf5923b11ead3e912ce jdk7-b111
+b852103caf73da70068473777ae867a457bb3ae1 jdk7-b112
--- a/corba/.hgtags	Mon Oct 04 16:21:26 2010 +0400
+++ b/corba/.hgtags	Mon Oct 04 14:36:45 2010 -0700
@@ -86,3 +86,4 @@
 c3dd858e09b20206459d9e7b0ead99d27ab00eab jdk7-b109
 0e1f80fda2271f53d4bbb59ec3f301dfbcef6a0a jdk7-b110
 640fa4d4e2ad4c2d7e4815c955026740d8c52b7a jdk7-b111
+cc67fdc4fee9a5b25caee4e71b51a8ff24ae7d1a jdk7-b112
--- a/hotspot/.hgtags	Mon Oct 04 16:21:26 2010 +0400
+++ b/hotspot/.hgtags	Mon Oct 04 14:36:45 2010 -0700
@@ -121,3 +121,4 @@
 cc4bb3022b3144dc5db0805b9ef6c7eff2aa3b81 jdk7-b109
 2f25f2b8de2700a1822463b1bd3d02b5e218018f jdk7-b110
 07b042e13dde4f3479ba9ec55120fcd5e8623323 jdk7-b111
+5511edd5d719f3fc9fdd04879482026a3d2c8652 jdk7-b112
--- a/jaxp/.hgtags	Mon Oct 04 16:21:26 2010 +0400
+++ b/jaxp/.hgtags	Mon Oct 04 14:36:45 2010 -0700
@@ -86,3 +86,4 @@
 0f382d6120fc07aed2209484a42458cabf405916 jdk7-b109
 d422dbdd09766269344b796b3a46a5b3f74557e1 jdk7-b110
 8106c747067c905d814a737a57fea0e29057b33f jdk7-b111
+1b05254242881527b4d5d711295c0fe708c8823a jdk7-b112
--- a/jaxws/.hgtags	Mon Oct 04 16:21:26 2010 +0400
+++ b/jaxws/.hgtags	Mon Oct 04 14:36:45 2010 -0700
@@ -86,3 +86,4 @@
 4f626e0d70bda68c76bbd0e89d2bc2407f979736 jdk7-b109
 95ecac35fb11530752bd0404c9bf02bcfb30990e jdk7-b110
 2575ebca96c7fb1b78f6ae025a97321210aba309 jdk7-b111
+8e0f0054817f0f73fb33e80fb1333fb45b1d513d jdk7-b112
--- a/jdk/.hgtags	Mon Oct 04 16:21:26 2010 +0400
+++ b/jdk/.hgtags	Mon Oct 04 14:36:45 2010 -0700
@@ -86,3 +86,4 @@
 ab0d3f54a63f2aadfcdd2e14b81f79362ce454e2 jdk7-b109
 176586cd040e4dd17a5ff6e91f72df10d7442453 jdk7-b110
 fb63a2688db807a73e2a3de7d9bab298f1bff0e8 jdk7-b111
+b53f226b1d91473ac54184afa827be07b87e0319 jdk7-b112
--- a/jdk/make/sun/cmm/lcms/Makefile	Mon Oct 04 16:21:26 2010 +0400
+++ b/jdk/make/sun/cmm/lcms/Makefile	Mon Oct 04 14:36:45 2010 -0700
@@ -80,7 +80,12 @@
 vpath %.c   $(SHARE_SRC)/native/sun/java2d
 
 ifeq ($(PLATFORM), windows)
-OTHER_CFLAGS += -DCMS_IS_WINDOWS_ -Dsqrtf=sqrt
+OTHER_CFLAGS += -DCMS_IS_WINDOWS_
+
+ifeq ($(COMPILER_VERSION), VS2003)
+OTHER_CFLAGS += -Dsqrtf=sqrt
+endif
+
 OTHER_LDLIBS = $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib
 OTHER_INCLUDES += -I$(SHARE_SRC)/native/sun/java2d \
                   -I$(SHARE_SRC)/native/sun/awt/debug
--- a/jdk/src/share/classes/java/awt/image/SampleModel.java	Mon Oct 04 16:21:26 2010 +0400
+++ b/jdk/src/share/classes/java/awt/image/SampleModel.java	Mon Oct 04 14:36:45 2010 -0700
@@ -937,14 +937,22 @@
                             int iArray[], DataBuffer data) {
         int pixels[];
         int Offset=0;
+        int x1 = x + w;
+        int y1 = y + h;
+
+        if (x < 0 || x1 < x || x1 > width ||
+            y < 0 || y1 < y || y1 > height)
+        {
+            throw new ArrayIndexOutOfBoundsException("Invalid coordinates.");
+        }
 
         if (iArray != null)
             pixels = iArray;
         else
             pixels = new int[w * h];
 
-        for(int i=y; i<(h+y); i++) {
-            for (int j=x; j<(w+x); j++) {
+        for(int i=y; i<y1; i++) {
+            for (int j=x; j<x1; j++) {
                 pixels[Offset++] = getSample(j, i, b, data);
             }
         }
@@ -978,14 +986,22 @@
                               DataBuffer data) {
         float pixels[];
         int   Offset=0;
+        int x1 = x + w;
+        int y1 = y + h;
+
+        if (x < 0 || x1 < x || x1 > width ||
+            y < 0 || y1 < y || y1 > height)
+        {
+            throw new ArrayIndexOutOfBoundsException("Invalid coordinates");
+        }
 
         if (fArray != null)
             pixels = fArray;
         else
             pixels = new float[w * h];
 
-        for (int i=y; i<(h+y); i++) {
-            for (int j=x; j<(w+x); j++) {
+        for (int i=y; i<y1; i++) {
+            for (int j=x; j<x1; j++) {
                 pixels[Offset++] = getSampleFloat(j, i, b, data);
             }
         }
@@ -1019,14 +1035,22 @@
                                DataBuffer data) {
         double pixels[];
         int    Offset=0;
+        int x1 = x + w;
+        int y1 = y + h;
+
+        if (x < 0 || x1 < x || x1 > width ||
+            y < 0 || y1 < y || y1 > height)
+        {
+            throw new ArrayIndexOutOfBoundsException("Invalid coordinates");
+        }
 
         if (dArray != null)
             pixels = dArray;
         else
             pixels = new double[w * h];
 
-        for (int i=y; i<(y+h); i++) {
-            for (int j=x; j<(x+w); j++) {
+        for (int i=y; i<y1; i++) {
+            for (int j=x; j<x1; j++) {
                 pixels[Offset++] = getSampleDouble(j, i, b, data);
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/GetSamplesTest.java	Mon Oct 04 14:36:45 2010 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2010, 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     6735275
+ * @summary Test verifies that SampleModel.getSamples() throws an appropriate
+ *           exception if coordinates are not in bounds.
+ *
+ * @run     main GetSamplesTest
+ */
+
+import java.awt.image.BandedSampleModel;
+import java.awt.image.ComponentSampleModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.PixelInterleavedSampleModel;
+import java.awt.image.SampleModel;
+import java.awt.image.SinglePixelPackedSampleModel;
+import java.util.Vector;
+
+public class GetSamplesTest {
+
+    public static int width = 100;
+    public static int height = 100;
+    public static int dataType = DataBuffer.TYPE_BYTE;
+    public static int numBands = 4;
+
+    public static void main(String[] args) {
+        Vector<Class<? extends SampleModel>> classes = new Vector<Class<? extends SampleModel>>();
+
+        classes.add(ComponentSampleModel.class);
+        classes.add(MultiPixelPackedSampleModel.class);
+        classes.add(SinglePixelPackedSampleModel.class);
+        classes.add(BandedSampleModel.class);
+        classes.add(PixelInterleavedSampleModel.class);
+
+        for (Class<? extends SampleModel> c : classes) {
+            doTest(c);
+        }
+    }
+    private static void doTest(Class<? extends SampleModel> c) {
+        System.out.println("Test for: " + c.getName());
+        SampleModel sm = createSampleModel(c);
+
+        DataBuffer db = sm.createDataBuffer();
+
+        int[] iArray = new int[ width * height + numBands];
+        float[] fArray = new float[ width * height + numBands];
+        double[] dArray = new double[ width * height + numBands];
+
+        boolean iOk = false;
+        boolean fOk = false;
+        boolean dOk = false;
+
+        try {
+            sm.getSamples(Integer.MAX_VALUE, 0, 1, 1, 0, iArray, db);
+        } catch (ArrayIndexOutOfBoundsException e) {
+            System.out.println(e.getMessage());
+            iOk = true;
+        }
+
+        try {
+            sm.getSamples(Integer.MAX_VALUE, 0, 1, 1, 0, fArray, db);
+        } catch (ArrayIndexOutOfBoundsException e) {
+            System.out.println(e.getMessage());
+            fOk = true;
+        }
+
+        try {
+            sm.getSamples(0, Integer.MAX_VALUE, 1, 1, 0, dArray, db);
+        } catch (ArrayIndexOutOfBoundsException e) {
+            System.out.println(e.getMessage());
+            dOk = true;
+        }
+        if (!iOk || !fOk || !dOk) {
+            throw new RuntimeException("Test for " + c.getSimpleName() +
+                    " failed: iOk=" + iOk + "; fOk=" + fOk + "; dOk=" + dOk);
+        }
+    }
+
+    private static SampleModel createSampleModel(Class<? extends SampleModel> cls) {
+        SampleModel res = null;
+
+        if (cls == ComponentSampleModel.class) {
+            res = new ComponentSampleModel(dataType, width, height, 4, width * 4, new int[] { 0, 1, 2, 3 } );
+        } else if (cls == MultiPixelPackedSampleModel.class) {
+            res = new MultiPixelPackedSampleModel(dataType, width, height, 4);
+        } else if (cls == SinglePixelPackedSampleModel.class) {
+            res = new SinglePixelPackedSampleModel(dataType, width, height,
+                    new int[]{ 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff });
+        } else if (cls == BandedSampleModel.class) {
+            res = new BandedSampleModel(dataType, width, height, numBands);
+        } else if (cls == PixelInterleavedSampleModel.class) {
+            res = new PixelInterleavedSampleModel(dataType, width, height, 4, width * 4, new int[] { 0, 1, 2, 3 });
+        } else {
+            throw new RuntimeException("Unknown class " + cls);
+        }
+        return res;
+    }
+}
--- a/langtools/.hgtags	Mon Oct 04 16:21:26 2010 +0400
+++ b/langtools/.hgtags	Mon Oct 04 14:36:45 2010 -0700
@@ -86,3 +86,4 @@
 4826378eaade4c6676c452efe954be4ee113cc11 jdk7-b109
 32da0f38d2fe96c558492b8707b40da24643d41e jdk7-b110
 8bec624274ef8535720cff553374347c2f4f5fb2 jdk7-b111
+fd2579b80b83bf5d4289426016c7d29174ba5dd9 jdk7-b112