Merge
authorlana
Mon, 04 Oct 2010 14:38:14 -0700
changeset 6663 bd462b0c169c
parent 6646 a7518af86b7a (diff)
parent 6662 c7e3eb015084 (current diff)
child 6698 79d1a8a47bdc
Merge
--- a/.hgtags	Mon Oct 04 13:05:14 2010 +0900
+++ b/.hgtags	Mon Oct 04 14:38:14 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 13:05:14 2010 +0900
+++ b/.hgtags-top-repo	Mon Oct 04 14:38:14 2010 -0700
@@ -86,3 +86,4 @@
 81dfc728d7bb7e1fff4a4dc6d0f7cea5a3315667 jdk7-b109
 2a02d4a6955c7c078aee9a604cb3be409800d82c jdk7-b110
 9702d6fef68e17533ee7fcf5923b11ead3e912ce jdk7-b111
+b852103caf73da70068473777ae867a457bb3ae1 jdk7-b112
--- a/corba/.hgtags	Mon Oct 04 13:05:14 2010 +0900
+++ b/corba/.hgtags	Mon Oct 04 14:38:14 2010 -0700
@@ -86,3 +86,4 @@
 c3dd858e09b20206459d9e7b0ead99d27ab00eab jdk7-b109
 0e1f80fda2271f53d4bbb59ec3f301dfbcef6a0a jdk7-b110
 640fa4d4e2ad4c2d7e4815c955026740d8c52b7a jdk7-b111
+cc67fdc4fee9a5b25caee4e71b51a8ff24ae7d1a jdk7-b112
--- a/hotspot/.hgtags	Mon Oct 04 13:05:14 2010 +0900
+++ b/hotspot/.hgtags	Mon Oct 04 14:38:14 2010 -0700
@@ -121,3 +121,4 @@
 cc4bb3022b3144dc5db0805b9ef6c7eff2aa3b81 jdk7-b109
 2f25f2b8de2700a1822463b1bd3d02b5e218018f jdk7-b110
 07b042e13dde4f3479ba9ec55120fcd5e8623323 jdk7-b111
+5511edd5d719f3fc9fdd04879482026a3d2c8652 jdk7-b112
--- a/jaxp/.hgtags	Mon Oct 04 13:05:14 2010 +0900
+++ b/jaxp/.hgtags	Mon Oct 04 14:38:14 2010 -0700
@@ -86,3 +86,4 @@
 0f382d6120fc07aed2209484a42458cabf405916 jdk7-b109
 d422dbdd09766269344b796b3a46a5b3f74557e1 jdk7-b110
 8106c747067c905d814a737a57fea0e29057b33f jdk7-b111
+1b05254242881527b4d5d711295c0fe708c8823a jdk7-b112
--- a/jaxws/.hgtags	Mon Oct 04 13:05:14 2010 +0900
+++ b/jaxws/.hgtags	Mon Oct 04 14:38:14 2010 -0700
@@ -86,3 +86,4 @@
 4f626e0d70bda68c76bbd0e89d2bc2407f979736 jdk7-b109
 95ecac35fb11530752bd0404c9bf02bcfb30990e jdk7-b110
 2575ebca96c7fb1b78f6ae025a97321210aba309 jdk7-b111
+8e0f0054817f0f73fb33e80fb1333fb45b1d513d jdk7-b112
--- a/jdk/.hgtags	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/.hgtags	Mon Oct 04 14:38:14 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 13:05:14 2010 +0900
+++ b/jdk/make/sun/cmm/lcms/Makefile	Mon Oct 04 14:38:14 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/Dialog.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/share/classes/java/awt/Dialog.java	Mon Oct 04 14:38:14 2010 -0700
@@ -1068,7 +1068,7 @@
                     modalityPushed();
                     try {
                         EventQueue eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
-                        secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 5000);
+                        secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0);
                         if (!secondaryLoop.enter()) {
                             secondaryLoop = null;
                         }
--- a/jdk/src/share/classes/java/awt/KeyboardFocusManager.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/share/classes/java/awt/KeyboardFocusManager.java	Mon Oct 04 14:38:14 2010 -0700
@@ -142,6 +142,9 @@
                 public void removeLastFocusRequest(Component heavyweight) {
                     KeyboardFocusManager.removeLastFocusRequest(heavyweight);
                 }
+                public void setMostRecentFocusOwner(Window window, Component component) {
+                    KeyboardFocusManager.setMostRecentFocusOwner(window, component);
+                }
             }
         );
     }
--- a/jdk/src/share/classes/java/awt/event/ActionEvent.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/share/classes/java/awt/event/ActionEvent.java	Mon Oct 04 14:38:14 2010 -0700
@@ -51,7 +51,7 @@
  * in the range from {@code ACTION_FIRST} to {@code ACTION_LAST}.
  *
  * @see ActionListener
- * @see <a href="http://java.sun.com/docs/books/tutorial/post1.0/ui/eventmodel.html">Tutorial: Java 1.1 Event Model</a>
+ * @see <a href="http://java.sun.com/docs/books/tutorial/uiswing/events/actionlistener.html">Tutorial: How to Write an Action Listener</a>
  *
  * @author Carl Quinn
  * @since 1.1
--- a/jdk/src/share/classes/java/awt/image/SampleModel.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/share/classes/java/awt/image/SampleModel.java	Mon Oct 04 14:38:14 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);
             }
         }
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java	Mon Oct 04 14:38:14 2010 -0700
@@ -344,6 +344,11 @@
          * Removes the last focus request for the heavyweight from the queue.
          */
         void removeLastFocusRequest(Component heavyweight);
+
+        /*
+         * Sets the most recent focus owner in the window.
+         */
+        void setMostRecentFocusOwner(Window window, Component component);
     }
 
     /*
--- a/jdk/src/share/classes/sun/awt/EmbeddedFrame.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/share/classes/sun/awt/EmbeddedFrame.java	Mon Oct 04 14:38:14 2010 -0700
@@ -70,7 +70,10 @@
     // JDK 1.1 compatibility
     private static final long serialVersionUID = 2967042741780317130L;
 
-    // Use these in traverseOut method to determine directions
+    /*
+     * The constants define focus traversal directions.
+     * Use them in {@code traverseIn}, {@code traverseOut} methods.
+     */
     protected static final boolean FORWARD = true;
     protected static final boolean BACKWARD = false;
 
@@ -284,6 +287,41 @@
     }
 
     /**
+     * This method is called by the embedder when we should receive focus as element
+     * of the traversal chain.  The method requests focus on:
+     * 1. the first Component of this EmbeddedFrame if user moves focus forward
+     *    in the focus traversal cycle.
+     * 2. the last Component of this EmbeddedFrame if user moves focus backward
+     *    in the focus traversal cycle.
+     *
+     * The direction parameter specifies which of the two mentioned cases is
+     * happening. Use FORWARD and BACKWARD constants defined in the EmbeddedFrame class
+     * to avoid confusing boolean values.
+     *
+     * A concrete implementation of this method is defined in the platform-dependent
+     * subclasses.
+     *
+     * @param direction FORWARD or BACKWARD
+     * @return true, if the EmbeddedFrame wants to get focus, false otherwise.
+     */
+    public boolean traverseIn(boolean direction) {
+        Component comp = null;
+
+        if (direction == FORWARD) {
+            comp = getFocusTraversalPolicy().getFirstComponent(this);
+        } else {
+            comp = getFocusTraversalPolicy().getLastComponent(this);
+        }
+        if (comp != null) {
+            // comp.requestFocus(); - Leads to a hung.
+
+            AWTAccessor.getKeyboardFocusManagerAccessor().setMostRecentFocusOwner(this, comp);
+            synthesizeWindowActivation(true);
+        }
+        return (null != comp);
+    }
+
+    /**
      * This method is called from dispatchKeyEvent in the following two cases:
      * 1. The focus is on the first Component of this EmbeddedFrame and we are
      *    about to transfer the focus backward.
--- a/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Mon Oct 04 14:38:14 2010 -0700
@@ -64,7 +64,10 @@
             accessor.setFile(fd, null);
             accessor.setFiles(fd, null, null);
         } else {
-            accessor.setDirectory(fd, directory);
+            // Fix 6987233: add the trailing slash if it's absent
+            accessor.setDirectory(fd, directory +
+                    (directory.endsWith(File.separator) ?
+                     "" : File.separator));
             accessor.setFile(fd, filenames[0]);
             accessor.setFiles(fd, directory, filenames);
         }
--- a/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/solaris/classes/sun/awt/X11/XBaseWindow.java	Mon Oct 04 14:38:14 2010 -0700
@@ -705,12 +705,8 @@
             throw new IllegalStateException("Attempt to resize uncreated window");
         }
         insLog.fine("Setting bounds on " + this + " to (" + x + ", " + y + "), " + width + "x" + height);
-        if (width <= 0) {
-            width = 1;
-        }
-        if (height <= 0) {
-            height = 1;
-        }
+        width = Math.max(MIN_SIZE, width);
+        height = Math.max(MIN_SIZE, height);
         XToolkit.awtLock();
         try {
              XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), getWindow(), x,y,width,height);
--- a/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Mon Oct 04 14:38:14 2010 -0700
@@ -763,12 +763,8 @@
     }
 
     private void checkShellRectSize(Rectangle shellRect) {
-        if (shellRect.width < 0) {
-            shellRect.width = 1;
-        }
-        if (shellRect.height < 0) {
-            shellRect.height = 1;
-        }
+        shellRect.width = Math.max(MIN_SIZE, shellRect.width);
+        shellRect.height = Math.max(MIN_SIZE, shellRect.height);
     }
 
     private void checkShellRectPos(Rectangle shellRect) {
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbeddedFrame.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbeddedFrame.java	Mon Oct 04 14:38:14 2010 -0700
@@ -28,9 +28,12 @@
 import sun.awt.EmbeddedFrame;
 import java.awt.*;
 import java.awt.AWTKeyStroke;
+import java.util.logging.Logger;
 
 public class XEmbeddedFrame extends EmbeddedFrame {
 
+    private static final Logger log = Logger.getLogger(XEmbeddedFrame.class.getName());
+
     long handle;
     public XEmbeddedFrame() {
     }
@@ -70,6 +73,21 @@
         this(handle, supportsXEmbed, false);
     }
 
+    /*
+     * The method shouldn't be called in case of active XEmbed.
+     */
+    public boolean traverseIn(boolean direction) {
+        XEmbeddedFramePeer peer = (XEmbeddedFramePeer)getPeer();
+        if (peer != null) {
+            if (peer.supportsXEmbed() && peer.isXEmbedActive()) {
+                log.fine("The method shouldn't be called when XEmbed is active!");
+            } else {
+                return super.traverseIn(direction);
+            }
+        }
+        return false;
+    }
+
     protected boolean traverseOut(boolean direction) {
         XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
         if (direction == FORWARD) {
@@ -81,6 +99,20 @@
         return true;
     }
 
+    /*
+     * The method shouldn't be called in case of active XEmbed.
+     */
+    public void synthesizeWindowActivation(boolean doActivate) {
+        XEmbeddedFramePeer peer = (XEmbeddedFramePeer)getPeer();
+        if (peer != null) {
+            if (peer.supportsXEmbed() && peer.isXEmbedActive()) {
+                log.fine("The method shouldn't be called when XEmbed is active!");
+            } else {
+                peer.synthesizeFocusInOut(doActivate);
+            }
+        }
+    }
+
     public void registerAccelerator(AWTKeyStroke stroke) {
         XEmbeddedFramePeer xefp = (XEmbeddedFramePeer) getPeer();
         if (xefp != null) {
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbeddedFramePeer.java	Mon Oct 04 14:38:14 2010 -0700
@@ -35,6 +35,8 @@
 import sun.awt.EmbeddedFrame;
 import sun.awt.SunToolkit;
 
+import static sun.awt.X11.XConstants.*;
+
 public class XEmbeddedFramePeer extends XFramePeer {
 
     private static final PlatformLogger xembedLog = PlatformLogger.getLogger("sun.awt.X11.xembed.XEmbeddedFramePeer");
@@ -305,4 +307,20 @@
         EmbeddedFrame frame = (EmbeddedFrame)target;
         frame.notifyModalBlocked(blocker, blocked);
     }
+
+    public void synthesizeFocusInOut(boolean doFocus) {
+        XFocusChangeEvent xev = new XFocusChangeEvent();
+
+        XToolkit.awtLock();
+        try {
+            xev.set_type(doFocus ? FocusIn : FocusOut);
+            xev.set_window(getFocusProxy().getWindow());
+            xev.set_mode(NotifyNormal);
+            XlibWrapper.XSendEvent(XToolkit.getDisplay(), getFocusProxy().getWindow(), false,
+                                   NoEventMask, xev.pData);
+        } finally {
+            XToolkit.awtUnlock();
+            xev.dispose();
+        }
+    }
 }
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Mon Oct 04 14:38:14 2010 -0700
@@ -1482,8 +1482,19 @@
         try {
             if (numberOfButtons == 0) {
                 numberOfButtons = getNumberOfButtonsImpl();
+                numberOfButtons = (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
+                //4th and 5th buttons are for wheel and shouldn't be reported as buttons.
+                //If we have more than 3 physical buttons and a wheel, we report N-2 buttons.
+                //If we have 3 physical buttons and a wheel, we report 3 buttons.
+                //If we have 1,2,3 physical buttons, we report it as is i.e. 1,2 or 3 respectively.
+                if (numberOfButtons >=5) {
+                    numberOfButtons -= 2;
+                } else if (numberOfButtons == 4 || numberOfButtons ==5){
+                    numberOfButtons = 3;
+                }
             }
-            return (numberOfButtons > MAX_BUTTONS_SUPPORTED)? MAX_BUTTONS_SUPPORTED : numberOfButtons;
+            //Assume don't have to re-query the number again and again.
+            return numberOfButtons;
         } finally {
             awtUnlock();
         }
--- a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Mon Oct 04 14:38:14 2010 -0700
@@ -556,24 +556,26 @@
 
         Component target = (Component)getTarget();
         Window window = SunToolkit.getContainingWindow(target);
-        if (window != null && !window.isOpaque()) {
-            // Non-opaque windows do not support heavyweight children.
-            // Redirect all painting to the Window's Graphics instead.
-            // The caller is responsible for calling the
-            // WindowPeer.updateWindow() after painting has finished.
-            int x = 0, y = 0;
-            for (Component c = target; c != window; c = c.getParent()) {
-                x += c.getX();
-                y += c.getY();
-            }
-
+        if (window != null) {
             Graphics g =
                 ((WWindowPeer)window.getPeer()).getTranslucentGraphics();
+            // getTranslucentGraphics() returns non-null value for non-opaque windows only
+            if (g != null) {
+                // Non-opaque windows do not support heavyweight children.
+                // Redirect all painting to the Window's Graphics instead.
+                // The caller is responsible for calling the
+                // WindowPeer.updateWindow() after painting has finished.
+                int x = 0, y = 0;
+                for (Component c = target; c != window; c = c.getParent()) {
+                    x += c.getX();
+                    y += c.getY();
+                }
 
-            g.translate(x, y);
-            g.clipRect(0, 0, target.getWidth(), target.getHeight());
+                g.translate(x, y);
+                g.clipRect(0, 0, target.getWidth(), target.getHeight());
 
-            return g;
+                return g;
+            }
         }
 
         SurfaceData surfaceData = this.surfaceData;
--- a/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java	Mon Oct 04 14:38:14 2010 -0700
@@ -191,9 +191,20 @@
     public void activateEmbeddingTopLevel() {
     }
 
-    public void synthesizeWindowActivation(boolean doActivate) {
-        ((WEmbeddedFramePeer)getPeer()).synthesizeWmActivate(doActivate);
+    public void synthesizeWindowActivation(final boolean doActivate) {
+        if (!doActivate || EventQueue.isDispatchThread()) {
+            ((WEmbeddedFramePeer)getPeer()).synthesizeWmActivate(doActivate);
+        } else {
+            // To avoid focus concurrence b/w IE and EmbeddedFrame
+            // activation is postponed by means of posting it to EDT.
+            EventQueue.invokeLater(new Runnable() {
+                    public void run() {
+                        ((WEmbeddedFramePeer)getPeer()).synthesizeWmActivate(true);
+                    }
+                });
+        }
     }
+
     public void registerAccelerator(AWTKeyStroke stroke) {}
     public void unregisterAccelerator(AWTKeyStroke stroke) {}
 
--- a/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Oct 04 14:38:14 2010 -0700
@@ -595,16 +595,6 @@
     }
 
     @Override
-    public Graphics getGraphics() {
-        synchronized (getStateLock()) {
-            if (!isOpaque) {
-                return getTranslucentGraphics();
-            }
-        }
-        return super.getGraphics();
-    }
-
-    @Override
     public void setBackground(Color c) {
         super.setBackground(c);
         synchronized (getStateLock()) {
--- a/jdk/src/windows/native/sun/windows/awt_Component.cpp	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp	Mon Oct 04 14:38:14 2010 -0700
@@ -2329,6 +2329,19 @@
     MSG msg;
     InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
 
+    AwtWindow *toplevel = GetContainer();
+    if (toplevel && !toplevel->IsSimpleWindow()) {
+        /*
+         * The frame should be focused by click in case it is
+         * the active window but not the focused window. See 6886678.
+         */
+        if (toplevel->GetHWnd() == ::GetActiveWindow() &&
+            toplevel->GetHWnd() != AwtComponent::GetFocusedWindow())
+        {
+            toplevel->AwtSetActiveWindow();
+        }
+    }
+
     SendMouseEvent(java_awt_event_MouseEvent_MOUSE_PRESSED, now, x, y,
                    GetJavaModifiers(), clickCount, JNI_FALSE,
                    GetButton(button), &msg);
--- a/jdk/src/windows/native/sun/windows/awt_Desktop.cpp	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/windows/native/sun/windows/awt_Desktop.cpp	Mon Oct 04 14:38:14 2010 -0700
@@ -59,15 +59,17 @@
                     FORMAT_MESSAGE_FROM_SYSTEM  |
                     FORMAT_MESSAGE_IGNORE_INSERTS,
                     NULL,
-                    GetLastError(),
+                    (int)retval,
                     MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
                     (LPTSTR)&buffer,
                     0,
                     NULL );
 
-        jstring errmsg = JNU_NewStringPlatform(env, buffer, len);
-        LocalFree(buffer);
-        return errmsg;
+        if (buffer) {
+            jstring errmsg = JNU_NewStringPlatform(env, buffer);
+            LocalFree(buffer);
+            return errmsg;
+        }
     }
 
     return NULL;
--- a/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Mon Oct 04 14:38:14 2010 -0700
@@ -505,7 +505,8 @@
     SetIntegerProperty(TEXT("win.drag.width"), cxdrag);
     SetIntegerProperty(TEXT("win.drag.height"), cydrag);
     SetIntegerProperty(TEXT("DnD.gestureMotionThreshold"), max(cxdrag, cydrag)/2);
-    SetIntegerProperty(TEXT("awt.mouse.numButtons"), GetSystemMetrics(SM_CMOUSEBUTTONS));
+    SetIntegerProperty(TEXT("awt.mouse.numButtons"), AwtToolkit::GetNumberOfButtons());
+
     SetIntegerProperty(TEXT("awt.multiClickInterval"), GetDoubleClickTime());
 
     // BEGIN cross-platform properties
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.cpp	Mon Oct 04 14:38:14 2010 -0700
@@ -133,6 +133,8 @@
 
 static LPCTSTR szAwtToolkitClassName = TEXT("SunAwtToolkit");
 
+static const int MOUSE_BUTTONS_WINDOWS_SUPPORTED = 5; //three standard buttons + XBUTTON1 + XBUTTON2.
+
 UINT AwtToolkit::GetMouseKeyState()
 {
     static BOOL mbSwapped = ::GetSystemMetrics(SM_SWAPBUTTON);
@@ -2310,5 +2312,9 @@
 
 JNIEXPORT jint JNICALL Java_sun_awt_windows_WToolkit_getNumberOfButtonsImpl
 (JNIEnv *, jobject self) {
-    return GetSystemMetrics(SM_CMOUSEBUTTONS);
+    return AwtToolkit::GetNumberOfButtons();
 }
+
+UINT AwtToolkit::GetNumberOfButtons() {
+    return MOUSE_BUTTONS_WINDOWS_SUPPORTED;
+}
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Mon Oct 04 14:38:14 2010 -0700
@@ -185,6 +185,7 @@
     BOOL IsDynamicLayoutActive();
     BOOL areExtraMouseButtonsEnabled();
     void setExtraMouseButtonsEnabled(BOOL enable);
+    static UINT GetNumberOfButtons();
 
     INLINE BOOL localPump() { return m_localPump; }
     INLINE BOOL VerifyComponents() { return FALSE; } // TODO: Use new DebugHelper class to set this flag
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Focus/FocusOwnerFrameOnClick/FocusOwnerFrameOnClick.java	Mon Oct 04 14:38:14 2010 -0700
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 1995, 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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      FocusOwnerFrameOnClick.java %W% %E%
+  @bug       6886678
+  @summary   Tests that clicking an owner frame switches focus from its owned window.
+  @author    Anton Tarasov: area=awt.focus
+  @library   ../../regtesthelpers
+  @build     Util
+  @run       main FocusOwnerFrameOnClick
+*/
+
+import java.awt.*;
+import java.awt.event.*;
+import java.applet.Applet;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.lang.reflect.InvocationTargetException;
+import test.java.awt.regtesthelpers.Util;
+
+public class FocusOwnerFrameOnClick extends Applet {
+    Robot robot;
+    Frame frame = new Frame("Frame");
+    Window window = new Window(frame);
+    Button fButton = new Button("fButton");
+    Button wButton = new Button("wButton");
+
+    AtomicBoolean focused = new AtomicBoolean(false);
+
+    public static void main(String[] args) {
+        FocusOwnerFrameOnClick app = new FocusOwnerFrameOnClick();
+        app.init();
+        app.start();
+    }
+
+    public void init() {
+        robot = Util.createRobot();
+
+        frame.setLayout(new FlowLayout());
+        frame.setSize(200, 200);
+        frame.add(fButton);
+
+        window.setLocation(300, 0);
+        window.add(wButton);
+        window.pack();
+    }
+
+    public void start() {
+        frame.setVisible(true);
+        Util.waitForIdle(robot);
+
+        window.setVisible(true);
+        Util.waitForIdle(robot);
+
+        if (!wButton.hasFocus()) {
+            if (!Util.trackFocusGained(wButton, new Runnable() {
+                    public void run() {
+                        Util.clickOnComp(wButton, robot);
+                    }
+                }, 2000, false))
+            {
+                throw new TestErrorException("wButton didn't gain focus on showing");
+            }
+        }
+
+        Runnable clickAction = new Runnable() {
+                public void run() {
+                    Point loc = fButton.getLocationOnScreen();
+                    Dimension dim = fButton.getSize();
+
+                    robot.mouseMove(loc.x, loc.y + dim.height + 20);
+                    robot.delay(50);
+                    robot.mousePress(InputEvent.BUTTON1_MASK);
+                    robot.delay(50);
+                    robot.mouseRelease(InputEvent.BUTTON1_MASK);
+                }
+            };
+
+        if (!Util.trackWindowGainedFocus(frame, clickAction, 2000, true)) {
+            throw new TestFailedException("The frame wasn't focused on click");
+        }
+
+        System.out.println("Test passed.");
+    }
+}
+
+/**
+ * Thrown when the behavior being verified is found wrong.
+ */
+class TestFailedException extends RuntimeException {
+    TestFailedException(String msg) {
+        super("Test failed: " + msg);
+    }
+}
+
+/**
+ * Thrown when an error not related to the behavior being verified is encountered.
+ */
+class TestErrorException extends RuntimeException {
+    TestErrorException(String msg) {
+        super("Unexpected error: " + msg);
+    }
+}
--- a/jdk/test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/test/java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Extra.java	Mon Oct 04 14:38:14 2010 -0700
@@ -21,16 +21,15 @@
     static final int SHIFT = 1;
     static final int CTRL = 2;
     static final int ALT = 3;
-    static CheckingModifierAdapter adapterTest1;
-    static CheckingModifierAdapter adapterTest2;
-    static CheckingModifierAdapter adapterTest3;
-    static CheckingModifierAdapter adapterTest4;
+    static CheckingModifierAdapterExtra adapterTest1;
+    static CheckingModifierAdapterExtra adapterTest2;
+    static CheckingModifierAdapterExtra adapterTest3;
+    static CheckingModifierAdapterExtra adapterTest4;
 
     static boolean debug = true; //dump all errors (debug) or throw first(under jtreg) exception
     static boolean autorun = false; //use robot or manual run
     static int testModifier = NONE;
 
-    static int [] mouseButtons;
     static int [] mouseButtonDownMasks;
 
     //an arrays representing a modifiersEx of extra mouse buttons while using ALT/CTRL/SHIFT or none of them
@@ -39,7 +38,6 @@
     static int [] modifiersExStandardCTRL;
     static int [] modifiersExStandardALT;
 
-    //    final static int [] mouseButtons = new int [] {MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON2_MASK, MouseEvent.BUTTON3_MASK};
     // BUTTON1, 2, 3 press-release.
     final static int  modifiersStandard = 0; //InputEvent.BUTTON_DOWN_MASK;
 
@@ -56,7 +54,7 @@
 
         if (modifiersEx != curStandardExModifiers[index]){
 //            System.out.println(">>>>>>>>>>>>>>> Pressed. modifiersEx "+modifiersEx +" : "+!= curStandardExModifiers");
-            MessageLogger.reportError("Test failed :  Pressed. modifiersEx != curStandardExModifiers");
+            MessageLogger.reportError("Test failed :  Pressed. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]);
         }
 
      //check event.paramString() output
@@ -168,7 +166,7 @@
         }
 
         if (modifiersEx != curStandardExModifiers[index]){
-            MessageLogger.reportError("Test failed :  Released. modifiersEx != curStandardExModifiers");
+            MessageLogger.reportError("Test failed :  Released. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]);
         }
 
      //check event.paramString() output
@@ -191,7 +189,7 @@
         }
 
         if (modifiersEx != curStandardExModifiers[index]){
-            MessageLogger.reportError("Test failed :  Clicked. modifiersEx != curStandardExModifiers");
+            MessageLogger.reportError("Test failed :  Clicked. modifiersEx != curStandardExModifiers. Got: " + modifiersEx + " , Expected: " + curStandardExModifiers[index]);
         }
 
      //check event.paramString() output
@@ -275,11 +273,11 @@
         this.addMouseListener(adapterTest1);
         robot.delay(1000);
         robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2);
-        for (int i = 3; i< mouseButtons.length; i++){
-            System.out.println("testNONE() => " +mouseButtons[i] );
-            robot.mousePress(mouseButtons[i]);
+        for (int i = 3; i< mouseButtonDownMasks.length; i++){
+            System.out.println("testNONE() => " +mouseButtonDownMasks[i] );
+            robot.mousePress(mouseButtonDownMasks[i]);
             robot.delay(100);
-            robot.mouseRelease(mouseButtons[i]);
+            robot.mouseRelease(mouseButtonDownMasks[i]);
         }
         robot.delay(1000);
         this.removeMouseListener(adapterTest1);
@@ -289,12 +287,12 @@
         this.addMouseListener(adapterTest2);
         robot.delay(1000);
         robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2);
-        for (int i = 3; i< mouseButtons.length; i++){
+        for (int i = 3; i< mouseButtonDownMasks.length; i++){
             robot.keyPress(KeyEvent.VK_SHIFT);
-            System.out.println("testSHIFT() => " +mouseButtons[i] );
-            robot.mousePress(mouseButtons[i]);
+            System.out.println("testSHIFT() => " +mouseButtonDownMasks[i] );
+            robot.mousePress(mouseButtonDownMasks[i]);
             robot.delay(100);
-            robot.mouseRelease(mouseButtons[i]);
+            robot.mouseRelease(mouseButtonDownMasks[i]);
             robot.keyRelease(KeyEvent.VK_SHIFT);
         }
         robot.delay(1000);
@@ -305,12 +303,12 @@
         this.addMouseListener(adapterTest3);
         robot.delay(1000);
         robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2);
-        for (int i = 3; i< mouseButtons.length; i++){
+        for (int i = 3; i< mouseButtonDownMasks.length; i++){
             robot.keyPress(KeyEvent.VK_CONTROL);
-            System.out.println("testCTRL() => " +mouseButtons[i] );
-            robot.mousePress(mouseButtons[i]);
+            System.out.println("testCTRL() => " +mouseButtonDownMasks[i] );
+            robot.mousePress(mouseButtonDownMasks[i]);
             robot.delay(100);
-            robot.mouseRelease(mouseButtons[i]);
+            robot.mouseRelease(mouseButtonDownMasks[i]);
             robot.keyRelease(KeyEvent.VK_CONTROL);
         }
         robot.delay(1000);
@@ -321,12 +319,12 @@
         this.addMouseListener(adapterTest4);
         robot.delay(1000);
         robot.mouseMove(getLocationOnScreen().x + getWidth()/2, getLocationOnScreen().y + getHeight()/2);
-        for (int i = 3; i< mouseButtons.length; i++){
+        for (int i = 3; i< mouseButtonDownMasks.length; i++){
             robot.keyPress(KeyEvent.VK_ALT);
-            System.out.println("testALT() => " +mouseButtons[i] );
-            robot.mousePress(mouseButtons[i]);
+            System.out.println("testALT() => " +mouseButtonDownMasks[i] );
+            robot.mousePress(mouseButtonDownMasks[i]);
             robot.delay(100);
-            robot.mouseRelease(mouseButtons[i]);
+            robot.mouseRelease(mouseButtonDownMasks[i]);
             robot.keyRelease(KeyEvent.VK_ALT);
         }
         robot.delay(1000);
@@ -368,52 +366,52 @@
     }
 
     public static void initAdapters(){
-        adapterTest1 = new CheckingModifierAdapter(NONE);
-        adapterTest2 = new CheckingModifierAdapter(SHIFT);
-        adapterTest3 = new CheckingModifierAdapter(CTRL);
-        adapterTest4 = new CheckingModifierAdapter(ALT);
+        adapterTest1 = new CheckingModifierAdapterExtra(NONE);
+        adapterTest2 = new CheckingModifierAdapterExtra(SHIFT);
+        adapterTest3 = new CheckingModifierAdapterExtra(CTRL);
+        adapterTest4 = new CheckingModifierAdapterExtra(ALT);
     }
 
     public static void initVars(){
-        int [] tmp = new int [MouseInfo.getNumberOfButtons()];
-        for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
-            tmp[i] = InputEvent.getMaskForButton(i+1);
-            //            System.out.println("TEST: "+tmp[i]);
+        //Init the array of the mouse button masks. It will be used for generating mouse events.
+        mouseButtonDownMasks = new int [MouseInfo.getNumberOfButtons()];
+        for (int i = 0; i < mouseButtonDownMasks.length; i++){
+            mouseButtonDownMasks[i] = InputEvent.getMaskForButton(i+1);
+            System.out.println("MouseArray [i] == "+mouseButtonDownMasks[i]);
         }
 
-        mouseButtons = Arrays.copyOf(tmp, tmp.length);
-
-        for (int i = 0; i < mouseButtons.length; i++){
-            System.out.println("MouseArray [i] == "+mouseButtons[i]);
-        }
-
-        mouseButtonDownMasks = Arrays.copyOf(tmp, tmp.length);
-
         // So we need to get the number of extra buttons on the mouse:  "MouseInfo.getNumberOfButtons() - 3"
         // and multyply on 3 because each button will generate three events : PRESS, RELEASE and CLICK.
-        tmp = new int [(MouseInfo.getNumberOfButtons()-3)*3];
+        int [] tmp = new int [(MouseInfo.getNumberOfButtons()-3)*3];
+
+        //Fill array of expected results for the case when mouse buttons are only used (no-modifier keys)
         Arrays.fill(tmp, 0);
-
         for (int i = 0, j = 3; i < tmp.length; i = i + 3, j++){
             tmp[i] = mouseButtonDownMasks[j];
         }
         modifiersExStandard = Arrays.copyOf(tmp, tmp.length);
 
+        //Fill array of expected results for the case when mouse buttons are only used with SHIFT modifier key
         Arrays.fill(tmp, InputEvent.SHIFT_DOWN_MASK);
-        for (int i = 0, j = 3; i < MouseInfo.getNumberOfButtons(); i = i + 3, j++){
-            tmp[i] = tmp[j] | mouseButtonDownMasks[j];
+        for (int i = 0, j = 3; i < tmp.length; i = i + 3, j++){
+            System.out.println("modifiersExStandardSHIFT FILLING : " + tmp[i] + " + " + mouseButtonDownMasks[j]);
+            tmp[i] = tmp[i] | mouseButtonDownMasks[j];
         }
         modifiersExStandardSHIFT = Arrays.copyOf(tmp, tmp.length);
 
+        //Fill array of expected results for the case when mouse buttons are only used with CTRL modifier key
         Arrays.fill(tmp, InputEvent.CTRL_DOWN_MASK);
-        for (int i = 0, j = 3; i < MouseInfo.getNumberOfButtons(); i = i + 3, j++){
-            tmp[i] = tmp[j] | mouseButtonDownMasks[j];
+        for (int i = 0, j = 3; i < tmp.length; i = i + 3, j++){
+            System.out.println("modifiersExStandardCTRL FILLING : " + tmp[i] + " + " + mouseButtonDownMasks[j]);
+            tmp[i] = tmp[i] | mouseButtonDownMasks[j];
         }
         modifiersExStandardCTRL = Arrays.copyOf(tmp, tmp.length);
 
+        //Fill array of expected results for the case when mouse buttons are only used with ALT modifier key
         Arrays.fill(tmp, InputEvent.ALT_DOWN_MASK);
-        for (int i = 0, j = 3; i < MouseInfo.getNumberOfButtons(); i = i + 3, j++){
-            tmp[i] = tmp[j] | mouseButtonDownMasks[j];
+        for (int i = 0, j = 3; i < tmp.length; i = i + 3, j++){
+            System.out.println("modifiersExStandardALT FILLING : " + tmp[i] + " + " + mouseButtonDownMasks[j]);
+            tmp[i] = tmp[i] | mouseButtonDownMasks[j];
         }
         modifiersExStandardALT = Arrays.copyOf(tmp, tmp.length);
     }
@@ -436,9 +434,9 @@
 /* A class that invoke appropriate verification
  * routine with current modifier.
  */
-class CheckingModifierAdapter extends MouseAdapter{
+class CheckingModifierAdapterExtra extends MouseAdapter{
     int modifier;
-    public CheckingModifierAdapter(int modifier){
+    public CheckingModifierAdapterExtra(int modifier){
         this.modifier = modifier;
     }
 
--- a/jdk/test/java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java	Mon Oct 04 13:05:14 2010 +0900
+++ b/jdk/test/java/awt/Toolkit/ToolkitPropertyTest/ToolkitPropertyTest_Enable.java	Mon Oct 04 14:38:14 2010 -0700
@@ -90,7 +90,7 @@
         int [] buttonMasks = new int[MouseInfo.getNumberOfButtons()]; // = InputEvent.getButtonDownMasks();
         for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
             buttonMasks[i] = InputEvent.getMaskForButton(i+1);
-            System.out.println("TEST: "+buttonMasks[i]);
+            System.out.println("TEST: buttonMasks["+ i +"] = " + buttonMasks[i]);
         }
 
         for (int i = 0; i < MouseInfo.getNumberOfButtons(); i++){
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/GetSamplesTest.java	Mon Oct 04 14:38:14 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 13:05:14 2010 +0900
+++ b/langtools/.hgtags	Mon Oct 04 14:38:14 2010 -0700
@@ -86,3 +86,4 @@
 4826378eaade4c6676c452efe954be4ee113cc11 jdk7-b109
 32da0f38d2fe96c558492b8707b40da24643d41e jdk7-b110
 8bec624274ef8535720cff553374347c2f4f5fb2 jdk7-b111
+fd2579b80b83bf5d4289426016c7d29174ba5dd9 jdk7-b112