changeset 5107:0481c146976f

Merge
author lana
date Wed, 13 Jun 2012 22:55:11 -0700
parents 3ce621d9b988 3d7847385e94
children 6c4ad045e3a0
files src/share/classes/sun/nio/ch/DevPollSelectorProvider.java
diffstat 33 files changed, 1086 insertions(+), 225 deletions(-) [+]
line wrap: on
line diff
--- a/make/bridge/Jabswitch/Makefile	Tue Jun 12 16:49:14 2012 -0700
+++ b/make/bridge/Jabswitch/Makefile	Wed Jun 13 22:55:11 2012 -0700
@@ -45,7 +45,7 @@
 JAB_MANIFEST_OUT = $(TEMPDIR)/jabswitch.exe.intermediate.manifest
 
 RC_FLAGS += /fo "$(VERSIONRES)"
-OTHER_CPPFLAGS += /Fo"$(TEMPDIR)/" /Fd"$(TEMPDIR)/" /analyze- /Od /Gd /nologo /MDd /Gm /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /RTC1 /W3 /ZI /Zc:wchar_t /EHsc 
+OTHER_CPPFLAGS += /MD /Fo"$(TEMPDIR)/" /Fd"$(TEMPDIR)/" /analyze- /Od /Gd /nologo /Gm /D "WIN32" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /RTC1 /W3 /ZI /Zc:wchar_t /EHsc 
 LDDFLAGS += Advapi32.lib Version.lib User32.lib
 
 all: buildexe copyfilejab
--- a/make/com/oracle/Makefile	Tue Jun 12 16:49:14 2012 -0700
+++ b/make/com/oracle/Makefile	Wed Jun 13 22:55:11 2012 -0700
@@ -30,6 +30,24 @@
 #SUBDIRS_MAKEFLAGS += JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation,-path
 include $(BUILDDIR)/common/Defs.gmk
 
+JFR_SRCDIRS_EXIST := $(shell \
+  if [ -d $(CLOSED_SHARE_SRC)/native/oracle/jfr ] ; then \
+    echo true; \
+  else \
+    echo false; \
+  fi)
+
+JFR =
+ifndef OPENJDK
+  ifndef JAVASE_EMBEDDED
+    ifeq ($(JFR_SRCDIRS_EXIST), true)
+      ifneq (${ARCH},arm)
+        JFR = jfr
+      endif
+    endif
+  endif
+endif
+
 # build com/oracle/security/ucrypto on Solaris platform for non-OpenJDK builds
 UCRYPTO =
 ifndef OPENJDK
@@ -38,15 +56,6 @@
   endif
 endif
 
-JFR =
-ifndef OPENJDK
-ifndef JAVASE_EMBEDDED 
-ifneq (${ARCH},arm)
-	JFR = jfr
-endif
-endif
-endif
-
 SUBDIRS = $(JFR) net nio util $(UCRYPTO)
 
 include $(BUILDDIR)/common/Subdirs.gmk
--- a/make/common/Defs-solaris.gmk	Tue Jun 12 16:49:14 2012 -0700
+++ b/make/common/Defs-solaris.gmk	Wed Jun 13 22:55:11 2012 -0700
@@ -232,18 +232,21 @@
 # optimization flags as used by FASTDEBUG. We also want all the
 # debug info in one place (-xs).
 #
+CFLAGS_COMMON=
+CXXFLAGS_COMMON=
 ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1)
   ifeq ($(LIBRARY_SUPPORTS_FULL_DEBUG_SYMBOLS),1)
     ifeq ($(VARIANT), OPT)
-      CC_OPT   = -g  -xs $(CC_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
-      CXX_OPT  = -g0 -xs $(CXX_OPT/$(FASTDEBUG_OPTIMIZATION_LEVEL))
+      OPTIMIZATION_LEVEL = $(FASTDEBUG_OPTIMIZATION_LEVEL)
+      CFLAGS_COMMON += -g  -xs
+      CXXFLAGS_COMMON += -g0 -xs
     endif
     CFLAGS_DEBUG_OPTION    += -xs
     CXXFLAGS_DEBUG_OPTION  += -xs
   endif
 endif
 
-CFLAGS_COMMON   = -L$(OBJDIR)
+CFLAGS_COMMON  += -L$(OBJDIR)
 
 # Do not allow C99 language features like declarations in code etc.
 CFLAGS_COMMON  += -xc99=%none
--- a/make/common/Release-embedded.gmk	Tue Jun 12 16:49:14 2012 -0700
+++ b/make/common/Release-embedded.gmk	Wed Jun 13 22:55:11 2012 -0700
@@ -159,11 +159,14 @@
 
 	@# Remove misc. other files
 	$(RM) -r $(JRE_REDUCED_IMAGE_DIR)/man
-	$(RM) -f $(JRE_REDUCED_IMAGE_DIR)/CHANGES
+	$(RM) $(JRE_REDUCED_IMAGE_DIR)/CHANGES
 
 	@# Copy back in the attach library
 	$(CP) $(JDK_IMAGE_DIR)/jre/lib/$(LIBARCH)/$(LIB_PREFIX)attach.$(LIB_SUFFIX) $(JRE_REDUCED_IMAGE_DIR)/lib/$(LIBARCH)
 
+	@# Remove FDS files: debuginfo, diz
+	$(FIND) $(JRE_REDUCED_IMAGE_DIR)/lib/$(LIBARCH) -type f \( -name "*.debuginfo" -o -name "*.diz" \) -print | $(XARGS) $(RM)
+
 	@$(ECHO) Done Creating Reduced JRE
 
 #
@@ -180,33 +183,33 @@
 	    $(TAR) cf - . | ($(CD) $(JRE_REDUCED_HEADLESS_IMAGE_DIR); $(TAR) xf - ); 
 
 	@# Replace the full rt.jar with the headless rt.jar
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/rt.jar
+	$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/rt.jar
 	$(CP) $(HL_RT_JAR) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/rt.jar
 
 	@#
 	@# Remove all of the files that are not needed for the
 	@# reduced Headless JRE
 	@#
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/gtkhelper
+	$(RM)  $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/gtkhelper
 	$(RM)  $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libjsoundalsa.so
 	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/audio
-	$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/applet
+	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/applet
 	$(RM)  $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/awt_robot
 	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/xawt
 	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libsplashscreen.so
 	@# Remove oblique fonts and reduce font support to LucidaSansRegular only
-	$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/oblique-fonts
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightDemiBold.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightDemiItalic.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightItalic.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightRegular.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaSansDemiBold.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaTypewriterBold.ttf
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaTypewriterRegular.ttf
+	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/oblique-fonts
+	$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightDemiBold.ttf
+	$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightDemiItalic.ttf
+	$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightItalic.ttf
+	$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaBrightRegular.ttf
+	$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaSansDemiBold.ttf
+	$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaTypewriterBold.ttf
+	$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/LucidaTypewriterRegular.ttf
 
 ifeq ($(PLATFORM), linux)
 # put out minimal fonts.dir file for the remaining font
-	$(RM) -f $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
+	$(RM) $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
 	$(ECHO) 6>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
 	$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-1">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
 	$(ECHO) "LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-iso8859-2">>$(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/fonts/fonts.dir
--- a/make/sun/font/Makefile	Tue Jun 12 16:49:14 2012 -0700
+++ b/make/sun/font/Makefile	Wed Jun 13 22:55:11 2012 -0700
@@ -90,6 +90,12 @@
 
 endif # PLATFORM
 
+# Turn off aliasing with GCC for ExtensionSubtables.cpp
+ifeq ($(PLATFORM), linux)
+  CXXFLAGS += $(CXXFLAGS_$(@F))
+  CXXFLAGS_ExtensionSubtables.o = -fno-strict-aliasing
+endif
+
 #In the non-OpenJDK mode we need to build T2K
 ifndef OPENJDK
 t2k:
--- a/src/macosx/native/sun/awt/AWTWindow.h	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/macosx/native/sun/awt/AWTWindow.h	Wed Jun 13 22:55:11 2012 -0700
@@ -44,6 +44,7 @@
     NSSize javaMaxSize;
     jint styleBits;
     BOOL isEnabled;
+    NSWindow *nsWindow;
 }
 
 // An instance of either AWTWindow_Normal or AWTWindow_Panel
--- a/src/share/classes/com/sun/jndi/dns/DnsClient.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/com/sun/jndi/dns/DnsClient.java	Wed Jun 13 22:55:11 2012 -0700
@@ -622,11 +622,7 @@
 
     //-------------------------------------------------------------------------
 
-    private static boolean debug = false;
-
-    public static void setDebug(boolean flag) {
-        debug = flag;
-    }
+    private static final boolean debug = false;
 
     private static void dprint(String mess) {
         if (debug) {
--- a/src/share/classes/java/nio/MappedByteBuffer.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/java/nio/MappedByteBuffer.java	Wed Jun 13 22:55:11 2012 -0700
@@ -139,6 +139,9 @@
         return isLoaded0(mappingAddress(offset), length, Bits.pageCount(length));
     }
 
+    // not used, but a potential target for a store, see load() for details.
+    private static byte unused;
+
     /**
      * Loads this buffer's content into physical memory.
      *
@@ -157,15 +160,20 @@
         long length = mappingLength(offset);
         load0(mappingAddress(offset), length);
 
-        // touch each page
+        // Read a byte from each page to bring it into memory. A checksum
+        // is computed as we go along to prevent the compiler from otherwise
+        // considering the loop as dead code.
         Unsafe unsafe = Unsafe.getUnsafe();
         int ps = Bits.pageSize();
         int count = Bits.pageCount(length);
         long a = mappingAddress(offset);
+        byte x = 0;
         for (int i=0; i<count; i++) {
-            unsafe.getByte(a);
+            x ^= unsafe.getByte(a);
             a += ps;
         }
+        if (unused != 0)
+            unused = x;
 
         return this;
     }
--- a/src/share/classes/java/util/HashMap.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/java/util/HashMap.java	Wed Jun 13 22:55:11 2012 -0700
@@ -186,7 +186,7 @@
      * {@code 2147483648 } ({@code Integer.MAX_VALUE}) value ensures that
      * alternative hashing is never used.
      */
-    static final int ALTERNATE_HASHING_THRESHOLD_DEFAULT = 0;
+    static final int ALTERNATE_HASHING_THRESHOLD_DEFAULT = 512;
 
     /**
      * holds values which can't be initialized until after VM is booted.
@@ -679,7 +679,7 @@
 
         Map.Entry<K,V> entry = (Map.Entry<K,V>) o;
         Object key = entry.getKey();
-        int hash = (key == null) ? 0 : hash(key.hashCode());
+        int hash = (key == null) ? 0 : hash(key);
         int i = indexFor(hash, table.length);
         Entry<K,V> prev = table[i];
         Entry<K,V> e = prev;
--- a/src/share/classes/java/util/Hashtable.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/java/util/Hashtable.java	Wed Jun 13 22:55:11 2012 -0700
@@ -174,7 +174,7 @@
      * {@code 2147483648 } ({@code Integer.MAX_VALUE}) value ensures that
      * alternative hashing is never used.
      */
-    static final int ALTERNATE_HASHING_THRESHOLD_DEFAULT = 0;
+    static final int ALTERNATE_HASHING_THRESHOLD_DEFAULT = 512;
 
     /**
      * holds values which can't be initialized until after VM is booted.
@@ -1063,7 +1063,7 @@
      */
     private static class Entry<K,V> implements Map.Entry<K,V> {
         int hash;
-        K key;
+        final K key;
         V value;
         Entry<K,V> next;
 
--- a/src/share/classes/java/util/WeakHashMap.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/java/util/WeakHashMap.java	Wed Jun 13 22:55:11 2012 -0700
@@ -195,7 +195,7 @@
     * whereas {@code 2147483648 } ({@code Integer.MAX_VALUE}) value ensures
     * that alternative hashing is never used.
     */
-    static final int ALTERNATE_HASHING_THRESHOLD_DEFAULT = 0;
+    static final int ALTERNATE_HASHING_THRESHOLD_DEFAULT = 512;
 
     /**
      * holds values which can't be initialized until after VM is booted.
--- a/src/share/classes/javax/swing/JPopupMenu.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/javax/swing/JPopupMenu.java	Wed Jun 13 22:55:11 2012 -0700
@@ -825,7 +825,7 @@
             popupFactory.setPopupType(PopupFactory.LIGHT_WEIGHT_POPUP);
         }
         else {
-            popupFactory.setPopupType(PopupFactory.MEDIUM_WEIGHT_POPUP);
+            popupFactory.setPopupType(PopupFactory.HEAVY_WEIGHT_POPUP);
         }
 
         // adjust the location of the popup
--- a/src/share/classes/javax/swing/PopupFactory.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/javax/swing/PopupFactory.java	Wed Jun 13 22:55:11 2012 -0700
@@ -203,12 +203,6 @@
                     popupType = HEAVY_WEIGHT_POPUP;
                     break;
                 }
-            } else if (c instanceof Window) {
-                Window w = (Window) c;
-                if (!w.isOpaque() || w.getOpacity() < 1 || w.getShape() != null) {
-                    popupType = HEAVY_WEIGHT_POPUP;
-                    break;
-                }
             }
             c = c.getParent();
         }
--- a/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/sun/nio/ch/DatagramChannelImpl.java	Wed Jun 13 22:55:11 2012 -0700
@@ -661,7 +661,12 @@
                         throw new AlreadyBoundException();
                     InetSocketAddress isa;
                     if (local == null) {
-                        isa = new InetSocketAddress(0);
+                        // only Inet4Address allowed with IPv4 socket
+                        if (family == StandardProtocolFamily.INET) {
+                            isa = new InetSocketAddress(InetAddress.getByName("0.0.0.0"), 0);
+                        } else {
+                            isa = new InetSocketAddress(0);
+                        }
                     } else {
                         isa = Net.checkAddress(local);
 
--- a/src/share/classes/sun/nio/ch/DevPollSelectorProvider.java	Tue Jun 12 16:49:14 2012 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.nio.ch;
-
-import java.io.IOException;
-import java.nio.channels.*;
-import java.nio.channels.spi.*;
-
-public class DevPollSelectorProvider
-    extends SelectorProviderImpl
-{
-    public AbstractSelector openSelector() throws IOException {
-        return new DevPollSelectorImpl(this);
-    }
-
-    public Channel inheritedChannel() throws IOException {
-        return InheritedChannel.getChannel();
-    }
-}
--- a/src/share/classes/sun/security/ssl/SSLContextImpl.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/sun/security/ssl/SSLContextImpl.java	Wed Jun 13 22:55:11 2012 -0700
@@ -144,7 +144,7 @@
             throws KeyManagementException {
         for (int i = 0; kms != null && i < kms.length; i++) {
             KeyManager km = kms[i];
-            if (km instanceof X509KeyManager == false) {
+            if (!(km instanceof X509KeyManager)) {
                 continue;
             }
             if (SunJSSE.isFIPS()) {
@@ -331,11 +331,11 @@
         Collection<CipherSuite> allowedCipherSuites =
                                     CipherSuite.allowedCipherSuites();
 
-        ArrayList<CipherSuite> suites = new ArrayList<>();
+        TreeSet<CipherSuite> suites = new TreeSet<>();
         if (!(protocols.collection().isEmpty()) &&
                 protocols.min.v != ProtocolVersion.NONE.v) {
             for (CipherSuite suite : allowedCipherSuites) {
-                if (suite.allowed == false || suite.priority < minPriority) {
+                if (!suite.allowed || suite.priority < minPriority) {
                     continue;
                 }
 
--- a/src/share/classes/sun/security/ssl/ServerHandshaker.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/sun/security/ssl/ServerHandshaker.java	Wed Jun 13 22:55:11 2012 -0700
@@ -1313,7 +1313,7 @@
                    return false;
                 }
             }
-            return (kerberosKeys != null);
+            return (kerberosKeys != null && kerberosKeys.length > 0);
         } catch (PrivilegedActionException e) {
             // Likely exception here is LoginExceptin
             if (debug != null && Debug.isOn("handshake")) {
--- a/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java	Wed Jun 13 22:55:11 2012 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -62,7 +62,10 @@
     @Override
     public SecretKey[] getServerKeys(AccessControlContext acc)
             throws LoginException {
-        return Krb5Util.getServiceCreds(GSSCaller.CALLER_SSL_SERVER, null, acc).getKKeys();
+        Krb5Util.ServiceCreds serviceCreds =
+            Krb5Util.getServiceCreds(GSSCaller.CALLER_SSL_SERVER, null, acc);
+        return serviceCreds != null ? serviceCreds.getKKeys() :
+                                        new KerberosKey[0];
     }
 
     @Override
--- a/src/share/demo/jfc/TransparentRuler/transparentruler/Ruler.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/share/demo/jfc/TransparentRuler/transparentruler/Ruler.java	Wed Jun 13 22:55:11 2012 -0700
@@ -134,6 +134,9 @@
 
     {
         jPopupMenu.add(new JMenuItem(exitAction));
+
+        // To avoid popup cutting by main window shape forbid light-weight popups
+        jPopupMenu.setLightWeightPopupEnabled(false);
     }
 
     /**
--- a/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XDecoratedPeer.java	Wed Jun 13 22:55:11 2012 -0700
@@ -721,15 +721,17 @@
             // Location, Client size + insets
             newLocation = new Point(xe.get_x() - currentInsets.left, xe.get_y() - currentInsets.top);
         } else {
-            // CDE/MWM/Metacity/Sawfish bug: if shell is resized using
-            // top or left border, we don't receive synthetic
-            // ConfigureNotify, only the one from X with zero
-            // coordinates.  This is the workaround to get real
-            // location, 6261336
+            // ICCCM 4.1.5 states that a real ConfigureNotify will be sent when
+            // a window is resized but the client can not tell if the window was
+            // moved or not. The client should consider the position as unkown
+            // and use TranslateCoordinates to find the actual position.
+            //
+            // TODO this should be the default for every case.
             switch (XWM.getWMID()) {
                 case XWM.CDE_WM:
                 case XWM.MOTIF_WM:
                 case XWM.METACITY_WM:
+                case XWM.MUTTER_WM:
                 case XWM.SAWFISH_WM:
                 {
                     Point xlocation = queryXLocation();
--- a/src/solaris/classes/sun/awt/X11/XWM.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/solaris/classes/sun/awt/X11/XWM.java	Wed Jun 13 22:55:11 2012 -0700
@@ -102,7 +102,8 @@
         METACITY_WM = 11,
         COMPIZ_WM = 12,
         LG3D_WM = 13,
-        CWM_WM = 14;
+        CWM_WM = 14,
+        MUTTER_WM = 15;
     public String toString() {
         switch  (WMID) {
           case NO_WM:
@@ -131,6 +132,8 @@
               return "LookingGlass";
           case CWM_WM:
               return "CWM";
+          case MUTTER_WM:
+              return "Mutter";
           case UNDETERMINED_WM:
           default:
               return "Undetermined WM";
@@ -573,6 +576,10 @@
 //                            getIntProperty(XToolkit.getDefaultRootWindow(), XAtom.XA_CARDINAL)) == 0);
     }
 
+    static boolean isMutter() {
+        return isNetWMName("Mutter");
+    }
+
     static boolean isNonReparentingWM() {
         return (XWM.getWMID() == XWM.COMPIZ_WM || XWM.getWMID() == XWM.LG3D_WM || XWM.getWMID() == XWM.CWM_WM);
     }
@@ -742,6 +749,8 @@
                 awt_wmgr = XWM.ENLIGHTEN_WM;
             } else if (isMetacity()) {
                 awt_wmgr = XWM.METACITY_WM;
+            } else if (isMutter()) {
+                awt_wmgr = XWM.MUTTER_WM;
             } else if (isSawfish()) {
                 awt_wmgr = XWM.SAWFISH_WM;
             } else if (isKDE2()) {
--- a/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/solaris/classes/sun/nio/ch/DevPollArrayWrapper.java	Wed Jun 13 22:55:11 2012 -0700
@@ -25,9 +25,10 @@
 
 package sun.nio.ch;
 
-import sun.misc.*;
 import java.io.IOException;
-import java.util.LinkedList;
+import java.util.BitSet;
+import java.util.Map;
+import java.util.HashMap;
 
 
 /**
@@ -66,62 +67,72 @@
     static final short EVENT_OFFSET  = 4;
     static final short REVENT_OFFSET = 6;
 
+    // Special value to indicate that an update should be ignored
+    static final byte  CANCELLED     = (byte)-1;
+
     // Maximum number of open file descriptors
     static final int   OPEN_MAX      = fdLimit();
 
     // Number of pollfd structures to create.
-    // DP_POLL ioctl allows up to OPEN_MAX-1
+    // dpwrite/ioctl(DP_POLL) allows up to OPEN_MAX-1
     static final int   NUM_POLLFDS   = Math.min(OPEN_MAX-1, 8192);
 
+    // Initial size of arrays for fd registration changes
+    private final int INITIAL_PENDING_UPDATE_SIZE = 64;
+
+    // maximum size of updatesLow
+    private final int MAX_UPDATE_ARRAY_SIZE = Math.min(OPEN_MAX, 64*1024);
+
+    // The pollfd array for results from devpoll driver
+    private final AllocatedNativeObject pollArray;
+
     // Base address of the native pollArray
-    private long pollArrayAddress;
+    private final long pollArrayAddress;
 
-    // Array of pollfd structs used for driver updates
-    private AllocatedNativeObject updatePollArray;
+    // The fd of the devpoll driver
+    private int wfd;
 
-    // Maximum number of POLL_FD structs to update at once
-    private int MAX_UPDATE_SIZE = Math.min(OPEN_MAX, 10000);
+    // The fd of the interrupt line going out
+    private int outgoingInterruptFD;
+
+    // The fd of the interrupt line coming in
+    private int incomingInterruptFD;
+
+    // The index of the interrupt FD
+    private int interruptedIndex;
+
+    // Number of updated pollfd entries
+    int updated;
+
+    // object to synchronize fd registration changes
+    private final Object updateLock = new Object();
+
+    // number of file descriptors with registration changes pending
+    private int updateCount;
+
+    // file descriptors with registration changes pending
+    private int[] updateDescriptors = new int[INITIAL_PENDING_UPDATE_SIZE];
+
+    // events for file descriptors with registration changes pending, indexed
+    // by file descriptor and stored as bytes for efficiency reasons. For
+    // file descriptors higher than MAX_UPDATE_ARRAY_SIZE (unlimited case at
+    // least then the update is stored in a map.
+    private final byte[] eventsLow = new byte[MAX_UPDATE_ARRAY_SIZE];
+    private Map<Integer,Byte> eventsHigh;
+
+    // Used by release and updateRegistrations to track whether a file
+    // descriptor is registered with /dev/poll.
+    private final BitSet registered = new BitSet();
 
     DevPollArrayWrapper() {
         int allocationSize = NUM_POLLFDS * SIZE_POLLFD;
         pollArray = new AllocatedNativeObject(allocationSize, true);
         pollArrayAddress = pollArray.address();
-        allocationSize = MAX_UPDATE_SIZE * SIZE_POLLFD;
-        updatePollArray = new AllocatedNativeObject(allocationSize, true);
         wfd = init();
+        if (OPEN_MAX > MAX_UPDATE_ARRAY_SIZE)
+            eventsHigh = new HashMap<>();
     }
 
-    // Machinery for remembering fd registration changes
-    // A hashmap could be used but the number of changes pending
-    // is expected to be small
-    private static class Updator {
-        int fd;
-        int mask;
-        Updator(int fd, int mask) {
-            this.fd = fd;
-            this.mask = mask;
-        }
-    }
-    private LinkedList<Updator> updateList = new LinkedList<Updator>();
-
-    // The pollfd array for results from devpoll driver
-    private AllocatedNativeObject pollArray;
-
-    // The fd of the devpoll driver
-    int wfd;
-
-    // The fd of the interrupt line going out
-    int outgoingInterruptFD;
-
-    // The fd of the interrupt line coming in
-    int incomingInterruptFD;
-
-    // The index of the interrupt FD
-    int interruptedIndex;
-
-    // Number of updated pollfd entries
-    int updated;
-
     void initInterrupt(int fd0, int fd1) {
         outgoingInterruptFD = fd1;
         incomingInterruptFD = fd0;
@@ -148,22 +159,60 @@
         return pollArray.getInt(offset);
     }
 
+    private void setUpdateEvents(int fd, byte events) {
+        if (fd < MAX_UPDATE_ARRAY_SIZE) {
+            eventsLow[fd] = events;
+        } else {
+            eventsHigh.put(Integer.valueOf(fd), Byte.valueOf(events));
+        }
+    }
+
+    private byte getUpdateEvents(int fd) {
+        if (fd < MAX_UPDATE_ARRAY_SIZE) {
+            return eventsLow[fd];
+        } else {
+            Byte result = eventsHigh.get(Integer.valueOf(fd));
+            // result should never be null
+            return result.byteValue();
+        }
+    }
+
     void setInterest(int fd, int mask) {
-        synchronized (updateList) {
-            updateList.add(new Updator(fd, mask));
+        synchronized (updateLock) {
+            // record the file descriptor and events, expanding the
+            // respective arrays first if necessary.
+            int oldCapacity = updateDescriptors.length;
+            if (updateCount == oldCapacity) {
+                int newCapacity = oldCapacity + INITIAL_PENDING_UPDATE_SIZE;
+                int[] newDescriptors = new int[newCapacity];
+                System.arraycopy(updateDescriptors, 0, newDescriptors, 0, oldCapacity);
+                updateDescriptors = newDescriptors;
+            }
+            updateDescriptors[updateCount++] = fd;
+
+            // events are stored as bytes for efficiency reasons
+            byte b = (byte)mask;
+            assert (b == mask) && (b != CANCELLED);
+            setUpdateEvents(fd, b);
         }
     }
 
     void release(int fd) {
-        synchronized (updateList) {
-            updateList.add(new Updator(fd, POLLREMOVE));
+        synchronized (updateLock) {
+            // cancel any pending update for this file descriptor
+            setUpdateEvents(fd, CANCELLED);
+
+            // remove from /dev/poll
+            if (registered.get(fd)) {
+                register(wfd, fd, POLLREMOVE);
+                registered.clear(fd);
+            }
         }
     }
 
     void closeDevPollFD() throws IOException {
         FileDispatcherImpl.closeIntFD(wfd);
         pollArray.free();
-        updatePollArray.free();
     }
 
     int poll(long timeout) throws IOException {
@@ -180,33 +229,48 @@
     }
 
     void updateRegistrations() throws IOException {
-        // Populate pollfd array with updated masks
-        synchronized (updateList) {
-            while (updateList.size() > 0) {
-                // We have to insert a dummy node in between each
-                // real update to use POLLREMOVE on the fd first because
-                // otherwise the changes are simply OR'd together
-                int index = 0;
-                Updator u = null;
-                while ((u = updateList.poll()) != null) {
-                    // First add pollfd struct to clear out this fd
-                    putPollFD(updatePollArray, index, u.fd, POLLREMOVE);
+        synchronized (updateLock) {
+            // Populate pollfd array with updated masks
+            int j = 0;
+            int index = 0;
+            while (j < updateCount) {
+                int fd = updateDescriptors[j];
+                short events = getUpdateEvents(fd);
+                boolean isRegistered = registered.get(fd);
+
+                // events = 0 => POLLREMOVE or do-nothing
+                if (events != CANCELLED) {
+                    if (events == 0) {
+                        if (isRegistered) {
+                            events = POLLREMOVE;
+                            registered.clear(fd);
+                        } else {
+                            events = CANCELLED;
+                        }
+                    } else {
+                        if (!isRegistered) {
+                            registered.set(fd);
+                        }
+                    }
+                }
+
+                // populate pollfd array with updated event
+                if (events != CANCELLED) {
+                    putPollFD(pollArray, index, fd, events);
                     index++;
-                    // Now add pollfd to update this fd, if necessary
-                    if (u.mask != POLLREMOVE) {
-                        putPollFD(updatePollArray, index, u.fd, (short)u.mask);
-                        index++;
+                    if (index >= NUM_POLLFDS) {
+                        registerMultiple(wfd, pollArray.address(), index);
+                        index = 0;
                     }
+                }
+                j++;
+            }
 
-                    // Check against the max update size; these are
-                    // all we will process. Valid index ranges from 0 to
-                    // (MAX_UPDATE_SIZE - 1) and we can use up to 2 per loop
-                    if (index >  MAX_UPDATE_SIZE - 2)
-                        break;
-                }
-                // Register the changes with /dev/poll
-                registerMultiple(wfd, updatePollArray.address(), index);
-             }
+            // write any remaining updates
+            if (index > 0)
+                registerMultiple(wfd, pollArray.address(), index);
+
+            updateCount = 0;
         }
     }
 
@@ -245,5 +309,4 @@
                              int wfd);
     private static native void interrupt(int fd);
     private static native int fdLimit();
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/solaris/classes/sun/nio/ch/DevPollSelectorProvider.java	Wed Jun 13 22:55:11 2012 -0700
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.nio.ch;
+
+import java.io.IOException;
+import java.nio.channels.*;
+import java.nio.channels.spi.*;
+
+public class DevPollSelectorProvider
+    extends SelectorProviderImpl
+{
+    public AbstractSelector openSelector() throws IOException {
+        return new DevPollSelectorImpl(this);
+    }
+
+    public Channel inheritedChannel() throws IOException {
+        return InheritedChannel.getChannel();
+    }
+}
--- a/src/solaris/native/java/util/TimeZone_md.c	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/solaris/native/java/util/TimeZone_md.c	Wed Jun 13 22:55:11 2012 -0700
@@ -96,9 +96,9 @@
 /*
  * Scans the specified directory and its subdirectories to find a
  * zoneinfo file which has the same content as /etc/localtime on Linux
- * or /usr/share/lib/zoneinfo/localtime (most likely a symbolic link)
- * on Solaris given in 'buf'. Returns a zone ID if found, otherwise,
- * NULL is returned.
+ * or /usr/share/lib/zoneinfo/localtime on Solaris given in 'buf'.
+ * If file is symbolic link, then the contents it points to are in buf.
+ * Returns a zone ID if found, otherwise, NULL is returned.
  */
 static char *
 findZoneinfoFile(char *buf, size_t size, const char *dir)
@@ -281,21 +281,27 @@
         tz = getZoneName(linkbuf);
         if (tz != NULL) {
             tz = strdup(tz);
+            return tz;
         }
-        return tz;
     }
 
     /*
      * If it's a regular file, we need to find out the same zoneinfo file
      * that has been copied as /etc/localtime.
+     * If initial symbolic link resolution failed, we should treat target
+     * file as a regular file.
      */
+    if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) {
+        return NULL;
+    }
+    if (fstat(fd, &statbuf) == -1) {
+        (void) close(fd);
+        return NULL;
+    }
     size = (size_t) statbuf.st_size;
     buf = (char *) malloc(size);
     if (buf == NULL) {
-        return NULL;
-    }
-    if ((fd = open(DEFAULT_ZONEINFO_FILE, O_RDONLY)) == -1) {
-        free((void *) buf);
+        (void) close(fd);
         return NULL;
     }
 
--- a/src/solaris/native/sun/nio/ch/DevPollArrayWrapper.c	Tue Jun 12 16:49:14 2012 -0700
+++ b/src/solaris/native/sun/nio/ch/DevPollArrayWrapper.c	Wed Jun 13 22:55:11 2012 -0700
@@ -118,27 +118,20 @@
 Java_sun_nio_ch_DevPollArrayWrapper_register(JNIEnv *env, jobject this,
                                              jint wfd, jint fd, jint mask)
 {
-    struct pollfd a[2];
-    unsigned char *pollBytes = (unsigned char *)&a[0];
-    unsigned char *pollEnd = pollBytes + sizeof(struct pollfd) * 2;
+    struct pollfd a[1];
+    int n;
 
-    /* We clear it first, otherwise any entries between poll invocations
-       get OR'd together */
     a[0].fd = fd;
-    a[0].events = POLLREMOVE;
+    a[0].events = mask;
     a[0].revents = 0;
 
-    a[1].fd = fd;
-    a[1].events = mask;
-    a[1].revents = 0;
-
-    while (pollBytes < pollEnd) {
-        int bytesWritten = write(wfd, pollBytes, (int)(pollEnd - pollBytes));
-        if (bytesWritten < 0) {
+    n = write(wfd, &a[0], sizeof(a));
+    if (n != sizeof(a)) {
+        if (n < 0) {
             JNU_ThrowIOExceptionWithLastError(env, "Error writing pollfds");
-            return;
+        } else {
+            JNU_ThrowIOException(env, "Unexpected number of bytes written");
         }
-        pollBytes += bytesWritten;
     }
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/WMSpecificTests/Mutter/MutterMaximizeTest.java	Wed Jun 13 22:55:11 2012 -0700
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2012 Red Hat, Inc.  All Rights Reserved.
+ * 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      7043963
+  @summary  Tests  that the screen location of windows is
+            updated properly after a maximize.
+  @author   Denis Lila
+  @library  ../../regtesthelpers
+  @build    Util
+  @run      main MutterMaximizeTest
+*/
+
+import java.awt.AWTException;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Window;
+import java.awt.event.InputEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import test.java.awt.regtesthelpers.Util;
+
+@SuppressWarnings("serial")
+public class MutterMaximizeTest extends Frame {
+
+    public static void main(String[] args) throws InterruptedException {
+        if (Util.getWMID() != Util.MUTTER_WM) {
+            System.out.println("This test is only useful on Mutter");
+            return;
+        }
+        MutterMaximizeTest frame = new MutterMaximizeTest();
+        frame.addWindowListener(Util.getClosingWindowAdapter());
+
+        //Display the window.
+        frame.setSize(500, 500);
+        Util.showWindowWait(frame);
+        runRobotTest(frame);
+    }
+
+    private static void runRobotTest(Frame frame) {
+        try {
+            Thread robotThread = startRegTest(frame);
+            robotThread.start();
+            waitForThread(robotThread);
+        } finally {
+            frame.dispose();
+        }
+    }
+
+    private static void waitForThread(Thread t) {
+        while (t.isAlive()) {
+            try {
+                t.join();
+            } catch (InterruptedException e) {
+            }
+        }
+    }
+
+    private static void sleepFor(long millis) {
+        long dT = 0;
+        long start = System.nanoTime();
+        while (dT < millis) {
+            try {
+                long toSleep = millis - dT/1000000;
+                if (toSleep > 0) {
+                    Thread.sleep(toSleep);
+                }
+                // if this ends without an interrupted exception,
+                // that's good enough.
+                break;
+            } catch (InterruptedException e) {
+                long now = System.nanoTime();
+                dT = now - start;
+            }
+        }
+    }
+
+    private static void rmove(Robot robot, Point p) {
+        robot.mouseMove(p.x, p.y);
+    }
+    private static void rdown(Robot robot) {
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.delay(50);
+    }
+    private static void rup(Robot robot) {
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.delay(50);
+    }
+
+    public static void click(Robot robot) {
+        rdown(robot);
+        rup(robot);
+    }
+
+    public static void doubleClick(Robot robot) {
+        click(robot);
+        click(robot);
+    }
+
+    private static void dragWindow(Window w, int dx, int dy, Robot robot) {
+        Point p = Util.getTitlePoint(w);
+        rmove(robot, p);
+        rdown(robot);
+        p.translate(dx, dy);
+        rmove(robot, p);
+        rup(robot);
+    }
+
+    // f must be visible
+    private static Thread startRegTest(final Frame f) {
+        Thread robot = new Thread(new Runnable() {
+            public void run() {
+                Robot r = Util.createRobot();
+                dragWindow(f, 100, 100, r);
+                // wait for the location to be set.
+                sleepFor(2000);
+
+                final Point l2 = f.getLocationOnScreen();
+
+                // double click should maximize the frame
+                doubleClick(r);
+
+                // wait for location again.
+                sleepFor(2000);
+                final Point l3 = f.getLocationOnScreen();
+                if (l3.equals(l2)) {
+                    throw new RuntimeException("Bad location after maximize. Window location has not moved");
+                }
+            }
+        });
+        return robot;
+    }
+}
+
--- a/test/java/awt/regtesthelpers/Util.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/test/java/awt/regtesthelpers/Util.java	Wed Jun 13 22:55:11 2012 -0700
@@ -162,16 +162,21 @@
         clickOnComp(comp, robot, 50);
     }
 
+    public static Point getTitlePoint(Window decoratedWindow) {
+        Point p = decoratedWindow.getLocationOnScreen();
+        Dimension d = decoratedWindow.getSize();
+        return new Point(p.x + (int)(d.getWidth()/2),
+                         p.y + (int)(decoratedWindow.getInsets().top/2));
+    }
+
     /*
      * Clicks on a title of Frame/Dialog.
      * WARNING: it may fail on some platforms when the window is not wide enough.
      */
     public static void clickOnTitle(final Window decoratedWindow, final Robot robot) {
-        Point p = decoratedWindow.getLocationOnScreen();
-        Dimension d = decoratedWindow.getSize();
-
         if (decoratedWindow instanceof Frame || decoratedWindow instanceof Dialog) {
-            robot.mouseMove(p.x + (int)(d.getWidth()/2), p.y + (int)decoratedWindow.getInsets().top/2);
+            Point p = getTitlePoint(decoratedWindow);
+            robot.mouseMove(p.x, p.y);
             robot.delay(50);
             robot.mousePress(InputEvent.BUTTON1_MASK);
             robot.delay(50);
@@ -409,7 +414,9 @@
         ICE_WM = 10,
         METACITY_WM = 11,
         COMPIZ_WM = 12,
-        LG3D_WM = 13;
+        LG3D_WM = 13,
+        CWM_WM = 14,
+        MUTTER_WM = 15;
 
     /*
      * Returns -1 in case of not X Window or any problems.
--- a/test/java/nio/MappedByteBuffer/Truncate.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/test/java/nio/MappedByteBuffer/Truncate.java	Wed Jun 13 22:55:11 2012 -0700
@@ -88,6 +88,11 @@
             }
         };
         Thread t = new Thread(r);
+        t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+            public void uncaughtException(Thread t, Throwable e) {
+                e.printStackTrace();
+            }
+        });
         t.start();
         try { t.join(); } catch (InterruptedException ignore) { }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/nio/channels/DatagramChannel/BindNull.java	Wed Jun 13 22:55:11 2012 -0700
@@ -0,0 +1,50 @@
+/*
+ * 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 7161881
+ * @run main/othervm -Djava.net.preferIPv6Addresses=true BindNull
+ * @summary Make sure the bind method uses an ipv4 address for the null case
+ *          when the DatagramChannel is connected to an IPv4 socket and
+ *          -Djava.net.preferIPv6Addresses=true.
+ */
+
+import java.io.*;
+import java.net.*;
+import java.nio.channels.*;
+
+public class BindNull {
+    public static void main(String[] args) throws IOException {
+        try (DatagramChannel dc = DatagramChannel.open()) {
+            dc.bind(null);
+        }
+        try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET)) {
+            dc.bind(null);
+        }
+        try (DatagramChannel dc = DatagramChannel.open(StandardProtocolFamily.INET6)) {
+            dc.bind(null);
+        } catch (UnsupportedOperationException uoe) {
+            // IPv6 not available
+        }
+    }
+}
--- a/test/javax/swing/JPopupMenu/6694823/bug6694823.java	Tue Jun 12 16:49:14 2012 -0700
+++ b/test/javax/swing/JPopupMenu/6694823/bug6694823.java	Wed Jun 13 22:55:11 2012 -0700
@@ -33,6 +33,8 @@
 import javax.swing.*;
 import java.awt.*;
 import sun.awt.SunToolkit;
+import java.security.Permission;
+import sun.security.util.SecurityConstants;
 
 public class bug6694823 {
     private static JFrame frame;
@@ -48,6 +50,8 @@
             }
         });
 
+        toolkit.realSync();
+
         // Get screen insets
         screenInsets = toolkit.getScreenInsets(frame.getGraphicsConfiguration());
         if (screenInsets.bottom == 0) {
@@ -55,26 +59,23 @@
             return;
         }
 
-        // Show popup as if from a standalone application
-        // The popup should be able to overlap the task bar
-        showPopup(false);
+        System.setSecurityManager(new SecurityManager(){
 
-        // Emulate applet security restrictions
-        toolkit.realSync();
-        System.setSecurityManager(new SecurityManager());
+            private String allowsAlwaysOnTopPermission = SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION.getName();
+
+            @Override
+            public void checkPermission(Permission perm) {
+                if (allowsAlwaysOnTopPermission.equals(perm.getName())) {
+                    throw new SecurityException();
+                }
+            }
+
+        });
 
         // Show popup as if from an applet
         // The popup shouldn't overlap the task bar. It should be shifted up.
-        showPopup(true);
+        checkPopup();
 
-        toolkit.realSync();
-        System.out.println("Test passed!");
-
-        SwingUtilities.invokeAndWait(new Runnable() {
-            public void run() {
-                frame.dispose();
-            }
-        });
     }
 
     private static void createGui() {
@@ -93,7 +94,7 @@
         frame.setSize(200, 200);
     }
 
-    private static void showPopup(final boolean shouldBeShifted) throws Exception {
+    private static void checkPopup() throws Exception {
         SwingUtilities.invokeAndWait(new Runnable() {
             public void run() {
                 // Place frame just above the task bar
@@ -121,20 +122,14 @@
         toolkit.realSync();
 
         SwingUtilities.invokeAndWait(new Runnable() {
+
             public void run() {
                 Point frameLoc = frame.getLocationOnScreen();
-                if (shouldBeShifted) {
-                    if (popup.getLocationOnScreen()
-                            .equals(new Point(frameLoc.x, frameLoc.y + point.y))) {
-                        throw new RuntimeException("Popup is not shifted");
-                    }
-                } else {
-                    if (!popup.getLocationOnScreen()
-                            .equals(new Point(frameLoc.x, frameLoc.y + point.y))) {
-                        throw new RuntimeException("Popup is unexpectedly shifted");
-                    }
+                if (popup.getLocationOnScreen().equals(new Point(frameLoc.x, frameLoc.y + point.y))) {
+                    throw new RuntimeException("Popup is not shifted");
                 }
                 popup.setVisible(false);
+                frame.dispose();
             }
         });
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/6800513/bug6800513.java	Wed Jun 13 22:55:11 2012 -0700
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2012 Red Hat, Inc.  All Rights Reserved.
+ * 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 6800513
+ * @summary GTK-LaF renders menus incompletely
+ * @author Mario Torre
+ * @library ../../regtesthelpers/
+ * @build Util
+ * @run main bug6800513
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.Field;
+import java.util.concurrent.Callable;
+
+public class bug6800513 {
+
+    private static JPopupMenu popupMenu;
+    private static JMenu menu;
+    private static JFrame frame;
+
+    public static void testFrame(final boolean defaultLightWeightPopupEnabled,
+            String expectedPopupClass) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                JPopupMenu.setDefaultLightWeightPopupEnabled(defaultLightWeightPopupEnabled);
+                createAndShowUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        clickOnMenu();
+
+        toolkit.realSync();
+
+        Field getPopup = JPopupMenu.class.getDeclaredField("popup");
+        getPopup.setAccessible(true);
+        Popup popup = (Popup) getPopup.get(popupMenu);
+
+        if (popup == null) {
+            throw new Exception("popup is null!");
+        }
+
+        String className = popup.getClass().getName();
+        if (!className.equals(expectedPopupClass)) {
+            throw new Exception("popup class is: " + className +
+                    ", expected: " + expectedPopupClass);
+        }
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                frame.dispose();
+                popupMenu = null;
+            }
+        });
+
+        toolkit.realSync();
+    }
+
+
+    public static void clickOnMenu() throws Exception {
+        Rectangle bounds = Util.invokeOnEDT(new Callable<Rectangle>() {
+            @Override
+            public Rectangle call() throws Exception {
+                return new Rectangle(menu.getLocationOnScreen(), menu.getSize());
+            }
+        });
+
+        Robot robot = new Robot();
+        robot.setAutoDelay(100);
+
+        robot.mouseMove(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
+
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+    }
+
+    private static class PopupListener implements PropertyChangeListener {
+        @Override
+        public void propertyChange(PropertyChangeEvent evt) {
+            if (evt.toString().contains("visible") && ((Boolean) evt.getNewValue() == true)) {
+                popupMenu = (JPopupMenu) evt.getSource();
+            }
+        }
+    }
+
+    public static void createAndShowUI() {
+        frame = new JFrame();
+
+        JMenuBar menuBar = new JMenuBar();
+        menu = new JMenu("Menu");
+
+        menu.add(new JMenuItem("Menu Item #1"));
+        menu.add(new JMenuItem("Menu Item #2"));
+        menu.add(new JMenuItem("Menu Item #3"));
+
+        menuBar.add(menu);
+
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setJMenuBar(menuBar);
+        frame.setSize(500, 500);
+
+        PopupListener listener = new PopupListener();
+        menu.getPopupMenu().addPropertyChangeListener(listener);
+
+        frame.setVisible(true);
+    }
+
+    public static void main(String[] args) throws Exception {
+        testFrame(false, "javax.swing.PopupFactory$HeavyWeightPopup");
+
+        testFrame(true, "javax.swing.PopupFactory$LightWeightPopup");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JPopupMenu/7156657/bug7156657.java	Wed Jun 13 22:55:11 2012 -0700
@@ -0,0 +1,157 @@
+/*
+ * 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.
+ */
+
+import com.sun.awt.AWTUtilities;
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.util.concurrent.Callable;
+
+/* @test
+   @bug 7156657
+   @summary Version 7 doesn't support translucent popup menus against a translucent window
+   @library ../../regtesthelpers
+   @author Pavel Porvatov
+*/
+public class bug7156657 {
+    private static JFrame lowerFrame;
+
+    private static JFrame frame;
+
+    private static JPopupMenu popupMenu;
+
+    public static void main(String[] args) throws Exception {
+        final Robot robot = new Robot();
+        final SunToolkit toolkit = ((SunToolkit) Toolkit.getDefaultToolkit());
+
+        Boolean skipTest = Util.invokeOnEDT(new Callable<Boolean>() {
+            @Override
+            public Boolean call() throws Exception {
+                frame = createFrame();
+
+                if (!AWTUtilities.isTranslucencyCapable(frame.getGraphicsConfiguration())) {
+                    System.out.println("Translucency is not supported, the test skipped");
+
+                    return true;
+                }
+
+                lowerFrame = createFrame();
+                lowerFrame.getContentPane().setBackground(Color.RED);
+                lowerFrame.setVisible(true);
+
+                popupMenu = new JPopupMenu();
+                popupMenu.setOpaque(false);
+                popupMenu.add(new TransparentMenuItem("1111"));
+                popupMenu.add(new TransparentMenuItem("2222"));
+                popupMenu.add(new TransparentMenuItem("3333"));
+
+                AWTUtilities.setWindowOpaque(frame, false);
+                JPanel pnContent = new JPanel();
+                pnContent.setBackground(new Color(255, 255, 255, 128));
+                frame.add(pnContent);
+                frame.setVisible(true);
+
+                return false;
+            }
+        });
+
+        if (skipTest) {
+            return;
+        }
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                popupMenu.show(frame, 0, 0);
+            }
+        });
+
+        toolkit.realSync();
+
+        Rectangle popupRectangle = Util.invokeOnEDT(new Callable<Rectangle>() {
+            @Override
+            public Rectangle call() throws Exception {
+                return popupMenu.getBounds();
+            }
+        });
+
+        BufferedImage redBackgroundCapture = robot.createScreenCapture(popupRectangle);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                lowerFrame.getContentPane().setBackground(Color.GREEN);
+            }
+        });
+
+        toolkit.realSync();
+
+        BufferedImage greenBackgroundCapture = robot.createScreenCapture(popupRectangle);
+
+        if (Util.compareBufferedImages(redBackgroundCapture, greenBackgroundCapture)) {
+            throw new RuntimeException("The test failed");
+        }
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                popupMenu.setVisible(false);
+                frame.dispose();
+                lowerFrame.dispose();
+            }
+        });
+
+        System.out.println("The test passed");
+    }
+
+
+    private static JFrame createFrame() {
+        JFrame result = new JFrame();
+
+        result.setLocation(0, 0);
+        result.setSize(400, 300);
+        result.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        result.setUndecorated(true);
+
+        return result;
+    }
+
+    private static class TransparentMenuItem extends JMenuItem {
+        public TransparentMenuItem(String text) {
+            super(text);
+            setOpaque(false);
+        }
+
+        @Override
+        public void paint(Graphics g) {
+            Graphics2D g2 = (Graphics2D) g.create();
+            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
+            super.paint(g2);
+            g2.dispose();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/ssl/sanity/ciphersuites/CipherSuitesInOrder.java	Wed Jun 13 22:55:11 2012 -0700
@@ -0,0 +1,236 @@
+/*
+ * 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 7174244
+ * @summary NPE in Krb5ProxyImpl.getServerKeys()
+ *
+ *     SunJSSE does not support dynamic system properties, no way to re-use
+ *     system properties in samevm/agentvm mode.
+ * @run main/othervm CipherSuitesInOrder
+ */
+
+import java.util.*;
+import javax.net.ssl.*;
+
+public class CipherSuitesInOrder {
+
+    // supported ciphersuites
+    private final static List<String> supportedCipherSuites =
+            Arrays.<String>asList(
+        "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
+        "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
+        "TLS_RSA_WITH_AES_256_CBC_SHA256",
+        "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384",
+        "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384",
+        "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
+        "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
+        "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
+        "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
+        "TLS_RSA_WITH_AES_256_CBC_SHA",
+        "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
+        "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
+        "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
+        "TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
+        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
+        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
+        "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",
+        "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+        "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+        "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
+        "TLS_ECDHE_RSA_WITH_RC4_128_SHA",
+        "SSL_RSA_WITH_RC4_128_SHA",
+        "TLS_ECDH_ECDSA_WITH_RC4_128_SHA",
+        "TLS_ECDH_RSA_WITH_RC4_128_SHA",
+        "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
+        "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
+        "SSL_RSA_WITH_3DES_EDE_CBC_SHA",
+        "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA",
+        "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA",
+        "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
+        "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA",
+        "SSL_RSA_WITH_RC4_128_MD5",
+
+        "TLS_EMPTY_RENEGOTIATION_INFO_SCSV",
+
+        "TLS_DH_anon_WITH_AES_256_CBC_SHA256",
+        "TLS_ECDH_anon_WITH_AES_256_CBC_SHA",
+        "TLS_DH_anon_WITH_AES_256_CBC_SHA",
+        "TLS_DH_anon_WITH_AES_128_CBC_SHA256",
+        "TLS_ECDH_anon_WITH_AES_128_CBC_SHA",
+        "TLS_DH_anon_WITH_AES_128_CBC_SHA",
+        "TLS_ECDH_anon_WITH_RC4_128_SHA",
+        "SSL_DH_anon_WITH_RC4_128_MD5",
+        "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA",
+        "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA",
+        "TLS_RSA_WITH_NULL_SHA256",
+        "TLS_ECDHE_ECDSA_WITH_NULL_SHA",
+        "TLS_ECDHE_RSA_WITH_NULL_SHA",
+        "SSL_RSA_WITH_NULL_SHA",
+        "TLS_ECDH_ECDSA_WITH_NULL_SHA",
+        "TLS_ECDH_RSA_WITH_NULL_SHA",
+        "TLS_ECDH_anon_WITH_NULL_SHA",
+        "SSL_RSA_WITH_NULL_MD5",
+        "SSL_RSA_WITH_DES_CBC_SHA",
+        "SSL_DHE_RSA_WITH_DES_CBC_SHA",
+        "SSL_DHE_DSS_WITH_DES_CBC_SHA",
+        "SSL_DH_anon_WITH_DES_CBC_SHA",
+        "SSL_RSA_EXPORT_WITH_RC4_40_MD5",
+        "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",
+        "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
+        "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
+        "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA",
+        "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
+        "TLS_KRB5_WITH_RC4_128_SHA",
+        "TLS_KRB5_WITH_RC4_128_MD5",
+        "TLS_KRB5_WITH_3DES_EDE_CBC_SHA",
+        "TLS_KRB5_WITH_3DES_EDE_CBC_MD5",
+        "TLS_KRB5_WITH_DES_CBC_SHA",
+        "TLS_KRB5_WITH_DES_CBC_MD5",
+        "TLS_KRB5_EXPORT_WITH_RC4_40_SHA",
+        "TLS_KRB5_EXPORT_WITH_RC4_40_MD5",
+        "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA",
+        "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5"
+    );
+
+    private final static String[] protocols = {
+        "", "SSL", "TLS", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2"
+    };
+
+
+    public static void main(String[] args) throws Exception {
+        // show all of the supported cipher suites
+        showSuites(supportedCipherSuites.toArray(new String[0]),
+                                "All supported cipher suites");
+
+        for (String protocol : protocols) {
+            System.out.println("//");
+            System.out.println("// " +
+                        "Testing for SSLContext of " + protocol);
+            System.out.println("//");
+            checkForProtocols(protocol);
+        }
+    }
+
+    public static void checkForProtocols(String protocol) throws Exception {
+        SSLContext context;
+        if (protocol.isEmpty()) {
+            context = SSLContext.getDefault();
+        } else {
+            context = SSLContext.getInstance(protocol);
+            context.init(null, null, null);
+        }
+
+        // check the order of default cipher suites of SSLContext
+        SSLParameters parameters = context.getDefaultSSLParameters();
+        checkSuites(parameters.getCipherSuites(),
+                "Default cipher suites in SSLContext");
+
+        // check the order of supported cipher suites of SSLContext
+        parameters = context.getSupportedSSLParameters();
+        checkSuites(parameters.getCipherSuites(),
+                "Supported cipher suites in SSLContext");
+
+
+        //
+        // Check the cipher suites order of SSLEngine
+        //
+        SSLEngine engine = context.createSSLEngine();
+
+        // check the order of endabled cipher suites
+        String[] ciphers = engine.getEnabledCipherSuites();
+        checkSuites(ciphers,
+                "Enabled cipher suites in SSLEngine");
+
+        // check the order of supported cipher suites
+        ciphers = engine.getSupportedCipherSuites();
+        checkSuites(ciphers,
+                "Supported cipher suites in SSLEngine");
+
+        //
+        // Check the cipher suites order of SSLSocket
+        //
+        SSLSocketFactory factory = context.getSocketFactory();
+        try (SSLSocket socket = (SSLSocket)factory.createSocket()) {
+
+            // check the order of endabled cipher suites
+            ciphers = socket.getEnabledCipherSuites();
+            checkSuites(ciphers,
+                "Enabled cipher suites in SSLSocket");
+
+            // check the order of supported cipher suites
+            ciphers = socket.getSupportedCipherSuites();
+            checkSuites(ciphers,
+                "Supported cipher suites in SSLSocket");
+        }
+
+        //
+        // Check the cipher suites order of SSLServerSocket
+        //
+        SSLServerSocketFactory serverFactory = context.getServerSocketFactory();
+        try (SSLServerSocket serverSocket =
+                (SSLServerSocket)serverFactory.createServerSocket()) {
+            // check the order of endabled cipher suites
+            ciphers = serverSocket.getEnabledCipherSuites();
+            checkSuites(ciphers,
+                "Enabled cipher suites in SSLServerSocket");
+
+            // check the order of supported cipher suites
+            ciphers = serverSocket.getSupportedCipherSuites();
+            checkSuites(ciphers,
+                "Supported cipher suites in SSLServerSocket");
+        }
+    }
+
+    private static void checkSuites(String[] suites, String title) {
+        showSuites(suites, title);
+
+        int loc = -1;
+        int index = 0;
+        for (String suite : suites) {
+            index = supportedCipherSuites.indexOf(suite);
+            if (index <= loc) {
+                throw new RuntimeException(suite + " is not in order");
+            }
+
+            loc = index;
+        }
+    }
+
+    private static void showSuites(String[] suites, String title) {
+        System.out.println(title + "[" + suites.length + "]:");
+        for (String suite : suites) {
+            System.out.println("  " + suite);
+        }
+    }
+}