diff --git a/make/sun/cmm/lcms/Makefile b/make/sun/cmm/lcms/Makefile index 1072c2fac7bf7c1bd74b7cccc10b29f98fa7b139..702c32680c8a1932225dec3460e08f7fca1ad23e 100644 --- a/make/sun/cmm/lcms/Makefile +++ b/make/sun/cmm/lcms/Makefile @@ -80,7 +80,12 @@ vpath %.c $(SHARE_SRC)/native/$(PKGDIR) 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 diff --git a/src/share/classes/java/awt/image/SampleModel.java b/src/share/classes/java/awt/image/SampleModel.java index cb7bd8a491f5eb8372ee532312d85217124d6a32..a2b02c44a6252a6e9f5ef5cc8326de71832bb6b7 100644 --- a/src/share/classes/java/awt/image/SampleModel.java +++ b/src/share/classes/java/awt/image/SampleModel.java @@ -937,14 +937,22 @@ public abstract class SampleModel 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 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 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> classes = new Vector>(); + + classes.add(ComponentSampleModel.class); + classes.add(MultiPixelPackedSampleModel.class); + classes.add(SinglePixelPackedSampleModel.class); + classes.add(BandedSampleModel.class); + classes.add(PixelInterleavedSampleModel.class); + + for (Class c : classes) { + doTest(c); + } + } + private static void doTest(Class 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 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; + } +}