changeset 5302:a054541fa782

Merge
author coffeys
date Thu, 06 Sep 2012 18:07:38 +0100
parents 23e21b08db78 7fe3c9a34d0a
children 3f44e9547a6b
files test/java/awt/Mouse/EnterExitEvents/DragWindowTest.java
diffstat 65 files changed, 1421 insertions(+), 604 deletions(-) [+]
line wrap: on
line diff
--- a/make/java/nio/Makefile	Thu Aug 23 13:07:08 2012 +0100
+++ b/make/java/nio/Makefile	Thu Sep 06 18:07:38 2012 +0100
@@ -274,7 +274,6 @@
 	sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
 	sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
 	\
-	sun/nio/fs/GnomeFileTypeDetector.java \
 	sun/nio/fs/BsdFileStore.java \
 	sun/nio/fs/BsdFileSystem.java \
 	sun/nio/fs/BsdFileSystemProvider.java \
@@ -306,7 +305,6 @@
 	UnixAsynchronousServerSocketChannelImpl.c \
 	UnixAsynchronousSocketChannelImpl.c \
 	\
-	GnomeFileTypeDetector.c \
 	BsdNativeDispatcher.c \
 	UnixCopyFile.c \
 	UnixNativeDispatcher.c \
@@ -322,7 +320,6 @@
 	sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java \
 	sun/nio/ch/UnixAsynchronousSocketChannelImpl.java \
 	\
-	sun/nio/fs/GnomeFileTypeDetector.java \
 	sun/nio/fs/BsdNativeDispatcher.java \
 	sun/nio/fs/UnixCopyFile.java \
 	sun/nio/fs/UnixNativeDispatcher.java
--- a/make/java/nio/mapfile-bsd	Thu Aug 23 13:07:08 2012 +0100
+++ b/make/java/nio/mapfile-bsd	Thu Sep 06 18:07:38 2012 +0100
@@ -121,10 +121,6 @@
 		Java_sun_nio_fs_BsdNativeDispatcher_getfsstat;
 		Java_sun_nio_fs_BsdNativeDispatcher_fsstatEntry;
 		Java_sun_nio_fs_BsdNativeDispatcher_endfsstat;
-		Java_sun_nio_fs_GnomeFileTypeDetector_initializeGio;
-		Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGio;
-		Java_sun_nio_fs_GnomeFileTypeDetector_initializeGnomeVfs;
-		Java_sun_nio_fs_GnomeFileTypeDetector_probeUsingGnomeVfs;
 		Java_sun_nio_fs_UnixNativeDispatcher_init;
 		Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
 		Java_sun_nio_fs_UnixNativeDispatcher_strerror;
@@ -170,7 +166,6 @@
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrgid;
 		Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
-		Java_sun_nio_fs_UnixNativeDispatcher_getextmntent;
 		Java_sun_nio_fs_UnixCopyFile_transfer;
 		handleSocketError;
 
--- a/make/java/nio/mapfile-linux	Thu Aug 23 13:07:08 2012 +0100
+++ b/make/java/nio/mapfile-linux	Thu Sep 06 18:07:38 2012 +0100
@@ -143,6 +143,7 @@
 		Java_sun_nio_fs_LinuxNativeDispatcher_fsetxattr0;
 		Java_sun_nio_fs_LinuxNativeDispatcher_fremovexattr0;
 		Java_sun_nio_fs_LinuxNativeDispatcher_setmntent0;
+                Java_sun_nio_fs_LinuxNativeDispatcher_getmntent;
 		Java_sun_nio_fs_LinuxNativeDispatcher_endmntent;
 		Java_sun_nio_fs_UnixNativeDispatcher_init;
 		Java_sun_nio_fs_UnixNativeDispatcher_getcwd;
@@ -189,7 +190,6 @@
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrgid;
 		Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
-		Java_sun_nio_fs_UnixNativeDispatcher_getextmntent;
 		Java_sun_nio_fs_UnixCopyFile_transfer;
 		handleSocketError;
 
--- a/make/java/nio/mapfile-solaris	Thu Aug 23 13:07:08 2012 +0100
+++ b/make/java/nio/mapfile-solaris	Thu Sep 06 18:07:38 2012 +0100
@@ -169,10 +169,10 @@
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrgid;
 		Java_sun_nio_fs_UnixNativeDispatcher_getpwnam0;
 		Java_sun_nio_fs_UnixNativeDispatcher_getgrnam0;
-		Java_sun_nio_fs_UnixNativeDispatcher_getextmntent;
 		Java_sun_nio_fs_UnixCopyFile_transfer;
 		Java_sun_nio_fs_SolarisNativeDispatcher_init;
 		Java_sun_nio_fs_SolarisNativeDispatcher_facl;
+		Java_sun_nio_fs_SolarisNativeDispatcher_getextmntent;
 		Java_sun_nio_fs_SolarisWatchService_init;
 		Java_sun_nio_fs_SolarisWatchService_portCreate;
 		Java_sun_nio_fs_SolarisWatchService_portAssociate;
--- a/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/macosx/classes/sun/lwawt/LWWindowPeer.java	Thu Sep 06 18:07:38 2012 +0100
@@ -751,42 +751,39 @@
             }
         } else {
             if (targetPeer != lastMouseEventPeer) {
-
-                if (id != MouseEvent.MOUSE_DRAGGED || lastMouseEventPeer == null) {
-                    // lastMouseEventPeer may be null if mouse was out of Java windows
-                    if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) {
-                        // Sometimes, MOUSE_EXITED is not sent by delegate (or is sent a bit
-                        // later), in which case lastWindowPeer is another window
-                        if (lastWindowPeer != this) {
-                            Point oldp = lastMouseEventPeer.windowToLocal(x, y, lastWindowPeer);
-                            // Additionally translate from this to lastWindowPeer coordinates
-                            Rectangle lr = lastWindowPeer.getBounds();
-                            oldp.x += r.x - lr.x;
-                            oldp.y += r.y - lr.y;
-                            postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
-                                                     MouseEvent.MOUSE_EXITED,
-                                                     when, modifiers,
-                                                     oldp.x, oldp.y, screenX, screenY,
-                                                     clickCount, popupTrigger, button));
-                        } else {
-                            Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
-                            postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
-                                                     MouseEvent.MOUSE_EXITED,
-                                                     when, modifiers,
-                                                     oldp.x, oldp.y, screenX, screenY,
-                                                     clickCount, popupTrigger, button));
-                        }
-                    }
-                    if (targetPeer != null && targetPeer.isEnabled() && id != MouseEvent.MOUSE_ENTERED) {
-                        Point newp = targetPeer.windowToLocal(x, y, curWindowPeer);
-                        postEvent(new MouseEvent(targetPeer.getTarget(),
-                                                 MouseEvent.MOUSE_ENTERED,
+                // lastMouseEventPeer may be null if mouse was out of Java windows
+                if (lastMouseEventPeer != null && lastMouseEventPeer.isEnabled()) {
+                    // Sometimes, MOUSE_EXITED is not sent by delegate (or is sent a bit
+                    // later), in which case lastWindowPeer is another window
+                    if (lastWindowPeer != this) {
+                        Point oldp = lastMouseEventPeer.windowToLocal(x, y, lastWindowPeer);
+                        // Additionally translate from this to lastWindowPeer coordinates
+                        Rectangle lr = lastWindowPeer.getBounds();
+                        oldp.x += r.x - lr.x;
+                        oldp.y += r.y - lr.y;
+                        postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
+                                                 MouseEvent.MOUSE_EXITED,
                                                  when, modifiers,
-                                                 newp.x, newp.y, screenX, screenY,
+                                                 oldp.x, oldp.y, screenX, screenY,
+                                                 clickCount, popupTrigger, button));
+                    } else {
+                        Point oldp = lastMouseEventPeer.windowToLocal(x, y, this);
+                        postEvent(new MouseEvent(lastMouseEventPeer.getTarget(),
+                                                 MouseEvent.MOUSE_EXITED,
+                                                 when, modifiers,
+                                                 oldp.x, oldp.y, screenX, screenY,
                                                  clickCount, popupTrigger, button));
                     }
                 }
                 lastMouseEventPeer = targetPeer;
+                if (targetPeer != null && targetPeer.isEnabled() && id != MouseEvent.MOUSE_ENTERED) {
+                    Point newp = targetPeer.windowToLocal(x, y, curWindowPeer);
+                    postEvent(new MouseEvent(targetPeer.getTarget(),
+                                             MouseEvent.MOUSE_ENTERED,
+                                             when, modifiers,
+                                             newp.x, newp.y, screenX, screenY,
+                                             clickCount, popupTrigger, button));
+                }
             }
             // TODO: fill "bdata" member of AWTEvent
 
--- a/src/share/classes/com/sun/crypto/provider/AESCrypt.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/com/sun/crypto/provider/AESCrypt.java	Thu Sep 06 18:07:38 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, 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
@@ -37,6 +37,7 @@
 package com.sun.crypto.provider;
 
 import java.security.InvalidKeyException;
+import java.util.Arrays;
 
 /**
  * Rijndael --pronounced Reindaal-- is a symmetric cipher with a 128-bit
@@ -54,7 +55,12 @@
     private Object[] sessionK = null;
     private int[] K = null;
 
-    /** (ROUNDS-1) * 4 */
+    /** Cipher encryption/decryption key */
+    // skip re-generating Session and Sub keys if the cipher key is
+    // the same
+    private byte[] lastKey = null;
+
+    /** ROUNDS * 4 */
     private int limit = 0;
 
     AESCrypt() {
@@ -82,41 +88,45 @@
                 key.length + " bytes");
         }
 
-        // generate session key and reset sub key.
-        sessionK = makeKey(key);
-        setSubKey(decrypting);
+        if (!Arrays.equals(key, lastKey)) {
+            // re-generate session key 'sessionK' when cipher key changes
+            makeSessionKey(key);
+            lastKey = key.clone();  // save cipher key
+        }
+
+        // set sub key to the corresponding session Key
+        this.K = (int[]) sessionK[(decrypting? 1:0)];
     }
 
-    private void setSubKey(boolean decrypting) {
-        int[][] Kd = (int[][]) sessionK[decrypting ? 1 : 0];
-        int rounds = Kd.length;
-        this.K = new int[rounds*4];
-        for(int i=0; i<rounds; i++) {
+    /**
+     * Expand an int[(ROUNDS+1)][4] into int[(ROUNDS+1)*4].
+     * For decryption round keys, need to rotate right by 4 ints.
+     * @param kr The round keys for encryption or decryption.
+     * @param decrypting True if 'kr' is for decryption and false otherwise.
+     */
+    private static final int[] expandToSubKey(int[][] kr, boolean decrypting) {
+        int total = kr.length;
+        int[] expK = new int[total*4];
+        if (decrypting) {
+            // decrypting, rotate right by 4 ints
+            // i.e. i==0
             for(int j=0; j<4; j++) {
-                K[i*4 + j] = Kd[i][j];
+                expK[j] = kr[total-1][j];
+            }
+            for(int i=1; i<total; i++) {
+                for(int j=0; j<4; j++) {
+                    expK[i*4 + j] = kr[i-1][j];
+                }
+            }
+        } else {
+            // encrypting, straight expansion
+            for(int i=0; i<total; i++) {
+                for(int j=0; j<4; j++) {
+                    expK[i*4 + j] = kr[i][j];
+                }
             }
         }
-
-        if (decrypting) {
-            int j0 = K[K.length-4];
-            int j1 = K[K.length-3];
-            int j2 = K[K.length-2];
-            int j3 = K[K.length-1];
-
-            for (int i=this.K.length-1; i>3; i--) {
-                this.K[i] = this.K[i-4];
-            }
-            K[0] = j0;
-            K[1] = j1;
-            K[2] = j2;
-            K[3] = j3;
-        }
-
-        ROUNDS_12 = (rounds>=13);
-        ROUNDS_14 = (rounds==15);
-
-        rounds--;
-        limit=rounds*4;
+        return expK;
     }
 
     private static int[]
@@ -566,10 +576,10 @@
     /**
      * Expand a user-supplied key material into a session key.
      *
-     * @param key The 128/192/256-bit user-key to use.
+     * @param k The 128/192/256-bit cipher key to use.
      * @exception InvalidKeyException  If the key is invalid.
      */
-    private static Object[] makeKey(byte[] k) throws InvalidKeyException {
+    private void makeSessionKey(byte[] k) throws InvalidKeyException {
         if (k == null) {
             throw new InvalidKeyException("Empty key");
         }
@@ -639,10 +649,18 @@
                            U4[ tt         & 0xFF];
             }
         }
-        // assemble the encryption (Ke) and decryption (Kd) round keys into
-        // one sessionKey object
-        Object[] result = new Object[] {Ke, Kd};
-        return result;
+
+        // assemble the encryption (Ke) and decryption (Kd) round keys
+        // and expand them into arrays of ints.
+        int[] expandedKe = expandToSubKey(Ke, false); // decrypting==false
+        int[] expandedKd = expandToSubKey(Kd, true);  // decrypting==true
+
+        ROUNDS_12 = (ROUNDS>=12);
+        ROUNDS_14 = (ROUNDS==14);
+        limit = ROUNDS*4;
+
+        // store the expanded sub keys into 'sessionK'
+        sessionK = new Object[] { expandedKe, expandedKd };
     }
 
 
--- a/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java	Thu Sep 06 18:07:38 2012 +0100
@@ -926,9 +926,20 @@
                                      int x, int y, int w, int h) {
         // Text is odd in that it uses the TEXT_BACKGROUND vs BACKGROUND.
         JComponent c = context.getComponent();
+        Container container = c.getParent();
+        Container containerParent = null;
         GTKStyle style = (GTKStyle)context.getStyle();
         Region id = context.getRegion();
         int state = context.getComponentState();
+
+        if (c instanceof ListCellRenderer && container != null) {
+            containerParent = container.getParent();
+            if (containerParent instanceof JComboBox
+                    && containerParent.hasFocus()) {
+                state |= SynthConstants.FOCUSED;
+            }
+        }
+
         synchronized (UNIXToolkit.GTK_LOCK) {
             if (ENGINE.paintCachedImage(g, x, y, w, h, id, state)) {
                 return;
@@ -938,9 +949,10 @@
             int focusSize = 0;
             boolean interiorFocus = style.getClassSpecificBoolValue(
                     context, "interior-focus", true);
+
+            focusSize = style.getClassSpecificIntValue(context,
+                    "focus-line-width",1);
             if (!interiorFocus && (state & SynthConstants.FOCUSED) != 0) {
-                focusSize = style.getClassSpecificIntValue(context,
-                        "focus-line-width",1);
                 x += focusSize;
                 y += focusSize;
                 w -= 2 * focusSize;
@@ -961,11 +973,25 @@
                                 h - (2 * yThickness),
                                 ColorType.TEXT_BACKGROUND);
 
-            if (focusSize > 0) {
-                x -= focusSize;
-                y -= focusSize;
-                w += 2 * focusSize;
-                h += 2 * focusSize;
+            if (focusSize > 0 && (state & SynthConstants.FOCUSED) != 0) {
+                if (!interiorFocus) {
+                    x -=  focusSize;
+                    y -=  focusSize;
+                    w +=  2 * focusSize;
+                    h +=  2 * focusSize;
+                } else {
+                    if (containerParent instanceof JComboBox) {
+                        x += (focusSize + 2);
+                        y += (focusSize + 1);
+                        w -= (2 * focusSize + 1);
+                        h -= (2 * focusSize + 2);
+                    } else {
+                        x += focusSize;
+                        y += focusSize;
+                        w -= 2 * focusSize;
+                        h -= 2 * focusSize;
+                    }
+                }
                 ENGINE.paintFocus(g, context, id, gtkState,
                         "entry", x, y, w, h);
             }
--- a/src/share/classes/java/awt/Component.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/java/awt/Component.java	Thu Sep 06 18:07:38 2012 +0100
@@ -150,7 +150,7 @@
  *    import java.awt.event.*;
  *    import java.io.Serializable;
  *
- *    class MyApp java.io.Serializable
+ *    class MyApp implements java.io.Serializable
  *    {
  *         BigObjectThatShouldNotBeSerializedWithAButton bigOne;
  *         Button aButton = new Button();
--- a/src/share/classes/java/beans/Introspector.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/java/beans/Introspector.java	Thu Sep 06 18:07:38 2012 +0100
@@ -1460,7 +1460,7 @@
     private PropertyDescriptor[] properties;
     private int defaultProperty;
     private MethodDescriptor[] methods;
-    private final Reference<BeanInfo> targetBeanInfoRef;
+    private Reference<BeanInfo> targetBeanInfoRef;
 
     public GenericBeanInfo(BeanDescriptor beanDescriptor,
                 EventSetDescriptor[] events, int defaultEvent,
@@ -1472,7 +1472,9 @@
         this.properties = properties;
         this.defaultProperty = defaultProperty;
         this.methods = methods;
-        this.targetBeanInfoRef = new SoftReference<BeanInfo>(targetBeanInfo);
+        this.targetBeanInfoRef = (targetBeanInfo != null)
+                ? new SoftReference<>(targetBeanInfo)
+                : null;
     }
 
     /**
@@ -1539,10 +1541,25 @@
     }
 
     public java.awt.Image getIcon(int iconKind) {
-        BeanInfo targetBeanInfo = this.targetBeanInfoRef.get();
+        BeanInfo targetBeanInfo = getTargetBeanInfo();
         if (targetBeanInfo != null) {
             return targetBeanInfo.getIcon(iconKind);
         }
         return super.getIcon(iconKind);
     }
+
+    private BeanInfo getTargetBeanInfo() {
+        if (this.targetBeanInfoRef == null) {
+            return null;
+        }
+        BeanInfo targetBeanInfo = this.targetBeanInfoRef.get();
+        if (targetBeanInfo == null) {
+            targetBeanInfo = ThreadGroupContext.getContext().getBeanInfoFinder()
+                    .find(this.beanDescriptor.getBeanClass());
+            if (targetBeanInfo != null) {
+                this.targetBeanInfoRef = new SoftReference<>(targetBeanInfo);
+            }
+        }
+        return targetBeanInfo;
+    }
 }
--- a/src/share/classes/java/beans/PropertyDescriptor.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/java/beans/PropertyDescriptor.java	Thu Sep 06 18:07:38 2012 +0100
@@ -109,6 +109,10 @@
         if (writeMethodName != null && getWriteMethod() == null) {
             throw new IntrospectionException("Method not found: " + writeMethodName);
         }
+        boundInitialization(beanClass);
+    }
+
+    private void boundInitialization(Class<?> beanClass) {
         // If this class or one of its base classes allow PropertyChangeListener,
         // then we assume that any properties we discover are "bound".
         // See Introspector.getTargetPropertyInfo() method.
@@ -159,6 +163,7 @@
         setReadMethod(read);
         setWriteMethod(write);
         this.baseName = base;
+        boundInitialization(bean);
     }
 
     /**
@@ -591,7 +596,7 @@
         Method yw = y.getWriteMethod();
 
         try {
-            if (yw != null && yw.getDeclaringClass() == getClass0()) {
+            if (yw != null) {
                 setWriteMethod(yw);
             } else {
                 setWriteMethod(xw);
--- a/src/share/classes/java/beans/XMLEncoder.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/java/beans/XMLEncoder.java	Thu Sep 06 18:07:38 2012 +0100
@@ -631,7 +631,12 @@
         }
 
         if (d.name != null) {
-            outputXML(isArgument ? "object" : "void", " idref=" + quote(d.name), value);
+            if (isArgument) {
+                writeln("<object idref=" + quote(d.name) + "/>");
+            }
+            else {
+                outputXML("void", " idref=" + quote(d.name), value);
+            }
         }
         else if (d.exp != null) {
             outputStatement(d.exp, outer, isArgument);
@@ -710,12 +715,14 @@
         }
         else {
             d.refs = 2;
-            getValueData(target).refs++;
-            List<Statement> statements = statementList(target);
-            if (!statements.contains(exp)) {
-                statements.add(exp);
+            if (d.name == null) {
+                getValueData(target).refs++;
+                List<Statement> statements = statementList(target);
+                if (!statements.contains(exp)) {
+                    statements.add(exp);
+                }
+                outputValue(target, outer, false);
             }
-            outputValue(target, outer, false);
             if (expression) {
                 outputValue(value, outer, isArgument);
             }
--- a/src/share/classes/java/nio/X-Buffer.java.template	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/java/nio/X-Buffer.java.template	Thu Sep 06 18:07:38 2012 +0100
@@ -888,6 +888,8 @@
      */
     public $Type$Buffer put(String src, int start, int end) {
         checkBounds(start, end - start, src.length());
+        if (end - start > remaining())
+            throw new BufferOverflowException();
         for (int i = start; i < end; i++)
             this.put(src.charAt(i));
         return this;
--- a/src/share/classes/java/security/Signature.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/java/security/Signature.java	Thu Sep 06 18:07:38 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, 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
@@ -658,7 +658,7 @@
         throws SignatureException {
         if (state == VERIFY) {
             if ((signature == null) || (offset < 0) || (length < 0) ||
-                (offset + length > signature.length)) {
+                (length > signature.length - offset)) {
                 throw new IllegalArgumentException("Bad arguments");
             }
 
--- a/src/share/classes/java/util/AbstractCollection.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/java/util/AbstractCollection.java	Thu Sep 06 18:07:38 2012 +0100
@@ -180,13 +180,21 @@
 
         for (int i = 0; i < r.length; i++) {
             if (! it.hasNext()) { // fewer elements than expected
-                if (a != r)
+                if (a == r) {
+                    r[i] = null; // null-terminate
+                } else if (a.length < i) {
                     return Arrays.copyOf(r, i);
-                r[i] = null; // null-terminate
-                return r;
+                } else {
+                    System.arraycopy(r, 0, a, 0, i);
+                    if (a.length > i) {
+                        a[i] = null;
+                    }
+                }
+                return a;
             }
             r[i] = (T)it.next();
         }
+        // more elements than expected
         return it.hasNext() ? finishToArray(r, it) : r;
     }
 
--- a/src/share/classes/javax/crypto/CryptoPermissions.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/javax/crypto/CryptoPermissions.java	Thu Sep 06 18:07:38 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, 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
@@ -30,10 +30,16 @@
 import java.util.Hashtable;
 import java.util.Vector;
 import java.util.NoSuchElementException;
+import java.util.concurrent.ConcurrentHashMap;
 import java.io.Serializable;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.BufferedReader;
+import java.io.ObjectStreamField;
+import java.io.ObjectInputStream;
+import java.io.ObjectInputStream.GetField;
+import java.io.ObjectOutputStream;
+import java.io.ObjectOutputStream.PutField;
 import java.io.IOException;
 
 /**
@@ -61,15 +67,24 @@
 
     private static final long serialVersionUID = 4946547168093391015L;
 
-    // This class is similar to java.security.Permissions
-    private Hashtable perms;
+    /**
+     * @serialField perms java.util.Hashtable
+     */
+    private static final ObjectStreamField[] serialPersistentFields = {
+        new ObjectStreamField("perms", Hashtable.class),
+    };
+
+    // Switched from Hashtable to ConcurrentHashMap to improve scalability.
+    // To maintain serialization compatibility, this field is made transient
+    // and custom readObject/writeObject methods are used.
+    private transient ConcurrentHashMap<String,PermissionCollection> perms;
 
     /**
      * Creates a new CryptoPermissions object containing
      * no CryptoPermissionCollections.
      */
     CryptoPermissions() {
-        perms = new Hashtable(7);
+        perms = new ConcurrentHashMap<>(7);
     }
 
     /**
@@ -132,9 +147,7 @@
                         getPermissionCollection(cryptoPerm);
         pc.add(cryptoPerm);
         String alg = cryptoPerm.getAlgorithm();
-        if (!perms.containsKey(alg)) {
-            perms.put(alg, pc);
-        }
+        perms.putIfAbsent(alg, pc);
     }
 
     /**
@@ -382,20 +395,17 @@
     PermissionCollection getPermissionCollection(String alg) {
         // If this CryptoPermissions includes CryptoAllPermission,
         // we should return CryptoAllPermission.
-        if (perms.containsKey(CryptoAllPermission.ALG_NAME)) {
-            return
-                (PermissionCollection)(perms.get(CryptoAllPermission.ALG_NAME));
-        }
+        PermissionCollection pc = perms.get(CryptoAllPermission.ALG_NAME);
+        if (pc == null) {
+            pc = perms.get(alg);
 
-        PermissionCollection pc = (PermissionCollection)perms.get(alg);
-
-        // If there isn't a PermissionCollection for
-        // the given algorithm,we should return the
-        // PermissionCollection for the wildcard
-        // if there is one.
-        if (pc == null) {
-            pc = (PermissionCollection)perms.get(
-                                       CryptoPermission.ALG_NAME_WILDCARD);
+            // If there isn't a PermissionCollection for
+            // the given algorithm,we should return the
+            // PermissionCollection for the wildcard
+            // if there is one.
+            if (pc == null) {
+                pc = perms.get(CryptoPermission.ALG_NAME_WILDCARD);
+            }
         }
         return pc;
     }
@@ -421,6 +431,28 @@
         }
         return pc;
     }
+
+    private void readObject(ObjectInputStream s)
+        throws IOException, ClassNotFoundException {
+        ObjectInputStream.GetField fields = s.readFields();
+        @SuppressWarnings("unchecked")
+        Hashtable<String,PermissionCollection> permTable =
+                (Hashtable<String,PermissionCollection>)
+                (fields.get("perms", null));
+        if (permTable != null) {
+            perms = new ConcurrentHashMap<>(permTable);
+        } else {
+            perms = new ConcurrentHashMap<>();
+        }
+    }
+
+    private void writeObject(ObjectOutputStream s) throws IOException {
+        Hashtable<String,PermissionCollection> permTable =
+                new Hashtable<>(perms);
+        ObjectOutputStream.PutField fields = s.putFields();
+        fields.put("perms", permTable);
+        s.writeFields();
+    }
 }
 
 final class PermissionsEnumerator implements Enumeration {
@@ -463,7 +495,6 @@
         } else {
             throw new NoSuchElementException("PermissionsEnumerator");
         }
-
     }
 
     private Enumeration getNextEnumWithMore() {
--- a/src/share/classes/javax/crypto/JceSecurityManager.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/javax/crypto/JceSecurityManager.java	Thu Sep 06 18:07:38 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, 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
@@ -29,6 +29,8 @@
 import java.net.*;
 import java.util.*;
 import java.util.jar.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 /**
  * The JCE security manager.
@@ -51,7 +53,10 @@
     private static final CryptoPermissions exemptPolicy;
     private static final CryptoAllPermission allPerm;
     private static final Vector TrustedCallersCache = new Vector(2);
-    private static final Map exemptCache = new HashMap();
+    private static final ConcurrentMap<URL,CryptoPermissions> exemptCache =
+            new ConcurrentHashMap<>();
+    private static final CryptoPermissions CACHE_NULL_MARK =
+            new CryptoPermissions();
 
     // singleton instance
     static final JceSecurityManager INSTANCE;
@@ -116,17 +121,19 @@
             return defaultPerm;
         }
 
-        CryptoPermissions appPerms;
-        synchronized (this.getClass()) {
-            if (exemptCache.containsKey(callerCodeBase)) {
-                appPerms = (CryptoPermissions)exemptCache.get(callerCodeBase);
-            } else {
-                appPerms = getAppPermissions(callerCodeBase);
-                exemptCache.put(callerCodeBase, appPerms);
+        CryptoPermissions appPerms = exemptCache.get(callerCodeBase);
+        if (appPerms == null) {
+            // no match found in cache
+            synchronized (this.getClass()) {
+                appPerms = exemptCache.get(callerCodeBase);
+                if (appPerms == null) {
+                    appPerms = getAppPermissions(callerCodeBase);
+                    exemptCache.putIfAbsent(callerCodeBase,
+                        (appPerms == null? CACHE_NULL_MARK:appPerms));
+                }
             }
         }
-
-        if (appPerms == null) {
+        if (appPerms == null || appPerms == CACHE_NULL_MARK) {
             return defaultPerm;
         }
 
--- a/src/share/classes/javax/swing/JTable.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/classes/javax/swing/JTable.java	Thu Sep 06 18:07:38 2012 +0100
@@ -5468,7 +5468,7 @@
                 if (constructor.getDeclaringClass() == String.class) {
                     value = s;
                 }
-                super.stopCellEditing();
+                return super.stopCellEditing();
             }
 
             try {
--- a/src/share/demo/management/MemoryMonitor/README.txt	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/share/demo/management/MemoryMonitor/README.txt	Thu Sep 06 18:07:38 2012 +0100
@@ -38,7 +38,7 @@
 
 To run the MemoryMonitor demo
 
-   java -jar <JDK_HOME>/demo/management/MemoryMonitor.jar 
+   java -jar <JDK_HOME>/demo/management/MemoryMonitor/MemoryMonitor.jar 
 
 These instructions assume that this installation's version of the java
 command is in your path.  If it isn't, then you should either
--- a/src/solaris/classes/sun/awt/X11/XLabelPeer.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/awt/X11/XLabelPeer.java	Thu Sep 06 18:07:38 2012 +0100
@@ -140,7 +140,7 @@
     }
     public void setFont(Font f) {
         super.setFont(f);
-        target.repaint();
+        repaint();
     }
 
     public void setAlignment(int align) {
--- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Thu Sep 06 18:07:38 2012 +0100
@@ -1164,15 +1164,25 @@
     }
 
     public void dispose() {
+        if (isGrabbed()) {
+            if (grabLog.isLoggable(PlatformLogger.FINE)) {
+                grabLog.fine("Generating UngrabEvent on {0} because of the window disposal", this);
+            }
+            postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource()));
+        }
+
         SunToolkit.awtLock();
+
         try {
             windows.remove(this);
         } finally {
             SunToolkit.awtUnlock();
         }
+
         if (warningWindow != null) {
             warningWindow.destroy();
         }
+
         removeRootPropertyEventDispatcher();
         mustControlStackPosition = false;
         super.dispose();
@@ -1190,6 +1200,7 @@
             }
         }
     }
+
     boolean isResizable() {
         return winAttr.isResizable;
     }
--- a/src/solaris/classes/sun/nio/fs/DefaultFileTypeDetector.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/nio/fs/DefaultFileTypeDetector.java	Thu Sep 06 18:07:38 2012 +0100
@@ -25,12 +25,15 @@
 
 package sun.nio.fs;
 
+import java.nio.file.FileSystems;
 import java.nio.file.spi.FileTypeDetector;
+import java.nio.file.spi.FileSystemProvider;
 
 public class DefaultFileTypeDetector {
     private DefaultFileTypeDetector() { }
 
     public static FileTypeDetector create() {
-        return new GnomeFileTypeDetector();
+        FileSystemProvider provider = FileSystems.getDefault().provider();
+        return ((UnixFileSystemProvider)provider).getFileTypeDetector();
     }
 }
--- a/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/nio/fs/LinuxFileSystem.java	Thu Sep 06 18:07:38 2012 +0100
@@ -82,7 +82,7 @@
             try {
                 for (;;) {
                     UnixMountEntry entry = new UnixMountEntry();
-                    int res = getextmntent(fp, entry);
+                    int res = getmntent(fp, entry);
                     if (res < 0)
                         break;
                     entries.add(entry);
--- a/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java	Thu Sep 06 18:07:38 2012 +0100
@@ -27,6 +27,7 @@
 
 import java.nio.file.*;
 import java.nio.file.attribute.*;
+import java.nio.file.spi.FileTypeDetector;
 import java.io.IOException;
 
 /**
@@ -96,4 +97,9 @@
             return super.readAttributes(file, type, options);
         }
     }
+
+    @Override
+    FileTypeDetector getFileTypeDetector() {
+        return new GnomeFileTypeDetector();
+    }
 }
--- a/src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/nio/fs/LinuxNativeDispatcher.java	Thu Sep 06 18:07:38 2012 +0100
@@ -51,9 +51,15 @@
     private static native long setmntent0(long pathAddress, long typeAddress)
         throws UnixException;
 
-   /**
-    * int endmntent(FILE* filep);
-    */
+    /**
+     * int getmntent(FILE *fp, struct mnttab *mp, int len);
+     */
+    static native int getmntent(long fp, UnixMountEntry entry)
+        throws UnixException;
+
+    /**
+     * int endmntent(FILE* filep);
+     */
     static native void endmntent(long stream) throws UnixException;
 
     /**
@@ -90,7 +96,6 @@
     private static native void fsetxattr0(int filedes, long nameAddress,
         long valueAdddress, int valueLen) throws UnixException;
 
-
     /**
      * fremovexattr(int filedes, const char *name);
      */
--- a/src/solaris/classes/sun/nio/fs/SolarisFileSystem.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/nio/fs/SolarisFileSystem.java	Thu Sep 06 18:07:38 2012 +0100
@@ -30,7 +30,7 @@
 import java.util.*;
 import java.security.AccessController;
 import sun.security.action.GetPropertyAction;
-import static sun.nio.fs.UnixNativeDispatcher.*;
+import static sun.nio.fs.SolarisNativeDispatcher.*;
 
 /**
  * Solaris implementation of FileSystem
--- a/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java	Thu Sep 06 18:07:38 2012 +0100
@@ -27,6 +27,7 @@
 
 import java.nio.file.*;
 import java.nio.file.attribute.*;
+import java.nio.file.spi.FileTypeDetector;
 import java.io.IOException;
 
 /**
@@ -79,4 +80,9 @@
                                                            Util.followLinks(options));
         return super.getFileAttributeView(obj, name, options);
     }
+
+    @Override
+    FileTypeDetector getFileTypeDetector() {
+        return new GnomeFileTypeDetector();
+    }
 }
--- a/src/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/nio/fs/SolarisNativeDispatcher.java	Thu Sep 06 18:07:38 2012 +0100
@@ -36,6 +36,12 @@
     private SolarisNativeDispatcher() { }
 
     /**
+     * int getextmntent(FILE *fp, struct extmnttab *mp, int len);
+     */
+    static native int getextmntent(long fp, UnixMountEntry entry)
+        throws UnixException;
+
+    /**
      * int facl(int filedes, int cmd, int nentries, void aclbufp)
      */
     static native int facl(int fd, int cmd, int nentries, long aclbufp)
--- a/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java	Thu Sep 06 18:07:38 2012 +0100
@@ -27,6 +27,7 @@
 
 import java.nio.file.*;
 import java.nio.file.attribute.*;
+import java.nio.file.spi.FileTypeDetector;
 import java.nio.channels.*;
 import java.net.URI;
 import java.util.concurrent.ExecutorService;
@@ -495,4 +496,17 @@
             return null;    // keep compiler happy
         }
     }
+
+    /**
+     * Returns a {@code FileTypeDetector} for this platform.
+     */
+    FileTypeDetector getFileTypeDetector() {
+        return new AbstractFileTypeDetector() {
+            @Override
+            public String implProbeContentType(Path file) {
+                return null;
+            }
+        };
+    }
+
 }
--- a/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/classes/sun/nio/fs/UnixNativeDispatcher.java	Thu Sep 06 18:07:38 2012 +0100
@@ -498,11 +498,6 @@
     private static native int getgrnam0(long nameAddress) throws UnixException;
 
     /**
-     * int getextmntent(FILE *fp, struct extmnttab *mp, int len);
-     */
-    static native int getextmntent(long fp, UnixMountEntry entry) throws UnixException;
-
-    /**
      * statvfs(const char* path, struct statvfs *buf)
      */
     static void statvfs(UnixPath path, UnixFileStoreAttributes attrs)
--- a/src/solaris/native/sun/awt/fontpath.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/awt/fontpath.c	Thu Sep 06 18:07:38 2012 +0100
@@ -583,9 +583,6 @@
 }
 
 #include <dlfcn.h>
-#if !(defined(__linux__) || defined(MACOSX))
-#include <link.h>
-#endif
 
 #include "fontconfig.h"
 
--- a/src/solaris/native/sun/java2d/opengl/OGLFuncs_md.h	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/java2d/opengl/OGLFuncs_md.h	Thu Sep 06 18:07:38 2012 +0100
@@ -28,7 +28,7 @@
 
 #include <stdlib.h>
 #ifndef MACOSX
-#include <link.h>
+#include <dlfcn.h>
 #endif
 #include "jvm_md.h"
 #include "J2D_GL/glx.h"
--- a/src/solaris/native/sun/java2d/x11/XRBackendNative.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/java2d/x11/XRBackendNative.c	Thu Sep 06 18:07:38 2012 +0100
@@ -70,7 +70,6 @@
 
 #ifdef __solaris__
 /* Solaris 10 will not have these symbols at runtime */
-#include <link.h>
 
 typedef Picture (*XRenderCreateLinearGradientFuncType)
                                      (Display *dpy,
--- a/src/solaris/native/sun/nio/ch/DatagramDispatcher.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/nio/ch/DatagramDispatcher.c	Thu Sep 06 18:07:38 2012 +0100
@@ -34,6 +34,7 @@
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <sys/socket.h>
+#include <string.h>
 
 #include "nio_util.h"
 #include <limits.h>
--- a/src/solaris/native/sun/nio/ch/Net.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/nio/ch/Net.c	Thu Sep 06 18:07:38 2012 +0100
@@ -39,83 +39,6 @@
 #include "nio_util.h"
 #include "nio.h"
 
-/**
- * Definitions for source-specific multicast to allow for building
- * with older header files.
- */
-
-#ifdef __solaris__
-
-#ifndef IP_BLOCK_SOURCE
-
-#define IP_BLOCK_SOURCE                 0x15
-#define IP_UNBLOCK_SOURCE               0x16
-#define IP_ADD_SOURCE_MEMBERSHIP        0x17
-#define IP_DROP_SOURCE_MEMBERSHIP       0x18
-
-#define MCAST_BLOCK_SOURCE              0x2b
-#define MCAST_UNBLOCK_SOURCE            0x2c
-#define MCAST_JOIN_SOURCE_GROUP         0x2d
-#define MCAST_LEAVE_SOURCE_GROUP        0x2e
-
-#endif  /* IP_BLOCK_SOURCE */
-
-struct my_ip_mreq_source {
-        struct in_addr  imr_multiaddr;
-        struct in_addr  imr_sourceaddr;
-        struct in_addr  imr_interface;
-};
-
-/*
- * Use #pragma pack() construct to force 32-bit alignment on amd64.
- */
-#if defined(amd64)
-#pragma pack(4)
-#endif
-
-struct my_group_source_req {
-        uint32_t                gsr_interface;  /* interface index */
-        struct sockaddr_storage gsr_group;      /* group address */
-        struct sockaddr_storage gsr_source;     /* source address */
-};
-
-#if defined(amd64)
-#pragma pack()
-#endif
-
-#endif  /* __solaris__ */
-
-
-#ifdef __linux__
-
-#ifndef IP_BLOCK_SOURCE
-
-#define IP_BLOCK_SOURCE                 38
-#define IP_UNBLOCK_SOURCE               37
-#define IP_ADD_SOURCE_MEMBERSHIP        39
-#define IP_DROP_SOURCE_MEMBERSHIP       40
-
-#define MCAST_BLOCK_SOURCE              43
-#define MCAST_UNBLOCK_SOURCE            44
-#define MCAST_JOIN_SOURCE_GROUP         42
-#define MCAST_LEAVE_SOURCE_GROUP        45
-
-#endif  /* IP_BLOCK_SOURCE */
-
-struct my_ip_mreq_source {
-        struct in_addr  imr_multiaddr;
-        struct in_addr  imr_interface;
-        struct in_addr  imr_sourceaddr;
-};
-
-struct my_group_source_req {
-        uint32_t                gsr_interface;  /* interface index */
-        struct sockaddr_storage gsr_group;      /* group address */
-        struct sockaddr_storage gsr_source;     /* source address */
-};
-
-#endif   /* __linux__ */
-
 #ifdef _ALLBSD_SOURCE
 
 #ifndef IP_BLOCK_SOURCE
@@ -155,7 +78,12 @@
         struct sockaddr_storage gsr_source;     /* source address */
 };
 
-#endif   /* _ALLBSD_SOURCE */
+#else   /* _ALLBSD_SOURCE */
+
+#define my_ip_mreq_source         ip_mreq_source
+#define my_group_source_req       group_source_req
+
+#endif
 
 
 #define COPY_INET6_ADDRESS(env, source, target) \
@@ -576,8 +504,8 @@
         optval = (void*)&mreq6;
         optlen = sizeof(mreq6);
     } else {
-#if defined (__linux__) || defined(MACOSX)
-        /* Include-mode filtering broken on Mac OS & Linux at least to 2.6.24 */
+#ifdef MACOSX
+        /* no IPv6 include-mode filtering for now */
         return IOS_UNAVAILABLE;
 #else
         initGroupSourceReq(env, group, index, source, &req);
--- a/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c	Thu Sep 06 18:07:38 2012 +0100
@@ -46,8 +46,6 @@
 static jfieldID entry_dir;
 static jfieldID entry_fstype;
 static jfieldID entry_options;
-static jfieldID entry_dev;
-
 
 struct fsstat_iter {
     struct statfs *buf;
@@ -81,7 +79,6 @@
     entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B");
     entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B");
     entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
-    entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J");
 }
 
 JNIEXPORT jlong JNICALL
@@ -160,7 +157,6 @@
         options="ro";
     else
         options="";
-    dev = 0;
 
     iter->pos++;
 
@@ -192,9 +188,6 @@
     (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)options);
     (*env)->SetObjectField(env, entry, entry_options, bytes);
 
-    if (dev != 0)
-        (*env)->SetLongField(env, entry, entry_dev, (jlong)dev);
-
     return 0;
 }
 
@@ -208,3 +201,4 @@
         free(iter);
     }
 }
+
--- a/src/solaris/native/sun/nio/fs/GnomeFileTypeDetector.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/nio/fs/GnomeFileTypeDetector.c	Thu Sep 06 18:07:38 2012 +0100
@@ -30,15 +30,12 @@
 
 #include <stdlib.h>
 #include <dlfcn.h>
-#ifndef __APPLE__
-#include <link.h>
-#endif
 
 #ifdef __solaris__
 #include <strings.h>
 #endif
 
-#if defined(__linux__) || defined(__APPLE__)
+#if defined(__linux__)
 #include <string.h>
 #endif
 
--- a/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c	Thu Sep 06 18:07:38 2012 +0100
@@ -29,6 +29,7 @@
 #include "jlong.h"
 
 #include <stdio.h>
+#include <string.h>
 #include <dlfcn.h>
 #include <errno.h>
 #include <mntent.h>
@@ -45,6 +46,11 @@
 fremovexattr_func* my_fremovexattr_func = NULL;
 flistxattr_func* my_flistxattr_func = NULL;
 
+static jfieldID entry_name;
+static jfieldID entry_dir;
+static jfieldID entry_fstype;
+static jfieldID entry_options;
+
 static void throwUnixException(JNIEnv* env, int errnum) {
     jobject x = JNU_NewObjectByName(env, "sun/nio/fs/UnixException",
         "(I)V", errnum);
@@ -60,6 +66,15 @@
     my_fsetxattr_func = (fsetxattr_func*)dlsym(RTLD_DEFAULT, "fsetxattr");
     my_fremovexattr_func = (fremovexattr_func*)dlsym(RTLD_DEFAULT, "fremovexattr");
     my_flistxattr_func = (flistxattr_func*)dlsym(RTLD_DEFAULT, "flistxattr");
+
+    clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry");
+    if (clazz == NULL)
+        return;
+
+    entry_name = (*env)->GetFieldID(env, clazz, "name", "[B");
+    entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B");
+    entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B");
+    entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
 }
 
 JNIEXPORT jint JNICALL
@@ -151,6 +166,61 @@
     return ptr_to_jlong(fp);
 }
 
+JNIEXPORT jint JNICALL
+Java_sun_nio_fs_LinuxNativeDispatcher_getmntent(JNIEnv* env, jclass this,
+    jlong value, jobject entry)
+{
+    struct mntent ent;
+    char buf[1024];
+    int buflen = sizeof(buf);
+    struct mntent* m;
+    FILE* fp = jlong_to_ptr(value);
+    jsize len;
+    jbyteArray bytes;
+    char* name;
+    char* dir;
+    char* fstype;
+    char* options;
+
+    m = getmntent_r(fp, &ent, (char*)&buf, buflen);
+    if (m == NULL)
+        return -1;
+    name = m->mnt_fsname;
+    dir = m->mnt_dir;
+    fstype = m->mnt_type;
+    options = m->mnt_opts;
+
+    len = strlen(name);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)name);
+    (*env)->SetObjectField(env, entry, entry_name, bytes);
+
+    len = strlen(dir);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)dir);
+    (*env)->SetObjectField(env, entry, entry_dir, bytes);
+
+    len = strlen(fstype);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)fstype);
+    (*env)->SetObjectField(env, entry, entry_fstype, bytes);
+
+    len = strlen(options);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)options);
+    (*env)->SetObjectField(env, entry, entry_options, bytes);
+
+    return 0;
+}
+
 JNIEXPORT void JNICALL
 Java_sun_nio_fs_LinuxNativeDispatcher_endmntent(JNIEnv* env, jclass this, jlong stream)
 {
--- a/src/solaris/native/sun/nio/fs/SolarisNativeDispatcher.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/nio/fs/SolarisNativeDispatcher.c	Thu Sep 06 18:07:38 2012 +0100
@@ -28,12 +28,22 @@
 #include "jvm.h"
 #include "jlong.h"
 
-#include <dlfcn.h>
+#include <strings.h>
 #include <errno.h>
 #include <sys/acl.h>
+#include <sys/mnttab.h>
+#include <sys/mkdev.h>
+
+#include "jni.h"
 
 #include "sun_nio_fs_SolarisNativeDispatcher.h"
 
+static jfieldID entry_name;
+static jfieldID entry_dir;
+static jfieldID entry_fstype;
+static jfieldID entry_options;
+static jfieldID entry_dev;
+
 static void throwUnixException(JNIEnv* env, int errnum) {
     jobject x = JNU_NewObjectByName(env, "sun/nio/fs/UnixException",
         "(I)V", errnum);
@@ -44,6 +54,15 @@
 
 JNIEXPORT void JNICALL
 Java_sun_nio_fs_SolarisNativeDispatcher_init(JNIEnv *env, jclass clazz) {
+    clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry");
+    if (clazz == NULL)
+        return;
+
+    entry_name = (*env)->GetFieldID(env, clazz, "name", "[B");
+    entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B");
+    entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B");
+    entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B");
+    entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J");
 }
 
 JNIEXPORT jint JNICALL
@@ -59,3 +78,63 @@
     }
     return (jint)n;
 }
+
+JNIEXPORT jint JNICALL
+Java_sun_nio_fs_SolarisNativeDispatcher_getextmntent(JNIEnv* env, jclass this,
+    jlong value, jobject entry)
+{
+    struct extmnttab ent;
+    FILE* fp = jlong_to_ptr(value);
+    jsize len;
+    jbyteArray bytes;
+    char* name;
+    char* dir;
+    char* fstype;
+    char* options;
+    dev_t dev;
+
+    if (getextmntent(fp, &ent, 0))
+        return -1;
+    name = ent.mnt_special;
+    dir = ent.mnt_mountp;
+    fstype = ent.mnt_fstype;
+    options = ent.mnt_mntopts;
+    dev = makedev(ent.mnt_major, ent.mnt_minor);
+    if (dev == NODEV) {
+        throwUnixException(env, errno);
+        return -1;
+    }
+
+    len = strlen(name);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)name);
+    (*env)->SetObjectField(env, entry, entry_name, bytes);
+
+    len = strlen(dir);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)dir);
+    (*env)->SetObjectField(env, entry, entry_dir, bytes);
+
+    len = strlen(fstype);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)fstype);
+    (*env)->SetObjectField(env, entry, entry_fstype, bytes);
+
+    len = strlen(options);
+    bytes = (*env)->NewByteArray(env, len);
+    if (bytes == NULL)
+        return -1;
+    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)options);
+    (*env)->SetObjectField(env, entry, entry_options, bytes);
+
+    if (dev != 0)
+        (*env)->SetLongField(env, entry, entry_dev, (jlong)dev);
+
+    return 0;
+}
--- a/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Thu Sep 06 18:07:38 2012 +0100
@@ -40,13 +40,10 @@
 
 #ifdef __solaris__
 #include <strings.h>
-#include <sys/mnttab.h>
-#include <sys/mkdev.h>
 #endif
 
 #ifdef __linux__
 #include <string.h>
-#include <mntent.h>
 #endif
 
 #ifdef _ALLBSD_SOURCE
@@ -1018,7 +1015,7 @@
 
         if (res != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') {
             /* not found or error */
-            if (errno != 0 && errno != ENOENT)
+            if (errno != 0 && errno != ENOENT && errno != ESRCH)
                 throwUnixException(env, errno);
         } else {
             uid = p->pw_uid;
@@ -1064,7 +1061,7 @@
         retry = 0;
         if (res != 0 || g == NULL || g->gr_name == NULL || *(g->gr_name) == '\0') {
             /* not found or error */
-            if (errno != 0 && errno != ENOENT) {
+            if (errno != 0 && errno != ENOENT && errno != ESRCH) {
                 if (errno == ERANGE) {
                     /* insufficient buffer size so need larger buffer */
                     buflen += ENT_BUF_SIZE;
@@ -1083,105 +1080,3 @@
 
     return gid;
 }
-
-JNIEXPORT jint JNICALL
-Java_sun_nio_fs_UnixNativeDispatcher_getextmntent(JNIEnv* env, jclass this,
-    jlong value, jobject entry)
-{
-#ifdef __solaris__
-    struct extmnttab ent;
-#elif defined(_ALLBSD_SOURCE)
-    char buf[1024];
-    char *str;
-    char *last;
-#else
-    struct mntent ent;
-    char buf[1024];
-    int buflen = sizeof(buf);
-    struct mntent* m;
-#endif
-    FILE* fp = jlong_to_ptr(value);
-    jsize len;
-    jbyteArray bytes;
-    char* name;
-    char* dir;
-    char* fstype;
-    char* options;
-    dev_t dev;
-
-#ifdef __solaris__
-    if (getextmntent(fp, &ent, 0))
-        return -1;
-    name = ent.mnt_special;
-    dir = ent.mnt_mountp;
-    fstype = ent.mnt_fstype;
-    options = ent.mnt_mntopts;
-    dev = makedev(ent.mnt_major, ent.mnt_minor);
-    if (dev == NODEV) {
-        /* possible bug on Solaris 8 and 9 */
-        throwUnixException(env, errno);
-        return -1;
-    }
-#elif defined(_ALLBSD_SOURCE)
-again:
-    if (!(str = fgets(buf, sizeof(buf), fp)))
-        return -1;
-
-    name = strtok_r(str, " \t\n", &last);
-    if (name == NULL)
-        return -1;
-
-    // skip comments
-    if (*name == '#')
-        goto again;
-
-    dir = strtok_r((char *)NULL, " \t\n", &last);
-    fstype = strtok_r((char *)NULL, " \t\n", &last);
-    options = strtok_r((char *)NULL, " \t\n", &last);
-    if (options == NULL)
-        return -1;
-    dev = 0;
-#else
-    m = getmntent_r(fp, &ent, (char*)&buf, buflen);
-    if (m == NULL)
-        return -1;
-    name = m->mnt_fsname;
-    dir = m->mnt_dir;
-    fstype = m->mnt_type;
-    options = m->mnt_opts;
-    dev = 0;
-#endif
-
-    len = strlen(name);
-    bytes = (*env)->NewByteArray(env, len);
-    if (bytes == NULL)
-        return -1;
-    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)name);
-    (*env)->SetObjectField(env, entry, entry_name, bytes);
-
-    len = strlen(dir);
-    bytes = (*env)->NewByteArray(env, len);
-    if (bytes == NULL)
-        return -1;
-    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)dir);
-    (*env)->SetObjectField(env, entry, entry_dir, bytes);
-
-    len = strlen(fstype);
-    bytes = (*env)->NewByteArray(env, len);
-    if (bytes == NULL)
-        return -1;
-    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)fstype);
-    (*env)->SetObjectField(env, entry, entry_fstype, bytes);
-
-    len = strlen(options);
-    bytes = (*env)->NewByteArray(env, len);
-    if (bytes == NULL)
-        return -1;
-    (*env)->SetByteArrayRegion(env, bytes, 0, len, (jbyte*)options);
-    (*env)->SetObjectField(env, entry, entry_options, bytes);
-
-    if (dev != 0)
-        (*env)->SetLongField(env, entry, entry_dev, (jlong)dev);
-
-    return 0;
-}
--- a/src/solaris/native/sun/security/jgss/wrapper/NativeFunc.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/security/jgss/wrapper/NativeFunc.c	Thu Sep 06 18:07:38 2012 +0100
@@ -26,9 +26,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <dlfcn.h>
-#ifndef __APPLE__
-#include <link.h>
-#endif
 #include "NativeFunc.h"
 
 /* standard GSS method names (ordering is from mapfile) */
--- a/src/solaris/native/sun/security/pkcs11/j2secmod_md.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/security/pkcs11/j2secmod_md.c	Thu Sep 06 18:07:38 2012 +0100
@@ -28,9 +28,6 @@
 #include <string.h>
 
 #include <dlfcn.h>
-#ifndef __APPLE__
-#include <link.h>
-#endif
 
 #include <jni_util.h>
 
--- a/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/security/pkcs11/wrapper/p11_md.c	Thu Sep 06 18:07:38 2012 +0100
@@ -64,9 +64,6 @@
 #include <assert.h>
 
 #include <dlfcn.h>
-#ifndef __APPLE__
-#include <link.h>
-#endif
 
 #include <jni.h>
 
--- a/src/solaris/native/sun/security/smartcardio/pcsc_md.c	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/native/sun/security/smartcardio/pcsc_md.c	Thu Sep 06 18:07:38 2012 +0100
@@ -29,9 +29,6 @@
 #include <assert.h>
 
 #include <dlfcn.h>
-#ifndef __APPLE__
-#include <link.h>
-#endif
 
 #include <winscard.h>
 
--- a/src/solaris/npt/npt_md.h	Thu Aug 23 13:07:08 2012 +0100
+++ b/src/solaris/npt/npt_md.h	Thu Sep 06 18:07:38 2012 +0100
@@ -32,9 +32,6 @@
 #include <string.h>
 #include <errno.h>
 #include <dlfcn.h>
-#ifndef __APPLE__
-#include <link.h>
-#endif
 #include <jvm_md.h>
 
 #define NPT_LIBNAME "npt"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Frame/ResizeAfterSetFont/ResizeAfterSetFont.java	Thu Sep 06 18:07:38 2012 +0100
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2012 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.
+ */
+
+/*
+ * Portions Copyright (c) 2012 IBM Corporation
+ */
+
+/*
+ @test
+ @bug 7170655
+ @summary Frame size does not change after changing font
+ @author Jonathan Lu
+ @library ../../regtesthelpers
+ @build Util
+ @run main ResizeAfterSetFont
+ */
+
+import java.awt.*;
+import test.java.awt.regtesthelpers.Util;
+
+public class ResizeAfterSetFont {
+
+    public static void main(String[] args) throws Exception {
+        Frame frame = new Frame("bug7170655");
+        frame.setLayout(new BorderLayout());
+        frame.setBackground(Color.LIGHT_GRAY);
+
+        Panel panel = new Panel();
+        panel.setLayout(new GridLayout(0, 1, 1, 1));
+
+        Label label = new Label("Test Label");
+        label.setBackground(Color.white);
+        label.setForeground(Color.RED);
+        label.setFont(new Font("Dialog", Font.PLAIN, 12));
+
+        panel.add(label);
+        frame.add(panel, "South");
+        frame.pack();
+        frame.setVisible(true);
+
+        Util.waitForIdle(null);
+
+        Dimension dimBefore = frame.getSize();
+        label.setFont(new Font("Dialog", Font.PLAIN, 24));
+
+        frame.validate();
+        frame.pack();
+        Dimension dimAfter = frame.getSize();
+
+        if (dimBefore.equals(dimAfter)) {
+            throw new Exception(
+                    "Frame size does not change after Label.setFont()!");
+        }
+    }
+}
--- a/test/java/awt/Mouse/EnterExitEvents/DragWindowTest.java	Thu Aug 23 13:07:08 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,219 +0,0 @@
-/*
- * Copyright (c) 2005, 2006, 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 7154048
- * @summary Window created under a mouse does not receive mouse enter event.
- *     Mouse Entered/Exited events are wrongly generated during dragging the window
- *     from one component to another
- * @library ../../regtesthelpers
- * @build Util
- * @author alexandr.scherbatiy area=awt.event
- * @run main DragWindowTest
- */
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-import java.util.concurrent.*;
-import sun.awt.SunToolkit;
-
-import test.java.awt.regtesthelpers.Util;
-
-public class DragWindowTest {
-
-    private static volatile int dragWindowMouseEnteredCount = 0;
-    private static volatile int dragWindowMouseReleasedCount = 0;
-    private static volatile int buttonMouseEnteredCount = 0;
-    private static volatile int labelMouseReleasedCount = 0;
-    private static MyDragWindow dragWindow;
-    private static JLabel label;
-    private static JButton button;
-
-    public static void main(String[] args) throws Exception {
-
-        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
-        Robot robot = new Robot();
-        robot.setAutoDelay(50);
-
-        SwingUtilities.invokeAndWait(new Runnable() {
-
-            @Override
-            public void run() {
-                createAndShowGUI();
-            }
-        });
-
-        toolkit.realSync();
-
-        Point pointToClick = Util.invokeOnEDT(new Callable<Point>() {
-
-            @Override
-            public Point call() throws Exception {
-                return getCenterPoint(label);
-            }
-        });
-
-
-        robot.mouseMove(pointToClick.x, pointToClick.y);
-        robot.mousePress(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
-
-        if (dragWindowMouseEnteredCount != 1) {
-            throw new RuntimeException("No MouseEntered event on Drag Window!");
-        }
-
-        Point pointToDrag = Util.invokeOnEDT(new Callable<Point>() {
-
-            @Override
-            public Point call() throws Exception {
-                button.addMouseListener(new ButtonMouseListener());
-                return getCenterPoint(button);
-            }
-        });
-
-        robot.mouseMove(pointToDrag.x, pointToDrag.y);
-        toolkit.realSync();
-
-        if (buttonMouseEnteredCount != 0) {
-            throw new RuntimeException("Extra MouseEntered event on button!");
-        }
-
-        robot.mouseRelease(InputEvent.BUTTON1_MASK);
-        toolkit.realSync();
-
-        if (labelMouseReleasedCount != 1) {
-            throw new RuntimeException("No MouseReleased event on label!");
-        }
-
-    }
-
-    private static Point getCenterPoint(Component comp) {
-        Point p = comp.getLocationOnScreen();
-        Rectangle rect = comp.getBounds();
-        return new Point(p.x + rect.width / 2, p.y + rect.height / 2);
-    }
-
-    private static void createAndShowGUI() {
-
-        JFrame frame = new JFrame("Main Frame");
-        frame.setSize(300, 200);
-        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
-        label = new JLabel("Label");
-
-        LabelMouseListener listener = new LabelMouseListener(frame);
-        label.addMouseListener(listener);
-        label.addMouseMotionListener(listener);
-
-        button = new JButton("Button");
-        Panel panel = new Panel(new BorderLayout());
-
-        panel.add(label, BorderLayout.NORTH);
-        panel.add(button, BorderLayout.CENTER);
-
-        frame.getContentPane().add(panel);
-        frame.setVisible(true);
-
-    }
-
-    private static Point getAbsoluteLocation(MouseEvent e) {
-        return new Point(e.getXOnScreen(), e.getYOnScreen());
-    }
-
-    static class MyDragWindow extends Window {
-
-        static int d = 30;
-
-        public MyDragWindow(Window parent, Point location) {
-            super(parent);
-            setSize(150, 150);
-            setVisible(true);
-            JPanel panel = new JPanel();
-            add(panel);
-            setLocation(location.x - d, location.y - d);
-            addMouseListener(new DragWindowMouseListener());
-        }
-
-        void dragTo(Point point) {
-            setLocation(point.x - d, point.y - d);
-        }
-    }
-
-    static class LabelMouseListener extends MouseAdapter {
-
-        Point origin;
-        Window parent;
-
-        public LabelMouseListener(Window parent) {
-            this.parent = parent;
-        }
-
-        @Override
-        public void mousePressed(MouseEvent e) {
-            if (dragWindow == null) {
-                dragWindow = new MyDragWindow(parent, getAbsoluteLocation(e));
-            } else {
-                dragWindow.setVisible(true);
-                dragWindow.dragTo(getAbsoluteLocation(e));
-            }
-        }
-
-        @Override
-        public void mouseReleased(MouseEvent e) {
-            labelMouseReleasedCount++;
-            if (dragWindow != null) {
-                dragWindow.setVisible(false);
-            }
-        }
-
-        public void mouseDragged(MouseEvent e) {
-            if (dragWindow != null) {
-                dragWindow.dragTo(getAbsoluteLocation(e));
-            }
-        }
-    }
-
-    static class DragWindowMouseListener extends MouseAdapter {
-
-        @Override
-        public void mouseEntered(MouseEvent e) {
-            dragWindowMouseEnteredCount++;
-        }
-
-        @Override
-        public void mouseReleased(MouseEvent e) {
-            dragWindowMouseReleasedCount++;
-        }
-    }
-
-    static class ButtonMouseListener extends MouseAdapter {
-
-        @Override
-        public void mouseEntered(MouseEvent e) {
-            buttonMouseEnteredCount++;
-        }
-    }
-}
--- a/test/java/beans/Introspector/6380849/TestBeanInfo.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/beans/Introspector/6380849/TestBeanInfo.java	Thu Sep 06 18:07:38 2012 +0100
@@ -38,8 +38,7 @@
 
 import java.beans.BeanInfo;
 import java.beans.Introspector;
-import java.lang.ref.Reference;
-import java.lang.reflect.Field;
+import java.lang.reflect.Method;
 
 public class TestBeanInfo implements Runnable {
 
@@ -60,10 +59,9 @@
         try {
             actual = Introspector.getBeanInfo(type);
             type = actual.getClass();
-            Field field = type.getDeclaredField("targetBeanInfoRef"); // NON-NLS: field name
-            field.setAccessible(true);
-            Reference ref = (Reference) field.get(actual);
-            actual = (BeanInfo) ref.get();
+            Method method = type.getDeclaredMethod("getTargetBeanInfo"); // NON-NLS: method name
+            method.setAccessible(true);
+            actual = (BeanInfo) method.invoke(actual);
         }
         catch (Exception exception) {
             throw new Error("unexpected error", exception);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/Test7186794.java	Thu Sep 06 18:07:38 2012 +0100
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2012, 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 7186794
+ * @summary Tests setter in the super class
+ * @author Sergey Malenkov
+ */
+
+import java.util.List;
+
+public class Test7186794 {
+
+    public static void main(String[] args) {
+        if (null == BeanUtils.findPropertyDescriptor(MyBean.class, "value").getWriteMethod()) {
+            throw new Error("The property setter is not found");
+        }
+    }
+
+    public static class BaseBean {
+
+        protected List<String> value;
+
+        public void setValue(List<String> value) {
+            this.value = value;
+        }
+    }
+
+    public static class MyBean extends BaseBean {
+        public List<String> getValue() {
+            return super.value;
+        }
+    }
+}
--- a/test/java/beans/Introspector/Test7189112.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/beans/Introspector/Test7189112.java	Thu Sep 06 18:07:38 2012 +0100
@@ -28,17 +28,11 @@
  * @author Sergey Malenkov
  */
 
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-
 public class Test7189112 {
 
-    public static void main(String[] args) throws IntrospectionException {
-        for (PropertyDescriptor pd : Introspector.getBeanInfo(MyBean.class).getPropertyDescriptors()) {
-            if (pd.getName().equals("value") && (null == pd.getWriteMethod())) {
-                throw new Error("The property setter is not found");
-            }
+    public static void main(String[] args) {
+        if (null == BeanUtils.findPropertyDescriptor(MyBean.class, "value").getWriteMethod()) {
+            throw new Error("The property setter is not found");
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/Test7192955.java	Thu Sep 06 18:07:38 2012 +0100
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2012, 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 7192955
+ * @summary Tests that all properties are bound
+ * @author Sergey Malenkov
+ */
+
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+public class Test7192955 {
+
+    public static void main(String[] args) {
+        if (!BeanUtils.findPropertyDescriptor(MyBean.class, "test").isBound()) {
+            throw new Error("a simple property is not bound");
+        }
+        if (!BeanUtils.findPropertyDescriptor(MyBean.class, "list").isBound()) {
+            throw new Error("a generic property is not bound");
+        }
+        if (!BeanUtils.findPropertyDescriptor(MyBean.class, "readOnly").isBound()) {
+            throw new Error("a read-only property is not bound");
+        }
+    }
+
+    public static class BaseBean {
+
+        private List<String> list;
+
+        public List<String> getList() {
+            return this.list;
+        }
+
+        public void setList(List<String> list) {
+            this.list = list;
+        }
+
+        public void addPropertyChangeListener(PropertyChangeListener listener) {
+        }
+
+        public void removePropertyChangeListener(PropertyChangeListener listener) {
+        }
+
+        public List<String> getReadOnly() {
+            return this.list;
+        }
+    }
+
+    public static class MyBean extends BaseBean {
+
+        private String test;
+
+        public String getTest() {
+            return this.test;
+        }
+
+        public void setTest(String test) {
+            this.test = test;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/Introspector/Test7195106.java	Thu Sep 06 18:07:38 2012 +0100
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, 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 7195106
+ * @summary Tests that explicit BeanInfo is not collected
+ * @author Sergey Malenkov
+ */
+
+import java.awt.Image;
+import java.awt.image.BufferedImage;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.SimpleBeanInfo;
+
+public class Test7195106 {
+
+    public static void main(String[] arg) throws Exception {
+        BeanInfo info = Introspector.getBeanInfo(My.class);
+        if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
+            throw new Error("Unexpected behavior");
+        }
+        try {
+            int[] array = new int[1024];
+            while (true) {
+                array = new int[array.length << 1];
+            }
+        }
+        catch (OutOfMemoryError error) {
+            System.gc();
+        }
+        if (null == info.getIcon(BeanInfo.ICON_COLOR_16x16)) {
+            throw new Error("Explicit BeanInfo is collected");
+        }
+    }
+
+    public static class My {
+    }
+
+    public static class MyBeanInfo extends SimpleBeanInfo {
+        @Override
+        public Image getIcon(int type) {
+            return new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/beans/XMLEncoder/Test7169395.java	Thu Sep 06 18:07:38 2012 +0100
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2012, 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 7169395
+ * @summary Tests that array list initialized correctly
+ * @author Sergey Malenkov
+ */
+
+import java.beans.ConstructorProperties;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+public class Test7169395 extends AbstractTest {
+
+    public static void main(String[] args) {
+        new Test7169395().test(true);
+    }
+
+    protected Object getObject() {
+        Container container = new Container();
+        container.add("test-null", null);
+        container.add("test-value", "value");
+        container.add("test-other", "other");
+        return container;
+    }
+
+    public static class Component {
+
+        private final Container container;
+        private final String name;
+        private String value;
+
+        @ConstructorProperties({ "container", "name" })
+        public Component(Container container, String name) {
+            this.container = container;
+            this.name = name;
+        }
+
+        public Container getContainer() {
+            return this.container;
+        }
+
+        public String getName() {
+            return this.name;
+        }
+
+        public String getValue() {
+            return this.value;
+        }
+
+        public void setValue(String value) {
+            this.value = value;
+        }
+    }
+
+    public static class Container {
+
+        private final Map<String, Component> map = new TreeMap<String, Component>();
+
+        public Collection<Component> getComponents() {
+            return new ArrayList<Component>(this.map.values());
+        }
+
+        public void setComponents(Collection<Component> components) {
+            this.map.clear();
+            for (Component component : components){
+                this.map.put(component.getName(), component);
+            }
+        }
+
+        public void add(String name, String value) {
+            Component list = new Component(this, name);
+            list.setValue(value);
+            this.map.put(name, list);
+        }
+    }
+}
--- a/test/java/nio/Buffer/Basic-X.java.template	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/Buffer/Basic-X.java.template	Thu Sep 06 18:07:38 2012 +0100
@@ -402,6 +402,19 @@
         ck(b, b.charAt(1), 'f');
         ck(b, b.subSequence(1, 3).toString().equals("fg"));
 
+        // String ops
+
+        // 7190219
+        b.clear();
+        int pos = b.position();
+        tryCatch(b, BufferOverflowException.class, new Runnable() {
+            public void run() {
+                b.put(String.valueOf(new char[b.capacity() + 1]), 0,
+                        b.capacity() + 1);
+            }});
+        ck(b, b.position(), pos);
+        relGet(b);
+
 #end[char]
 
         // Compact
--- a/test/java/nio/Buffer/Basic.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/Buffer/Basic.java	Thu Sep 06 18:07:38 2012 +0100
@@ -25,7 +25,7 @@
  * @summary Unit test for buffers
  * @bug 4413135 4414911 4416536 4416562 4418782 4471053 4472779 4490253 4523725
  *      4526177 4463011 4660660 4661219 4663521 4782970 4804304 4938424 6231529
- *      6221101 6234263 6535542 6591971 6593946 6795561
+ *      6221101 6234263 6535542 6591971 6593946 6795561 7190219
  * @author Mark Reinhold
  */
 
--- a/test/java/nio/Buffer/BasicByte.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/Buffer/BasicByte.java	Thu Sep 06 18:07:38 2012 +0100
@@ -404,6 +404,19 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
         // Compact
 
         relPut(b);
--- a/test/java/nio/Buffer/BasicChar.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/Buffer/BasicChar.java	Thu Sep 06 18:07:38 2012 +0100
@@ -402,6 +402,19 @@
         ck(b, b.charAt(1), 'f');
         ck(b, b.subSequence(1, 3).toString().equals("fg"));
 
+        // String ops
+
+        // 7190219
+        b.clear();
+        int pos = b.position();
+        tryCatch(b, BufferOverflowException.class, new Runnable() {
+            public void run() {
+                b.put(String.valueOf(new char[b.capacity() + 1]), 0,
+                        b.capacity() + 1);
+            }});
+        ck(b, b.position(), pos);
+        relGet(b);
+
 
 
         // Compact
--- a/test/java/nio/Buffer/BasicDouble.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/Buffer/BasicDouble.java	Thu Sep 06 18:07:38 2012 +0100
@@ -404,6 +404,19 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
         // Compact
 
         relPut(b);
--- a/test/java/nio/Buffer/BasicFloat.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/Buffer/BasicFloat.java	Thu Sep 06 18:07:38 2012 +0100
@@ -404,6 +404,19 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
         // Compact
 
         relPut(b);
--- a/test/java/nio/Buffer/BasicInt.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/Buffer/BasicInt.java	Thu Sep 06 18:07:38 2012 +0100
@@ -404,6 +404,19 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
         // Compact
 
         relPut(b);
--- a/test/java/nio/Buffer/BasicLong.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/Buffer/BasicLong.java	Thu Sep 06 18:07:38 2012 +0100
@@ -404,6 +404,19 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
         // Compact
 
         relPut(b);
--- a/test/java/nio/Buffer/BasicShort.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/Buffer/BasicShort.java	Thu Sep 06 18:07:38 2012 +0100
@@ -404,6 +404,19 @@
 
 
 
+
+
+
+
+
+
+
+
+
+
+
+
+
         // Compact
 
         relPut(b);
--- a/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java	Thu Aug 23 13:07:08 2012 +0100
+++ b/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java	Thu Sep 06 18:07:38 2012 +0100
@@ -22,10 +22,11 @@
  */
 
 /* @test
- * @bug 4527345 7026376
+ * @bug 4527345 7026376 6633549
  * @summary Unit test for DatagramChannel's multicast support
  * @build MulticastSendReceiveTests NetworkConfiguration
  * @run main MulticastSendReceiveTests
+ * @run main/othervm -Djava.net.preferIPv4Stack=true MulticastSendReceiveTests
  */
 
 import java.nio.ByteBuffer;
@@ -186,6 +187,10 @@
                 id = sendDatagram(source, nif, group, port);
                 receiveDatagram(dc, source, id);
             } catch (UnsupportedOperationException x) {
+                String os = System.getProperty("os.name");
+                // Exclude-mode filtering supported on these platforms so UOE should never be thrown
+                if (os.equals("SunOS") || os.equals("Linux"))
+                    throw x;
                 System.out.println("Exclude-mode filtering not supported!");
             }
 
@@ -212,6 +217,10 @@
                 id = sendDatagram(source, nif, group, port);
                 receiveDatagram(dc, source, id);
             } catch (UnsupportedOperationException x) {
+                String os = System.getProperty("os.name");
+                // Include-mode filtering supported on these platforms so UOE should never be thrown
+                if (os.equals("SunOS") || os.equals("Linux"))
+                    throw x;
                 System.out.println("Include-mode filtering not supported!");
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/security/Signature/VerifyRangeCheckOverflow.java	Thu Sep 06 18:07:38 2012 +0100
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2012 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.
+ */
+
+/*
+ * Portions Copyright (c) 2012 IBM Corporation
+ */
+
+/* @test
+ * @bug 7172149
+ * @summary AIOOBE from Signature.verify after integer overflow
+ * @author Jonathan Lu
+ */
+
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PublicKey;
+import java.security.Signature;
+
+public class VerifyRangeCheckOverflow {
+
+    public static void main(String[] args) throws Exception {
+        KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA");
+        keyPairGenerator.initialize(1024);
+        KeyPair keys = keyPairGenerator.generateKeyPair();
+        PublicKey publicKey = keys.getPublic();
+        byte[] sigBytes = new byte[100];
+
+        Signature signature = Signature.getInstance("SHA1withDSA");
+        signature.initVerify(publicKey);
+        try {
+            signature.verify(sigBytes, Integer.MAX_VALUE, 1);
+        } catch (IllegalArgumentException ex) {
+            // Expected
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/AbstractCollection/ToArrayTest.java	Thu Sep 06 18:07:38 2012 +0100
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2012 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 7121314
+ * @summary AbstractCollection.toArray(T[]) doesn't return the given array
+ *           in concurrent modification.
+ * @author Ulf Zibis, David Holmes
+ */
+
+import java.util.AbstractCollection;
+import java.util.Arrays;
+import java.util.Iterator;
+
+public class ToArrayTest {
+
+    static class TestCollection<E> extends AbstractCollection<E> {
+        private final E[] elements;
+        private int[] sizes;
+        private int nextSize;
+
+        public TestCollection(E[] elements) {
+            this.elements = elements;
+            setSizeSequence(new int[] { elements.length });
+        }
+
+        /*
+         * Sets the values that size() will return on each use. The next
+         * call to size will return sizes[0], then sizes[1] etc. This allows us
+         * to emulate a concurrent change to the contents of the collection
+         * without having to perform concurrent changes. If sizes[n+1] contains
+         * a larger value, the collection will appear to have shrunk when
+         * iterated; if a smaller value then the collection will appear to have
+         * grown when iterated.
+         */
+        void setSizeSequence(int... sizes) {
+            this.sizes = sizes;
+            nextSize = 0;
+        }
+
+        /* can change collection's size after each invocation */
+        @Override
+        public int size() {
+            return sizes[nextSize == sizes.length - 1 ? nextSize : nextSize++];
+        }
+
+        @Override
+        public Iterator<E> iterator() {
+            return new Iterator<E>() {
+                int pos = 0;
+
+                public boolean hasNext() {
+                    return pos < sizes[nextSize];
+                }
+                public E next() {
+                    return elements[pos++];
+                }
+                public void remove() {
+                    throw new UnsupportedOperationException(
+                            "Not supported yet.");
+                }
+            };
+        }
+    }
+
+    static final Object[] OBJECTS = { new Object(), new Object(), new Object() };
+    static final TestCollection<?> CANDIDATE = new TestCollection<Object>(OBJECTS);
+    static final int CAP = OBJECTS.length; // capacity of the CANDIDATE
+    static final int LAST = CAP - 1; // last possible array index
+    Object[] a;
+    Object[] res;
+
+    int last() {
+        return a.length - 1;
+    }
+
+    protected void test() throws Throwable {
+        // Check array type conversion
+        res = new TestCollection<>(new Object[] { "1", "2" }).toArray(new String[0]);
+        check(res instanceof String[]);
+        check(res.length == 2);
+        check(res[1] == "2");
+
+        // Check incompatible type of target array
+        try {
+            res = CANDIDATE.toArray(new String[CAP]);
+            check(false);
+        } catch (Throwable t) {
+            check(t instanceof ArrayStoreException);
+        }
+
+        // Check more elements than a.length
+        a = new Object[CAP - 1]; // appears too small
+        res = CANDIDATE.toArray(a);
+        check(res != a);
+        check(res[LAST] != null);
+
+        // Check equal elements as a.length
+        a = new Object[CAP]; // appears to match
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] != null);
+
+        // Check equal elements as a.length
+        a = new Object[CAP + 1]; // appears too big
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] == null);
+
+        // Check less elements than expected, but more than a.length
+        a = new Object[CAP - 2]; // appears too small
+        CANDIDATE.setSizeSequence(CAP, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res != a);
+        check(res.length == CAP - 1);
+        check(res[LAST - 1] != null);
+
+        // Check less elements than expected, but equal as a.length
+        a = Arrays.copyOf(OBJECTS, CAP); // appears to match
+        CANDIDATE.setSizeSequence(CAP, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] == null);
+
+        // Check more elements than expected and more than a.length
+        a = new Object[CAP - 1]; // appears to match
+        CANDIDATE.setSizeSequence(CAP - 1, CAP);
+        res = CANDIDATE.toArray(a);
+        check(res != a);
+        check(res[LAST] != null);
+
+        // Check more elements than expected, but equal as a.length
+        a = new Object[CAP - 1]; // appears to match
+        CANDIDATE.setSizeSequence(CAP - 2, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] != null);
+
+        // Check more elements than expected, but less than a.length
+        a = Arrays.copyOf(OBJECTS, CAP); // appears to match
+        CANDIDATE.setSizeSequence(CAP - 2, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] == null);
+
+        test_7121314();
+    }
+
+    /*
+     * Major target of this testcase, bug 7121314.
+     */
+    protected void test_7121314() throws Throwable {
+        // Check equal elements as a.length, but less than expected
+        a = new Object[CAP - 1]; // appears too small
+        CANDIDATE.setSizeSequence(CAP, CAP - 1);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] != null);
+
+        // Check less elements than a.length and less than expected
+        a = Arrays.copyOf(OBJECTS, CAP - 1); // appears too small
+        CANDIDATE.setSizeSequence(CAP, CAP - 2);
+        res = CANDIDATE.toArray(a);
+        check(res == a);
+        check(res[last()] == null);
+
+    }
+
+    public static void main(String[] args) throws Throwable {
+        ToArrayTest testcase = new ToArrayTest();
+        try {
+            testcase.test();
+        } catch (Throwable t) {
+            unexpected(t);
+        }
+
+        System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
+        if (failed > 0) throw new Exception("Some tests failed");
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    static volatile int passed = 0, failed = 0;
+    static void pass() { passed++; }
+    static void fail() { failed++; Thread.dumpStack(); }
+    static void fail(String msg) { System.out.println(msg); fail(); }
+    static void unexpected(Throwable t) { failed++; t.printStackTrace(); }
+    static void check(boolean cond) { if (cond) pass(); else fail(); }
+    static void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else {System.out.println(x + " not equal to " + y); fail(); }
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JTable/7055065/bug7055065.java	Thu Sep 06 18:07:38 2012 +0100
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2012 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.
+ */
+
+/*
+ * Portions Copyright (c) 2012 IBM Corporation
+ */
+
+/* @test 1.1 2012/04/19
+ * @bug 7055065
+ * @summary NullPointerException when sorting JTable with empty cell
+ * @author Jonathan Lu
+ * @library ../../regtesthelpers/
+ * @build Util
+ * @run main bug7055065
+ */
+
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableModel;
+import javax.swing.table.TableRowSorter;
+import sun.awt.SunToolkit;
+import java.util.concurrent.Callable;
+
+public class bug7055065 {
+
+    private static JTable table;
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                createAndShowUI();
+            }
+        });
+
+        toolkit.realSync();
+        clickCell(robot, 1, 1);
+        Util.hitKeys(robot, KeyEvent.VK_BACK_SPACE, KeyEvent.VK_BACK_SPACE,
+                KeyEvent.VK_BACK_SPACE);
+
+        toolkit.realSync();
+        clickColumnHeader(robot, 1);
+
+        toolkit.realSync();
+        clickColumnHeader(robot, 1);
+    }
+
+    private static void clickCell(Robot robot, final int row, final int column)
+        throws Exception {
+        Point point = Util.invokeOnEDT(new Callable<Point>() {
+            @Override
+            public Point call() throws Exception {
+                Rectangle rect = table.getCellRect(row, column, false);
+                Point point = new Point(rect.x + rect.width / 2, rect.y
+                    + rect.height / 2);
+                SwingUtilities.convertPointToScreen(point, table);
+                return point;
+            }
+        });
+
+        robot.mouseMove(point.x, point.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+
+    private static void clickColumnHeader(Robot robot, final int column)
+        throws Exception {
+        Point point = Util.invokeOnEDT(new Callable<Point>() {
+            @Override
+            public Point call() throws Exception {
+                Rectangle rect = table.getCellRect(0, column, false);
+                int headerHeight = table.getTableHeader().getHeight();
+                Point point = new Point(rect.x + rect.width / 2, rect.y
+                    - headerHeight / 2);
+                SwingUtilities.convertPointToScreen(point, table);
+                return point;
+            }
+        });
+
+        robot.mouseMove(point.x, point.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+
+    private static void createAndShowUI() {
+        JFrame frame = new JFrame("SimpleTableDemo");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        JPanel newContentPane = new JPanel();
+        newContentPane.setOpaque(true);
+        frame.setContentPane(newContentPane);
+
+        final String[] columnNames = { "String", "Number" };
+        final Object[][] data = { { "aaaa", new Integer(1) },
+            { "bbbb", new Integer(3) }, { "cccc", new Integer(2) },
+            { "dddd", new Integer(4) }, { "eeee", new Integer(5) } };
+        table = new JTable(data, columnNames);
+
+        table.setPreferredScrollableViewportSize(new Dimension(500, 400));
+        table.setFillsViewportHeight(true);
+
+        TableModel dataModel = new AbstractTableModel() {
+
+            public int getColumnCount() {
+                return columnNames.length;
+            }
+
+            public int getRowCount() {
+                return data.length;
+            }
+
+            public Object getValueAt(int row, int col) {
+                return data[row][col];
+            }
+
+            public String getColumnName(int column) {
+                return columnNames[column];
+            }
+
+            public Class<?> getColumnClass(int c) {
+                return getValueAt(0, c).getClass();
+            }
+
+            public boolean isCellEditable(int row, int col) {
+                return col != 5;
+            }
+
+            public void setValueAt(Object aValue, int row, int column) {
+                data[row][column] = aValue;
+            }
+        };
+        table.setModel(dataModel);
+        TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(
+                dataModel);
+        table.setRowSorter(sorter);
+
+        JScrollPane scrollPane = new JScrollPane(table);
+        newContentPane.add(scrollPane);
+
+        frame.pack();
+        frame.setLocation(0, 0);
+        frame.setVisible(true);
+    }
+}