Merge
authorlana
Thu, 10 Mar 2011 20:49:43 -0800
changeset 8582 403d8b87612c
parent 8504 2984b0fec670 (current diff)
parent 8581 f22e1f4ade7c (diff)
child 8588 36e3e74be5ae
Merge
jdk/make/common/Release.gmk
jdk/src/share/classes/sun/misc/BootClassLoaderHook.java
jdk/src/share/classes/sun/misc/JavaSecurityCodeSignerAccess.java
jdk/test/sun/misc/BootClassLoaderHook/TestHook.java
--- a/jdk/make/common/Release.gmk	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/make/common/Release.gmk	Thu Mar 10 20:49:43 2011 -0800
@@ -62,7 +62,8 @@
 # This is an interim solution until the ct.sym is replaced
 # with a new module system (being discussed for JDK 7).
 #
-EXPORTED_PRIVATE_PKGS = com.sun.servicetag
+EXPORTED_PRIVATE_PKGS = com.sun.servicetag \
+                        com.oracle.net
 
 # 64-bit solaris has a few special cases. We define the variable
 # SOLARIS64 for use in this Makefile to easily test those cases
--- a/jdk/make/common/shared/Defs-java.gmk	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/make/common/shared/Defs-java.gmk	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2011, 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
@@ -45,7 +45,7 @@
   JAVA_MEM_FLAGS   += -Xms$(MIN_VM_MEMORY)m -XX:PermSize=32m -XX:MaxPermSize=160m
 endif
 
-# 
+#
 # All java tools (javac, javah, and javadoc) run faster with certain java
 #    options, this macro should be used with all these tools.
 #    In particular, the client VM makes these tools run faster when
@@ -122,6 +122,17 @@
   JAVACFLAGS  += -Werror
 endif
 
+#
+# Some licensees do not get the Security Source bundles.  We will
+# fall back on the prebuilt jce.jar so that we can do a best
+# attempt at building.  If sources exist, we always want to
+# build/use the most recent source instead of an older jce.jar, whether
+# built implicitly/explicitly.
+#
+ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),)
+  JCEFLAGS = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar
+endif
+
 # Add the source level
 SOURCE_LANGUAGE_VERSION = 7
 LANGUAGE_VERSION = -source $(SOURCE_LANGUAGE_VERSION)
@@ -132,11 +143,11 @@
 CLASS_VERSION = -target $(TARGET_CLASS_VERSION)
 JAVACFLAGS  += $(CLASS_VERSION)
 JAVACFLAGS  += -encoding ascii
-JAVACFLAGS  += "-Xbootclasspath:$(CLASSBINDIR)"
+JAVACFLAGS  += "-Xbootclasspath:$(CLASSBINDIR)$(JCEFLAGS)"
 JAVACFLAGS  += $(OTHER_JAVACFLAGS)
 
 # Needed for javah
-JAVAHFLAGS += -bootclasspath $(CLASSBINDIR)
+JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCEFLAGS)"
 
 # Needed for javadoc to ensure it builds documentation
 # against the newly built classes
--- a/jdk/make/docs/NON_CORE_PKGS.gmk	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/make/docs/NON_CORE_PKGS.gmk	Thu Mar 10 20:49:43 2011 -0800
@@ -91,8 +91,6 @@
 TRACING_PKGS     = com.sun.tracing         \
                    com.sun.tracing.dtrace
 
-ORACLENET_PKGS   = com.oracle.net
-
 # non-core packages in rt.jar
 NON_CORE_PKGS    = $(DOMAPI_PKGS) \
                    $(MGMT_PKGS) \
@@ -103,6 +101,5 @@
                    $(HTTPSERVER_PKGS) \
                    $(SMARTCARDIO_PKGS) \
                    $(TRACING_PKGS) \
-                   $(SCTPAPI_PKGS) \
-                   $(ORACLENET_PKGS)
+                   $(SCTPAPI_PKGS)
 
--- a/jdk/make/java/java/FILES_java.gmk	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/make/java/java/FILES_java.gmk	Thu Mar 10 20:49:43 2011 -0800
@@ -466,7 +466,6 @@
     java/security/ProtectionDomain.java \
     java/net/URLClassLoader.java \
     java/net/URLConnection.java \
-    sun/misc/BootClassLoaderHook.java \
     sun/misc/Launcher.java \
     sun/misc/MetaIndex.java \
     sun/misc/URLClassPath.java \
--- a/jdk/make/sun/awt/Makefile	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/make/sun/awt/Makefile	Thu Mar 10 20:49:43 2011 -0800
@@ -368,7 +368,7 @@
 FONTCONFIGS_SRC	= $(CLOSED_SRC)/solaris/classes/sun/awt/fontconfigs
 _FONTCONFIGS	= \
 	fontconfig.properties				\
-	fontconfig.RedHat.properties			\
+	fontconfig.RedHat.5.5.properties		\
 	fontconfig.Turbo.properties			\
 	fontconfig.SuSE.10.properties                   \
 	fontconfig.SuSE.11.properties
--- a/jdk/make/sun/awt/mapfile-mawt-vers	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/make/sun/awt/mapfile-mawt-vers	Thu Mar 10 20:49:43 2011 -0800
@@ -424,6 +424,7 @@
 		Java_sun_java2d_xr_XRSurfaceData_initXRPicture;
 		Java_sun_java2d_xr_XRSurfaceData_initIDs;
 		Java_sun_java2d_xr_XRSurfaceData_XRInitSurface;
+		Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture;
 		Java_sun_java2d_xr_XRBackendNative_initIDs;
 		Java_sun_java2d_xr_XIDGenerator_bufferXIDs;
 		Java_sun_java2d_xr_XRBackendNative_freeGC;
--- a/jdk/make/sun/xawt/mapfile-vers	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/make/sun/xawt/mapfile-vers	Thu Mar 10 20:49:43 2011 -0800
@@ -374,6 +374,7 @@
         Java_sun_java2d_xr_XRSurfaceData_initXRPicture;
         Java_sun_java2d_xr_XRSurfaceData_initIDs;
         Java_sun_java2d_xr_XRSurfaceData_XRInitSurface;
+	Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture;
 	Java_sun_java2d_xr_XRBackendNative_initIDs;
 	Java_sun_java2d_xr_XRBackendNative_freeGC;
 	Java_sun_java2d_xr_XRBackendNative_createGC;
@@ -432,6 +433,7 @@
         Java_sun_awt_X11_GtkFileDialogPeer_run;
         Java_sun_awt_X11_GtkFileDialogPeer_quit;
         Java_sun_awt_X11_GtkFileDialogPeer_toFront;
+        Java_sun_awt_X11_GtkFileDialogPeer_setBounds;
 
 	Java_sun_print_CUPSPrinter_initIDs;
 	Java_sun_print_CUPSPrinter_getCupsServer;
--- a/jdk/src/share/classes/com/sun/jarsigner/ContentSignerParameters.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/jarsigner/ContentSignerParameters.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -26,9 +26,7 @@
 package com.sun.jarsigner;
 
 import java.net.URI;
-import java.security.cert.X509CRL;
 import java.security.cert.X509Certificate;
-import java.util.Set;
 import java.util.zip.ZipFile;
 
 /**
@@ -83,13 +81,6 @@
     public X509Certificate[] getSignerCertificateChain();
 
     /**
-     * Retrieves the signer's X.509 CRLs.
-     *
-     * @return An unmodifiable set of X.509 CRLs (never <code>null</code>)
-     */
-    public Set<X509CRL> getCRLs();
-
-    /**
      * Retrieves the content that was signed.
      * The content is the JAR file's signature file.
      *
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -1011,7 +1011,7 @@
         return -1;
     }
 
-    Comparator<Entry> entryOutputOrder = new Comparator<>() {
+    Comparator<Entry> entryOutputOrder = new Comparator<Entry>() {
         public int compare(Entry  e0, Entry e1) {
             int k0 = getOutputIndex(e0);
             int k1 = getOutputIndex(e1);
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -785,7 +785,7 @@
             defMap.entrySet().toArray(layoutsAndCounts);
             // Sort by count, most frequent first.
             // Predefs. participate in this sort, though it does not matter.
-            Arrays.sort(layoutsAndCounts, new Comparator<>() {
+            Arrays.sort(layoutsAndCounts, new Comparator<Object>() {
                 public int compare(Object o0, Object o1) {
                     Map.Entry e0 = (Map.Entry) o0;
                     Map.Entry e1 = (Map.Entry) o1;
--- a/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/Connection.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -380,13 +380,19 @@
     }
 
     LdapRequest writeRequest(BerEncoder ber, int msgId) throws IOException {
-        return writeRequest(ber, msgId, false /* pauseAfterReceipt */);
+        return writeRequest(ber, msgId, false /* pauseAfterReceipt */, -1);
     }
 
-    LdapRequest writeRequest(BerEncoder ber, int msgId, boolean pauseAfterReceipt)
-        throws IOException {
+    LdapRequest writeRequest(BerEncoder ber, int msgId,
+        boolean pauseAfterReceipt) throws IOException {
+        return writeRequest(ber, msgId, pauseAfterReceipt, -1);
+    }
 
-        LdapRequest req = new LdapRequest(msgId, pauseAfterReceipt);
+    LdapRequest writeRequest(BerEncoder ber, int msgId,
+        boolean pauseAfterReceipt, int replyQueueCapacity) throws IOException {
+
+        LdapRequest req =
+            new LdapRequest(msgId, pauseAfterReceipt, replyQueueCapacity);
         addRequest(req);
 
         if (traceFile != null) {
--- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapClient.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapClient.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -516,7 +516,8 @@
     LdapResult search(String dn, int scope, int deref, int sizeLimit,
                       int timeLimit, boolean attrsOnly, String attrs[],
                       String filter, int batchSize, Control[] reqCtls,
-                      Hashtable binaryAttrs, boolean waitFirstReply)
+                      Hashtable binaryAttrs, boolean waitFirstReply,
+                      int replyQueueCapacity)
         throws IOException, NamingException {
 
         ensureOpen();
@@ -543,7 +544,8 @@
                 if (isLdapv3) encodeControls(ber, reqCtls);
             ber.endSeq();
 
-         LdapRequest req = conn.writeRequest(ber, curMsgId);
+         LdapRequest req =
+                conn.writeRequest(ber, curMsgId, false, replyQueueCapacity);
 
          res.msgId = curMsgId;
          res.status = LdapClient.LDAP_SUCCESS; //optimistic
--- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapCtx.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -191,6 +191,14 @@
     // Environment property for the domain name (derived from this context's DN)
     private static final String DOMAIN_NAME = "com.sun.jndi.ldap.domainname";
 
+    // Block until the first search reply is received
+    private static final String WAIT_FOR_REPLY =
+        "com.sun.jndi.ldap.search.waitForReply";
+
+    // Size of the queue of unprocessed search replies
+    private static final String REPLY_QUEUE_SIZE =
+        "com.sun.jndi.ldap.search.replyQueueSize";
+
     // ----------------- Fields that don't change -----------------------
     private static final NameParser parser = new LdapNameParser();
 
@@ -246,6 +254,8 @@
     private Hashtable binaryAttrs = null;    // attr values returned as byte[]
     private int connectTimeout = -1;         // no timeout value
     private int readTimeout = -1;            // no timeout value
+    private boolean waitForReply = true;     // wait for search response
+    private int replyQueueSize  = -1;        // unlimited queue size
     private boolean useSsl = false;          // true if SSL protocol is active
     private boolean useDefaultPortNumber = false; // no port number was supplied
 
@@ -1759,8 +1769,8 @@
                                          SearchControls cons,
                                          Continuation cont)
             throws NamingException {
-        return searchAux(name, filter, cloneSearchControls(cons), true, true,
-                         cont);
+        return searchAux(name, filter, cloneSearchControls(cons), true,
+                 waitForReply, cont);
     }
 
     protected NamingEnumeration c_search(Name name,
@@ -1928,7 +1938,7 @@
     }
 
     private LdapResult doSearch(Name name, String filter, SearchControls cons,
-        boolean relative, boolean waitFirstReply) throws NamingException {
+        boolean relative, boolean waitForReply) throws NamingException {
             ensureOpen();
             try {
                 int scope;
@@ -1984,7 +1994,8 @@
                         batchSize,
                         reqCtls,
                         binaryAttrs,
-                        waitFirstReply);
+                        waitForReply,
+                        replyQueueSize);
                 respCtls = answer.resControls; // retrieve response controls
                 return answer;
 
@@ -2170,6 +2181,10 @@
             connectTimeout = -1;
         } else if (propName.equals(READ_TIMEOUT)) {
             readTimeout = -1;
+        } else if (propName.equals(WAIT_FOR_REPLY)) {
+            waitForReply = true;
+        } else if (propName.equals(REPLY_QUEUE_SIZE)) {
+            replyQueueSize = -1;
 
 // The following properties affect the connection
 
@@ -2225,6 +2240,11 @@
                 setConnectTimeout((String)propVal);
             } else if (propName.equals(READ_TIMEOUT)) {
                 setReadTimeout((String)propVal);
+            } else if (propName.equals(WAIT_FOR_REPLY)) {
+                setWaitForReply((String)propVal);
+            } else if (propName.equals(REPLY_QUEUE_SIZE)) {
+                setReplyQueueSize((String)propVal);
+
 // The following properties affect the connection
 
             } else if (propName.equals(Context.SECURITY_PROTOCOL)) {
@@ -2312,6 +2332,13 @@
         // Set the read timeout
         setReadTimeout((String)envprops.get(READ_TIMEOUT));
 
+        // Set the flag that controls whether to block until the first reply
+        // is received
+        setWaitForReply((String)envprops.get(WAIT_FOR_REPLY));
+
+        // Set the size of the queue of unprocessed search replies
+        setReplyQueueSize((String)envprops.get(REPLY_QUEUE_SIZE));
+
         // When connection is created, it will use these and other
         // properties from the environment
     }
@@ -2442,6 +2469,34 @@
     }
 
     /**
+     * Sets the size of the queue of unprocessed search replies
+     */
+    private void setReplyQueueSize(String replyQueueSizeProp) {
+        if (replyQueueSizeProp != null) {
+           replyQueueSize = Integer.parseInt(replyQueueSizeProp);
+            // disallow an empty queue
+            if (replyQueueSize <= 0) {
+                replyQueueSize = -1;    // unlimited
+            }
+        } else {
+            replyQueueSize = -1;        // unlimited
+        }
+    }
+
+    /**
+     * Sets the flag that controls whether to block until the first search
+     * reply is received
+     */
+    private void setWaitForReply(String waitForReplyProp) {
+        if (waitForReplyProp != null &&
+            (waitForReplyProp.equalsIgnoreCase("false"))) {
+            waitForReply = false;
+        } else {
+            waitForReply = true;
+        }
+    }
+
+    /**
      * Sets the read timeout value
      */
     private void setReadTimeout(String readTimeoutProp) {
--- a/jdk/src/share/classes/com/sun/jndi/ldap/LdapRequest.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/jndi/ldap/LdapRequest.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, 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
@@ -26,7 +26,8 @@
 package com.sun.jndi.ldap;
 
 import java.io.IOException;
-import java.util.Vector;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
 import javax.naming.CommunicationException;
 
 final class LdapRequest {
@@ -35,14 +36,26 @@
     int msgId;          // read-only
 
     private int gotten = 0;
-    private Vector replies = new Vector(3);
+    private BlockingQueue<BerDecoder> replies;
+    private int highWatermark = -1;
     private boolean cancelled = false;
     private boolean pauseAfterReceipt = false;
     private boolean completed = false;
 
     LdapRequest(int msgId, boolean pause) {
+        this(msgId, pause, -1);
+    }
+
+    LdapRequest(int msgId, boolean pause, int replyQueueCapacity) {
         this.msgId = msgId;
         this.pauseAfterReceipt = pause;
+        if (replyQueueCapacity == -1) {
+            this.replies = new LinkedBlockingQueue<BerDecoder>();
+        } else {
+            this.replies =
+                new LinkedBlockingQueue<BerDecoder>(replyQueueCapacity);
+            highWatermark = (replyQueueCapacity * 80) / 100; // 80% capacity
+        }
     }
 
     synchronized void cancel() {
@@ -57,7 +70,13 @@
         if (cancelled) {
             return false;
         }
-        replies.addElement(ber);
+
+        // Add a new reply to the queue of unprocessed replies.
+        try {
+            replies.put(ber);
+        } catch (InterruptedException e) {
+            // ignore
+        }
 
         // peek at the BER buffer to check if it is a SearchResultDone PDU
         try {
@@ -70,6 +89,14 @@
         ber.reset();
 
         notify(); // notify anyone waiting for reply
+        /*
+         * If a queue capacity has been set then trigger a pause when the
+         * queue has filled to 80% capacity. Later, when the queue has drained
+         * then the reader gets unpaused.
+         */
+        if (highWatermark != -1 && replies.size() >= highWatermark) {
+            return true; // trigger the pause
+        }
         return pauseAfterReceipt;
     }
 
@@ -79,14 +106,12 @@
                 " cancelled");
         }
 
-        if (gotten < replies.size()) {
-            BerDecoder answer = (BerDecoder)replies.elementAt(gotten);
-            replies.setElementAt(null, gotten); // remove reference
-            ++gotten; // skip to next
-            return answer;
-        } else {
-            return null;
-        }
+        /*
+         * Remove a reply if the queue is not empty.
+         * poll returns null if queue is empty.
+         */
+        BerDecoder reply = replies.poll();
+        return reply;
     }
 
     synchronized boolean hasSearchCompleted() {
--- a/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java	Thu Mar 10 20:49:43 2011 -0800
@@ -25,12 +25,10 @@
 
 package com.sun.media.sound;
 
-import java.util.Vector;
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.IOException;
-import java.io.DataInputStream;
 
 import java.io.BufferedOutputStream;
 import java.io.DataOutputStream;
@@ -398,7 +396,8 @@
         header = baos.toByteArray();
         headerStream = new ByteArrayInputStream( header );
 
-        aiffStream = new SequenceInputStream(headerStream,codedAudioStream);
+        aiffStream = new SequenceInputStream(headerStream,
+                            new NoCloseInputStream(codedAudioStream));
 
         return aiffStream;
 
--- a/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java	Thu Mar 10 20:49:43 2011 -0800
@@ -52,9 +52,6 @@
     private static final short seg_end [] = {0xFF, 0x1FF, 0x3FF,
                                              0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF};
 
-    private static final int tempBufferSize = 64;
-    private byte tempBuffer [] = null;
-
     /**
      * Initializes the decode tables
      */
@@ -199,12 +196,9 @@
         AudioFormat inputFormat = stream.getFormat();
 
         if( inputFormat.matches(outputFormat) ) {
-
             cs = stream;
         } else {
-
             cs = (AudioInputStream) (new AlawCodecStream(stream, outputFormat));
-            tempBuffer = new byte[tempBufferSize];
         }
 
         return cs;
@@ -264,6 +258,10 @@
 
     class AlawCodecStream extends AudioInputStream {
 
+        // tempBuffer required only for encoding (when encode is true)
+        private static final int tempBufferSize = 64;
+        private byte tempBuffer [] = null;
+
         /**
          * True to encode to a-law, false to decode to linear
          */
@@ -303,6 +301,7 @@
                 encodeFormat = outputFormat;
                 decodeFormat = inputFormat;
                 PCMIsBigEndian = inputFormat.isBigEndian();
+                tempBuffer = new byte[tempBufferSize];
             }
 
             if (PCMIsBigEndian) {
--- a/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java	Thu Mar 10 20:49:43 2011 -0800
@@ -25,12 +25,10 @@
 
 package com.sun.media.sound;
 
-import java.util.Vector;
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.IOException;
-import java.lang.IllegalArgumentException;
 
 import java.io.BufferedOutputStream;
 import java.io.DataOutputStream;
@@ -131,10 +129,10 @@
             // $$fb: 2001-07-13: done. Fixes Bug 4479981
             RandomAccessFile raf=new RandomAccessFile(out, "rw");
             if (raf.length()<=0x7FFFFFFFl) {
-                                // skip AU magic and data offset field
+                // skip AU magic and data offset field
                 raf.skipBytes(8);
                 raf.writeInt(bytesWritten-AuFileFormat.AU_HEADERSIZE);
-                                // that's all
+                // that's all
             }
             raf.close();
         }
@@ -303,7 +301,8 @@
         dos.close();
         header = baos.toByteArray();
         headerStream = new ByteArrayInputStream( header );
-        auStream = new SequenceInputStream(headerStream,codedAudioStream);
+        auStream = new SequenceInputStream(headerStream,
+                        new NoCloseInputStream(codedAudioStream));
 
         return auStream;
     }
--- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java	Thu Mar 10 20:49:43 2011 -0800
@@ -395,11 +395,7 @@
         protected volatile boolean noService = false; // do not run the nService method
 
         // Guards all native calls.
-        protected Object lockNative = new Object();
-        // Guards the lastOpened static variable in implOpen and implClose.
-        protected static Object lockLast = new Object();
-        // Keeps track of last opened line, see implOpen "trick".
-        protected static DirectDL lastOpened;
+        protected final Object lockNative = new Object();
 
         // CONSTRUCTOR
         protected DirectDL(DataLine.Info info,
@@ -501,48 +497,21 @@
             // align buffer to full frames
             bufferSize = ((int) bufferSize / format.getFrameSize()) * format.getFrameSize();
 
-            synchronized(lockLast) {
-                id = nOpen(mixerIndex, deviceID, isSource,
-                        encoding,
-                        hardwareFormat.getSampleRate(),
-                        hardwareFormat.getSampleSizeInBits(),
-                        hardwareFormat.getFrameSize(),
-                        hardwareFormat.getChannels(),
-                        hardwareFormat.getEncoding().equals(
-                            AudioFormat.Encoding.PCM_SIGNED),
-                        hardwareFormat.isBigEndian(),
-                        bufferSize);
+            id = nOpen(mixerIndex, deviceID, isSource,
+                    encoding,
+                    hardwareFormat.getSampleRate(),
+                    hardwareFormat.getSampleSizeInBits(),
+                    hardwareFormat.getFrameSize(),
+                    hardwareFormat.getChannels(),
+                    hardwareFormat.getEncoding().equals(
+                        AudioFormat.Encoding.PCM_SIGNED),
+                    hardwareFormat.isBigEndian(),
+                    bufferSize);
 
-                if (id == 0) {
-                    // Bah... Dirty trick. The most likely cause is an application
-                    // already having a line open for this particular hardware
-                    // format and forgetting about it. If so, silently close that
-                    // implementation and try again. Unfortuantely we can only
-                    // open one line per hardware format currently.
-                    if (lastOpened != null
-                            && hardwareFormat.matches(lastOpened.hardwareFormat)) {
-                        lastOpened.implClose();
-                        lastOpened = null;
-
-                        id = nOpen(mixerIndex, deviceID, isSource,
-                                encoding,
-                                hardwareFormat.getSampleRate(),
-                                hardwareFormat.getSampleSizeInBits(),
-                                hardwareFormat.getFrameSize(),
-                                hardwareFormat.getChannels(),
-                                hardwareFormat.getEncoding().equals(
-                                    AudioFormat.Encoding.PCM_SIGNED),
-                                hardwareFormat.isBigEndian(),
-                                bufferSize);
-                    }
-
-                    if (id == 0) {
-                        // TODO: nicer error messages...
-                        throw new LineUnavailableException(
-                            "line with format "+format+" not supported.");
-                    }
-                }
-                lastOpened = this;
+            if (id == 0) {
+                // TODO: nicer error messages...
+                throw new LineUnavailableException(
+                        "line with format "+format+" not supported.");
             }
 
             this.bufferSize = nGetBufferSize(id, isSource);
@@ -615,14 +584,13 @@
             }
             synchronized (lockNative) {
                 nStop(id, isSource);
-
+            }
+            // wake up any waiting threads
+            synchronized(lock) {
                 // need to set doIO to false before notifying the
                 // read/write thread, that's why isStartedRunning()
                 // cannot be used
                 doIO = false;
-            }
-            // wake up any waiting threads
-            synchronized(lock) {
                 lock.notifyAll();
             }
             setActive(false);
@@ -649,12 +617,8 @@
             doIO = false;
             long oldID = id;
             id = 0;
-            synchronized (lockLast) {
-                synchronized (lockNative) {
-                    nClose(oldID, isSource);
-                    if (lastOpened == this)
-                      lastOpened = null;
-                }
+            synchronized (lockNative) {
+                nClose(oldID, isSource);
             }
             bytePosition = 0;
             softwareConversionSize = 0;
@@ -667,10 +631,9 @@
             if (id == 0) {
                 return 0;
             }
-            int a = 0;
+            int a;
             synchronized (lockNative) {
-                if (doIO)
-                    a = nAvailable(id, isSource);
+                a = nAvailable(id, isSource);
             }
             return a;
         }
@@ -726,7 +689,7 @@
                     lock.notifyAll();
                 }
                 synchronized (lockNative) {
-                    if (id != 0 && doIO) {
+                    if (id != 0) {
                         // then flush native buffers
                         nFlush(id, isSource);
                     }
@@ -737,10 +700,9 @@
 
         // replacement for getFramePosition (see AbstractDataLine)
         public long getLongFramePosition() {
-            long pos = 0;
+            long pos;
             synchronized (lockNative) {
-                if (doIO)
-                    pos = nGetBytePosition(id, isSource, bytePosition);
+                pos = nGetBytePosition(id, isSource, bytePosition);
             }
             // hack because ALSA sometimes reports wrong framepos
             if (pos < 0) {
@@ -786,12 +748,11 @@
             }
             int written = 0;
             while (!flushing) {
-                int thisWritten = 0;
+                int thisWritten;
                 synchronized (lockNative) {
-                    if (doIO)
-                        thisWritten = nWrite(id, b, off, len,
-                                softwareConversionSize,
-                                leftGain, rightGain);
+                    thisWritten = nWrite(id, b, off, len,
+                            softwareConversionSize,
+                            leftGain, rightGain);
                     if (thisWritten < 0) {
                         // error in native layer
                         break;
@@ -1014,10 +975,9 @@
             }
             int read = 0;
             while (doIO && !flushing) {
-                int thisRead = 0;
+                int thisRead;
                 synchronized (lockNative) {
-                    if (doIO)
-                        thisRead = nRead(id, b, off, len, softwareConversionSize);
+                    thisRead = nRead(id, b, off, len, softwareConversionSize);
                     if (thisRead < 0) {
                         // error in native layer
                         break;
@@ -1252,8 +1212,7 @@
             // set new native position (if necessary)
             // this must come after the flush!
             synchronized (lockNative) {
-                if (doIO)
-                    nSetBytePosition(id, isSource, frames * frameSize);
+                nSetBytePosition(id, isSource, frames * frameSize);
             }
 
             if (Printer.debug) Printer.debug("  DirectClip.setFramePosition: "
--- a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java	Thu Mar 10 20:49:43 2011 -0800
@@ -775,15 +775,22 @@
         Receiver rec = null;
         // first try to connect to the default synthesizer
         // IMPORTANT: this code needs to be synch'ed with
-        //            MidiSystem.getReceiver(boolean), because the same
+        //            MidiSystem.getSequencer(boolean), because the same
         //            algorithm needs to be used!
         try {
             Synthesizer synth = MidiSystem.getSynthesizer();
-            synth.open();
             if (synth instanceof ReferenceCountingDevice) {
                 rec = ((ReferenceCountingDevice) synth).getReceiverReferenceCounting();
             } else {
-                rec = synth.getReceiver();
+                synth.open();
+                try {
+                    rec = synth.getReceiver();
+                } finally {
+                    // make sure that the synth is properly closed
+                    if (rec == null) {
+                        synth.close();
+                    }
+                }
             }
         } catch (Exception e) {
             // something went wrong with synth
--- a/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java	Thu Mar 10 20:49:43 2011 -0800
@@ -127,7 +127,7 @@
                 resolution = timing;
             } else {
                 // SMPTE based timing.  first decipher the frame code.
-                int frameCode = (-1 * timing) >> 8;
+                int frameCode = -1 * (timing >> 8);
                 switch(frameCode) {
                 case 24:
                     divisionType = Sequence.SMPTE_24;
--- a/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java	Thu Mar 10 20:49:43 2011 -0800
@@ -30,14 +30,9 @@
 import java.io.OutputStream;
 import java.io.IOException;
 import java.io.DataInputStream;
-import java.io.RandomAccessFile;
-import java.net.URL;
 
-import javax.sound.sampled.AudioFormat;
 import javax.sound.sampled.AudioFileFormat;
 import javax.sound.sampled.AudioInputStream;
-import javax.sound.sampled.AudioSystem;
-import javax.sound.sampled.UnsupportedAudioFileException;
 import javax.sound.sampled.spi.AudioFileWriter;
 
 
@@ -177,4 +172,62 @@
         return i;
     }
 
+    /**
+     * InputStream wrapper class which prevent source stream from being closed.
+     * The class is usefull for use with SequenceInputStream to prevent
+     * closing of the source input streams.
+     */
+    protected class NoCloseInputStream extends InputStream {
+        private final InputStream in;
+
+        public NoCloseInputStream(InputStream in) {
+            this.in = in;
+        }
+
+        @Override
+        public int read() throws IOException {
+            return in.read();
+        }
+
+        @Override
+        public int read(byte b[]) throws IOException {
+            return in.read(b);
+        }
+
+        @Override
+        public int read(byte b[], int off, int len) throws IOException {
+            return in.read(b, off, len);
+        }
+
+        @Override
+        public long skip(long n) throws IOException {
+            return in.skip(n);
+        }
+
+        @Override
+        public int available() throws IOException {
+            return in.available();
+        }
+
+        @Override
+        public void close() throws IOException {
+            // don't propagate the call
+        }
+
+        @Override
+        public void mark(int readlimit) {
+            in.mark(readlimit);
+        }
+
+        @Override
+        public void reset() throws IOException {
+            in.reset();
+        }
+
+        @Override
+        public boolean markSupported() {
+            return in.markSupported();
+        }
+
+    }
 }
--- a/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java	Thu Mar 10 20:49:43 2011 -0800
@@ -25,12 +25,10 @@
 
 package com.sun.media.sound;
 
-import java.util.Vector;
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.IOException;
-import java.lang.IllegalArgumentException;
 
 import java.io.BufferedOutputStream;
 import java.io.DataOutputStream;
@@ -371,7 +369,8 @@
         dos.close();
         header = baos.toByteArray();
         headerStream = new ByteArrayInputStream( header );
-        waveStream = new SequenceInputStream(headerStream,codedAudioStream);
+        waveStream = new SequenceInputStream(headerStream,
+                            new NoCloseInputStream(codedAudioStream));
 
         return (InputStream)waveStream;
     }
--- a/jdk/src/share/classes/java/awt/Font.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/awt/Font.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1985,8 +1985,22 @@
      * @since 1.2
      */
     public int canDisplayUpTo(String str) {
-        return canDisplayUpTo(new StringCharacterIterator(str), 0,
-            str.length());
+        Font2D font2d = getFont2D();
+        int len = str.length();
+        for (int i = 0; i < len; i++) {
+            char c = str.charAt(i);
+            if (font2d.canDisplay(c)) {
+                continue;
+            }
+            if (!Character.isHighSurrogate(c)) {
+                return i;
+            }
+            if (!font2d.canDisplay(str.codePointAt(i))) {
+                return i;
+            }
+            i++;
+        }
+        return -1;
     }
 
     /**
@@ -2009,11 +2023,21 @@
      * @since 1.2
      */
     public int canDisplayUpTo(char[] text, int start, int limit) {
-        while (start < limit && canDisplay(text[start])) {
-            ++start;
+        Font2D font2d = getFont2D();
+        for (int i = start; i < limit; i++) {
+            char c = text[i];
+            if (font2d.canDisplay(c)) {
+                continue;
+            }
+            if (!Character.isHighSurrogate(c)) {
+                return i;
+            }
+            if (!font2d.canDisplay(Character.codePointAt(text, i, limit))) {
+                return i;
+            }
+            i++;
         }
-
-        return start == limit ? -1 : start;
+        return -1;
     }
 
     /**
@@ -2034,13 +2058,26 @@
      * @since 1.2
      */
     public int canDisplayUpTo(CharacterIterator iter, int start, int limit) {
-        for (char c = iter.setIndex(start);
-             iter.getIndex() < limit && canDisplay(c);
-             c = iter.next()) {
+        Font2D font2d = getFont2D();
+        char c = iter.setIndex(start);
+        for (int i = start; i < limit; i++, c = iter.next()) {
+            if (font2d.canDisplay(c)) {
+                continue;
+            }
+            if (!Character.isHighSurrogate(c)) {
+                return i;
+            }
+            char c2 = iter.next();
+            // c2 could be CharacterIterator.DONE which is not a low surrogate.
+            if (!Character.isLowSurrogate(c2)) {
+                return i;
+            }
+            if (!font2d.canDisplay(Character.toCodePoint(c, c2))) {
+                return i;
+            }
+            i++;
         }
-
-        int result = iter.getIndex();
-        return result == limit ? -1 : result;
+        return -1;
     }
 
     /**
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java	Thu Mar 10 20:49:43 2011 -0800
@@ -58,7 +58,6 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
-import sun.misc.BootClassLoaderHook;
 
 /**
  * A representation of color profile data for device independent and
@@ -865,8 +864,7 @@
         case ColorSpace.CS_PYCC:
             synchronized(ICC_Profile.class) {
                 if (PYCCprofile == null) {
-                    if (BootClassLoaderHook.getHook() != null ||
-                        standardProfileExists("PYCC.pf"))
+                    if (standardProfileExists("PYCC.pf"))
                     {
                         ProfileDeferralInfo pInfo =
                             new ProfileDeferralInfo("PYCC.pf",
--- a/jdk/src/share/classes/java/io/File.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/io/File.java	Thu Mar 10 20:49:43 2011 -0800
@@ -2055,7 +2055,7 @@
      *
      * @return  a {@code Path} constructed from this abstract path
      *
-     * @throws  InvalidPathException
+     * @throws  java.nio.file.InvalidPathException
      *          if a {@code Path} object cannot be constructed from the abstract
      *          path (see {@link java.nio.file.FileSystem#getPath FileSystem.getPath})
      *
--- a/jdk/src/share/classes/java/lang/ClassLoader.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java	Thu Mar 10 20:49:43 2011 -0800
@@ -51,7 +51,6 @@
 import java.util.Hashtable;
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
-import sun.misc.BootClassLoaderHook;
 import sun.misc.ClassFileTransformer;
 import sun.misc.CompoundEnumeration;
 import sun.misc.Resource;
@@ -1300,7 +1299,6 @@
      * Find resources from the VM's built-in classloader.
      */
     private static URL getBootstrapResource(String name) {
-        BootClassLoaderHook.preLoadResource(name);
         URLClassPath ucp = getBootstrapClassPath();
         Resource res = ucp.getResource(name);
         return res != null ? res.getURL() : null;
@@ -1814,7 +1812,6 @@
     // Invoked in the java.lang.Runtime class to implement load and loadLibrary.
     static void loadLibrary(Class fromClass, String name,
                             boolean isAbsolute) {
-        BootClassLoaderHook.preLoadLibrary(name);
         ClassLoader loader =
             (fromClass == null) ? null : fromClass.getClassLoader();
         if (sys_paths == null) {
--- a/jdk/src/share/classes/java/lang/Package.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/lang/Package.java	Thu Mar 10 20:49:43 2011 -0800
@@ -576,12 +576,10 @@
      * Returns the Manifest for the specified JAR file name.
      */
     private static Manifest loadManifest(String fn) {
-        try {
-            FileInputStream fis = new FileInputStream(fn);
-            JarInputStream jis = new JarInputStream(fis, false);
-            Manifest man = jis.getManifest();
-            jis.close();
-            return man;
+        try (FileInputStream fis = new FileInputStream(fn);
+             JarInputStream jis = new JarInputStream(fis, false))
+        {
+            return jis.getManifest();
         } catch (IOException e) {
             return null;
         }
--- a/jdk/src/share/classes/java/net/HttpURLConnection.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/net/HttpURLConnection.java	Thu Mar 10 20:49:43 2011 -0800
@@ -400,7 +400,8 @@
      * @exception ProtocolException if the method cannot be reset or if
      *              the requested method isn't valid for HTTP.
      * @exception SecurityException if a security manager is set and the
-     *              "allowHttpTrace" NetPermission is not granted.
+     *              method is "TRACE", but the "allowHttpTrace"
+     *              NetPermission is not granted.
      * @see #getRequestMethod()
      */
     public void setRequestMethod(String method) throws ProtocolException {
--- a/jdk/src/share/classes/java/net/NetPermission.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/net/NetPermission.java	Thu Mar 10 20:49:43 2011 -0800
@@ -73,6 +73,13 @@
  *   </tr>
  *
  * <tr>
+ *  <td>getNetworkInformation</td>
+ *  <td>The ability to retrieve all information about local network interfaces.</td>
+ *  <td>Malicious code can read information about network hardware such as
+ *  MAC addresses, which could be used to construct local IPv6 addresses.</td>
+ * </tr>
+ *
+ * <tr>
  *   <td>getProxySelector</td>
  *   <td>The ability to get the proxy selector used to make decisions
  *   on which proxies to use when making network connections.</td>
--- a/jdk/src/share/classes/java/net/URI.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/net/URI.java	Thu Mar 10 20:49:43 2011 -0800
@@ -991,7 +991,7 @@
      *   authority and path are taken from the given URI. </p></li>
      *
      *   <li><p> Otherwise the new URI's authority component is copied from
-     *   this URI, and its path is computed as follows: </p></li>
+     *   this URI, and its path is computed as follows: </p>
      *
      *   <ol type=a>
      *
@@ -1005,7 +1005,7 @@
      *     path and then normalizing the result as if by invoking the {@link
      *     #normalize() normalize} method. </p></li>
      *
-     *   </ol>
+     *   </ol></li>
      *
      * </ol>
      *
@@ -1511,7 +1511,7 @@
      *   fragments. </p></li>
      *
      *   <li><p> Two hierarchical URIs with identical schemes are ordered
-     *   according to the ordering of their authority components: </p></li>
+     *   according to the ordering of their authority components: </p>
      *
      *   <ul type=disc>
      *
@@ -1526,7 +1526,7 @@
      *     the URIs are ordered according to the ordering of their authority
      *     components. </p></li>
      *
-     *   </ul>
+     *   </ul></li>
      *
      *   <li><p> Finally, two hierarchical URIs with identical schemes and
      *   authority components are ordered according to the ordering of their
--- a/jdk/src/share/classes/java/net/package.html	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/net/package.html	Thu Mar 10 20:49:43 2011 -0800
@@ -31,18 +31,18 @@
 
 <p> The java.net package can be roughly divided in two sections:</p>
 <ul>
-    <li> <p><i>A Low Level API</i>, which deals with the following abstractions:</p></li>
+    <li> <p><i>A Low Level API</i>, which deals with the following abstractions:</p>
     <ul>
       <li><p><i>Addresses</i>, which are networking identifiers, like IP addresses.</p></li>
       <li><p><i>Sockets</i>, which are basic bidirectional data communication mechanisms.</p></li>
       <li><p><i>Interfaces</i>, which describe network interfaces. </p></li>
-    </ul>
-    <li> <p><i>A High Level API</i>, which deals with the following abstractions:</p></li>
+    </ul></li>
+    <li> <p><i>A High Level API</i>, which deals with the following abstractions:</p>
     <ul>
       <li><p><i>URIs</i>, which represent Universal Resource Identifiers.</p></li>
       <li><p><i>URLs</i>, which represent Universal Resource Locators.</p></li>
       <li><p><i>Connections</i>, which represents connections to the resource pointed to by <i>URLs</i>.</p></li>
-      </ul>
+      </ul></li>
 </ul>
 <h2>Addresses</h2>
 <p>Addresses are used throughout the java.net APIs as either host identifiers, or socket endpoint identifiers.</p>
--- a/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/nio/channels/AsynchronousFileChannel.java	Thu Mar 10 20:49:43 2011 -0800
@@ -48,12 +48,12 @@
  *
  * <p> An asynchronous file channel does not have a <i>current position</i>
  * within the file. Instead, the file position is specified to each read and
- * write methd that initiate asynchronous operations. A {@link CompletionHandler}
+ * write method that initiates asynchronous operations. A {@link CompletionHandler}
  * is specified as a parameter and is invoked to consume the result of the I/O
  * operation. This class also defines read and write methods that initiate
  * asynchronous operations, returning a {@link Future} to represent the pending
  * result of the operation. The {@code Future} may be used to check if the
- * operation has completed, to wait for its completion.
+ * operation has completed, wait for its completion, and retrieve the result.
  *
  * <p> In addition to read and write operations, this class defines the
  * following operations: </p>
@@ -73,13 +73,13 @@
  * which tasks are submitted to handle I/O events and dispatch to completion
  * handlers that consume the results of I/O operations on the channel. The
  * completion handler for an I/O operation initiated on a channel is guaranteed
- * to be invoked by one threads in the thread pool (This ensures that the
+ * to be invoked by one of the threads in the thread pool (This ensures that the
  * completion handler is run by a thread with the expected <em>identity</em>).
  * Where an I/O operation completes immediately, and the initiating thread is
  * itself a thread in the thread pool, then the completion handler may be invoked
  * directly by the initiating thread. When an {@code AsynchronousFileChannel} is
  * created without specifying a thread pool then the channel is associated with
- * a system-dependent and default thread pool that may be shared with other
+ * a system-dependent default thread pool that may be shared with other
  * channels. The default thread pool is configured by the system properties
  * defined by the {@link AsynchronousChannelGroup} class.
  *
--- a/jdk/src/share/classes/java/nio/channels/SocketChannel.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/nio/channels/SocketChannel.java	Thu Mar 10 20:49:43 2011 -0800
@@ -182,10 +182,13 @@
         SocketChannel sc = open();
         try {
             sc.connect(remote);
-        } finally {
-            if (!sc.isConnected()) {
-                try { sc.close(); } catch (IOException x) { }
+        } catch (Throwable x) {
+            try {
+                sc.close();
+            } catch (Throwable suppressed) {
+                x.addSuppressed(suppressed);
             }
+            throw x;
         }
         assert sc.isConnected();
         return sc;
--- a/jdk/src/share/classes/java/nio/file/CopyMoveHelper.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/nio/file/CopyMoveHelper.java	Thu Mar 10 20:49:43 2011 -0800
@@ -135,11 +135,13 @@
                 view.setTimes(attrs.lastModifiedTime(),
                               attrs.lastAccessTime(),
                               attrs.creationTime());
-            } catch (IOException x) {
+            } catch (Throwable x) {
                 // rollback
                 try {
                     Files.delete(target);
-                } catch (IOException ignore) { }
+                } catch (Throwable suppressed) {
+                    x.addSuppressed(suppressed);
+                }
                 throw x;
             }
         }
--- a/jdk/src/share/classes/java/nio/file/Files.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/nio/file/Files.java	Thu Mar 10 20:49:43 2011 -0800
@@ -129,17 +129,18 @@
      * <pre>
      *     Path path = ...
      *
-     *     // replace an existing file or create the file if it doesn't initially exist
+     *     // truncate and overwrite an existing file, or create the file if
+     *     // it doesn't initially exist
      *     OutputStream out = Files.newOutputStream(path);
      *
      *     // append to an existing file, fail if the file does not exist
      *     out = Files.newOutputStream(path, APPEND);
      *
      *     // append to an existing file, create file if it doesn't initially exist
-     *     out = Files.newOutputStream(CREATE, APPEND);
+     *     out = Files.newOutputStream(path, CREATE, APPEND);
      *
      *     // always create new file, failing if it already exists
-     *     out = Files.newOutputStream(CREATE_NEW);
+     *     out = Files.newOutputStream(path, CREATE_NEW);
      * </pre>
      *
      * @param   path
@@ -793,7 +794,8 @@
                                       FileAttribute<?>... attrs)
         throws IOException
     {
-        return TempFileHelper.createTempFile(dir, prefix, suffix, attrs);
+        return TempFileHelper.createTempFile(Objects.requireNonNull(dir),
+                                             prefix, suffix, attrs);
     }
 
     /**
@@ -890,13 +892,14 @@
                                            FileAttribute<?>... attrs)
         throws IOException
     {
-        return TempFileHelper.createTempDirectory(dir, prefix, attrs);
+        return TempFileHelper.createTempDirectory(Objects.requireNonNull(dir),
+                                                  prefix, attrs);
     }
 
     /**
      * Creates a new directory in the default temporary-file directory, using
-     * the given prefix and suffix to generate its name. The resulting {@code
-     * Path} is associated with the default {@code FileSystem}.
+     * the given prefix to generate its name. The resulting {@code Path} is
+     * associated with the default {@code FileSystem}.
      *
      * <p> This method works in exactly the manner specified by {@link
      * #createTempDirectory(Path,String,FileAttribute[])} method for the case
@@ -2583,7 +2586,7 @@
      * walkFileTree(start, EnumSet.noneOf(FileVisitOption.class), Integer.MAX_VALUE, visitor)
      * </pre></blockquote>
      * In other words, it does not follow symbolic links, and visits all levels
-     * of the file level.
+     * of the file tree.
      *
      * @param   start
      *          the starting file
@@ -3005,7 +3008,7 @@
      * or after some bytes have been written to the file.
      *
      * <p> <b>Usage example</b>: By default the method creates a new file or
-     * overrides an existing file. Suppose you instead want to append bytes
+     * overwrites an existing file. Suppose you instead want to append bytes
      * to an existing file:
      * <pre>
      *     Path path = ...
--- a/jdk/src/share/classes/java/security/CodeSigner.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/security/CodeSigner.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -26,10 +26,7 @@
 package java.security;
 
 import java.io.*;
-import java.security.cert.CRL;
 import java.security.cert.CertPath;
-import sun.misc.JavaSecurityCodeSignerAccess;
-import sun.misc.SharedSecrets;
 
 /**
  * This class encapsulates information about a code signer.
@@ -167,44 +164,6 @@
         return sb.toString();
     }
 
-    // A private attribute attached to this CodeSigner object. Can be accessed
-    // through SharedSecrets.getJavaSecurityCodeSignerAccess().[g|s]etCRLs
-    //
-    // Currently called in SignatureFileVerifier.getSigners
-    private transient CRL[] crls;
-
-    /**
-     * Sets the CRLs attached
-     * @param crls, null to clear
-     */
-    void setCRLs(CRL[] crls) {
-        this.crls = crls;
-    }
-
-    /**
-     * Returns the CRLs attached
-     * @return the crls, initially null
-     */
-    CRL[] getCRLs() {
-        return crls;
-    }
-
-    // Set up JavaSecurityCodeSignerAccess in SharedSecrets
-    static {
-        SharedSecrets.setJavaSecurityCodeSignerAccess(
-                new JavaSecurityCodeSignerAccess() {
-            @Override
-            public void setCRLs(CodeSigner signer, CRL[] crls) {
-                signer.setCRLs(crls);
-            }
-
-            @Override
-            public CRL[] getCRLs(CodeSigner signer) {
-                return signer.getCRLs();
-            }
-        });
-    }
-
     // Explicitly reset hash code value to -1
     private void readObject(ObjectInputStream ois)
         throws IOException, ClassNotFoundException {
--- a/jdk/src/share/classes/java/util/Calendar.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/Calendar.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, 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
@@ -554,7 +554,7 @@
 
     /**
      * Field number for <code>get</code> and <code>set</code> indicating the
-     * daylight savings offset in milliseconds.
+     * daylight saving offset in milliseconds.
      * <p>
      * This field reflects the correct daylight saving offset value of
      * the time zone of this <code>Calendar</code> if the
--- a/jdk/src/share/classes/java/util/Currency.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/Currency.java	Thu Mar 10 20:49:43 2011 -0800
@@ -233,7 +233,9 @@
                                              "currency.properties");
                     if (propFile.exists()) {
                         Properties props = new Properties();
-                        props.load(new FileReader(propFile));
+                        try (FileReader fr = new FileReader(propFile)) {
+                            props.load(fr);
+                        }
                         Set<String> keys = props.stringPropertyNames();
                         Pattern propertiesPattern =
                             Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
--- a/jdk/src/share/classes/java/util/GregorianCalendar.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/GregorianCalendar.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, 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
@@ -260,7 +260,7 @@
  * // create a Pacific Standard Time time zone
  * SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
  *
- * // set up rules for daylight savings time
+ * // set up rules for Daylight Saving Time
  * pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
  * pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
  *
--- a/jdk/src/share/classes/java/util/TimeZone.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/TimeZone.java	Thu Mar 10 20:49:43 2011 -0800
@@ -339,8 +339,9 @@
     /**
      * Returns a name in the specified {@code style} of this {@code TimeZone}
      * suitable for presentation to the user in the default locale. If the
-     * specified {@code daylight} is {@code true}, a daylight saving time name
-     * is returned. Otherwise, a standard time name is returned.
+     * specified {@code daylight} is {@code true}, a Daylight Saving Time name
+     * is returned (even if this {@code TimeZone} doesn't observe Daylight Saving
+     * Time). Otherwise, a Standard Time name is returned.
      *
      * <p>This method is equivalent to:
      * <pre><blockquote>
@@ -348,7 +349,8 @@
      *                Locale.getDefault({@link Locale.Category#DISPLAY}))
      * </blockquote></pre>
      *
-     * @param daylight if {@code true}, return the daylight saving time name.
+     * @param daylight {@code true} specifying a Daylight Saving Time name, or
+     *                 {@code false} specifying a Standard Time name
      * @param style either {@link #LONG} or {@link #SHORT}
      * @return the human-readable name of this time zone in the default locale.
      * @exception IllegalArgumentException if {@code style} is invalid.
@@ -356,6 +358,7 @@
      * @see #getDisplayName(boolean, int, Locale)
      * @see Locale#getDefault(Locale.Category)
      * @see Locale.Category
+     * @see java.text.DateFormatSymbols#getZoneStrings()
      */
     public final String getDisplayName(boolean daylight, int style) {
         return getDisplayName(daylight, style,
@@ -365,8 +368,9 @@
     /**
      * Returns a name in the specified {@code style} of this {@code TimeZone}
      * suitable for presentation to the user in the specified {@code
-     * locale}. If the specified {@code daylight} is {@code true}, a daylight
-     * saving time name is returned. Otherwise, a standard time name is
+     * locale}. If the specified {@code daylight} is {@code true}, a Daylight
+     * Saving Time name is returned (even if this {@code TimeZone} doesn't
+     * observe Daylight Saving Time). Otherwise, a Standard Time name is
      * returned.
      *
      * <p>When looking up a time zone name, the {@linkplain
@@ -379,13 +383,15 @@
      * found, the name is returned. Otherwise, a string in the
      * <a href="#NormalizedCustomID">normalized custom ID format</a> is returned.
      *
-     * @param daylight if {@code true}, return the daylight saving time name.
+     * @param daylight {@code true} specifying a Daylight Saving Time name, or
+     *                 {@code false} specifying a Standard Time name
      * @param style either {@link #LONG} or {@link #SHORT}
-     * @param locale the locale in which to supply the display name.
+     * @param locale   the locale in which to supply the display name.
      * @return the human-readable name of this time zone in the given locale.
      * @exception IllegalArgumentException if {@code style} is invalid.
      * @exception NullPointerException if {@code locale} is {@code null}.
      * @since 1.2
+     * @see java.text.DateFormatSymbols#getZoneStrings()
      */
     public String getDisplayName(boolean daylight, int style, Locale locale) {
         if (style != SHORT && style != LONG) {
@@ -526,10 +532,10 @@
 
     /**
      * Queries if the given {@code date} is in Daylight Saving Time in
-     * this {@code TimeZone}.
+     * this time zone.
      *
-     * @param date the given {@code Date}.
-     * @return {@code true} if the given {@code date} is in Daylight Saving Time,
+     * @param date the given Date.
+     * @return {@code true} if the given date is in Daylight Saving Time,
      *         {@code false}, otherwise.
      */
     abstract public boolean inDaylightTime(Date date);
@@ -566,7 +572,7 @@
      * @param rawOffset the given time zone GMT offset in milliseconds.
      * @return an array of IDs, where the time zone for that ID has
      * the specified GMT offset. For example, "America/Phoenix" and "America/Denver"
-     * both have GMT-07:00, but differ in daylight savings behavior.
+     * both have GMT-07:00, but differ in daylight saving behavior.
      * @see #getRawOffset()
      */
     public static synchronized String[] getAvailableIDs(int rawOffset) {
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedDeque.java	Thu Mar 10 20:49:43 2011 -0800
@@ -272,13 +272,6 @@
 
     private static final Node<Object> PREV_TERMINATOR, NEXT_TERMINATOR;
 
-    static {
-        PREV_TERMINATOR = new Node<Object>(null);
-        PREV_TERMINATOR.next = PREV_TERMINATOR;
-        NEXT_TERMINATOR = new Node<Object>(null);
-        NEXT_TERMINATOR.prev = NEXT_TERMINATOR;
-    }
-
     @SuppressWarnings("unchecked")
     Node<E> prevTerminator() {
         return (Node<E>) PREV_TERMINATOR;
@@ -294,6 +287,9 @@
         volatile E item;
         volatile Node<E> next;
 
+        Node() {  // default constructor for NEXT_TERMINATOR, PREV_TERMINATOR
+        }
+
         /**
          * Constructs a new node.  Uses relaxed write because item can
          * only be seen after publication via casNext or casPrev.
@@ -324,14 +320,25 @@
 
         // Unsafe mechanics
 
-        private static final sun.misc.Unsafe UNSAFE =
-            sun.misc.Unsafe.getUnsafe();
-        private static final long prevOffset =
-            objectFieldOffset(UNSAFE, "prev", Node.class);
-        private static final long itemOffset =
-            objectFieldOffset(UNSAFE, "item", Node.class);
-        private static final long nextOffset =
-            objectFieldOffset(UNSAFE, "next", Node.class);
+        private static final sun.misc.Unsafe UNSAFE;
+        private static final long prevOffset;
+        private static final long itemOffset;
+        private static final long nextOffset;
+
+        static {
+            try {
+                UNSAFE = sun.misc.Unsafe.getUnsafe();
+                Class k = Node.class;
+                prevOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("prev"));
+                itemOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("item"));
+                nextOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("next"));
+            } catch (Exception e) {
+                throw new Error(e);
+            }
+        }
     }
 
     /**
@@ -1422,14 +1429,6 @@
         initHeadTail(h, t);
     }
 
-    // Unsafe mechanics
-
-    private static final sun.misc.Unsafe UNSAFE =
-        sun.misc.Unsafe.getUnsafe();
-    private static final long headOffset =
-        objectFieldOffset(UNSAFE, "head", ConcurrentLinkedDeque.class);
-    private static final long tailOffset =
-        objectFieldOffset(UNSAFE, "tail", ConcurrentLinkedDeque.class);
 
     private boolean casHead(Node<E> cmp, Node<E> val) {
         return UNSAFE.compareAndSwapObject(this, headOffset, cmp, val);
@@ -1439,15 +1438,25 @@
         return UNSAFE.compareAndSwapObject(this, tailOffset, cmp, val);
     }
 
-    static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
-                                  String field, Class<?> klazz) {
+    // Unsafe mechanics
+
+    private static final sun.misc.Unsafe UNSAFE;
+    private static final long headOffset;
+    private static final long tailOffset;
+    static {
+        PREV_TERMINATOR = new Node<Object>();
+        PREV_TERMINATOR.next = PREV_TERMINATOR;
+        NEXT_TERMINATOR = new Node<Object>();
+        NEXT_TERMINATOR.prev = NEXT_TERMINATOR;
         try {
-            return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
-        } catch (NoSuchFieldException e) {
-            // Convert Exception to corresponding Error
-            NoSuchFieldError error = new NoSuchFieldError(field);
-            error.initCause(e);
-            throw error;
+            UNSAFE = sun.misc.Unsafe.getUnsafe();
+            Class k = ConcurrentLinkedDeque.class;
+            headOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("head"));
+            tailOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("tail"));
+        } catch (Exception e) {
+            throw new Error(e);
         }
     }
 }
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentLinkedQueue.java	Thu Mar 10 20:49:43 2011 -0800
@@ -194,12 +194,22 @@
 
         // Unsafe mechanics
 
-        private static final sun.misc.Unsafe UNSAFE =
-            sun.misc.Unsafe.getUnsafe();
-        private static final long nextOffset =
-            objectFieldOffset(UNSAFE, "next", Node.class);
-        private static final long itemOffset =
-            objectFieldOffset(UNSAFE, "item", Node.class);
+        private static final sun.misc.Unsafe UNSAFE;
+        private static final long itemOffset;
+        private static final long nextOffset;
+
+        static {
+            try {
+                UNSAFE = sun.misc.Unsafe.getUnsafe();
+                Class k = Node.class;
+                itemOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("item"));
+                nextOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("next"));
+            } catch (Exception e) {
+                throw new Error(e);
+            }
+        }
     }
 
     /**
@@ -790,14 +800,6 @@
             throw new NullPointerException();
     }
 
-    // Unsafe mechanics
-
-    private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-    private static final long headOffset =
-        objectFieldOffset(UNSAFE, "head", ConcurrentLinkedQueue.class);
-    private static final long tailOffset =
-        objectFieldOffset(UNSAFE, "tail", ConcurrentLinkedQueue.class);
-
     private boolean casTail(Node<E> cmp, Node<E> val) {
         return UNSAFE.compareAndSwapObject(this, tailOffset, cmp, val);
     }
@@ -806,15 +808,21 @@
         return UNSAFE.compareAndSwapObject(this, headOffset, cmp, val);
     }
 
-    static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
-                                  String field, Class<?> klazz) {
+    // Unsafe mechanics
+
+    private static final sun.misc.Unsafe UNSAFE;
+    private static final long headOffset;
+    private static final long tailOffset;
+    static {
         try {
-            return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
-        } catch (NoSuchFieldException e) {
-            // Convert Exception to corresponding Error
-            NoSuchFieldError error = new NoSuchFieldError(field);
-            error.initCause(e);
-            throw error;
+            UNSAFE = sun.misc.Unsafe.getUnsafe();
+            Class k = ConcurrentLinkedQueue.class;
+            headOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("head"));
+            tailOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("tail"));
+        } catch (Exception e) {
+            throw new Error(e);
         }
     }
 }
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Thu Mar 10 20:49:43 2011 -0800
@@ -507,13 +507,24 @@
             return new AbstractMap.SimpleImmutableEntry<K,V>(key, v);
         }
 
-        // Unsafe mechanics
-        private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-        private static final long valueOffset =
-            objectFieldOffset(UNSAFE, "value", Node.class);
-        private static final long nextOffset =
-            objectFieldOffset(UNSAFE, "next", Node.class);
+        // UNSAFE mechanics
+
+        private static final sun.misc.Unsafe UNSAFE;
+        private static final long valueOffset;
+        private static final long nextOffset;
 
+        static {
+            try {
+                UNSAFE = sun.misc.Unsafe.getUnsafe();
+                Class k = Node.class;
+                valueOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("value"));
+                nextOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("next"));
+            } catch (Exception e) {
+                throw new Error(e);
+            }
+        }
     }
 
     /* ---------------- Indexing -------------- */
@@ -580,10 +591,18 @@
         }
 
         // Unsafe mechanics
-        private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-        private static final long rightOffset =
-            objectFieldOffset(UNSAFE, "right", Index.class);
-
+        private static final sun.misc.Unsafe UNSAFE;
+        private static final long rightOffset;
+        static {
+            try {
+                UNSAFE = sun.misc.Unsafe.getUnsafe();
+                Class k = Index.class;
+                rightOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("right"));
+            } catch (Exception e) {
+                throw new Error(e);
+            }
+        }
     }
 
     /* ---------------- Head nodes -------------- */
@@ -3082,20 +3101,16 @@
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-    private static final long headOffset =
-        objectFieldOffset(UNSAFE, "head", ConcurrentSkipListMap.class);
-
-    static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
-                                  String field, Class<?> klazz) {
+    private static final sun.misc.Unsafe UNSAFE;
+    private static final long headOffset;
+    static {
         try {
-            return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
-        } catch (NoSuchFieldException e) {
-            // Convert Exception to corresponding Error
-            NoSuchFieldError error = new NoSuchFieldError(field);
-            error.initCause(e);
-            throw error;
+            UNSAFE = sun.misc.Unsafe.getUnsafe();
+            Class k = ConcurrentSkipListMap.class;
+            headOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("head"));
+        } catch (Exception e) {
+            throw new Error(e);
         }
     }
-
 }
--- a/jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Thu Mar 10 20:49:43 2011 -0800
@@ -470,16 +470,20 @@
     }
 
     // Support for resetting map in clone
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
+    private void setMap(ConcurrentNavigableMap<E,Object> map) {
+        UNSAFE.putObjectVolatile(this, mapOffset, map);
+    }
+
+    private static final sun.misc.Unsafe UNSAFE;
     private static final long mapOffset;
     static {
         try {
-            mapOffset = unsafe.objectFieldOffset
-                (ConcurrentSkipListSet.class.getDeclaredField("m"));
-        } catch (Exception ex) { throw new Error(ex); }
+            UNSAFE = sun.misc.Unsafe.getUnsafe();
+            Class k = ConcurrentSkipListSet.class;
+            mapOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("m"));
+        } catch (Exception e) {
+            throw new Error(e);
+        }
     }
-    private void setMap(ConcurrentNavigableMap<E,Object> map) {
-        unsafe.putObjectVolatile(this, mapOffset, map);
-    }
-
 }
--- a/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1318,16 +1318,19 @@
     }
 
     // Support for resetting lock while deserializing
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
+    private void resetLock() {
+        UNSAFE.putObjectVolatile(this, lockOffset, new ReentrantLock());
+    }
+    private static final sun.misc.Unsafe UNSAFE;
     private static final long lockOffset;
     static {
         try {
-            lockOffset = unsafe.objectFieldOffset
-                (CopyOnWriteArrayList.class.getDeclaredField("lock"));
-            } catch (Exception ex) { throw new Error(ex); }
+            UNSAFE = sun.misc.Unsafe.getUnsafe();
+            Class k = CopyOnWriteArrayList.class;
+            lockOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("lock"));
+        } catch (Exception e) {
+            throw new Error(e);
+        }
     }
-    private void resetLock() {
-        unsafe.putObjectVolatile(this, lockOffset, new ReentrantLock());
-    }
-
 }
--- a/jdk/src/share/classes/java/util/concurrent/LinkedTransferQueue.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/LinkedTransferQueue.java	Thu Mar 10 20:49:43 2011 -0800
@@ -525,16 +525,27 @@
             return false;
         }
 
+        private static final long serialVersionUID = -3375979862319811754L;
+
         // Unsafe mechanics
-        private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-        private static final long nextOffset =
-            objectFieldOffset(UNSAFE, "next", Node.class);
-        private static final long itemOffset =
-            objectFieldOffset(UNSAFE, "item", Node.class);
-        private static final long waiterOffset =
-            objectFieldOffset(UNSAFE, "waiter", Node.class);
-
-        private static final long serialVersionUID = -3375979862319811754L;
+        private static final sun.misc.Unsafe UNSAFE;
+        private static final long itemOffset;
+        private static final long nextOffset;
+        private static final long waiterOffset;
+        static {
+            try {
+                UNSAFE = sun.misc.Unsafe.getUnsafe();
+                Class k = Node.class;
+                itemOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("item"));
+                nextOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("next"));
+                waiterOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("waiter"));
+            } catch (Exception e) {
+                throw new Error(e);
+            }
+        }
     }
 
     /** head of the queue; null until first enqueue */
@@ -1312,23 +1323,22 @@
 
     // Unsafe mechanics
 
-    private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-    private static final long headOffset =
-        objectFieldOffset(UNSAFE, "head", LinkedTransferQueue.class);
-    private static final long tailOffset =
-        objectFieldOffset(UNSAFE, "tail", LinkedTransferQueue.class);
-    private static final long sweepVotesOffset =
-        objectFieldOffset(UNSAFE, "sweepVotes", LinkedTransferQueue.class);
-
-    static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
-                                  String field, Class<?> klazz) {
+    private static final sun.misc.Unsafe UNSAFE;
+    private static final long headOffset;
+    private static final long tailOffset;
+    private static final long sweepVotesOffset;
+    static {
         try {
-            return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
-        } catch (NoSuchFieldException e) {
-            // Convert Exception to corresponding Error
-            NoSuchFieldError error = new NoSuchFieldError(field);
-            error.initCause(e);
-            throw error;
+            UNSAFE = sun.misc.Unsafe.getUnsafe();
+            Class k = LinkedTransferQueue.class;
+            headOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("head"));
+            tailOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("tail"));
+            sweepVotesOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("sweepVotes"));
+        } catch (Exception e) {
+            throw new Error(e);
         }
     }
 }
--- a/jdk/src/share/classes/java/util/concurrent/Phaser.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/Phaser.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1137,18 +1137,16 @@
 
     // Unsafe mechanics
 
-    private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-    private static final long stateOffset =
-        objectFieldOffset("state", Phaser.class);
-
-    private static long objectFieldOffset(String field, Class<?> klazz) {
+    private static final sun.misc.Unsafe UNSAFE;
+    private static final long stateOffset;
+    static {
         try {
-            return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
-        } catch (NoSuchFieldException e) {
-            // Convert Exception to corresponding Error
-            NoSuchFieldError error = new NoSuchFieldError(field);
-            error.initCause(e);
-            throw error;
+            UNSAFE = sun.misc.Unsafe.getUnsafe();
+            Class k = Phaser.class;
+            stateOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("state"));
+        } catch (Exception e) {
+            throw new Error(e);
         }
     }
 }
--- a/jdk/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Thu Mar 10 20:49:43 2011 -0800
@@ -963,21 +963,16 @@
     }
 
     // Unsafe mechanics
-    private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-    private static final long allocationSpinLockOffset =
-        objectFieldOffset(UNSAFE, "allocationSpinLock",
-                          PriorityBlockingQueue.class);
-
-    static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
-                                  String field, Class<?> klazz) {
+    private static final sun.misc.Unsafe UNSAFE;
+    private static final long allocationSpinLockOffset;
+    static {
         try {
-            return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
-        } catch (NoSuchFieldException e) {
-            // Convert Exception to corresponding Error
-            NoSuchFieldError error = new NoSuchFieldError(field);
-            error.initCause(e);
-            throw error;
+            UNSAFE = sun.misc.Unsafe.getUnsafe();
+            Class k = PriorityBlockingQueue.class;
+            allocationSpinLockOffset = UNSAFE.objectFieldOffset
+                (k.getDeclaredField("allocationSpinLock"));
+        } catch (Exception e) {
+            throw new Error(e);
         }
     }
-
 }
--- a/jdk/src/share/classes/java/util/concurrent/SynchronousQueue.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/SynchronousQueue.java	Thu Mar 10 20:49:43 2011 -0800
@@ -279,12 +279,22 @@
             }
 
             // Unsafe mechanics
-            private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-            private static final long nextOffset =
-                objectFieldOffset(UNSAFE, "next", SNode.class);
-            private static final long matchOffset =
-                objectFieldOffset(UNSAFE, "match", SNode.class);
+            private static final sun.misc.Unsafe UNSAFE;
+            private static final long matchOffset;
+            private static final long nextOffset;
 
+            static {
+                try {
+                    UNSAFE = sun.misc.Unsafe.getUnsafe();
+                    Class k = SNode.class;
+                    matchOffset = UNSAFE.objectFieldOffset
+                        (k.getDeclaredField("match"));
+                    nextOffset = UNSAFE.objectFieldOffset
+                        (k.getDeclaredField("next"));
+                } catch (Exception e) {
+                    throw new Error(e);
+                }
+            }
         }
 
         /** The head (top) of the stack */
@@ -498,10 +508,18 @@
         }
 
         // Unsafe mechanics
-        private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-        private static final long headOffset =
-            objectFieldOffset(UNSAFE, "head", TransferStack.class);
-
+        private static final sun.misc.Unsafe UNSAFE;
+        private static final long headOffset;
+        static {
+            try {
+                UNSAFE = sun.misc.Unsafe.getUnsafe();
+                Class k = TransferStack.class;
+                headOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("head"));
+            } catch (Exception e) {
+                throw new Error(e);
+            }
+        }
     }
 
     /** Dual Queue */
@@ -558,11 +576,22 @@
             }
 
             // Unsafe mechanics
-            private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-            private static final long nextOffset =
-                objectFieldOffset(UNSAFE, "next", QNode.class);
-            private static final long itemOffset =
-                objectFieldOffset(UNSAFE, "item", QNode.class);
+            private static final sun.misc.Unsafe UNSAFE;
+            private static final long itemOffset;
+            private static final long nextOffset;
+
+            static {
+                try {
+                    UNSAFE = sun.misc.Unsafe.getUnsafe();
+                    Class k = QNode.class;
+                    itemOffset = UNSAFE.objectFieldOffset
+                        (k.getDeclaredField("item"));
+                    nextOffset = UNSAFE.objectFieldOffset
+                        (k.getDeclaredField("next"));
+                } catch (Exception e) {
+                    throw new Error(e);
+                }
+            }
         }
 
         /** Head of queue */
@@ -791,15 +820,24 @@
             }
         }
 
-        // unsafe mechanics
-        private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
-        private static final long headOffset =
-            objectFieldOffset(UNSAFE, "head", TransferQueue.class);
-        private static final long tailOffset =
-            objectFieldOffset(UNSAFE, "tail", TransferQueue.class);
-        private static final long cleanMeOffset =
-            objectFieldOffset(UNSAFE, "cleanMe", TransferQueue.class);
-
+        private static final sun.misc.Unsafe UNSAFE;
+        private static final long headOffset;
+        private static final long tailOffset;
+        private static final long cleanMeOffset;
+        static {
+            try {
+                UNSAFE = sun.misc.Unsafe.getUnsafe();
+                Class k = TransferQueue.class;
+                headOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("head"));
+                tailOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("tail"));
+                cleanMeOffset = UNSAFE.objectFieldOffset
+                    (k.getDeclaredField("cleanMe"));
+            } catch (Exception e) {
+                throw new Error(e);
+            }
+        }
     }
 
     /**
--- a/jdk/src/share/classes/java/util/jar/JarFile.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/jar/JarFile.java	Thu Mar 10 20:49:43 2011 -0800
@@ -376,9 +376,9 @@
      */
     private byte[] getBytes(ZipEntry ze) throws IOException {
         byte[] b = new byte[(int)ze.getSize()];
-        DataInputStream is = new DataInputStream(super.getInputStream(ze));
-        is.readFully(b, 0, b.length);
-        is.close();
+        try (DataInputStream is = new DataInputStream(super.getInputStream(ze))) {
+            is.readFully(b, 0, b.length);
+        }
         return b;
     }
 
@@ -480,10 +480,10 @@
             JarEntry manEntry = getManEntry();
             if (manEntry != null) {
                 byte[] b = new byte[(int)manEntry.getSize()];
-                DataInputStream dis = new DataInputStream(
-                                                          super.getInputStream(manEntry));
-                dis.readFully(b, 0, b.length);
-                dis.close();
+                try (DataInputStream dis = new DataInputStream(
+                         super.getInputStream(manEntry))) {
+                    dis.readFully(b, 0, b.length);
+                }
 
                 int last = b.length - src.length;
                 int i = 0;
--- a/jdk/src/share/classes/java/util/zip/ZipEntry.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/java/util/zip/ZipEntry.java	Thu Mar 10 20:49:43 2011 -0800
@@ -26,7 +26,6 @@
 package java.util.zip;
 
 import java.util.Date;
-import sun.misc.BootClassLoaderHook;
 
 /**
  * This class is used to represent a ZIP file entry.
--- a/jdk/src/share/classes/javax/crypto/SecretKeyFactory.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/javax/crypto/SecretKeyFactory.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -61,7 +61,6 @@
  * <p> Every implementation of the Java platform is required to support the
  * following standard <code>SecretKeyFactory</code> algorithms:
  * <ul>
- * <li><tt>AES</tt></li>
  * <li><tt>DES</tt></li>
  * <li><tt>DESede</tt></li>
  * </ul>
--- a/jdk/src/share/classes/javax/sound/midi/MidiSystem.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/javax/sound/midi/MidiSystem.java	Thu Mar 10 20:49:43 2011 -0800
@@ -441,13 +441,6 @@
                 Synthesizer synth = getSynthesizer();
                 if (synth instanceof ReferenceCountingDevice) {
                     rec = ((ReferenceCountingDevice) synth).getReceiverReferenceCounting();
-                    // only use MixerSynth if it could successfully load a soundbank
-                    if (synth.getClass().toString().contains("com.sun.media.sound.MixerSynth")
-                        && (synth.getDefaultSoundbank() == null)) {
-                        // don't use this receiver if no soundbank available
-                        rec = null;
-                        synth.close();
-                    }
                 } else {
                     synth.open();
                     try {
--- a/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java	Thu Mar 10 20:49:43 2011 -0800
@@ -174,6 +174,8 @@
         if(!wasIcon(f)) {
             Rectangle r = getBoundsForIconOf(f);
             desktopIcon.setBounds(r.x, r.y, r.width, r.height);
+            // we must validate the hierarchy to not break the hw/lw mixing
+            desktopIcon.revalidate();
             setWasIcon(f, Boolean.TRUE);
         }
 
@@ -453,11 +455,9 @@
 
     /** This moves the <code>JComponent</code> and repaints the damaged areas. */
     public void setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight) {
-        boolean didResize = (f.getWidth() != newWidth || f.getHeight() != newHeight);
         f.setBounds(newX, newY, newWidth, newHeight);
-        if(didResize) {
-            f.validate();
-        }
+        // we must validate the hierarchy to not break the hw/lw mixing
+        f.revalidate();
     }
 
     /** Convenience method to remove the desktopIcon of <b>f</b> is necessary. */
--- a/jdk/src/share/classes/javax/swing/JComponent.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/JComponent.java	Thu Mar 10 20:49:43 2011 -0800
@@ -5158,31 +5158,30 @@
                 }
             }
         }
-
         try {
-            g = safelyGetGraphics(paintingComponent, c);
-            try {
-                if (hasBuffer) {
-                    RepaintManager rm = RepaintManager.currentManager(
-                                               bufferedComponent);
-                    rm.beginPaint();
-                    try {
-                        rm.paint(paintingComponent, bufferedComponent, g,
-                                 paintImmediatelyClip.x,
-                                 paintImmediatelyClip.y,
-                                 paintImmediatelyClip.width,
-                                 paintImmediatelyClip.height);
-                    } finally {
-                        rm.endPaint();
+            if ((g = safelyGetGraphics(paintingComponent, c)) != null) {
+                try {
+                    if (hasBuffer) {
+                        RepaintManager rm = RepaintManager.currentManager(
+                                bufferedComponent);
+                        rm.beginPaint();
+                        try {
+                            rm.paint(paintingComponent, bufferedComponent, g,
+                                    paintImmediatelyClip.x,
+                                    paintImmediatelyClip.y,
+                                    paintImmediatelyClip.width,
+                                    paintImmediatelyClip.height);
+                        } finally {
+                            rm.endPaint();
+                        }
+                    } else {
+                        g.setClip(paintImmediatelyClip.x, paintImmediatelyClip.y,
+                                paintImmediatelyClip.width, paintImmediatelyClip.height);
+                        paintingComponent.paint(g);
                     }
+                } finally {
+                    g.dispose();
                 }
-                else {
-                    g.setClip(paintImmediatelyClip.x,paintImmediatelyClip.y,
-                       paintImmediatelyClip.width,paintImmediatelyClip.height);
-                    paintingComponent.paint(g);
-                }
-            } finally {
-                g.dispose();
             }
         }
         finally {
--- a/jdk/src/share/classes/javax/swing/JViewport.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/JViewport.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1111,6 +1111,8 @@
                 view.setLocation(newX, newY);
                 repaintAll = false;
             }
+            // we must validate the hierarchy to not break the hw/lw mixing
+            revalidate();
             fireStateChanged();
         }
     }
--- a/jdk/src/share/classes/javax/swing/text/Utilities.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/text/Utilities.java	Thu Mar 10 20:49:43 2011 -0800
@@ -390,11 +390,15 @@
             }
             if ((x >= currX) && (x < nextX)) {
                 // found the hit position... return the appropriate side
-                if ((round == false) || ((x - currX) < (nextX - x))) {
-                    return i - txtOffset;
-                } else {
-                    return i + 1 - txtOffset;
+                int offset = ((round == false) || ((x - currX) < (nextX - x))) ?
+                        (i - txtOffset) : (i + 1 - txtOffset);
+                // the length of the string measured as a whole may differ from
+                // the sum of individual character lengths, for example if
+                // fractional metrics are enabled; and we must guard from this.
+                while (metrics.charsWidth(txt, txtOffset, offset + 1) > (x - x0)) {
+                    offset--;
                 }
+                return (offset < 0 ? 0 : offset);
             }
             currX = nextX;
         }
@@ -404,24 +408,6 @@
     }
 
     /**
-     * Adjust text offset so that the length of a resulting string as a whole
-     * fits into the specified width.
-     */
-    static int adjustOffsetForFractionalMetrics(
-            Segment s, FontMetrics fm, int offset, int width) {
-        // Sometimes the offset returned by getTabbedTextOffset is beyond the
-        // available area, when fractional metrics are enabled. We should
-        // guard against this.
-        if (offset < s.count) {
-            while (offset > 0 &&
-                    fm.charsWidth(s.array, s.offset, offset + 1) > width) {
-                offset--;
-            }
-        }
-        return offset;
-    }
-
-    /**
      * Determine where to break the given text to fit
      * within the given span. This tries to find a word boundary.
      * @param s  the source of the text
@@ -443,7 +429,6 @@
         int txtCount = s.count;
         int index = Utilities.getTabbedTextOffset(s, metrics, x0, x,
                                                   e, startOffset, false);
-        index = adjustOffsetForFractionalMetrics(s, metrics, index, x - x0);
 
         if (index >= txtCount - 1) {
             return txtCount;
--- a/jdk/src/share/classes/javax/swing/text/WrappedPlainView.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/text/WrappedPlainView.java	Thu Mar 10 20:49:43 2011 -0800
@@ -239,11 +239,9 @@
                                                 tabBase, tabBase + currentWidth,
                                                 this, p0);
         } else {
-            int offset = Utilities.getTabbedTextOffset(segment, metrics,
-                    tabBase, tabBase + currentWidth, this, p0, false);
-            offset = Utilities.adjustOffsetForFractionalMetrics(
-                    segment, metrics, offset, currentWidth);
-            p = p0 + offset;
+            p = p0 + Utilities.getTabbedTextOffset(segment, metrics,
+                                                   tabBase, tabBase + currentWidth,
+                                                   this, p0, false);
         }
         SegmentCache.releaseSharedSegment(segment);
         return p;
--- a/jdk/src/share/classes/javax/swing/text/html/CSSBorder.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/text/html/CSSBorder.java	Thu Mar 10 20:49:43 2011 -0800
@@ -203,10 +203,11 @@
 
     public void paintBorder(Component c, Graphics g,
                                         int x, int y, int width, int height) {
-        assert (g instanceof Graphics2D) : "need Graphics2D instanse";
-        Graphics2D g2 = (Graphics2D) g;
-        Color savedColor = g2.getColor();
-        Shape savedClip = g2.getClip();
+        if (!(g instanceof Graphics2D)) {
+            return;
+        }
+
+        Graphics2D g2 = (Graphics2D) g.create();
 
         int[] widths = getWidths();
 
@@ -238,16 +239,16 @@
                 BorderPainter painter = getBorderPainter(i);
 
                 double angle = i * Math.PI / 2;
+                g2.setClip(g.getClip()); // Restore initial clip
                 g2.translate(intCorners[i][0], intCorners[i][1]);
                 g2.rotate(angle);
-                g2.setClip(shape);
-                painter.paint(shape, g, color, i);
+                g2.clip(shape);
+                painter.paint(shape, g2, color, i);
                 g2.rotate(-angle);
                 g2.translate(-intCorners[i][0], -intCorners[i][1]);
             }
         }
-        g2.setColor(savedColor);
-        g2.setClip(savedClip);
+        g2.dispose();
     }
 
 
--- a/jdk/src/share/classes/sun/font/StrikeCache.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/font/StrikeCache.java	Thu Mar 10 20:49:43 2011 -0800
@@ -319,8 +319,7 @@
                 ArrayList<Long> gids = null;
 
                 for (int i = 0; i < glyphPtrs.length; i++) {
-                    if (glyphPtrs[i] != 0 && unsafe.getByte(glyphPtrs[i] + managedOffset) == 0
-                            && unsafe.getInt(glyphPtrs[i] + cacheCellOffset) != 0) {
+                    if (glyphPtrs[i] != 0 && unsafe.getByte(glyphPtrs[i] + managedOffset) == 0) {
 
                         if (gids == null) {
                             gids = new ArrayList<Long>();
@@ -330,6 +329,8 @@
                 }
 
                 if (gids != null) {
+                    // Any reference by the disposers to the native glyph ptrs
+                    // must be done before this returns.
                     notifyDisposeListeners(gids);
                 }
             }
@@ -345,8 +346,7 @@
 
                 for (int i=0; i < glyphPtrs.length; i++) {
                     if (glyphPtrs[i] != 0
-                            && unsafe.getByte(glyphPtrs[i] + managedOffset) == 0
-                            && unsafe.getInt(glyphPtrs[i] + cacheCellOffset) != 0) {
+                            && unsafe.getByte(glyphPtrs[i] + managedOffset) == 0) {
 
                         if (gids == null) {
                             gids = new ArrayList<Long>();
@@ -356,6 +356,8 @@
                 }
 
                 if (gids != null) {
+                    // Any reference by the disposers to the native glyph ptrs
+                    // must be done before this returns.
                     notifyDisposeListeners(gids);
                 }
         }
--- a/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java	Thu Mar 10 20:49:43 2011 -0800
@@ -109,7 +109,7 @@
         Region clip = sg.getCompClip();
         int abox[] = new int[4];
         AATileGenerator aatg =
-            renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0,
+            renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, lw1, lw2,
                                             clip, abox);
         if (aatg == null) {
             // Nothing to render
--- a/jdk/src/share/classes/sun/misc/BootClassLoaderHook.java	Thu Mar 10 17:11:08 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.misc;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URLStreamHandlerFactory;
-import sun.misc.URLClassPath;
-
-/**
- * BootClassLoaderHook defines an interface for a hook to inject
- * into the bootstrap class loader.
- *
- * With jkernel now removed, no hook is set
- */
-public abstract class BootClassLoaderHook {
-    private static BootClassLoaderHook bootLoaderHook = null;
-    public static synchronized BootClassLoaderHook getHook() {
-        return bootLoaderHook;
-    }
-
-    public static synchronized void setHook(BootClassLoaderHook hook) {
-        if (!VM.isBooted()) {
-            throw new InternalError("hook can only be set after VM is booted");
-        }
-        if (bootLoaderHook != null) {
-            throw new InternalError("hook should not be reinitialized");
-        }
-        bootLoaderHook = hook;
-    }
-
-    protected BootClassLoaderHook() {
-    }
-
-    /**
-     * A method to be invoked before a class loader loads
-     * a bootstrap class.
-     *
-     * @param classname the binary name of the class
-     */
-    public static void preLoadClass(String classname) {
-        BootClassLoaderHook hook = getHook();
-        if (hook != null) {
-            hook.loadBootstrapClass(classname);
-        }
-    }
-
-    /**
-     * A method to be invoked before a class loader loads
-     * a resource.
-     *
-     * @param resourcename the resource name
-     */
-    public static void preLoadResource(String resourcename) {
-        BootClassLoaderHook hook = getHook();
-        if (hook != null) {
-            hook.getBootstrapResource(resourcename);
-        }
-    }
-
-    /**
-     * A method to be invoked before a library is loaded.
-     *
-     * @param libname the name of the library
-     */
-    public static void preLoadLibrary(String libname) {
-        BootClassLoaderHook hook = getHook();
-        if (hook != null) {
-            hook.loadLibrary(libname);
-        }
-    }
-
-    /**
-     * Returns a pathname of a JAR or class that the hook loads
-     * per this loadClass request; or null.
-     *
-     * @param classname the binary name of the class
-     */
-    public abstract String loadBootstrapClass(String className);
-
-    /**
-     * Returns a pathname of a resource file that the hook loads
-     * per this getResource request; or null.
-     *
-     * @param resourceName the resource name
-     */
-    public abstract String getBootstrapResource(String resourceName);
-
-    /**
-     * Returns true if the hook successfully performs an operation per
-     * this loadLibrary request; or false if it fails.
-     *
-     * @param libname the name of the library
-     */
-    public abstract boolean loadLibrary(String libname);
-
-    /**
-     * Returns a bootstrap class path constructed by the hook.
-     *
-     * @param bcp VM's bootstrap class path
-     * @param factory Launcher's URL stream handler
-     */
-    public abstract URLClassPath getBootstrapClassPath(URLClassPath bcp,
-            URLStreamHandlerFactory factory);
-
-    /**
-     * Returns true if the current thread is in the process of doing
-     * a prefetching operation.
-     */
-    public abstract boolean isCurrentThreadPrefetching();
-
-    /**
-     * Returns true if the hook successfully prefetches the specified file.
-     *
-     * @param name a platform independent pathname
-     */
-    public abstract boolean prefetchFile(String name);
-}
--- a/jdk/src/share/classes/sun/misc/JavaSecurityCodeSignerAccess.java	Thu Mar 10 17:11:08 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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.misc;
-
-import java.security.CodeSigner;
-import java.security.cert.CRL;
-
-public interface JavaSecurityCodeSignerAccess {
-    void setCRLs(CodeSigner signer, CRL[] crls);
-    CRL[] getCRLs(CodeSigner signer);
-}
--- a/jdk/src/share/classes/sun/misc/Launcher.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/Launcher.java	Thu Mar 10 20:49:43 2011 -0800
@@ -38,7 +38,6 @@
 import java.util.Set;
 import java.util.Vector;
 import java.security.AccessController;
-import java.security.AllPermission;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.security.AccessControlContext;
@@ -117,18 +116,6 @@
         return loader;
     }
 
-    public static void addURLToAppClassLoader(URL u) {
-        AccessController.checkPermission(new AllPermission());
-        ClassLoader loader = Launcher.getLauncher().getClassLoader();
-        ((Launcher.AppClassLoader) loader).addAppURL(u);
-    }
-
-    public static void addURLToExtClassLoader(URL u) {
-        AccessController.checkPermission(new AllPermission());
-        ClassLoader loader = Launcher.getLauncher().getClassLoader();
-        ((Launcher.ExtClassLoader) loader.getParent()).addExtURL(u);
-    }
-
     /*
      * The class loader used for loading installed extensions.
      */
@@ -247,11 +234,6 @@
             return null;
         }
 
-        protected Class findClass(String name) throws ClassNotFoundException {
-            BootClassLoaderHook.preLoadClass(name);
-            return super.findClass(name);
-        }
-
         private static AccessControlContext getContext(File[] dirs)
             throws IOException
         {
@@ -316,7 +298,6 @@
         public Class loadClass(String name, boolean resolve)
             throws ClassNotFoundException
         {
-            BootClassLoaderHook.preLoadClass(name);
             int i = name.lastIndexOf('.');
             if (i != -1) {
                 SecurityManager sm = System.getSecurityManager();
@@ -373,10 +354,6 @@
 
             return acc;
         }
-
-        void addAppURL(URL url) {
-            super.addURL(url);
-        }
     }
 
     private static class BootClassPathHolder {
@@ -413,11 +390,7 @@
     }
 
     public static URLClassPath getBootstrapClassPath() {
-        URLClassPath bcp = BootClassPathHolder.bcp;
-        // if DownloadManager is installed, return the bootstrap class path
-        // maintained by the Java kernel
-        BootClassLoaderHook hook = BootClassLoaderHook.getHook();
-        return hook == null ? bcp : hook.getBootstrapClassPath(bcp, factory);
+        return BootClassPathHolder.bcp;
     }
 
     private static URL[] pathToURLs(File[] path) {
--- a/jdk/src/share/classes/sun/misc/SharedSecrets.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/SharedSecrets.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, 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
@@ -28,7 +28,6 @@
 import java.util.jar.JarFile;
 import java.io.Console;
 import java.io.FileDescriptor;
-import java.security.CodeSigner;
 import java.security.ProtectionDomain;
 
 /** A repository of "shared secrets", which are a mechanism for
@@ -49,7 +48,6 @@
     private static JavaNioAccess javaNioAccess;
     private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
     private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess;
-    private static JavaSecurityCodeSignerAccess javaSecurityCodeSignerAccess;
 
     public static JavaUtilJarAccess javaUtilJarAccess() {
         if (javaUtilJarAccess == null) {
@@ -127,16 +125,4 @@
                 unsafe.ensureClassInitialized(ProtectionDomain.class);
             return javaSecurityProtectionDomainAccess;
     }
-
-    public static void setJavaSecurityCodeSignerAccess
-            (JavaSecurityCodeSignerAccess jscsa) {
-        javaSecurityCodeSignerAccess = jscsa;
-    }
-
-    public static JavaSecurityCodeSignerAccess
-            getJavaSecurityCodeSignerAccess() {
-        if (javaSecurityCodeSignerAccess == null)
-            unsafe.ensureClassInitialized(CodeSigner.class);
-        return javaSecurityCodeSignerAccess;
-    }
 }
--- a/jdk/src/share/classes/sun/net/httpserver/ChunkedInputStream.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/net/httpserver/ChunkedInputStream.java	Thu Mar 10 20:49:43 2011 -0800
@@ -69,32 +69,33 @@
      */
     private int readChunkHeader () throws IOException {
         boolean gotCR = false;
-        char c;
+        int c;
         char[] len_arr = new char [16];
         int len_size = 0;
         boolean end_of_len = false;
 
-        while ((c=(char)in.read())!= -1) {
+        while ((c=in.read())!= -1) {
+            char ch = (char) c;
             if (len_size == len_arr.length -1) {
                 throw new IOException ("invalid chunk header");
             }
             if (gotCR) {
-                if (c == LF) {
+                if (ch == LF) {
                     int l = numeric (len_arr, len_size);
                     return l;
                 } else {
                     gotCR = false;
                 }
                 if (!end_of_len) {
-                    len_arr[len_size++] = c;
+                    len_arr[len_size++] = ch;
                 }
             } else {
-                if (c == CR) {
+                if (ch == CR) {
                     gotCR = true;
-                } else if (c == ';') {
+                } else if (ch == ';') {
                     end_of_len = true;
                 } else if (!end_of_len) {
-                    len_arr[len_size++] = c;
+                    len_arr[len_size++] = ch;
                 }
             }
         }
--- a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java	Thu Mar 10 20:49:43 2011 -0800
@@ -475,8 +475,8 @@
                 assert !target.isOpen();
                 try {
                     close();
-                } catch (IOException ignore) {
-                    // nothing we can do
+                } catch (Throwable suppressed) {
+                    e.addSuppressed(suppressed);
                 }
                 throw e;
             } catch (IOException ioe) {
--- a/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -42,14 +42,12 @@
  * Cipher implementation class. This class currently supports
  * DES, DESede, AES, ARCFOUR, and Blowfish.
  *
- * This class is designed to support ECB and CBC with NoPadding and
- * PKCS5Padding for both. It will use its own padding impl if the
- * native mechanism does not support padding.
+ * This class is designed to support ECB, CBC, CTR with NoPadding
+ * and ECB, CBC with PKCS5Padding. It will use its own padding impl
+ * if the native mechanism does not support padding.
  *
- * Note that PKCS#11 current only supports ECB and CBC. There are no
- * provisions for other modes such as CFB, OFB, PCBC, or CTR mode.
- * However, CTR could be implemented relatively easily (and efficiently)
- * on top of ECB mode in this class, if need be.
+ * Note that PKCS#11 currently only supports ECB, CBC, and CTR.
+ * There are no provisions for other modes such as CFB, OFB, and PCBC.
  *
  * @author  Andreas Sterbenz
  * @since   1.5
@@ -60,6 +58,8 @@
     private final static int MODE_ECB = 3;
     // mode constant for CBC mode
     private final static int MODE_CBC = 4;
+    // mode constant for CTR mode
+    private final static int MODE_CTR = 5;
 
     // padding constant for NoPadding
     private final static int PAD_NONE = 5;
@@ -157,7 +157,7 @@
     private byte[] padBuffer;
     private int padBufferLen;
 
-    // original IV, if in MODE_CBC
+    // original IV, if in MODE_CBC or MODE_CTR
     private byte[] iv;
 
     // number of bytes buffered internally by the native mechanism and padBuffer
@@ -213,6 +213,8 @@
                         ("CBC mode not supported with stream ciphers");
             }
             result = MODE_CBC;
+        } else if (mode.equals("CTR")) {
+            result = MODE_CTR;
         } else {
             throw new NoSuchAlgorithmException("Unsupported mode " + mode);
         }
@@ -228,6 +230,10 @@
         if (padding.equals("NOPADDING")) {
             paddingType = PAD_NONE;
         } else if (padding.equals("PKCS5PADDING")) {
+            if (this.blockMode == MODE_CTR) {
+                throw new NoSuchPaddingException
+                    ("PKCS#5 padding not supported with CTR mode");
+            }
             paddingType = PAD_PKCS5;
             if (mechanism != CKM_DES_CBC_PAD && mechanism != CKM_DES3_CBC_PAD &&
                     mechanism != CKM_AES_CBC_PAD) {
@@ -348,11 +354,14 @@
                             ("IV not used in ECB mode");
                 }
             }
-        } else { // MODE_CBC
+        } else { // MODE_CBC or MODE_CTR
             if (iv == null) {
                 if (encrypt == false) {
-                    throw new InvalidAlgorithmParameterException
-                            ("IV must be specified for decryption in CBC mode");
+                    String exMsg =
+                        (blockMode == MODE_CBC ?
+                         "IV must be specified for decryption in CBC mode" :
+                         "IV must be specified for decryption in CTR mode");
+                    throw new InvalidAlgorithmParameterException(exMsg);
                 }
                 // generate random IV
                 if (random == null) {
@@ -410,13 +419,15 @@
         if (session == null) {
             session = token.getOpSession();
         }
+        CK_MECHANISM mechParams = (blockMode == MODE_CTR?
+            new CK_MECHANISM(mechanism, new CK_AES_CTR_PARAMS(iv)) :
+            new CK_MECHANISM(mechanism, iv));
+
         try {
             if (encrypt) {
-                token.p11.C_EncryptInit(session.id(),
-                        new CK_MECHANISM(mechanism, iv), p11Key.keyID);
+                token.p11.C_EncryptInit(session.id(), mechParams, p11Key.keyID);
             } else {
-                token.p11.C_DecryptInit(session.id(),
-                        new CK_MECHANISM(mechanism, iv), p11Key.keyID);
+                token.p11.C_DecryptInit(session.id(), mechParams, p11Key.keyID);
             }
         } catch (PKCS11Exception ex) {
             // release session when initialization failed
--- a/jdk/src/share/classes/sun/security/pkcs11/P11RSACipher.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11RSACipher.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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,6 +62,11 @@
     // mode constant for public key decryption (verifying)
     private final static int MODE_VERIFY  = 4;
 
+    // padding type constant for NoPadding
+    private final static int PAD_NONE = 1;
+    // padding type constant for PKCS1Padding
+    private final static int PAD_PKCS1 = 2;
+
     // token instance
     private final Token token;
 
@@ -77,6 +82,9 @@
     // mode, one of MODE_* above
     private int mode;
 
+    // padding, one of PAD_* above
+    private int padType;
+
     private byte[] buffer;
     private int bufOfs;
 
@@ -113,8 +121,10 @@
     protected void engineSetPadding(String padding)
             throws NoSuchPaddingException {
         String lowerPadding = padding.toLowerCase(Locale.ENGLISH);
-        if (lowerPadding.equals("pkcs1Padding")) {
-            // empty
+        if (lowerPadding.equals("pkcs1padding")) {
+            padType = PAD_PKCS1;
+        } else if (lowerPadding.equals("nopadding")) {
+            padType = PAD_NONE;
         } else {
             throw new NoSuchPaddingException("Unsupported padding " + padding);
         }
@@ -209,7 +219,8 @@
         int n = (p11Key.keyLength() + 7) >> 3;
         outputSize = n;
         buffer = new byte[n];
-        maxInputSize = encrypt ? (n - PKCS1_MIN_PADDING_LENGTH) : n;
+        maxInputSize = ((padType == PAD_PKCS1 && encrypt) ?
+                            (n - PKCS1_MIN_PADDING_LENGTH) : n);
         try {
             initialize();
         } catch (PKCS11Exception e) {
--- a/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/pkcs11/SunPKCS11.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -621,12 +621,16 @@
                 m(CKM_AES_CBC_PAD, CKM_AES_CBC));
         d(CIP, "AES/ECB",                       P11Cipher,      s("AES"),
                 m(CKM_AES_ECB));
+        d(CIP, "AES/CTR/NoPadding",             P11Cipher,
+                m(CKM_AES_CTR));
         d(CIP, "Blowfish/CBC",                  P11Cipher,
                 m(CKM_BLOWFISH_CBC));
 
         // XXX RSA_X_509, RSA_OAEP not yet supported
-        d(CIP, "RSA/ECB/PKCS1Padding",          P11RSACipher,
+        d(CIP, "RSA/ECB/PKCS1Padding",          P11RSACipher,   s("RSA"),
                 m(CKM_RSA_PKCS));
+        d(CIP, "RSA/ECB/NoPadding",             P11RSACipher,
+                m(CKM_RSA_X_509));
 
         d(SIG, "RawDSA",        P11Signature,           s("NONEwithDSA"),
                 m(CKM_DSA));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/security/pkcs11/wrapper/CK_AES_CTR_PARAMS.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, 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.security.pkcs11.wrapper;
+
+/**
+ * This class represents the necessary parameters required by
+ * the CKM_AES_CTR mechanism as defined in CK_AES_CTR_PARAMS structure.<p>
+ * <B>PKCS#11 structure:</B>
+ * <PRE>
+ * typedef struct CK_AES_CTR_PARAMS {
+ *   CK_ULONG ulCounterBits;
+ *   CK_BYTE cb[16];
+ * } CK_AES_CTR_PARAMS;
+ * </PRE>
+ *
+ * @author Yu-Ching Valerie Peng
+ * @since   1.7
+ */
+public class CK_AES_CTR_PARAMS {
+
+    private final long ulCounterBits;
+    private final byte cb[];
+
+    public CK_AES_CTR_PARAMS(byte[] cb) {
+        ulCounterBits = 128;
+        this.cb = cb.clone();
+    }
+
+    public String toString() {
+        StringBuffer buffer = new StringBuffer();
+
+        buffer.append(Constants.INDENT);
+        buffer.append("ulCounterBits: ");
+        buffer.append(ulCounterBits);
+        buffer.append(Constants.NEWLINE);
+
+        buffer.append(Constants.INDENT);
+        buffer.append("cb: ");
+        buffer.append(Functions.toHexString(cb));
+
+        return buffer.toString();
+    }
+}
--- a/jdk/src/share/classes/sun/security/pkcs11/wrapper/CK_MECHANISM.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/pkcs11/wrapper/CK_MECHANISM.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -48,6 +48,7 @@
 package sun.security.pkcs11.wrapper;
 
 import java.math.BigInteger;
+import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
 
 /**
  * class CK_MECHANISM specifies a particular mechanism and any parameters it
@@ -127,6 +128,10 @@
         init(mechanism, params);
     }
 
+    public CK_MECHANISM(long mechanism, CK_AES_CTR_PARAMS params) {
+        init(mechanism, params);
+    }
+
     private void init(long mechanism, Object pParameter) {
         this.mechanism = mechanism;
         this.pParameter = pParameter;
--- a/jdk/src/share/classes/sun/security/pkcs11/wrapper/PKCS11Constants.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/pkcs11/wrapper/PKCS11Constants.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -47,8 +47,6 @@
 
 package sun.security.pkcs11.wrapper;
 
-
-
 /**
  * This interface holds constants of the PKCS#11 v2.11 standard.
  * This is mainly the content of the 'pkcs11t.h' header file.
@@ -306,6 +304,10 @@
 
     public static final long  CKK_VENDOR_DEFINED  = 0x80000000L;
 
+    // new for v2.20 amendment 3
+    //public static final long  CKK_CAMELLIA          = 0x00000025L;
+    //public static final long  CKK_ARIA              = 0x00000026L;
+
     // pseudo key type ANY (for template manager)
     public static final long  PCKK_ANY            = 0x7FFFFF22L;
 
@@ -690,6 +692,34 @@
 
     public static final long  CKM_VENDOR_DEFINED             = 0x80000000L;
 
+    // new for v2.20 amendment 3
+    public static final long  CKM_SHA224                     = 0x00000255L;
+    public static final long  CKM_SHA224_HMAC                = 0x00000256L;
+    public static final long  CKM_SHA224_HMAC_GENERAL        = 0x00000257L;
+    public static final long  CKM_SHA224_KEY_DERIVATION      = 0x00000396L;
+    public static final long  CKM_SHA224_RSA_PKCS            = 0x00000046L;
+    public static final long  CKM_SHA224_RSA_PKCS_PSS        = 0x00000047L;
+    public static final long  CKM_AES_CTR                    = 0x00001086L;
+    /*
+    public static final long  CKM_CAMELLIA_KEY_GEN           = 0x00000550L;
+    public static final long  CKM_CAMELLIA_ECB               = 0x00000551L;
+    public static final long  CKM_CAMELLIA_CBC               = 0x00000552L;
+    public static final long  CKM_CAMELLIA_MAC               = 0x00000553L;
+    public static final long  CKM_CAMELLIA_MAC_GENERAL       = 0x00000554L;
+    public static final long  CKM_CAMELLIA_CBC_PAD           = 0x00000555L;
+    public static final long  CKM_CAMELLIA_ECB_ENCRYPT_DATA  = 0x00000556L;
+    public static final long  CKM_CAMELLIA_CBC_ENCRYPT_DATA  = 0x00000557L;
+    public static final long  CKM_CAMELLIA_CTR               = 0x00000558L;
+    public static final long  CKM_ARIA_KEY_GEN               = 0x00000560L;
+    public static final long  CKM_ARIA_ECB                   = 0x00000561L;
+    public static final long  CKM_ARIA_CBC                   = 0x00000562L;
+    public static final long  CKM_ARIA_MAC                   = 0x00000563L;
+    public static final long  CKM_ARIA_MAC_GENERAL           = 0x00000564L;
+    public static final long  CKM_ARIA_CBC_PAD               = 0x00000565L;
+    public static final long  CKM_ARIA_ECB_ENCRYPT_DATA      = 0x00000566L;
+    public static final long  CKM_ARIA_CBC_ENCRYPT_DATA      = 0x00000567L;
+    */
+
     // NSS private
     public static final long  CKM_NSS_TLS_PRF_GENERAL        = 0x80000373L;
 
@@ -881,7 +911,8 @@
 
     /* The following MGFs are defined */
     public static final long  CKG_MGF1_SHA1       =  0x00000001L;
-
+    // new for v2.20 amendment 3
+    public static final long  CKG_MGF1_SHA224     = 0x00000005L;
 
     /* The following encoding parameter sources are defined */
     public static final long  CKZ_DATA_SPECIFIED   = 0x00000001L;
--- a/jdk/src/share/classes/sun/security/tools/JarSigner.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/tools/JarSigner.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -26,7 +26,6 @@
 package sun.security.tools;
 
 import java.io.*;
-import java.security.cert.X509CRL;
 import java.util.*;
 import java.util.zip.*;
 import java.util.jar.*;
@@ -36,7 +35,6 @@
 import java.text.Collator;
 import java.text.MessageFormat;
 import java.security.cert.Certificate;
-import java.security.cert.CRL;
 import java.security.cert.X509Certificate;
 import java.security.cert.CertificateException;
 import java.security.*;
@@ -58,7 +56,6 @@
 import sun.security.x509.*;
 import sun.security.util.*;
 import sun.misc.BASE64Encoder;
-import sun.misc.SharedSecrets;
 
 
 /**
@@ -117,13 +114,11 @@
     static final int SIGNED_BY_ALIAS = 0x08;    // signer is in alias list
 
     X509Certificate[] certChain;    // signer's cert chain (when composing)
-    Set<X509CRL> crls;                 // signer provided CRLs
     PrivateKey privateKey;          // private key
     KeyStore store;                 // the keystore specified by -keystore
                                     // or the default keystore, never null
 
     String keystore; // key store file
-    List<String> crlfiles = new ArrayList<>();  // CRL files to add
     boolean nullStream = false; // null keystore input stream (NONE)
     boolean token = false; // token-based keystore
     String jarfile;  // jar files to sign or verify
@@ -151,7 +146,6 @@
     boolean signManifest = true; // "sign" the whole manifest
     boolean externalSF = true; // leave the .SF out of the PKCS7 block
     boolean strict = false;  // treat warnings as error
-    boolean autoCRL = false;    // Automatcially add CRL defined in cert
 
     // read zip entry raw bytes
     private ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
@@ -232,29 +226,6 @@
             } else {
                 loadKeyStore(keystore, true);
                 getAliasInfo(alias);
-                crls = new HashSet<X509CRL>();
-                if (crlfiles.size() > 0 || autoCRL) {
-                    CertificateFactory fac =
-                            CertificateFactory.getInstance("X509");
-                    List<CRL> list = new ArrayList<>();
-                    for (String file: crlfiles) {
-                        Collection<? extends CRL> tmp = KeyTool.loadCRLs(file);
-                        for (CRL crl: tmp) {
-                            if (crl instanceof X509CRL) {
-                                crls.add((X509CRL)crl);
-                            }
-                        }
-                    }
-                    if (autoCRL) {
-                        List<CRL> crlsFromCert =
-                                KeyTool.readCRLsFromCert(certChain[0]);
-                        for (CRL crl: crlsFromCert) {
-                            if (crl instanceof X509CRL) {
-                                crls.add((X509CRL)crl);
-                            }
-                        }
-                    }
-                }
 
                 // load the alternative signing mechanism
                 if (altSignerClass != null) {
@@ -396,13 +367,6 @@
             } else if (collator.compare(flags, "-digestalg") ==0) {
                 if (++n == args.length) usageNoArg();
                 digestalg = args[n];
-            } else if (collator.compare(flags, "-crl") ==0) {
-                if ("auto".equals(modifier)) {
-                    autoCRL = true;
-                } else {
-                    if (++n == args.length) usageNoArg();
-                    crlfiles.add(args[n]);
-                }
             } else if (collator.compare(flags, "-certs") ==0) {
                 showcerts = true;
             } else if (collator.compare(flags, "-strict") ==0) {
@@ -549,9 +513,6 @@
                 (".sigalg.algorithm.name.of.signature.algorithm"));
         System.out.println();
         System.out.println(rb.getString
-                (".crl.auto.file.include.CRL.in.signed.jar"));
-        System.out.println();
-        System.out.println(rb.getString
                 (".verify.verify.a.signed.JAR.file"));
         System.out.println();
         System.out.println(rb.getString
@@ -691,20 +652,6 @@
                             if (showcerts) {
                                 sb.append(si);
                                 sb.append('\n');
-                                CRL[] crls = SharedSecrets
-                                        .getJavaSecurityCodeSignerAccess()
-                                        .getCRLs(signer);
-                                if (crls != null) {
-                                    for (CRL crl: crls) {
-                                        if (crl instanceof X509CRLImpl) {
-                                            sb.append(tab).append("[");
-                                            sb.append(String.format(
-                                                    rb.getString("with.a.CRL.including.d.entries"),
-                                                    ((X509CRLImpl)crl).getRevokedCertificates().size()))
-                                                .append("]\n");
-                                        }
-                                    }
-                                }
                             }
                         }
                     } else if (showcerts && !verbose.equals("all")) {
@@ -1284,7 +1231,7 @@
 
             try {
                 block =
-                    sf.generateBlock(privateKey, sigalg, certChain, crls,
+                    sf.generateBlock(privateKey, sigalg, certChain,
                         externalSF, tsaUrl, tsaCert, signingMechanism, args,
                         zipFile);
             } catch (SocketTimeoutException e) {
@@ -2249,7 +2196,6 @@
     public Block generateBlock(PrivateKey privateKey,
                                String sigalg,
                                X509Certificate[] certChain,
-                               Set<X509CRL> crls,
                                boolean externalSF, String tsaUrl,
                                X509Certificate tsaCert,
                                ContentSigner signingMechanism,
@@ -2257,7 +2203,7 @@
         throws NoSuchAlgorithmException, InvalidKeyException, IOException,
             SignatureException, CertificateException
     {
-        return new Block(this, privateKey, sigalg, certChain, crls, externalSF,
+        return new Block(this, privateKey, sigalg, certChain, externalSF,
                 tsaUrl, tsaCert, signingMechanism, args, zipFile);
     }
 
@@ -2271,8 +2217,7 @@
          * Construct a new signature block.
          */
         Block(SignatureFile sfg, PrivateKey privateKey, String sigalg,
-            X509Certificate[] certChain, Set<X509CRL> crls,
-            boolean externalSF, String tsaUrl,
+            X509Certificate[] certChain, boolean externalSF, String tsaUrl,
             X509Certificate tsaCert, ContentSigner signingMechanism,
             String[] args, ZipFile zipFile)
             throws NoSuchAlgorithmException, InvalidKeyException, IOException,
@@ -2359,7 +2304,7 @@
             // Assemble parameters for the signing mechanism
             ContentSignerParameters params =
                 new JarSignerParameters(args, tsaUri, tsaCert, signature,
-                    signatureAlgorithm, certChain, crls, content, zipFile);
+                    signatureAlgorithm, certChain, content, zipFile);
 
             // Generate the signature block
             block = signingMechanism.generateSignedData(
@@ -2400,7 +2345,6 @@
     private byte[] signature;
     private String signatureAlgorithm;
     private X509Certificate[] signerCertificateChain;
-    private Set<X509CRL> crls;
     private byte[] content;
     private ZipFile source;
 
@@ -2409,8 +2353,7 @@
      */
     JarSignerParameters(String[] args, URI tsa, X509Certificate tsaCertificate,
         byte[] signature, String signatureAlgorithm,
-        X509Certificate[] signerCertificateChain, Set<X509CRL> crls,
-        byte[] content,
+        X509Certificate[] signerCertificateChain, byte[] content,
         ZipFile source) {
 
         if (signature == null || signatureAlgorithm == null ||
@@ -2423,7 +2366,6 @@
         this.signature = signature;
         this.signatureAlgorithm = signatureAlgorithm;
         this.signerCertificateChain = signerCertificateChain;
-        this.crls = crls;
         this.content = content;
         this.source = source;
     }
@@ -2499,13 +2441,4 @@
     public ZipFile getSource() {
         return source;
     }
-
-    @Override
-    public Set<X509CRL> getCRLs() {
-        if (crls == null) {
-            return Collections.emptySet();
-        } else {
-            return Collections.unmodifiableSet(crls);
-        }
-    }
 }
--- a/jdk/src/share/classes/sun/security/tools/JarSignerResources.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/tools/JarSignerResources.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -74,8 +74,6 @@
                 "[-digestalg <algorithm>]    name of digest algorithm"},
         {".sigalg.algorithm.name.of.signature.algorithm",
                 "[-sigalg <algorithm>]       name of signature algorithm"},
-        {".crl.auto.file.include.CRL.in.signed.jar",
-                "[-crl[:auto| <file>]        include CRL in signed jar"},
         {".verify.verify.a.signed.JAR.file",
                 "[-verify]                   verify a signed JAR file"},
         {".verbose.suboptions.verbose.output.when.signing.verifying.",
@@ -193,7 +191,6 @@
         {"using.an.alternative.signing.mechanism",
                 "using an alternative signing mechanism"},
         {"entry.was.signed.on", "entry was signed on {0}"},
-        {"with.a.CRL.including.d.entries", "with a CRL including %d entries"},
         {"Warning.", "Warning: "},
         {"This.jar.contains.unsigned.entries.which.have.not.been.integrity.checked.",
                 "This jar contains unsigned entries which have not been integrity-checked. "},
--- a/jdk/src/share/classes/sun/security/tools/KeyTool.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/tools/KeyTool.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, 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
@@ -25,7 +25,6 @@
 
 package sun.security.tools;
 
-import sun.misc.SharedSecrets;
 import java.io.*;
 import java.security.CodeSigner;
 import java.security.KeyStore;
@@ -2311,16 +2310,6 @@
                                     out.println();
                                 }
                             }
-                            CRL[] crls = SharedSecrets
-                                    .getJavaSecurityCodeSignerAccess()
-                                    .getCRLs(signer);
-                            if (crls != null) {
-                                out.println(rb.getString("CRLs."));
-                                out.println();
-                                for (CRL crl: crls) {
-                                    printCRL(crl, out);
-                                }
-                            }
                         }
                     }
                 }
--- a/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, 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
@@ -38,7 +38,6 @@
 import java.util.List;
 
 import com.sun.jarsigner.*;
-import java.security.cert.X509CRL;
 import java.util.Arrays;
 import sun.security.pkcs.*;
 import sun.security.timestamp.*;
@@ -238,9 +237,8 @@
         AlgorithmId[] algorithms = {digestAlgorithmId};
 
         // Create the PKCS #7 signed data message
-        PKCS7 p7 =
-            new PKCS7(algorithms, contentInfo, signerCertificateChain,
-                    parameters.getCRLs().toArray(new X509CRL[parameters.getCRLs().size()]), signerInfos);
+        PKCS7 p7 = new PKCS7(algorithms, contentInfo, signerCertificateChain,
+                null, signerInfos);
         ByteArrayOutputStream p7out = new ByteArrayOutputStream();
         p7.encodeSignedData(p7out);
 
--- a/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java	Thu Mar 10 20:49:43 2011 -0800
@@ -37,7 +37,6 @@
 import sun.security.pkcs.*;
 import sun.security.timestamp.TimestampToken;
 import sun.misc.BASE64Decoder;
-import sun.misc.SharedSecrets;
 
 import sun.security.jca.Providers;
 
@@ -486,12 +485,7 @@
                 signers = new ArrayList<CodeSigner>();
             }
             // Append the new code signer
-            CodeSigner signer = new CodeSigner(certChain, getTimestamp(info));
-            if (block.getCRLs() != null) {
-                SharedSecrets.getJavaSecurityCodeSignerAccess().setCRLs(
-                        signer, block.getCRLs());
-            }
-            signers.add(signer);
+            signers.add(new CodeSigner(certChain, getTimestamp(info)));
 
             if (debug != null) {
                 debug.println("Signature Block Certificate: " +
--- a/jdk/src/share/classes/sun/tools/native2ascii/Main.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/tools/native2ascii/Main.java	Thu Mar 10 20:49:43 2011 -0800
@@ -94,7 +94,7 @@
      * Run the converter
      */
     public synchronized boolean convert(String argv[]){
-        Vector v = new Vector(2);
+        List<String> v = new ArrayList<>(2);
         File outputFile = null;
         boolean createOutputFile = false;
 
@@ -115,7 +115,7 @@
                     usage();
                     return false;
                 }
-                v.addElement(argv[i]);
+                v.add(argv[i]);
             }
         }
         if (encodingString == null)
@@ -126,11 +126,11 @@
             initializeConverter();
 
             if (v.size() == 1)
-                inputFileName = (String)v.elementAt(0);
+                inputFileName = v.get(0);
 
             if (v.size() == 2) {
-                inputFileName = (String)v.elementAt(0);
-                outputFileName = (String)v.elementAt(1);
+                inputFileName = v.get(0);
+                outputFileName = v.get(1);
                 createOutputFile = true;
             }
 
@@ -363,9 +363,7 @@
 
     private String formatMsg(String key, String arg) {
         String msg = getMsg(key);
-        String[] args = new String[1];
-        args[0] = arg;
-        return MessageFormat.format(msg, (Object)args);
+        return MessageFormat.format(msg, arg);
     }
 
 
--- a/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java	Thu Mar 10 20:49:43 2011 -0800
@@ -127,7 +127,9 @@
             calendarProps = (Properties) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                 public Object run() throws IOException {
                     Properties props = new Properties();
-                    props.load(new FileInputStream(fname));
+                    try (FileInputStream fis = new FileInputStream(fname)) {
+                        props.load(fis);
+                    }
                     return props;
                 }
             });
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -266,7 +266,7 @@
         int index = getTransitionIndex(date, type);
 
         // prior to the transition table, returns the raw offset.
-        // should support LMT.
+        // FIXME: should support LMT.
         if (index < 0) {
             int offset = getLastRawOffset();
             if (offsets != null) {
@@ -297,7 +297,13 @@
             if (type != UTC_TIME) {
                 msec -= rawOffset;
             }
-            int dstoffset = tz.inDaylightTime(new Date(msec)) ? tz.getDSTSavings() : 0;
+            int dstoffset = tz.getOffset(msec) - rawOffset;
+
+            // Check if it's in a standard-to-daylight transition.
+            if (dstoffset > 0 && tz.getOffset(msec - dstoffset) == rawoffset) {
+                dstoffset = 0;
+            }
+
             if (offsets != null) {
                 offsets[0] = rawoffset;
                 offsets[1] = dstoffset;
@@ -452,6 +458,36 @@
         return (simpleTimeZoneParams != null);
     }
 
+    @Override
+    public boolean observesDaylightTime() {
+        if (simpleTimeZoneParams != null) {
+            return true;
+        }
+        if (transitions == null) {
+            return false;
+        }
+
+        // Look up the transition table to see if it's in DST right
+        // now or if there's any standard-to-daylight transition at
+        // any future.
+        long utc = System.currentTimeMillis() - rawOffsetDiff;
+        int index = getTransitionIndex(utc, UTC_TIME);
+
+        // before transitions in the transition table
+        if (index < 0) {
+            return false;
+        }
+
+        // the time is in the table range.
+        for (int i = index; i < transitions.length; i++) {
+            if ((transitions[i] & DST_MASK) != 0) {
+                return true;
+            }
+        }
+        // No further DST is observed.
+        return false;
+    }
+
     /**
      * Queries if the specified date is in Daylight Saving Time.
      */
--- a/jdk/src/share/classes/sun/util/logging/PlatformLogger.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/classes/sun/util/logging/PlatformLogger.java	Thu Mar 10 20:49:43 2011 -0800
@@ -535,7 +535,14 @@
         }
 
         void doLog(int level, String msg, Object... params) {
-            LoggingSupport.log(javaLogger, levelObjects.get(level), msg, params);
+            // only pass String objects to the j.u.l.Logger which may
+            // be created by untrusted code
+            int len = (params != null) ? params.length : 0;
+            Object[] sparams = new String[len];
+            for (int i = 0; i < len; i++) {
+                sparams [i] = String.valueOf(params[i]);
+            }
+            LoggingSupport.log(javaLogger, levelObjects.get(level), msg, sparams);
         }
 
         boolean isEnabled() {
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipDirectoryStream.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipDirectoryStream.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -76,7 +76,7 @@
         } catch (IOException e) {
             throw new IllegalStateException(e);
         }
-        return new Iterator<>() {
+        return new Iterator<Path>() {
             private Path next;
             @Override
             public boolean hasNext() {
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Thu Mar 10 20:49:43 2011 -0800
@@ -112,11 +112,8 @@
         }
         // sm and existence check
         zfpath.getFileSystem().provider().checkAccess(zfpath, AccessMode.READ);
-        try {
-            zfpath.getFileSystem().provider().checkAccess(zfpath, AccessMode.WRITE);
-        } catch (AccessDeniedException x) {
+        if (!Files.isWritable(zfpath))
             this.readOnly = true;
-        }
         this.zc = ZipCoder.get(nameEncoding);
         this.defaultdir = new ZipPath(this, getBytes(defaultDir));
         this.ch = Files.newByteChannel(zfpath, READ);
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -590,7 +590,7 @@
 
     @Override
     public Iterator<Path> iterator() {
-        return new Iterator<>() {
+        return new Iterator<Path>() {
             private int i = 0;
 
             @Override
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_convert.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/p11_convert.c	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -695,6 +695,46 @@
 }
 
 /*
+ * converts the Java CK_AES_CTR_PARAMS object to a CK_AES_CTR_PARAMS structure
+ *
+ * @param env - used to call JNI funktions to get the Java classes and objects
+ * @param jParam - the Java CK_AES_CTR_PARAMS object to convert
+ * @param ckpParam - pointer to the new CK_AES_CTR_PARAMS structure
+ */
+void jAesCtrParamsToCKAesCtrParam(JNIEnv *env, jobject jParam,
+                                  CK_AES_CTR_PARAMS_PTR ckpParam) {
+    jclass jAesCtrParamsClass;
+    jfieldID fieldID;
+    jlong jCounterBits;
+    jobject jCb;
+    CK_BYTE_PTR ckBytes;
+    CK_ULONG ckTemp;
+
+    /* get ulCounterBits */
+    jAesCtrParamsClass = (*env)->FindClass(env, CLASS_AES_CTR_PARAMS);
+    if (jAesCtrParamsClass == NULL) { return; }
+    fieldID = (*env)->GetFieldID(env, jAesCtrParamsClass, "ulCounterBits", "J");
+    if (fieldID == NULL) { return; }
+    jCounterBits = (*env)->GetLongField(env, jParam, fieldID);
+
+    /* get cb */
+    fieldID = (*env)->GetFieldID(env, jAesCtrParamsClass, "cb", "[B");
+    if (fieldID == NULL) { return; }
+    jCb = (*env)->GetObjectField(env, jParam, fieldID);
+
+    /* populate java values */
+    ckpParam->ulCounterBits = jLongToCKULong(jCounterBits);
+    jByteArrayToCKByteArray(env, jCb, &ckBytes, &ckTemp);
+    if ((*env)->ExceptionCheck(env)) { return; }
+    if (ckTemp != 16) {
+        TRACE1("ERROR: WRONG CTR IV LENGTH %d", ckTemp);
+    } else {
+        memcpy(ckpParam->cb, ckBytes, ckTemp);
+        free(ckBytes);
+    }
+}
+
+/*
  * converts a Java CK_MECHANISM object into a CK_MECHANISM structure
  *
  * @param env - used to call JNI funktions to get the values out of the Java object
@@ -937,12 +977,10 @@
 {
     /* get all Java mechanism parameter classes */
     jclass jVersionClass, jSsl3MasterKeyDeriveParamsClass, jSsl3KeyMatParamsClass;
-    jclass jTlsPrfParamsClass, jRsaPkcsOaepParamsClass, jPbeParamsClass;
-    jclass jPkcs5Pbkd2ParamsClass, jRsaPkcsPssParamsClass;
+    jclass jTlsPrfParamsClass, jAesCtrParamsClass, jRsaPkcsOaepParamsClass;
+    jclass jPbeParamsClass, jPkcs5Pbkd2ParamsClass, jRsaPkcsPssParamsClass;
     jclass jEcdh1DeriveParamsClass, jEcdh2DeriveParamsClass;
     jclass jX942Dh1DeriveParamsClass, jX942Dh2DeriveParamsClass;
-
-    /* get all Java mechanism parameter classes */
     TRACE0("\nDEBUG: jMechanismParameterToCKMechanismParameter");
 
     /* most common cases, i.e. NULL/byte[]/long, are already handled by
@@ -1046,6 +1084,33 @@
         return;
     }
 
+    jAesCtrParamsClass = (*env)->FindClass(env, CLASS_AES_CTR_PARAMS);
+    if (jAesCtrParamsClass == NULL) { return; }
+    if ((*env)->IsInstanceOf(env, jParam, jAesCtrParamsClass)) {
+        /*
+         * CK_AES_CTR_PARAMS
+         */
+        CK_AES_CTR_PARAMS_PTR ckpParam;
+
+        ckpParam = (CK_AES_CTR_PARAMS_PTR) malloc(sizeof(CK_AES_CTR_PARAMS));
+        if (ckpParam == NULL) {
+            JNU_ThrowOutOfMemoryError(env, 0);
+            return;
+        }
+
+        /* convert jParameter to CKParameter */
+        jAesCtrParamsToCKAesCtrParam(env, jParam, ckpParam);
+        if ((*env)->ExceptionCheck(env)) {
+            free(ckpParam);
+            return;
+        }
+
+        /* get length and pointer of parameter */
+        *ckpLength = sizeof(CK_AES_CTR_PARAMS);
+        *ckpParamPtr = ckpParam;
+        return;
+    }
+
     jRsaPkcsOaepParamsClass = (*env)->FindClass(env, CLASS_RSA_PKCS_OAEP_PARAMS);
     if (jRsaPkcsOaepParamsClass == NULL) { return; }
     if ((*env)->IsInstanceOf(env, jParam, jRsaPkcsOaepParamsClass)) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs-11v2-20a3.h	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,124 @@
+/* pkcs-11v2-20a3.h include file for the PKCS #11 Version 2.20 Amendment 3
+   document. */
+
+/* $Revision: 1.4 $ */
+
+/* License to copy and use this software is granted provided that it is
+ * identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface
+ * (Cryptoki) Version 2.20 Amendment 3" in all material mentioning or
+ * referencing this software.
+
+ * RSA Security Inc. makes no representations concerning either the
+ * merchantability of this software or the suitability of this software for
+ * any particular purpose. It is provided "as is" without express or implied
+ * warranty of any kind.
+ */
+
+/* This file is preferably included after inclusion of pkcs11.h */
+
+#ifndef _PKCS_11V2_20A3_H_
+#define _PKCS_11V2_20A3_H_ 1
+
+/* Are the definitions of this file already included in pkcs11t.h ? */
+#ifndef CKK_CAMELLIA
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Key types */
+
+/* Camellia is new for PKCS #11 v2.20 amendment 3 */
+#define CKK_CAMELLIA                   0x00000025
+/* ARIA is new for PKCS #11 v2.20 amendment 3 */
+#define CKK_ARIA                       0x00000026
+
+
+/* Mask-generating functions */
+
+/* SHA-224 is new for PKCS #11 v2.20 amendment 3 */
+#define CKG_MGF1_SHA224                0x00000005
+
+
+/* Mechanism Identifiers */
+
+/* SHA-224 is new for PKCS #11 v2.20 amendment 3 */
+#define CKM_SHA224                     0x00000255
+#define CKM_SHA224_HMAC                0x00000256
+#define CKM_SHA224_HMAC_GENERAL        0x00000257
+
+/* SHA-224 key derivation is new for PKCS #11 v2.20 amendment 3 */
+#define CKM_SHA224_KEY_DERIVATION      0x00000396
+
+/* SHA-224 RSA mechanisms are new for PKCS #11 v2.20 amendment 3 */
+#define CKM_SHA224_RSA_PKCS            0x00000046
+#define CKM_SHA224_RSA_PKCS_PSS        0x00000047
+
+/* AES counter mode is new for PKCS #11 v2.20 amendment 3 */
+#define CKM_AES_CTR                    0x00001086
+
+/* Camellia is new for PKCS #11 v2.20 amendment 3 */
+#define CKM_CAMELLIA_KEY_GEN           0x00000550
+#define CKM_CAMELLIA_ECB               0x00000551
+#define CKM_CAMELLIA_CBC               0x00000552
+#define CKM_CAMELLIA_MAC               0x00000553
+#define CKM_CAMELLIA_MAC_GENERAL       0x00000554
+#define CKM_CAMELLIA_CBC_PAD           0x00000555
+#define CKM_CAMELLIA_ECB_ENCRYPT_DATA  0x00000556
+#define CKM_CAMELLIA_CBC_ENCRYPT_DATA  0x00000557
+#define CKM_CAMELLIA_CTR               0x00000558
+
+/* ARIA is new for PKCS #11 v2.20 amendment 3 */
+#define CKM_ARIA_KEY_GEN               0x00000560
+#define CKM_ARIA_ECB                   0x00000561
+#define CKM_ARIA_CBC                   0x00000562
+#define CKM_ARIA_MAC                   0x00000563
+#define CKM_ARIA_MAC_GENERAL           0x00000564
+#define CKM_ARIA_CBC_PAD               0x00000565
+#define CKM_ARIA_ECB_ENCRYPT_DATA      0x00000566
+#define CKM_ARIA_CBC_ENCRYPT_DATA      0x00000567
+
+
+/* Mechanism parameters */
+
+/* CK_AES_CTR_PARAMS is new for PKCS #11 v2.20 amendment 3 */
+typedef struct CK_AES_CTR_PARAMS {
+    CK_ULONG ulCounterBits;
+    CK_BYTE cb[16];
+} CK_AES_CTR_PARAMS;
+
+typedef CK_AES_CTR_PARAMS CK_PTR CK_AES_CTR_PARAMS_PTR;
+
+/* CK_CAMELLIA_CTR_PARAMS is new for PKCS #11 v2.20 amendment 3 */
+typedef struct CK_CAMELLIA_CTR_PARAMS {
+    CK_ULONG ulCounterBits;
+    CK_BYTE cb[16];
+} CK_CAMELLIA_CTR_PARAMS;
+
+typedef CK_CAMELLIA_CTR_PARAMS CK_PTR CK_CAMELLIA_CTR_PARAMS_PTR;
+
+/* CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS is new for PKCS #11 v2.20 amendment 3 */
+typedef struct CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS {
+    CK_BYTE      iv[16];
+    CK_BYTE_PTR  pData;
+    CK_ULONG     length;
+} CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS;
+
+typedef CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS_PTR;
+
+/* CK_ARIA_CBC_ENCRYPT_DATA_PARAMS is new for PKCS #11 v2.20 amendment 3 */
+typedef struct CK_ARIA_CBC_ENCRYPT_DATA_PARAMS {
+    CK_BYTE      iv[16];
+    CK_BYTE_PTR  pData;
+    CK_ULONG     length;
+} CK_ARIA_CBC_ENCRYPT_DATA_PARAMS;
+
+typedef CK_ARIA_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_ARIA_CBC_ENCRYPT_DATA_PARAMS_PTR;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+#endif
--- a/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/share/native/sun/security/pkcs11/wrapper/pkcs11wrapper.h	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  */
 
 /* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
@@ -153,6 +153,7 @@
 #include "p11_md.h"
 
 #include "pkcs11.h"
+#include "pkcs-11v2-20a3.h"
 #include <jni.h>
 #include <jni_util.h>
 
@@ -272,6 +273,7 @@
 #define CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_SSL3_MASTER_KEY_DERIVE_PARAMS"
 #define CLASS_SSL3_KEY_MAT_PARAMS "sun/security/pkcs11/wrapper/CK_SSL3_KEY_MAT_PARAMS"
 #define CLASS_TLS_PRF_PARAMS "sun/security/pkcs11/wrapper/CK_TLS_PRF_PARAMS"
+#define CLASS_AES_CTR_PARAMS "sun/security/pkcs11/wrapper/CK_AES_CTR_PARAMS"
 
 /* function to convert a PKCS#11 return value other than CK_OK into a Java Exception
  * or to throw a PKCS11RuntimeException
--- a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Thu Mar 10 20:49:43 2011 -0800
@@ -571,9 +571,9 @@
                     long newLastSyncTime = 0;
                     try {
                         newLastSyncTime = prefsFile.lastModified();
-                        FileInputStream fis = new FileInputStream(prefsFile);
-                        XmlSupport.importMap(fis, m);
-                        fis.close();
+                        try (FileInputStream fis = new FileInputStream(prefsFile)) {
+                            XmlSupport.importMap(fis, m);
+                        }
                     } catch(Exception e) {
                         if (e instanceof InvalidPreferencesFormatException) {
                             getLogger().warning("Invalid preferences format in "
@@ -618,9 +618,9 @@
                         if (!dir.exists() && !dir.mkdirs())
                             throw new BackingStoreException(dir +
                                                              " create failed.");
-                        FileOutputStream fos = new FileOutputStream(tmpFile);
-                        XmlSupport.exportMap(fos, prefsCache);
-                        fos.close();
+                        try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
+                            XmlSupport.exportMap(fos, prefsCache);
+                        }
                         if (!tmpFile.renameTo(prefsFile))
                             throw new BackingStoreException("Can't rename " +
                             tmpFile + " to " + prefsFile);
--- a/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java	Thu Mar 10 20:49:43 2011 -0800
@@ -56,12 +56,14 @@
     }
 
     private native void run(String title, int mode, String dir, String file,
-            FilenameFilter filter, boolean isMultipleMode);
+                            FilenameFilter filter, boolean isMultipleMode, int x, int y);
     private native void quit();
 
     @Override
     public native void toFront();
 
+    @Override
+    public native void setBounds(int x, int y, int width, int height, int op);
 
     /**
      * Called exclusively by the native C code.
@@ -106,9 +108,8 @@
                 Thread t = new Thread() {
                     public void run() {
                         GtkFileDialogPeer.this.run(fd.getTitle(), fd.getMode(),
-                                fd.getDirectory(), fd.getFile(), fd
-                                        .getFilenameFilter(), fd
-                                        .isMultipleMode());
+                                   fd.getDirectory(), fd.getFile(), fd.getFilenameFilter(), fd.isMultipleMode(),
+                                   fd.getX(), fd.getY());
                         fd.setVisible(false);
                     }
                 };
--- a/jdk/src/solaris/classes/sun/font/XRGlyphCache.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/classes/sun/font/XRGlyphCache.java	Thu Mar 10 20:49:43 2011 -0800
@@ -70,9 +70,14 @@
         try {
             SunToolkit.awtLock();
 
-            ArrayList<Integer> glyphIDList = new ArrayList<Integer>(glyphPtrList.size());
+            GrowableIntArray glyphIDList = new GrowableIntArray(1, glyphPtrList.size());
             for (long glyphPtr : glyphPtrList) {
-                glyphIDList.add(XRGlyphCacheEntry.getGlyphID(glyphPtr));
+                int glyphID = XRGlyphCacheEntry.getGlyphID(glyphPtr);
+
+                //Check if glyph hasn't been freed already
+                if (glyphID != 0) {
+                   glyphIDList.addInt(glyphID);
+                }
             }
             freeGlyphs(glyphIDList);
         } finally {
@@ -83,7 +88,6 @@
     protected int getFreeGlyphID() {
         if (freeGlyphIDs.size() > 0) {
             int newID = freeGlyphIDs.remove(freeGlyphIDs.size() - 1);
-            ;
             return newID;
         }
         return nextID++;
@@ -246,7 +250,7 @@
             glyph.setPinned();
         }
 
-        ArrayList<Integer> deleteGlyphList = new ArrayList<Integer>();
+        GrowableIntArray deleteGlyphList = new GrowableIntArray(1, 10);
         int pixelsToRelease = cachedPixels - MAX_CACHED_PIXELS;
 
         for (int i = cacheList.size() - 1; i >= 0 && pixelsToRelease > 0; i--) {
@@ -254,7 +258,7 @@
 
             if (!entry.isPinned()) {
                 pixelsToRelease -= entry.getPixelCnt();
-                deleteGlyphList.add(new Integer(entry.getGlyphID()));
+                deleteGlyphList.addInt(entry.getGlyphID());
             }
         }
 
@@ -265,26 +269,23 @@
         freeGlyphs(deleteGlyphList);
     }
 
-    private void freeGlyphs(List<Integer> glyphIdList) {
-
-        freeGlyphIDs.addAll(glyphIdList);
+    private void freeGlyphs(GrowableIntArray glyphIdList) {
+        GrowableIntArray removedLCDGlyphs = new GrowableIntArray(1, 10);
+        GrowableIntArray removedGrayscaleGlyphs = new GrowableIntArray(1, 10);
 
-        GrowableIntArray removedLCDGlyphs = new GrowableIntArray(1, 1);
-        GrowableIntArray removedGrayscaleGlyphs = new GrowableIntArray(1, 1);
+        for (int i=0; i < glyphIdList.getSize(); i++) {
+            int glyphId = glyphIdList.getInt(i);
+            freeGlyphIDs.add(glyphId);
 
-        for (Integer glyphId : glyphIdList) {
-            tmp.setValue(glyphId.intValue());
+            tmp.setValue(glyphId);
             XRGlyphCacheEntry entry = cacheMap.get(tmp);
             cachedPixels -= entry.getPixelCnt();
-
-            int removedGlyphID = entry.getGlyphID();
-            tmp.setValue(removedGlyphID);
             cacheMap.remove(tmp);
 
             if (entry.getGlyphSet() == grayGlyphSet) {
-                removedGrayscaleGlyphs.addInt(removedGlyphID);
+                removedGrayscaleGlyphs.addInt(glyphId);
             } else {
-                removedLCDGlyphs.addInt(removedGlyphID);
+                removedLCDGlyphs.addInt(glyphId);
             }
 
             entry.setGlyphID(0);
--- a/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java	Thu Mar 10 20:49:43 2011 -0800
@@ -55,6 +55,8 @@
 
     native void initXRPicture(long xsdo, int pictForm);
 
+    native void freeXSDOPicture(long xsdo);
+
     public static final String DESC_BYTE_A8_X11 = "Byte A8 Pixmap";
     public static final String DESC_INT_RGB_X11 = "Integer RGB Pixmap";
     public static final String DESC_INT_ARGB_X11 = "Integer ARGB-Pre Pixmap";
@@ -531,6 +533,17 @@
         public Object getDestination() {
             return peer.getTarget();
         }
+
+       public void invalidate() {
+           try {
+               SunToolkit.awtLock();
+               freeXSDOPicture(getNativeOps());
+           }finally {
+               SunToolkit.awtUnlock();
+           }
+
+           super.invalidate();
+       }
     }
 
     public static class XRInternalSurfaceData extends XRSurfaceData {
--- a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousServerSocketChannelImpl.java	Thu Mar 10 20:49:43 2011 -0800
@@ -236,7 +236,9 @@
         } catch (SecurityException x) {
             try {
                 ch.close();
-            } catch (IOException ignore) { }
+            } catch (Throwable suppressed) {
+                x.addSuppressed(suppressed);
+            }
             throw x;
         }
         return ch;
--- a/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/classes/sun/nio/ch/UnixAsynchronousSocketChannelImpl.java	Thu Mar 10 20:49:43 2011 -0800
@@ -137,7 +137,7 @@
         return port;
     }
 
-    // register for events if there are outstanding I/O operations
+    // register events for outstanding I/O operations, caller already owns updateLock
     private void updateEvents() {
         assert Thread.holdsLock(updateLock);
         int events = 0;
@@ -149,6 +149,13 @@
             port.startPoll(fdVal, events);
     }
 
+    // register events for outstanding I/O operations
+    private void lockAndUpdateEvents() {
+        synchronized (updateLock) {
+            updateEvents();
+        }
+    }
+
     // invoke to finish read and/or write operations
     private void finish(boolean mayInvokeDirect,
                         boolean readable,
@@ -255,10 +262,11 @@
             // close channel if connection cannot be established
             try {
                 close();
-            } catch (IOException ignore) { }
+            } catch (Throwable suppressed) {
+                e.addSuppressed(suppressed);
+            }
         }
 
-
         // invoke handler and set result
         CompletionHandler<Void,Object> handler = connectHandler;
         Object att = connectAttachment;
@@ -345,7 +353,9 @@
         if (e != null) {
             try {
                 close();
-            } catch (IOException ignore) { }
+            } catch (Throwable suppressed) {
+                e.addSuppressed(suppressed);
+            }
         }
         if (handler == null) {
             return CompletedFuture.withResult(null, e);
@@ -399,9 +409,8 @@
             exc = x;
         } finally {
             // restart poll in case of concurrent write
-            synchronized (updateLock) {
-                updateEvents();
-            }
+            if (!(exc instanceof AsynchronousCloseException))
+                lockAndUpdateEvents();
             end();
         }
 
@@ -595,9 +604,8 @@
             exc = x;
         } finally {
             // restart poll in case of concurrent write
-            synchronized (updateLock) {
-                updateEvents();
-            }
+            if (!(exc instanceof AsynchronousCloseException))
+                lockAndUpdateEvents();
             end();
         }
 
--- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, 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
@@ -77,22 +77,24 @@
          */
 #endif /* __linux__ */
         struct hostent res, res2, *hp;
-        char buf[HENT_BUF_SIZE];
-        char buf2[HENT_BUF_SIZE];
+        // these buffers must be pointer-aligned so they are declared
+        // with pointer type
+        char *buf[HENT_BUF_SIZE/(sizeof (char *))];
+        char *buf2[HENT_BUF_SIZE/(sizeof (char *))];
         int h_error=0;
 
 #ifdef __GLIBC__
-        gethostbyname_r(hostname, &res, buf, sizeof(buf), &hp, &h_error);
+        gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &hp, &h_error);
 #else
-        hp = gethostbyname_r(hostname, &res, buf, sizeof(buf), &h_error);
+        hp = gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &h_error);
 #endif
         if (hp) {
 #ifdef __GLIBC__
             gethostbyaddr_r(hp->h_addr, hp->h_length, AF_INET,
-                            &res2, buf2, sizeof(buf2), &hp, &h_error);
+                            &res2, (char*)buf2, sizeof(buf2), &hp, &h_error);
 #else
             hp = gethostbyaddr_r(hp->h_addr, hp->h_length, AF_INET,
-                                 &res2, buf2, sizeof(buf2), &h_error);
+                                 &res2, (char*)buf2, sizeof(buf2), &h_error);
 #endif
             if (hp) {
                 /*
@@ -136,7 +138,9 @@
     const char *hostname;
     jobjectArray ret = 0;
     struct hostent res, *hp = 0;
-    char buf[HENT_BUF_SIZE];
+    // this buffer must be pointer-aligned so is declared
+    // with pointer type
+    char *buf[HENT_BUF_SIZE/(sizeof (char *))];
 
     /* temporary buffer, on the off chance we need to expand */
     char *tmp = NULL;
@@ -176,9 +180,9 @@
 
     /* Try once, with our static buffer. */
 #ifdef __GLIBC__
-    gethostbyname_r(hostname, &res, buf, sizeof(buf), &hp, &h_error);
+    gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &hp, &h_error);
 #else
-    hp = gethostbyname_r(hostname, &res, buf, sizeof(buf), &h_error);
+    hp = gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &h_error);
 #endif
 
     /* With the re-entrant system calls, it's possible that the buffer
@@ -251,7 +255,9 @@
     jstring ret = NULL;
     jint addr;
     struct hostent hent, *hp = 0;
-    char buf[HENT_BUF_SIZE];
+    // this buffer must be pointer-aligned so is declared
+    // with pointer type
+    char *buf[HENT_BUF_SIZE/(sizeof (char *))];
     int h_error = 0;
     char *tmp = NULL;
 
@@ -273,10 +279,10 @@
     addr = htonl(addr);
 #ifdef __GLIBC__
     gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent,
-                    buf, sizeof(buf), &hp, &h_error);
+                    (char*)buf, sizeof(buf), &hp, &h_error);
 #else
     hp = gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent,
-                         buf, sizeof(buf), &h_error);
+                         (char*)buf, sizeof(buf), &h_error);
 #endif
     /* With the re-entrant system calls, it's possible that the buffer
      * we pass to it is not large enough to hold an exceptionally
--- a/jdk/src/solaris/native/java/net/NetworkInterface.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/java/net/NetworkInterface.c	Thu Mar 10 20:49:43 2011 -0800
@@ -45,7 +45,6 @@
 #ifdef __linux__
 #include <sys/ioctl.h>
 #include <bits/ioctls.h>
-#include <linux/sockios.h>
 #include <sys/utsname.h>
 #include <stdio.h>
 #endif
@@ -1100,7 +1099,7 @@
 #ifdef AF_INET6
 static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
     FILE *f;
-    char addr6[40], devname[20];
+    char addr6[40], devname[21];
     char addr6p[8][5];
     int plen, scope, dad_status, if_idx;
     uint8_t ipv6addr[16];
--- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c	Thu Mar 10 20:49:43 2011 -0800
@@ -34,8 +34,8 @@
 #include <fcntl.h>
 #endif
 #ifdef __linux__
-#include <linux/unistd.h>
-#include <linux/sysctl.h>
+#include <unistd.h>
+#include <sys/sysctl.h>
 #include <sys/utsname.h>
 #include <netinet/ip.h>
 
--- a/jdk/src/solaris/native/java/net/PlainSocketImpl.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/java/net/PlainSocketImpl.c	Thu Mar 10 20:49:43 2011 -0800
@@ -42,8 +42,8 @@
 #include <fcntl.h>
 #endif
 #ifdef __linux__
-#include <linux/unistd.h>
-#include <linux/sysctl.h>
+#include <unistd.h>
+#include <sys/sysctl.h>
 #endif
 
 #include "jvm.h"
--- a/jdk/src/solaris/native/java/net/linux_close.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/java/net/linux_close.c	Thu Mar 10 20:49:43 2011 -0800
@@ -112,7 +112,7 @@
  */
 static inline fdEntry_t *getFdEntry(int fd)
 {
-    if (fd < 0 || fd > fdCount) {
+    if (fd < 0 || fd >= fdCount) {
         return NULL;
     }
     return &fdTable[fd];
--- a/jdk/src/solaris/native/java/net/net_util_md.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/java/net/net_util_md.c	Thu Mar 10 20:49:43 2011 -0800
@@ -608,7 +608,7 @@
     {
         /* now find the scope_id for "lo" */
 
-        char devname[20];
+        char devname[21];
         char addr6p[8][5];
         int plen, scope, dad_status, if_idx;
 
@@ -651,7 +651,7 @@
 static void initLocalIfs () {
     FILE *f;
     unsigned char staddr [16];
-    char ifname [32];
+    char ifname [33];
     struct localinterface *lif=0;
     int index, x1, x2, x3;
     unsigned int u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,ua,ub,uc,ud,ue,uf;
@@ -660,7 +660,7 @@
         return ;
     }
     while (fscanf (f, "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x "
-                "%d %x %x %x %s",&u0,&u1,&u2,&u3,&u4,&u5,&u6,&u7,
+                "%d %x %x %x %32s",&u0,&u1,&u2,&u3,&u4,&u5,&u6,&u7,
                 &u8,&u9,&ua,&ub,&uc,&ud,&ue,&uf,
                 &index, &x1, &x2, &x3, ifname) == 21) {
         staddr[0] = (unsigned char)u0;
@@ -1102,7 +1102,7 @@
      * index.
      */
     if (match) {
-        char devname[20];
+        char devname[21];
         char addr6p[8][5];
         int plen, scope, dad_status, if_idx;
 
--- a/jdk/src/solaris/native/sun/awt/gtk2_interface.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.c	Thu Mar 10 20:49:43 2011 -0800
@@ -608,7 +608,10 @@
         fp_gtk_viewport_new = dl_symbol("gtk_viewport_new");
         fp_gtk_window_new = dl_symbol("gtk_window_new");
         fp_gtk_window_present = dl_symbol("gtk_window_present");
-        fp_gtk_dialog_new = dl_symbol("gtk_dialog_new");
+        fp_gtk_window_move = dl_symbol("gtk_window_move");
+        fp_gtk_window_resize = dl_symbol("gtk_window_resize");
+
+          fp_gtk_dialog_new = dl_symbol("gtk_dialog_new");
         fp_gtk_frame_new = dl_symbol("gtk_frame_new");
 
         fp_gtk_adjustment_new = dl_symbol("gtk_adjustment_new");
--- a/jdk/src/solaris/native/sun/awt/gtk2_interface.h	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.h	Thu Mar 10 20:49:43 2011 -0800
@@ -750,7 +750,8 @@
 GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
 void (*fp_gtk_widget_destroy)(GtkWidget *widget);
 void (*fp_gtk_window_present)(GtkWindow *window);
-
+void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
+void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
 
 /**
  * Function Pointers for GtkFileChooser
--- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Thu Mar 10 20:49:43 2011 -0800
@@ -102,6 +102,33 @@
     fp_gdk_threads_leave();
 }
 
+/*
+ * Class:     sun_awt_X11_GtkFileDialogPeer
+ * Method:    setBounds
+ * Signature: (IIIII)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_setBounds
+(JNIEnv * env, jobject jpeer, jint x, jint y, jint width, jint height, jint op)
+{
+    GtkWindow* dialog;
+
+    fp_gdk_threads_enter();
+
+    dialog = (GtkWindow*)jlong_to_ptr(
+        (*env)->GetLongField(env, jpeer, widgetFieldID));
+
+    if (dialog != NULL) {
+        if (x >= 0 && y >= 0) {
+            fp_gtk_window_move(dialog, (gint)x, (gint)y);
+        }
+        if (width > 0 && height > 0) {
+            fp_gtk_window_resize(dialog, (gint)width, (gint)height);
+        }
+    }
+
+    fp_gdk_threads_leave();
+}
+
 /**
  * Convert a GSList to an array of filenames (without the parent folder)
  */
@@ -175,12 +202,12 @@
 /*
  * Class:     sun_awt_X11_GtkFileDialogPeer
  * Method:    run
- * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;Z;)V
+ * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;ZII)V
  */
 JNIEXPORT void JNICALL
 Java_sun_awt_X11_GtkFileDialogPeer_run(JNIEnv * env, jobject jpeer,
         jstring jtitle, jint mode, jstring jdir, jstring jfile,
-        jobject jfilter, jboolean multiple)
+        jobject jfilter, jboolean multiple, int x, int y)
 {
     GtkWidget *dialog = NULL;
     GtkFileFilter *filter;
@@ -244,6 +271,14 @@
                 dialog), TRUE);
     }
 
+    /* Set the initial location */
+    if (x >= 0 && y >= 0) {
+        fp_gtk_window_move((GtkWindow*)dialog, (gint)x, (gint)y);
+
+        // NOTE: it doesn't set the initial size for the file chooser
+        // as it seems like the file chooser overrides the size internally
+    }
+
     fp_g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(
             handle_response), jpeer);
 
--- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h	Thu Mar 10 20:49:43 2011 -0800
@@ -20,10 +20,10 @@
 /*
  * Class:     sun_awt_X11_GtkFileDialogPeer
  * Method:    run
- * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;Z;)V
+ * Signature: (Ljava/lang/String;ILjava/lang/String;Ljava/lang/String;Ljava/io/FilenameFilter;ZII)V
  */
 JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_run
-(JNIEnv *, jobject, jstring, jint, jstring, jstring, jobject, jboolean);
+(JNIEnv *, jobject, jstring, jint, jstring, jstring, jobject, jboolean, jint, jint);
 
 /*
  * Class:     sun_awt_X11_GtkFileDialogPeer
@@ -41,6 +41,14 @@
 JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront
 (JNIEnv *, jobject);
 
+/*
+ * Class:     sun_awt_X11_GtkFileDialogPeer
+ * Method:    setBounds
+ * Signature: (IIIII)V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_setBounds
+(JNIEnv * env, jobject jpeer, jint x, jint y, jint width, jint height, jint op);
+
 #ifdef __cplusplus
 }
 #endif
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c	Thu Mar 10 20:49:43 2011 -0800
@@ -375,6 +375,12 @@
     AWT_LOCK();
 
     xsdo->invalid = JNI_TRUE;
+
+    if (xsdo->xrPic != None) {
+        XRenderFreePicture(awt_display, xsdo->xrPic);
+        xsdo->xrPic = None;
+     }
+
     if (xsdo->isPixmap == JNI_TRUE && xsdo->drawable != 0) {
 #ifdef MITSHM
         if (xsdo->shmPMData.shmSegInfo != NULL) {
--- a/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/x11/XRBackendNative.c	Thu Mar 10 20:49:43 2011 -0800
@@ -304,23 +304,27 @@
     color.blue = blue;
 
     if (rectCnt <= 256) {
-      xRects = &sRects[0];
+        xRects = &sRects[0];
     } else {
-      xRects = (XRectangle *) malloc(sizeof(XRectangle) * rectCnt);
-      if (xRects == NULL) {
-        return;
-      }
+        xRects = (XRectangle *) malloc(sizeof(XRectangle) * rectCnt);
+        if (xRects == NULL) {
+            return;
+        }
     }
 
-    if ((rects = (jint *) (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
-      return;
+    if ((rects = (jint *)
+         (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
+        if (xRects != &sRects[0]) {
+            free(xRects);
+        }
+        return;
     }
 
     for (i=0; i < rectCnt; i++) {
-      xRects[i].x = rects[i*4 + 0];
-      xRects[i].y = rects[i*4 + 1];
-      xRects[i].width = rects[i*4 + 2];
-      xRects[i].height = rects[i*4 + 3];
+        xRects[i].x = rects[i*4 + 0];
+        xRects[i].y = rects[i*4 + 1];
+        xRects[i].width = rects[i*4 + 2];
+        xRects[i].height = rects[i*4 + 3];
     }
 
     XRenderFillRectangles(awt_display, op,
@@ -328,7 +332,7 @@
 
     (*env)->ReleasePrimitiveArrayCritical(env, rectArray, rects, JNI_ABORT);
     if (xRects != &sRects[0]) {
-      free(xRects);
+        free(xRects);
     }
 }
 
@@ -610,17 +614,30 @@
     Glyph *gid = (Glyph *) malloc(sizeof(Glyph) * glyphCnt);
 
     if (xginfo == NULL || gid == NULL) {
-      return;
+        if (xginfo != NULL) {
+            free(xginfo);
+        }
+        if (gid != NULL) {
+            free(gid);
+        }
+        return;
     }
 
-    if ((glyphInfoPtrs = (jlong *) (*env)->GetPrimitiveArrayCritical(env, glyphInfoPtrsArray, NULL)) == NULL) {
+    if ((glyphInfoPtrs = (jlong *)(*env)->
+        GetPrimitiveArrayCritical(env, glyphInfoPtrsArray, NULL)) == NULL)
+    {
+        free(xginfo);
+        free(gid);
         return;
     }
 
     if ((pixelData = (unsigned char *)
-        (*env)->GetPrimitiveArrayCritical(env, pixelDataArray, NULL)) == NULL) {
+        (*env)->GetPrimitiveArrayCritical(env, pixelDataArray, NULL)) == NULL)
+    {
         (*env)->ReleasePrimitiveArrayCritical(env,
-                                  glyphInfoPtrsArray, glyphInfoPtrs, JNI_ABORT);
+                                glyphInfoPtrsArray, glyphInfoPtrs, JNI_ABORT);
+        free(xginfo);
+        free(gid);
         return;
     }
 
@@ -637,7 +654,7 @@
     }
 
     XRenderAddGlyphs(awt_display, glyphSet, &gid[0], &xginfo[0], glyphCnt,
-                     pixelData, pixelDataLength);
+                     (const char*)pixelData, pixelDataLength);
 
     (*env)->ReleasePrimitiveArrayCritical(env, glyphInfoPtrsArray, glyphInfoPtrs, JNI_ABORT);
     (*env)->ReleasePrimitiveArrayCritical(env, pixelDataArray, pixelData, JNI_ABORT);
@@ -684,22 +701,44 @@
       xelts = &selts[0];
     }else {
       xelts = (XGlyphElt32 *) malloc(sizeof(XGlyphElt32) * eltCnt);
+      if (xelts == NULL) {
+          return;
+      }
     }
 
     if (glyphCnt <= 256) {
       xids = &sids[0];
-    }else {
+    } else {
       xids = (Glyph *) malloc(sizeof(Glyph) * glyphCnt);
+      if (xids == NULL) {
+          if (xelts != &selts[0]) {
+            free(xelts);
+          }
+          return;
+      }
     }
 
-    if ((ids = (jint *) (*env)->GetPrimitiveArrayCritical(env, glyphIDArray, NULL)) == NULL) {
-      return;
+    if ((ids = (jint *)
+         (*env)->GetPrimitiveArrayCritical(env, glyphIDArray, NULL)) == NULL) {
+        if (xelts != &selts[0]) {
+            free(xelts);
+        }
+        if (xids != &sids[0]) {
+            free(xids);
+        }
+        return;
     }
     if ((elts = (jint *)
           (*env)->GetPrimitiveArrayCritical(env, eltArray, NULL)) == NULL) {
         (*env)->ReleasePrimitiveArrayCritical(env,
                                               glyphIDArray, ids, JNI_ABORT);
-      return;
+        if (xelts != &selts[0]) {
+            free(xelts);
+        }
+        if (xids != &sids[0]) {
+            free(xids);
+        }
+        return;
     }
 
     for (i=0; i < glyphCnt; i++) {
@@ -724,11 +763,11 @@
     (*env)->ReleasePrimitiveArrayCritical(env, eltArray, elts, JNI_ABORT);
 
     if (xelts != &selts[0]) {
-      free(xelts);
+        free(xelts);
     }
 
     if (xids != &sids[0]) {
-      free(xids);
+        free(xids);
     }
 }
 
@@ -762,8 +801,12 @@
       }
     }
 
-    if ((rects = (jint *) (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
-      return;
+    if ((rects = (jint*)
+         (*env)->GetPrimitiveArrayCritical(env, rectArray, NULL)) == NULL) {
+        if (xRects != &sRects[0]) {
+            free(xRects);
+        }
+        return;
     }
 
     for (i=0; i < rectCnt; i++) {
--- a/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/x11/XRSurfaceData.c	Thu Mar 10 20:49:43 2011 -0800
@@ -114,3 +114,26 @@
     XShared_initSurface(env, xsdo, depth, width, height, drawable);
 #endif /* !HEADLESS */
 }
+
+
+
+JNIEXPORT void JNICALL
+Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture(JNIEnv *env, jobject xsd,
+                                                  jlong pXSData)
+{
+#ifndef HEADLESS
+    X11SDOps *xsdo;
+
+    J2dTraceLn(J2D_TRACE_INFO, "in XRSurfaceData_freeXSDOPicture");
+
+    xsdo = X11SurfaceData_GetOps(env, xsd);
+    if (xsdo == NULL) {
+        return;
+    }
+
+    if(xsdo->xrPic != None) {
+       XRenderFreePicture(awt_display, xsdo->xrPic);
+       xsdo->xrPic = None;
+    }
+#endif /* !HEADLESS */
+}
--- a/jdk/src/windows/classes/sun/nio/ch/PendingIoCache.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/windows/classes/sun/nio/ch/PendingIoCache.java	Thu Mar 10 20:49:43 2011 -0800
@@ -110,8 +110,7 @@
             if (closed)
                 return;
 
-            // handle the case that where there are I/O operations that have
-            // not completed.
+            // handle case where I/O operations that have not completed.
             if (!pendingIoMap.isEmpty())
                 clearPendingIoMap();
 
@@ -132,7 +131,9 @@
         closePending = true;
         try {
             this.wait(50);
-        } catch (InterruptedException x) { }
+        } catch (InterruptedException x) {
+            Thread.currentThread().interrupt();
+        }
         closePending = false;
         if (pendingIoMap.isEmpty())
             return;
--- a/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java	Thu Mar 10 20:49:43 2011 -0800
@@ -439,6 +439,7 @@
                 address = ((DirectBuffer)buf).address();
             }
 
+            boolean pending = false;
             try {
                 begin();
 
@@ -449,6 +450,7 @@
                 n = readFile(handle, address, rem, position, overlapped);
                 if (n == IOStatus.UNAVAILABLE) {
                     // I/O is pending
+                    pending = true;
                     return;
                 } else if (n == IOStatus.EOF) {
                     result.setResult(n);
@@ -460,14 +462,15 @@
                 // failed to initiate read
                 result.setFailure(toIOException(x));
             } finally {
+                if (!pending) {
+                    // release resources
+                    if (overlapped != 0L)
+                        ioCache.remove(overlapped);
+                    releaseBufferIfSubstituted();
+                }
                 end();
             }
 
-            // release resources
-            if (overlapped != 0L)
-                ioCache.remove(overlapped);
-            releaseBufferIfSubstituted();
-
             // invoke completion handler
             Invoker.invoke(result);
         }
--- a/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java	Thu Mar 10 20:49:43 2011 -0800
@@ -239,14 +239,14 @@
                     result.setResult(null);
                 }
             } catch (Throwable x) {
+                if (overlapped != 0L)
+                    ioCache.remove(overlapped);
                 exc = x;
             } finally {
                 end();
             }
 
             if (exc != null) {
-                if (overlapped != 0L)
-                    ioCache.remove(overlapped);
                 closeChannel();
                 result.setFailure(toIOException(exc));
             }
--- a/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/windows/classes/sun/nio/fs/WindowsFileStore.java	Thu Mar 10 20:49:43 2011 -0800
@@ -201,13 +201,12 @@
         if (!(ob instanceof WindowsFileStore))
             return false;
         WindowsFileStore other = (WindowsFileStore)ob;
-        return this.volInfo.volumeSerialNumber() == other.volInfo.volumeSerialNumber();
+        return root.equals(other.root);
     }
 
     @Override
     public int hashCode() {
-        // reveals VSN without permission check - okay?
-        return volInfo.volumeSerialNumber();
+        return root.hashCode();
     }
 
     @Override
--- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp	Thu Mar 10 20:49:43 2011 -0800
@@ -109,7 +109,6 @@
     m_isMenuDropped = FALSE;
     m_isInputMethodWindow = FALSE;
     m_isUndecorated = FALSE;
-    m_proxyFocusOwner = NULL;
     m_lastProxiedFocusOwner = NULL;
     m_actualFocusedWindow = NULL;
     m_iconic = FALSE;
@@ -127,7 +126,6 @@
 
 void AwtFrame::Dispose()
 {
-    DestroyProxyFocusOwner();
     AwtWindow::Dispose();
 }
 
@@ -308,22 +306,9 @@
     return frame;
 }
 
-LRESULT CALLBACK AwtFrame::ProxyWindowProc(HWND hwnd, UINT message,
-                                           WPARAM wParam, LPARAM lParam)
+LRESULT AwtFrame::ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, MsgRouting &mr)
 {
-    TRY;
-
-    DASSERT(::IsWindow(hwnd));
-
-    AwtFrame *parent = (AwtFrame *)
-        AwtComponent::GetComponentImpl(::GetParent(hwnd));
-
-    if (!parent || parent->GetProxyFocusOwner() != hwnd ||
-        message == AwtComponent::WmAwtIsComponent ||
-        message == WM_GETOBJECT)
-    {
-        return ComCtl32Util::GetInstance().DefWindowProc(NULL, hwnd, message, wParam, lParam);
-    }
+    LRESULT retValue = 0L;
 
     AwtComponent *focusOwner = NULL;
     // IME and input language related messages need to be sent to a window
@@ -346,19 +331,23 @@
         // TODO: when a Choice's list is dropped down and we're scrolling in
         // the list WM_MOUSEWHEEL messages come to the poxy, not to the list. Why?
         case WM_MOUSEWHEEL:
-            focusOwner = AwtComponent::GetComponent(parent->GetLastProxiedFocusOwner());
-            if  (focusOwner != NULL) {
-                return focusOwner->WindowProc(message, wParam, lParam);
+            focusOwner = AwtComponent::GetComponent(GetLastProxiedFocusOwner());
+            if  (focusOwner != NULL &&
+                 focusOwner != this) // avoid recursive calls
+            {
+                 retValue = focusOwner->WindowProc(message, wParam, lParam);
+                 mr = mrConsume;
             }
             break;
         case WM_SETFOCUS:
-            if (!sm_suppressFocusAndActivation && parent->IsEmbeddedFrame()) {
-                parent->AwtSetActiveWindow();
+            if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {
+                AwtSetActiveWindow();
             }
-            return 0;
+            mr = mrConsume;
+            break;
         case WM_KILLFOCUS:
-            if (!sm_suppressFocusAndActivation && parent->IsEmbeddedFrame()) {
-                AwtWindow::SynthesizeWmActivate(FALSE, parent->GetHWnd(), NULL);
+            if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) {
+                AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL);
 
             } else if (sm_restoreFocusAndActivation) {
                 if (AwtComponent::GetFocusedWindow() != NULL) {
@@ -369,64 +358,28 @@
                     }
                 }
             }
-            return 0;
+            mr = mrConsume;
+            break;
         case 0x0127: // WM_CHANGEUISTATE
         case 0x0128: // WM_UPDATEUISTATE
-            return 0;
+            mr = mrConsume;
+            break;
     }
-    return parent->WindowProc(message, wParam, lParam);
-
-    CATCH_BAD_ALLOC_RET(0);
-}
 
-void AwtFrame::CreateProxyFocusOwner()
-{
-    if (AwtToolkit::IsMainThread()) {
-        AwtFrame::_CreateProxyFocusOwner((void *)this);
-    } else {
-        AwtToolkit::GetInstance().InvokeFunction(AwtFrame::_CreateProxyFocusOwner, (void *)this);
-    }
+    return retValue;
 }
 
-void AwtFrame::_CreateProxyFocusOwner(void *param)
-{
-    DASSERT(AwtToolkit::IsMainThread());
-
-    AwtFrame *f = (AwtFrame *)param;
-    DASSERT(f->m_proxyFocusOwner == NULL);
-
-    f->m_proxyFocusOwner = ::CreateWindow(TEXT("STATIC"),
-                                          TEXT("ProxyFocusOwner"),
-                                          WS_CHILD,
-                                          0, 0, 0, 0, f->GetHWnd(), NULL,
-                                          AwtToolkit::GetInstance().
-                                          GetModuleHandle(),
-                                          NULL);
-
-    f->m_proxyDefWindowProc = ComCtl32Util::GetInstance().SubclassHWND(f->m_proxyFocusOwner, ProxyWindowProc);
-}
-
-void AwtFrame::DestroyProxyFocusOwner()
+LRESULT AwtFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
 {
-    // proxy focus owner must be destroyed on toolkit thread only
-    if (AwtToolkit::IsMainThread()) {
-        AwtFrame::_DestroyProxyFocusOwner((void *)this);
-    } else {
-        AwtToolkit::GetInstance().InvokeFunction(AwtFrame::_DestroyProxyFocusOwner, (void *)this);
-    }
-}
+    MsgRouting mr = mrDoDefault;
+    LRESULT retValue = 0L;
+
+    retValue = ProxyWindowProc(message, wParam, lParam, mr);
 
-void AwtFrame::_DestroyProxyFocusOwner(void *param)
-{
-    DASSERT(AwtToolkit::IsMainThread());
-
-    AwtFrame *f = (AwtFrame *)param;
-    if (f->m_proxyFocusOwner != NULL) {
-        HWND toDestroy = f->m_proxyFocusOwner;
-        f->m_proxyFocusOwner = NULL;
-        ComCtl32Util::GetInstance().UnsubclassHWND(toDestroy, ProxyWindowProc, f->m_proxyDefWindowProc);
-        ::DestroyWindow(toDestroy);
+    if (mr != mrConsume) {
+        retValue = AwtWindow::WindowProc(message, wParam, lParam);
     }
+    return retValue;
 }
 
 MsgRouting AwtFrame::WmShowWindow(BOOL show, UINT status)
--- a/jdk/src/windows/native/sun/windows/awt_Frame.h	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.h	Thu Mar 10 20:49:43 2011 -0800
@@ -96,6 +96,8 @@
     AwtMenuBar* GetMenuBar();
     void SetMenuBar(AwtMenuBar*);
 
+    virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
+
     MsgRouting WmGetMinMaxInfo(LPMINMAXINFO lpmmi);
     MsgRouting WmSize(UINT type, int w, int h);
     MsgRouting WmActivate(UINT nState, BOOL fMinimized, HWND opposite);
@@ -117,10 +119,7 @@
     INLINE BOOL IsUndecorated() { return m_isUndecorated; }
 
     INLINE HWND GetProxyFocusOwner() {
-        if (m_proxyFocusOwner == NULL) {
-            CreateProxyFocusOwner();
-        }
-        return m_proxyFocusOwner;
+        return GetHWnd();
     }
 
     void SetMaximizedBounds(int x, int y, int w, int h);
@@ -159,15 +158,7 @@
     BOOL m_isUndecorated;
 
 private:
-    static LRESULT CALLBACK ProxyWindowProc(HWND hwnd, UINT message,
-                                            WPARAM wParam, LPARAM lParam);
-    void CreateProxyFocusOwner();
-    void DestroyProxyFocusOwner();
-
-    /* creates proxy focus owner, called on Toolkit thread */
-    static void _CreateProxyFocusOwner(void *param);
-    /* destroys proxy focus owner, called on Toolkit thread */
-    static void _DestroyProxyFocusOwner(void *param);
+    LRESULT ProxyWindowProc(UINT message, WPARAM wParam, LPARAM lParam, MsgRouting &mr);
 
     /* The frame's embedding parent (if any) */
     HWND m_parentWnd;
@@ -188,10 +179,6 @@
     /* The frame is an InputMethodWindow */
     BOOL m_isInputMethodWindow;
 
-    /* Receives all keyboard input when an AwtWindow which is not an AwtFrame
-       or an AwtDialog (or one of its children) has the logical input focus. */
-    HWND m_proxyFocusOwner;
-
     /* Retains the last/current sm_focusOwner proxied. Actually, it should be
      * a component of an owned window last/currently active. */
     HWND m_lastProxiedFocusOwner;
--- a/jdk/src/windows/native/sun/windows/awt_TrayIcon.cpp	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/windows/native/sun/windows/awt_TrayIcon.cpp	Thu Mar 10 20:49:43 2011 -0800
@@ -200,10 +200,9 @@
             m_nid.cbSize = (BYTE *)(&m_nid.guidItem) - (BYTE *)(&m_nid.cbSize);
             break;
         case 6: // WIN_XP
-            // Uncomment these two lines when moving to VS2008
-//            m_nid.cbSize = (BYTE *)(&m_nid.hBalloonIcon) - (BYTE *)(&m_nid.cbSize);
-//            break;
-        default: // WIN_VISTA?
+            m_nid.cbSize = (BYTE *)(&m_nid.hBalloonIcon) - (BYTE *)(&m_nid.cbSize);
+            break;
+        default: // WIN_VISTA
             m_nid.cbSize = sizeof(m_nid);
             break;
     }
--- a/jdk/src/windows/native/sun/windows/awt_Window.cpp	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/src/windows/native/sun/windows/awt_Window.cpp	Thu Mar 10 20:49:43 2011 -0800
@@ -221,6 +221,8 @@
 
     m_windowType = NORMAL;
     m_alwaysOnTop = false;
+
+    fullScreenExclusiveModeState = FALSE;
 }
 
 AwtWindow::~AwtWindow()
--- a/jdk/test/ProblemList.txt	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/ProblemList.txt	Thu Mar 10 20:49:43 2011 -0800
@@ -380,30 +380,9 @@
 
 # jdk_nio
 
-# 6944810
-java/nio/channels/FileChannel/ReleaseOnCloseDeadlock.java       windows-all
-
 # 6963118
 java/nio/channels/Selector/Wakeup.java                          windows-all
 
-# The asynchronous I/O implementation on Windows requires Windows XP or newer.
-# We can remove the following once all Windows 2000 machines have been
-# decommissioned.
-java/nio/channels/AsynchronousChannelGroup/Basic.java           windows-5.0
-java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java      windows-5.0
-java/nio/channels/AsynchronousChannelGroup/Identity.java        windows-5.0
-java/nio/channels/AsynchronousChannelGroup/Restart.java         windows-5.0
-java/nio/channels/AsynchronousChannelGroup/Unbounded.java       windows-5.0
-java/nio/channels/AsynchronousDatagramChannel/Basic.java        windows-5.0
-java/nio/channels/AsynchronousFileChannel/Lock.java             windows-5.0
-java/nio/channels/AsynchronousServerSocketChannel/Basic.java    windows-5.0
-java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java windows-5.0
-java/nio/channels/AsynchronousSocketChannel/Basic.java          windows-5.0
-java/nio/channels/AsynchronousSocketChannel/DieBeforeComplete.java windows-5.0
-java/nio/channels/AsynchronousSocketChannel/Leaky.java          windows-5.0
-java/nio/channels/AsynchronousSocketChannel/StressLoopback.java windows-5.0
-java/nio/channels/Channels/Basic2.java                          windows-5.0
-
 # 6959891
 com/sun/nio/sctp/SctpChannel/SocketOptionTests.java
 
@@ -625,9 +604,6 @@
 # Timeout on solaris-sparcv9 or exception thrown
 com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java	 	solaris-all
 
-# File 6535697.test input stream left open? windows samevm
-java/security/cert/CertificateFactory/openssl/OpenSSLCert.java	generic-all
-
 # Leaving file open: SerialVersion.current, windows samevm
 java/security/BasicPermission/SerialVersion.java		generic-all
 
@@ -717,6 +693,7 @@
 # Filed 6933803
 java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java	generic-all
 
+# Filed 7022325
 # Fails with assertion error on windows
 #   11 separate stacktraces created... file reuse problem?
 java/util/zip/ZipFile/ReadLongZipFileName.java			generic-all
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/jndi/ldap/NoWaitForReplyTest.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2011, 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 6748156
+ * @summary add an new JNDI property to control the boolean flag WaitForReply
+ */
+
+import java.net.Socket;
+import java.net.ServerSocket;
+import java.io.*;
+import javax.naming.*;
+import javax.naming.directory.*;
+import java.util.Hashtable;
+
+public class NoWaitForReplyTest {
+
+    public static void main(String[] args) throws Exception {
+
+        boolean passed = false;
+
+        // start the LDAP server
+        DummyServer ldapServer = new DummyServer();
+        ldapServer.start();
+
+        // Set up the environment for creating the initial context
+        Hashtable env = new Hashtable(11);
+        env.put(Context.PROVIDER_URL, "ldap://localhost:" +
+            ldapServer.getPortNumber());
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+            "com.sun.jndi.ldap.LdapCtxFactory");
+
+        // Wait up to 10 seconds for a response from the LDAP server
+        env.put("com.sun.jndi.ldap.read.timeout", "10000");
+
+        // Don't wait until the first search reply is received
+        env.put("com.sun.jndi.ldap.search.waitForReply", "false");
+
+        // Send the LDAP search request without first authenticating (no bind)
+        env.put("java.naming.ldap.version", "3");
+
+
+        try {
+
+            // Create initial context
+            System.out.println("Client: connecting to the server");
+            DirContext ctx = new InitialDirContext(env);
+
+            SearchControls scl = new SearchControls();
+            scl.setSearchScope(SearchControls.SUBTREE_SCOPE);
+            System.out.println("Client: performing search");
+            NamingEnumeration answer =
+            ctx.search("ou=People,o=JNDITutorial", "(objectClass=*)", scl);
+
+            // Server will never reply: either we waited in the call above until
+            // the timeout (fail) or we did not wait and reached here (pass).
+            passed = true;
+            System.out.println("Client: did not wait until first reply");
+
+            // Close the context when we're done
+            ctx.close();
+
+        } catch (NamingException e) {
+            // timeout (ignore)
+        }
+        ldapServer.interrupt();
+
+        if (!passed) {
+            throw new Exception(
+                "Test FAILED: should not have waited until first search reply");
+        }
+        System.out.println("Test PASSED");
+    }
+
+    static class DummyServer extends Thread {
+
+        private final ServerSocket serverSocket;
+
+        DummyServer() throws IOException {
+            this.serverSocket = new ServerSocket(0);
+            System.out.println("Server: listening on port " + serverSocket.getLocalPort());
+        }
+
+        public int getPortNumber() {
+            return serverSocket.getLocalPort();
+        }
+
+        public void run() {
+            try (Socket socket = serverSocket.accept()) {
+                System.out.println("Server: accepted a connection");
+                InputStream in = socket.getInputStream();
+
+                while (!isInterrupted()) {
+                   in.skip(in.available());
+                }
+
+            } catch (Exception e) {
+                // ignore
+
+            } finally {
+                System.out.println("Server: shutting down");
+                try {
+                    serverSocket.close();
+                } catch (IOException e) {
+                    // ignore
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/FontClass/SurrogateTest/SupplementaryCanDisplayUpToTest.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2011, 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 6623219
+ * @summary Test canDisplayUpTo with supplementary characters.
+ */
+
+import java.awt.*;
+import java.text.*;
+
+public class SupplementaryCanDisplayUpToTest {
+    // Lists consisting of a font name, test text, and its expected
+    // return value. Test text uses private area code point U+F0000
+    // (\udb80\udc00).
+    private static String[][] DATA = {
+        // Windows
+        { "Meiryo", "\ud87e\udd45\ud87e\udd47\udb80\udc00", "4" },
+        { "Meiryo", "\ud87e\udd45\ud87e\udd47\udb80Z", "4" },
+        { "Meiryo", "\ud87e\udd45\ud87e\udd47\udb80", "4" },
+        { "Meiryo", "\ud87e\udd45\ud87e\udd47\udc00", "4" },
+        { "Meiryo", "\ud87e\udd45\ud87e\udd47", "-1" },
+
+        // Linux
+        { "AR PL UMing TW", "\ud87e\udc25\ud87e\udc3b\udb80\udc00", "4" },
+        { "AR PL UMing TW", "\ud87e\udc25\ud87e\udc3b\udb80Z", "4" },
+        { "AR PL UMing TW", "\ud87e\udc25\ud87e\udc3b\udb80", "4" },
+        { "AR PL UMing TW", "\ud87e\udc25\ud87e\udc3b\udc00", "4" },
+        { "AR PL UMing TW", "\ud87e\udc25\ud87e\udc3b", "-1" },
+
+        // Solaris
+        { "FZMingTi", "\ud87e\udc25\ud87e\udc3b\udb80\udc00", "4" },
+        { "FZMingTi", "\ud87e\udc25\ud87e\udc3b\udb80Z", "4" },
+        { "FZMingTi", "\ud87e\udc25\ud87e\udc3b\udb80", "4" },
+        { "FZMingTi", "\ud87e\udc25\ud87e\udc3b\udc00", "4" },
+        { "FZMingTi", "\ud87e\udc25\ud87e\udc3b", "-1" },
+    };
+    private static int errorcount = 0;
+
+    public static void main(String[] args) {
+        for (String[] data : DATA) {
+            String fontname = data[0];
+            Font font = new Font(fontname, Font.PLAIN, 16);
+            if (font.getFamily().equals(Font.DIALOG)) {
+                // Skip any unavailable fonts.
+                continue;
+            }
+
+            System.out.printf("Testing with font '%s'... ", fontname);
+            int errors = 0;
+            String text = data[1];
+            int expected = Integer.parseInt(data[2]);
+
+            int result = font.canDisplayUpTo(text);
+            if (result != expected) {
+                System.err.println("canDisplayUpTo(String) returns " + result);
+                errors++;
+            }
+
+            result = font.canDisplayUpTo(text.toCharArray(), 0, text.length());
+            if (result != expected) {
+                System.err.println("canDisplayUpTo(char[], int, int) returns " + result);
+                errors++;
+            }
+
+            CharacterIterator iter = new StringCharacterIterator(text);
+            result = font.canDisplayUpTo(iter, iter.getBeginIndex(), iter.getEndIndex());
+            if (result != expected) {
+                System.err.println("canDisplayUpTo(CharacterIterator, int, int) returns " + result);
+                errors++;
+            }
+
+            if (errors == 0) {
+                System.out.println("passed");
+            } else {
+                System.out.println("failed");
+                errorcount += errors;
+            }
+        }
+        if (errorcount > 0) {
+            throw new RuntimeException("SupplementaryCanDisplayUpToTest: failed");
+        }
+    }
+}
--- a/jdk/test/java/io/File/SetLastModified.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/io/File/SetLastModified.java	Thu Mar 10 20:49:43 2011 -0800
@@ -105,9 +105,9 @@
             System.getProperty("os.name").startsWith("Windows") ? 0L : 3L*G;
         long pos = 0L;
         while (pos <= MAX_POSITION) {
-            FileChannel fc = new FileOutputStream(f).getChannel();
-            fc.position(pos).write(ByteBuffer.wrap("x".getBytes()));
-            fc.close();
+            try (FileChannel fc = new FileOutputStream(f).getChannel()) {
+                fc.position(pos).write(ByteBuffer.wrap("x".getBytes()));
+            }
             ot = f.lastModified();
             System.out.format("check with file size: %d\n", f.length());
             if (!f.setLastModified(nt))
--- a/jdk/test/java/io/FileOutputStream/AtomicAppend.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/io/FileOutputStream/AtomicAppend.java	Thu Mar 10 20:49:43 2011 -0800
@@ -47,12 +47,12 @@
             for (int i = 0; i < nThreads; i++)
                 es.execute(new Runnable() { public void run() {
                     try {
-                        FileOutputStream s = new FileOutputStream(file, true);
-                        for (int j = 0; j < 1000; j++) {
-                            s.write((int) 'x');
-                            s.flush();
+                        try (FileOutputStream s = new FileOutputStream(file, true)) {
+                            for (int j = 0; j < 1000; j++) {
+                                s.write((int) 'x');
+                                s.flush();
+                            }
                         }
-                        s.close();
                     } catch (Throwable t) { unexpected(t); }}});
             es.shutdown();
             es.awaitTermination(10L, TimeUnit.MINUTES);
--- a/jdk/test/java/io/OutputStreamWriter/Encode.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/io/OutputStreamWriter/Encode.java	Thu Mar 10 20:49:43 2011 -0800
@@ -35,8 +35,9 @@
         new Encode();
     }
 
+    final ServerSocket ss = new ServerSocket(0);
+
     Encode() throws Exception {
-        ss = new ServerSocket(0);
         (new Thread(this)).start();
         String toEncode = "\uD800\uDC00 \uD801\uDC01 ";
         String enc1 = URLEncoder.encode(toEncode, "UTF-8");
@@ -47,27 +48,31 @@
             "/missing.nothtml";
         HttpURLConnection uc =  (HttpURLConnection)new URL(url).openConnection();
         uc.connect();
-        String enc2 = URLEncoder.encode(toEncode, "UTF-8");
-        if (!enc1.equals(enc2))
-            throw new RuntimeException("test failed");
-        uc.disconnect();
+        try {
+            String enc2 = URLEncoder.encode(toEncode, "UTF-8");
+            if (!enc1.equals(enc2)) {
+                System.out.println("test failed");
+                throw new RuntimeException("test failed");
+            }
+        } finally {
+            uc.disconnect();
+        }
     }
 
-    ServerSocket ss;
-
     public void run() {
-        try {
-            Socket s = ss.accept();
-            BufferedReader in = new BufferedReader(
-                new InputStreamReader(s.getInputStream()));
+        try (ServerSocket serv = ss;
+             Socket s = serv.accept();
+             BufferedReader in =
+                 new BufferedReader(new InputStreamReader(s.getInputStream())))
+        {
             String req = in.readLine();
-            PrintStream out = new PrintStream(new BufferedOutputStream(
-                s.getOutputStream()));
-            out.print("HTTP/1.1 403 Forbidden\r\n");
-            out.print("\r\n");
-            out.flush();
-            s.close();
-            ss.close();
+            try (OutputStream os = s.getOutputStream();
+                 BufferedOutputStream bos = new BufferedOutputStream(os);
+                 PrintStream out = new PrintStream(bos))
+            {
+                out.print("HTTP/1.1 403 Forbidden\r\n");
+                out.print("\r\n");
+            }
         } catch (Exception e) {
             e.printStackTrace();
         }
--- a/jdk/test/java/io/PrintStream/EncodingConstructor.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/io/PrintStream/EncodingConstructor.java	Thu Mar 10 20:49:43 2011 -0800
@@ -34,11 +34,11 @@
 
     public static void main(String args[]) throws Exception {
         ByteArrayOutputStream bo = new ByteArrayOutputStream();
-        PrintStream ps = new PrintStream(bo, false, "UTF-8");
         String s = "xyzzy";
         int n = s.length();
-        ps.print(s);
-        ps.close();
+        try (PrintStream ps = new PrintStream(bo, false, "UTF-8")) {
+            ps.print(s);
+        }
         byte[] ba = bo.toByteArray();
         if (ba.length != n)
             throw new Exception("Length mismatch: " + n + " " + ba.length);
--- a/jdk/test/java/io/PrintStream/FailingConstructors.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/io/PrintStream/FailingConstructors.java	Thu Mar 10 20:49:43 2011 -0800
@@ -35,6 +35,8 @@
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
+import java.nio.file.Files;
+import java.nio.file.Path;
 
 public class FailingConstructors {
     static final String fileName = "FailingConstructorsTest";
@@ -45,14 +47,13 @@
         test(false, new File(fileName));
 
         /* create the file and write its contents */
-        File file = File.createTempFile(fileName, null);
-        file.deleteOnExit();
-        FileOutputStream fos = new FileOutputStream(file);
-        fos.write(FILE_CONTENTS.getBytes());
-        fos.close();
-
-        test(true, file);
-        file.delete();
+        Path path = Files.createTempFile(fileName, null);
+        try {
+            Files.write(path, FILE_CONTENTS.getBytes());
+            test(true, path.toFile());
+        } finally {
+            Files.delete(path);
+        }
     }
 
     private static void test(boolean exists, File file) throws Throwable {
--- a/jdk/test/java/io/Serializable/evolution/RenamePackage/install/SerialDriver.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/io/Serializable/evolution/RenamePackage/install/SerialDriver.java	Thu Mar 10 20:49:43 2011 -0800
@@ -27,7 +27,7 @@
  * @build install/SerialDriver.java test/SerialDriver.java extension/ExtendedObjectInputStream.java
  * @summary Enable resolveClass() to accommodate package renaming.
  * This fix enables one to implement a resolveClass method that maps a
- * Serialiazable class within a serialization stream to the same class
+ * Serializable class within a serialization stream to the same class
  * in a different package within the JVM runtime. See run shell script
  * for instructions on how to run this test.
  */
@@ -86,16 +86,15 @@
         File f = new File("stream.ser");
         if (serialize) {
             // Serialize the subclass
-            try {
-                FileOutputStream fo = new FileOutputStream(f);
-                ObjectOutputStream so = new ObjectOutputStream(fo);
+            try (FileOutputStream fo = new FileOutputStream(f);
+                 ObjectOutputStream so = new ObjectOutputStream(fo))
+            {
                 so.writeObject(obj);
                 /* Skip arrays since they do not work with rename yet.
                    The serialVersionUID changes due to the name change
                    and there is no way to set the serialVersionUID for an
                    array. */
                 so.writeObject(array);
-                so.flush();
             } catch (Exception e) {
                 System.out.println(e);
                 throw e;
@@ -103,16 +102,14 @@
         }
         if (deserialize) {
             // Deserialize the subclass
-            try {
-                FileInputStream fi = new FileInputStream(f);
-                ExtendedObjectInputStream si =
-                    new ExtendedObjectInputStream(fi);
+            try (FileInputStream fi = new FileInputStream(f);
+                 ExtendedObjectInputStream si = new ExtendedObjectInputStream(fi))
+            {
                 si.addRenamedClassName("test.SerialDriver", "install.SerialDriver");
                 si.addRenamedClassName("[Ltest.SerialDriver;",
                                        "[Linstall.SerialDriver");
                 obj = (SerialDriver) si.readObject();
                 array = (SerialDriver[]) si.readObject();
-                si.close();
             } catch (Exception e) {
                 System.out.println(e);
                 throw e;
--- a/jdk/test/java/io/Serializable/evolution/RenamePackage/test/SerialDriver.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/io/Serializable/evolution/RenamePackage/test/SerialDriver.java	Thu Mar 10 20:49:43 2011 -0800
@@ -27,7 +27,7 @@
  * @build install/SerialDriver.java test/SerialDriver.java extension/ExtendedObjectInputStream.java
  * @summary Enable resolveClass() to accommodate package renaming.
  * This fix enables one to implement a resolveClass method that maps a
- * Serialiazable class within a serialization stream to the same class
+ * Serializable class within a serialization stream to the same class
  * in a different package within the JVM runtime. See run shell script
  * for instructions on how to run this test.
  */
@@ -83,14 +83,13 @@
         File f = new File("stream.ser");
         if (serialize) {
             // Serialize the subclass
-            try {
-                FileOutputStream fo = new FileOutputStream(f);
-                ObjectOutputStream so = new ObjectOutputStream(fo);
+            try (FileOutputStream fo = new FileOutputStream(f);
+                 ObjectOutputStream so = new ObjectOutputStream(fo))
+            {
                 so.writeObject(obj);
                 /* Comment out since renaming arrays does not work
                    since it changes the serialVersionUID. */
                 so.writeObject(array);
-                so.flush();
             } catch (Exception e) {
                 System.out.println(e);
                 throw e;
@@ -98,16 +97,15 @@
         }
         if (deserialize) {
             // Deserialize the subclass
-            try {
-                FileInputStream fi = new FileInputStream(f);
-                ExtendedObjectInputStream si = new ExtendedObjectInputStream(fi);
+            try (FileInputStream fi = new FileInputStream(f);
+                 ExtendedObjectInputStream si = new ExtendedObjectInputStream(fi))
+            {
                 si.addRenamedClassName("install.SerialDriver",
                                        "test.SerialDriver");
                 si.addRenamedClassName("[Linstall.SerialDriver;",
                                        "[Ltest.SerialDriver");
                 obj = (SerialDriver) si.readObject();
                 array = (SerialDriver[]) si.readObject();
-                si.close();
             } catch (Exception e) {
                 System.out.println(e);
                 throw e;
--- a/jdk/test/java/lang/Character/CheckScript.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/lang/Character/CheckScript.java	Thu Mar 10 20:49:43 2011 -0800
@@ -12,40 +12,43 @@
 
 public class CheckScript {
 
-    public static void main(String[] args) throws Exception {
-
-        BufferedReader sbfr = null;
+    static BufferedReader open(String[] args) throws FileNotFoundException {
         if (args.length == 0) {
-            sbfr = new BufferedReader(new FileReader(new File(System.getProperty("test.src", "."), "Scripts.txt")));
+            return new BufferedReader(new FileReader(new File(System.getProperty("test.src", "."), "Scripts.txt")));
         } else if (args.length == 1) {
-            sbfr = new BufferedReader(new FileReader(args[0]));
+            return new BufferedReader(new FileReader(args[0]));
         } else {
             System.out.println("java CharacterScript Scripts.txt");
             throw new RuntimeException("Datafile name should be specified.");
         }
+    }
+
+    public static void main(String[] args) throws Exception {
+
         Matcher m = Pattern.compile("(\\p{XDigit}+)(?:\\.{2}(\\p{XDigit}+))?\\s+;\\s+(\\w+)\\s+#.*").matcher("");
         String line = null;
         HashMap<String,ArrayList<Integer>> scripts = new HashMap<>();
-        while ((line = sbfr.readLine()) != null) {
-            if (line.length() <= 1 || line.charAt(0) == '#') {
-                continue;
-            }
-            m.reset(line);
-            if (m.matches()) {
-                int start = Integer.parseInt(m.group(1), 16);
-                int end = (m.group(2)==null)?start
-                                            :Integer.parseInt(m.group(2), 16);
-                String name = m.group(3).toLowerCase(Locale.ENGLISH);
-                ArrayList<Integer> ranges = scripts.get(name);
-                if (ranges == null) {
-                    ranges = new ArrayList<Integer>();
-                    scripts.put(name, ranges);
+        try (BufferedReader sbfr = open(args)) {
+            while ((line = sbfr.readLine()) != null) {
+                if (line.length() <= 1 || line.charAt(0) == '#') {
+                    continue;
                 }
-                ranges.add(start);
-                ranges.add(end);
+                m.reset(line);
+                if (m.matches()) {
+                    int start = Integer.parseInt(m.group(1), 16);
+                    int end = (m.group(2)==null)?start
+                                                :Integer.parseInt(m.group(2), 16);
+                    String name = m.group(3).toLowerCase(Locale.ENGLISH);
+                    ArrayList<Integer> ranges = scripts.get(name);
+                    if (ranges == null) {
+                        ranges = new ArrayList<Integer>();
+                        scripts.put(name, ranges);
+                    }
+                    ranges.add(start);
+                    ranges.add(end);
+                }
             }
         }
-        sbfr.close();
         // check all defined ranges
         Integer[] ZEROSIZEARRAY = new Integer[0];
         for (String name : scripts.keySet()) {
--- a/jdk/test/java/lang/ProcessBuilder/Basic.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/lang/ProcessBuilder/Basic.java	Thu Mar 10 20:49:43 2011 -0800
@@ -26,7 +26,7 @@
  * @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689
  *      5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
  *      6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
- *      4947220
+ *      4947220 7018606
  * @summary Basic tests for Process and Environment Variable code
  * @run main/othervm/timeout=300 Basic
  * @author Martin Buchholz
@@ -47,6 +47,9 @@
 
 public class Basic {
 
+    /* used for Windows only */
+    static final String systemRoot = System.getenv("SystemRoot");
+
     private static String commandOutput(Reader r) throws Throwable {
         StringBuilder sb = new StringBuilder();
         int c;
@@ -1073,7 +1076,11 @@
         try {
             ProcessBuilder pb = new ProcessBuilder();
             pb.environment().clear();
-            equal(getenvInChild(pb), "");
+            String expected = Windows.is() ? "SystemRoot="+systemRoot+",": "";
+            if (Windows.is()) {
+                pb.environment().put("SystemRoot", systemRoot);
+            }
+            equal(getenvInChild(pb), expected);
         } catch (Throwable t) { unexpected(t); }
 
         //----------------------------------------------------------------
@@ -1561,13 +1568,21 @@
             List<String> childArgs = new ArrayList<String>(javaChildArgs);
             childArgs.add("System.getenv()");
             String[] cmdp = childArgs.toArray(new String[childArgs.size()]);
-            String[] envp = {"=ExitValue=3", "=C:=\\"};
+            String[] envp;
+            String[] envpWin = {"=ExitValue=3", "=C:=\\", "SystemRoot="+systemRoot};
+            String[] envpOth = {"=ExitValue=3", "=C:=\\"};
+            if (Windows.is()) {
+                envp = envpWin;
+            } else {
+                envp = envpOth;
+            }
             Process p = Runtime.getRuntime().exec(cmdp, envp);
-            String expected = Windows.is() ? "=C:=\\,=ExitValue=3," : "=C:=\\,";
+            String expected = Windows.is() ? "=C:=\\,SystemRoot="+systemRoot+",=ExitValue=3," : "=C:=\\,";
             equal(commandOutput(p), expected);
             if (Windows.is()) {
                 ProcessBuilder pb = new ProcessBuilder(childArgs);
                 pb.environment().clear();
+                pb.environment().put("SystemRoot", systemRoot);
                 pb.environment().put("=ExitValue", "3");
                 pb.environment().put("=C:", "\\");
                 equal(commandOutput(pb), expected);
@@ -1591,10 +1606,18 @@
             List<String> childArgs = new ArrayList<String>(javaChildArgs);
             childArgs.add("System.getenv()");
             String[] cmdp = childArgs.toArray(new String[childArgs.size()]);
-            String[] envp = {"LC_ALL=C\u0000\u0000", // Yuck!
+            String[] envpWin = {"SystemRoot="+systemRoot, "LC_ALL=C\u0000\u0000", // Yuck!
+                             "FO\u0000=B\u0000R"};
+            String[] envpOth = {"LC_ALL=C\u0000\u0000", // Yuck!
                              "FO\u0000=B\u0000R"};
+            String[] envp;
+            if (Windows.is()) {
+                envp = envpWin;
+            } else {
+                envp = envpOth;
+            }
             Process p = Runtime.getRuntime().exec(cmdp, envp);
-            check(commandOutput(p).equals("LC_ALL=C,"),
+            check(commandOutput(p).equals(Windows.is() ? "SystemRoot="+systemRoot+",LC_ALL=C," : "LC_ALL=C,"),
                   "Incorrect handling of envstrings containing NULs");
         } catch (Throwable t) { unexpected(t); }
 
@@ -2144,6 +2167,7 @@
     static void equal(Object x, Object y) {
         if (x == null ? y == null : x.equals(y)) pass();
         else fail(x + " not equal to " + y);}
+
     public static void main(String[] args) throws Throwable {
         try {realMain(args);} catch (Throwable t) {unexpected(t);}
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
--- a/jdk/test/java/lang/Runtime/shutdown/ShutdownHooks.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/lang/Runtime/shutdown/ShutdownHooks.java	Thu Mar 10 20:49:43 2011 -0800
@@ -43,9 +43,9 @@
         file = new File(dir, args[1]);
         // write to file
         System.out.println("writing to "+ file);
-        PrintWriter pw = new PrintWriter(file);
-        pw.println("Shutdown begins");
-        pw.close();
+        try (PrintWriter pw = new PrintWriter(file)) {
+            pw.println("Shutdown begins");
+        }
     }
 
     public static class Cleaner extends Thread {
@@ -56,10 +56,8 @@
             // register the DeleteOnExitHook while the application
             // shutdown hook is running
             file.deleteOnExit();
-            try {
-                PrintWriter pw = new PrintWriter(file);
+            try (PrintWriter pw = new PrintWriter(file)) {
                 pw.println("file is being deleted");
-                pw.close();
             } catch (FileNotFoundException e) {
                 throw new RuntimeException(e);
             }
--- a/jdk/test/java/lang/Thread/StartOOMTest.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/lang/Thread/StartOOMTest.java	Thu Mar 10 20:49:43 2011 -0800
@@ -22,11 +22,14 @@
  */
 
 /*
- * @test
- * @bug 6379235
- * @ignore until 6721694 is fixed
- * @run main/othervm -server -Xmx32m -Xms32m -Xss256m StartOOMTest
- * @summary ThreadGroup accounting mistake possible with failure of Thread.start()
+ * This test is relatively useful for verifying 6379235, but
+ * is too resource intensive, especially on 64 bit systems,
+ * to be run automatically, see 6721694.
+ *
+ * When run it should be typically be run with the server vm
+ * and a relatively small java heap, and a large stack size
+ * ( to provoke the OOM quicker ).
+ *    java -server -Xmx32m -Xms32m -Xss256m StartOOMTest
  */
 
 import java.util.*;
--- a/jdk/test/java/lang/instrument/BootClassPath/Setup.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/lang/instrument/BootClassPath/Setup.java	Thu Mar 10 20:49:43 2011 -0800
@@ -62,31 +62,33 @@
          * Create manifest file with Boot-Class-Path encoding the
          * sub-directory name.
          */
-        FileOutputStream out = new FileOutputStream(manifestFile);
-        out.write("Manifest-Version: 1.0\n".getBytes("UTF-8"));
+        try (FileOutputStream out = new FileOutputStream(manifestFile)) {
+            out.write("Manifest-Version: 1.0\n".getBytes("UTF-8"));
 
-        byte[] premainBytes = ("Premain-Class: " + premainClass + "\n").getBytes("UTF-8");
-        out.write(premainBytes);
+            byte[] premainBytes =
+                ("Premain-Class: " + premainClass + "\n").getBytes("UTF-8");
+            out.write(premainBytes);
 
-        out.write( "Boot-Class-Path: ".getBytes("UTF-8") );
+            out.write( "Boot-Class-Path: ".getBytes("UTF-8") );
 
-        byte[] value = bootClassPath.getBytes("UTF-8");
-        for (int i=0; i<value.length; i++) {
-            int v = (int)value[i];
-            if (v < 0) v += 256;
-            byte[] escaped =  ("%" + Integer.toHexString(v)).getBytes("UTF-8");
-            out.write(escaped);
+            byte[] value = bootClassPath.getBytes("UTF-8");
+            for (int i=0; i<value.length; i++) {
+                int v = (int)value[i];
+                if (v < 0) v += 256;
+                byte[] escaped =
+                    ("%" + Integer.toHexString(v)).getBytes("UTF-8");
+                out.write(escaped);
+            }
+            out.write( "\n\n".getBytes("UTF-8") );
         }
-        out.write( "\n\n".getBytes("UTF-8") );
-        out.close();
 
         /*
          * Write the name of the boot dir to "boot.dir"
          */
         f = new File(workDir + fileSeparator + "boot.dir");
-        out = new FileOutputStream(f);
-        out.write(bootDir.getBytes(defaultEncoding));
-        out.close();
+        try (FileOutputStream out = new FileOutputStream(f)) {
+            out.write(bootDir.getBytes(defaultEncoding));
+        }
     }
 
     /* ported from test/sun/tools/launcher/UnicodeTest.java */
--- a/jdk/test/java/lang/instrument/ilib/Inject.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/lang/instrument/ilib/Inject.java	Thu Mar 10 20:49:43 2011 -0800
@@ -118,23 +118,24 @@
         }
 
         void dump(File outDir, String filename) throws IOException {
-            FileOutputStream fileOut = new FileOutputStream(new File(outDir, filename));
-            DataOutputStream dataOut = new DataOutputStream(fileOut);
-
-            String currentClassName = null;
+            try (FileOutputStream fileOut =
+                     new FileOutputStream(new File(outDir, filename));
+                 DataOutputStream dataOut = new DataOutputStream(fileOut))
+            {
+                String currentClassName = null;
 
-            dataOut.writeInt(infoList.size());
-            for (Iterator<Info> it = infoList.iterator(); it.hasNext(); ) {
-                Info info = it.next();
-                if (!info.className.equals(currentClassName)) {
-                    dataOut.writeInt(123456); // class name marker
-                    currentClassName = info.className;
-                    dataOut.writeUTF(currentClassName);
+                dataOut.writeInt(infoList.size());
+                for (Iterator<Info> it = infoList.iterator(); it.hasNext(); ) {
+                    Info info = it.next();
+                    if (!info.className.equals(currentClassName)) {
+                        dataOut.writeInt(123456); // class name marker
+                        currentClassName = info.className;
+                        dataOut.writeUTF(currentClassName);
+                    }
+                    dataOut.writeInt(info.location);
+                    dataOut.writeUTF(info.methodName);
                 }
-                dataOut.writeInt(info.location);
-                dataOut.writeUTF(info.methodName);
             }
-            dataOut.close();
         }
 
         public byte[] bytecodes(String className, String methodName, int location) {
--- a/jdk/test/java/math/BigInteger/BigIntegerTest.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/math/BigInteger/BigIntegerTest.java	Thu Mar 10 20:49:43 2011 -0800
@@ -645,26 +645,17 @@
             BigInteger b2 = null;
 
             File f = new File("serialtest");
-            FileOutputStream fos = new FileOutputStream(f);
-            try {
-                ObjectOutputStream oos = new ObjectOutputStream(fos);
-                try {
+
+            try (FileOutputStream fos = new FileOutputStream(f)) {
+                try (ObjectOutputStream oos = new ObjectOutputStream(fos)) {
                     oos.writeObject(b1);
                     oos.flush();
-                } finally {
-                    oos.close();
                 }
 
-                FileInputStream fis = new FileInputStream(f);
-                try {
-                    ObjectInputStream ois = new ObjectInputStream(fis);
-                    try {
-                        b2 = (BigInteger)ois.readObject();
-                    } finally {
-                        ois.close();
-                    }
-                } finally {
-                    fis.close();
+                try (FileInputStream fis = new FileInputStream(f);
+                     ObjectInputStream ois = new ObjectInputStream(fis))
+                {
+                    b2 = (BigInteger)ois.readObject();
                 }
 
                 if (!b1.equals(b2) ||
@@ -673,8 +664,6 @@
                     System.err.println("Serialized failed for hex " +
                                        b1.toString(16));
                 }
-            } finally {
-                fos.close();
             }
             f.delete();
         }
@@ -683,29 +672,17 @@
             BigInteger b1 = fetchNumber(rnd.nextInt(100));
             BigInteger b2 = null;
             File f = new File("serialtest");
-            FileOutputStream fos = new FileOutputStream(f);
-            try {
-                ObjectOutputStream oos = new ObjectOutputStream(fos);
-                try {
+            try (FileOutputStream fos = new FileOutputStream(f)) {
+                try (ObjectOutputStream oos = new ObjectOutputStream(fos)) {
                     oos.writeObject(b1);
                     oos.flush();
-                } finally {
-                    oos.close();
                 }
 
-                FileInputStream fis = new FileInputStream(f);
-                try {
-                    ObjectInputStream ois = new ObjectInputStream(fis);
-                    try {
-                        b2 = (BigInteger)ois.readObject();
-                    } finally {
-                        ois.close();
-                    }
-                } finally {
-                    fis.close();
+                try (FileInputStream fis = new FileInputStream(f);
+                     ObjectInputStream ois = new ObjectInputStream(fis))
+                {
+                    b2 = (BigInteger)ois.readObject();
                 }
-            } finally {
-                fos.close();
             }
 
             if (!b1.equals(b2) ||
--- a/jdk/test/java/net/URLConnection/RedirectLimit.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/net/URLConnection/RedirectLimit.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, 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
@@ -36,105 +36,81 @@
 import java.net.*;
 
 class RedirLimitServer extends Thread {
+    static final int TIMEOUT = 10 * 1000;
+    static final int NUM_REDIRECTS = 9;
 
-    ServerSocket s;
-    Socket   s1;
-    InputStream  is;
-    OutputStream os;
-    int port;
-    int nredirects = 9;
-
-    String reply1 = "HTTP/1.1 307 Temporary Redirect\r\n" +
+    static final String reply1 = "HTTP/1.1 307 Temporary Redirect\r\n" +
         "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
         "Server: Apache/1.3.14 (Unix)\r\n" +
         "Location: http://localhost:";
-    String reply2 = ".html\r\n" +
+    static final String reply2 = ".html\r\n" +
         "Connection: close\r\n" +
         "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" +
         "<html>Hello</html>";
-
-    RedirLimitServer (ServerSocket y) {
-        s = y;
-        port = s.getLocalPort();
-    }
-
-    String reply3 = "HTTP/1.1 200 Ok\r\n" +
+    static final String reply3 = "HTTP/1.1 200 Ok\r\n" +
         "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
         "Server: Apache/1.3.14 (Unix)\r\n" +
         "Connection: close\r\n" +
         "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" +
         "World";
 
-    public void run () {
+    final ServerSocket ss;
+    final int port;
+
+    RedirLimitServer(ServerSocket ss) {
+        this.ss = ss;
+        port = ss.getLocalPort();
+    }
+
+    public void run() {
         try {
-            s.setSoTimeout (2000);
-            for (int i=0; i<nredirects; i++) {
-                s1 = s.accept ();
-                s1.setSoTimeout (2000);
-                is = s1.getInputStream ();
-                os = s1.getOutputStream ();
-                is.read ();
-                String reply = reply1 + port + "/redirect" + i + reply2;
-                os.write (reply.getBytes());
-                os.close();
+            ss.setSoTimeout(TIMEOUT);
+            for (int i=0; i<NUM_REDIRECTS; i++) {
+                try (Socket s = ss.accept()) {
+                    s.setSoTimeout(TIMEOUT);
+                    InputStream is = s.getInputStream();
+                    OutputStream os = s.getOutputStream();
+                    is.read();
+                    String reply = reply1 + port + "/redirect" + i + reply2;
+                    os.write(reply.getBytes());
+                }
             }
-            s1 = s.accept ();
-            is = s1.getInputStream ();
-            os = s1.getOutputStream ();
-            is.read ();
-            os.write (reply3.getBytes());
-            os.close();
-        }
-        catch (Exception e) {
-            /* Just need thread to terminate */
+            try (Socket s = ss.accept()) {
+                InputStream is = s.getInputStream();
+                OutputStream os = s.getOutputStream();
+                is.read();
+                os.write(reply3.getBytes());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         } finally {
-            try { s.close(); } catch (IOException unused) {}
+            try { ss.close(); } catch (IOException unused) {}
         }
     }
 };
 
-
 public class RedirectLimit {
-
-    public static final int DELAY = 10;
-
     public static void main(String[] args) throws Exception {
-        int nLoops = 1;
-        int nSize = 10;
-        int port, n =0;
-        byte b[] = new byte[nSize];
-        RedirLimitServer server;
-        ServerSocket sock;
+        ServerSocket ss = new ServerSocket (0);
+        int port = ss.getLocalPort();
+        RedirLimitServer server = new RedirLimitServer(ss);
+        server.start();
 
+        InputStream in = null;
         try {
-            sock = new ServerSocket (0);
-            port = sock.getLocalPort ();
-        }
-        catch (Exception e) {
-            System.out.println ("Exception: " + e);
-            return;
-        }
-
-        server = new RedirLimitServer(sock);
-        server.start ();
-
-        try  {
-
-            String s = "http://localhost:" + port;
-            URL url = new URL(s);
+            URL url = new URL("http://localhost:" + port);
             URLConnection conURL =  url.openConnection();
 
             conURL.setDoInput(true);
             conURL.setAllowUserInteraction(false);
             conURL.setUseCaches(false);
 
-            InputStream in = conURL.getInputStream();
+            in = conURL.getInputStream();
             if ((in.read() != (int)'W') || (in.read()!=(int)'o')) {
-                throw new RuntimeException ("Unexpected string read");
+                throw new RuntimeException("Unexpected string read");
             }
-        }
-        catch(IOException e) {
-            throw new RuntimeException ("Exception caught " + e);
+        } finally {
+            if ( in != null ) { in.close(); }
         }
     }
 }
--- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java	Thu Mar 10 20:49:43 2011 -0800
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4607272 6842687 6878369
+ * @bug 4607272 6842687 6878369 6944810 7023403
  * @summary Unit test for AsynchronousSocketChannel
  * @run main/timeout=600 Basic
  */
--- a/jdk/test/java/nio/file/DirectoryStream/Basic.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/nio/file/DirectoryStream/Basic.java	Thu Mar 10 20:49:43 2011 -0800
@@ -69,7 +69,7 @@
             throw new RuntimeException("entry not found");
 
         // check filtering: f* should match foo
-        DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<>() {
+        DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
             private PathMatcher matcher =
                 dir.getFileSystem().getPathMatcher("glob:f*");
             public boolean accept(Path file) {
--- a/jdk/test/java/nio/file/FileStore/Basic.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/nio/file/FileStore/Basic.java	Thu Mar 10 20:49:43 2011 -0800
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4313887 6873621 6979526 7006126
+ * @bug 4313887 6873621 6979526 7006126 7020517
  * @summary Unit test for java.nio.file.FileStore
  * @library ..
  */
--- a/jdk/test/java/nio/file/Files/TemporaryFiles.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/nio/file/Files/TemporaryFiles.java	Thu Mar 10 20:49:43 2011 -0800
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4313887 6838333 7006126
+ * @bug 4313887 6838333 7006126 7023034
  * @summary Unit test for Files.createTempXXX
  * @library ..
  */
@@ -167,5 +167,31 @@
         testInvalidFileTemp("../blah", null);
         testInvalidFileTemp("dir/blah", null);
         testInvalidFileTemp("blah", ".dat/foo");
+
+        // nulls
+        try {
+            Files.createTempFile("blah", ".tmp", (FileAttribute<?>[])null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException ignore) { }
+        try {
+            Files.createTempFile("blah", ".tmp", new FileAttribute<?>[] { null });
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException ignore) { }
+        try {
+            Files.createTempDirectory("blah", (FileAttribute<?>[])null);
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException ignore) { }
+        try {
+            Files.createTempDirectory("blah", new FileAttribute<?>[] { null });
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException ignore) { }
+        try {
+            Files.createTempFile((Path)null, "blah", ".tmp");
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException ignore) { }
+        try {
+            Files.createTempDirectory((Path)null, "blah");
+            throw new RuntimeException("NullPointerException expected");
+        } catch (NullPointerException ignore) { }
     }
 }
--- a/jdk/test/java/security/cert/CertificateFactory/openssl/OpenSSLCert.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/security/cert/CertificateFactory/openssl/OpenSSLCert.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, 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
@@ -28,6 +28,8 @@
  */
 
 import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.Arrays;
 import java.security.cert.CertificateFactory;
 
@@ -46,24 +48,20 @@
     }
 
     static void test(String... files) throws Exception {
-        FileOutputStream fout = new FileOutputStream(OUTFILE);
-        for (String file: files) {
-            FileInputStream fin = new FileInputStream(
-                new File(System.getProperty("test.src", "."), file));
-            byte[] buffer = new byte[4096];
-            while (true) {
-                int len = fin.read(buffer);
-                if (len < 0) break;
-                fout.write(buffer, 0, len);
+        try (FileOutputStream fout = new FileOutputStream(OUTFILE)) {
+            String here = System.getProperty("test.src", "");
+            for (String file: files) {
+                Files.copy(Paths.get(here, file), fout);
             }
-            fin.close();
         }
-        fout.close();
-        System.out.println("Testing " + Arrays.toString(files) + "...");
-        if (CertificateFactory.getInstance("X509")
-                .generateCertificates(new FileInputStream(OUTFILE))
-                .size() != files.length) {
-            throw new Exception("Not same number");
+        try (FileInputStream fin = new FileInputStream(OUTFILE)) {
+            System.out.println("Testing " + Arrays.toString(files) + "...");
+            if (CertificateFactory.getInstance("X509")
+                    .generateCertificates(fin)
+                    .size() != files.length) {
+                throw new Exception("Not same number");
+            }
         }
+        Files.delete(Paths.get(OUTFILE));
     }
 }
--- a/jdk/test/java/util/Collection/MOAT.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/Collection/MOAT.java	Thu Mar 10 20:49:43 2011 -0800
@@ -28,6 +28,8 @@
  *          6431845 4802633 6570566 6570575 6570631 6570924 6691185 6691215
  * @summary Run many tests on many Collection and Map implementations
  * @author  Martin Buchholz
+ * @run main MOAT
+ * @run main/othervm -XX:+AggressiveOpts MOAT
  */
 
 /* Mother Of All (Collection) Tests
--- a/jdk/test/java/util/Currency/ValidateISO4217.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/Currency/ValidateISO4217.java	Thu Mar 10 20:49:43 2011 -0800
@@ -111,57 +111,58 @@
 
     static void test1() throws Exception {
 
-        FileReader fr = new FileReader(new File(System.getProperty("test.src", "."), datafile));
-        BufferedReader in = new BufferedReader(fr);
-        String line;
-        SimpleDateFormat format = null;
+        try (FileReader fr = new FileReader(new File(System.getProperty("test.src", "."), datafile));
+             BufferedReader in = new BufferedReader(fr))
+        {
+            String line;
+            SimpleDateFormat format = null;
 
-        while ((line = in.readLine()) != null) {
-            if (line.length() == 0 || line.charAt(0) == '#') {
-                continue;
-            }
+            while ((line = in.readLine()) != null) {
+                if (line.length() == 0 || line.charAt(0) == '#') {
+                    continue;
+                }
 
-            StringTokenizer tokens = new StringTokenizer(line, "\t");
-            String country = tokens.nextToken();
-            if (country.length() != 2) {
-                continue;
-            }
+                StringTokenizer tokens = new StringTokenizer(line, "\t");
+                String country = tokens.nextToken();
+                if (country.length() != 2) {
+                    continue;
+                }
 
-            String currency;
-            String numeric;
-            String minorUnit;
-            int tokensCount = tokens.countTokens();
-            if (tokensCount < 3) {
-                currency = "";
-                numeric = "0";
-                minorUnit = "0";
-            } else {
-                currency = tokens.nextToken();
-                numeric = tokens.nextToken();
-                minorUnit = tokens.nextToken();
-                testCurrencies.add(Currency.getInstance(currency));
+                String currency;
+                String numeric;
+                String minorUnit;
+                int tokensCount = tokens.countTokens();
+                if (tokensCount < 3) {
+                    currency = "";
+                    numeric = "0";
+                    minorUnit = "0";
+                } else {
+                    currency = tokens.nextToken();
+                    numeric = tokens.nextToken();
+                    minorUnit = tokens.nextToken();
+                    testCurrencies.add(Currency.getInstance(currency));
 
-                // check for the cutover
-                if (tokensCount > 3) {
-                    if (format == null) {
-                        format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US);
-                        format.setTimeZone(TimeZone.getTimeZone("GMT"));
-                        format.setLenient(false);
-                    }
-                    if (format.parse(tokens.nextToken()).getTime() <
-                        System.currentTimeMillis()) {
-                        currency = tokens.nextToken();
-                        numeric = tokens.nextToken();
-                        minorUnit = tokens.nextToken();
-                        testCurrencies.add(Currency.getInstance(currency));
+                    // check for the cutover
+                    if (tokensCount > 3) {
+                        if (format == null) {
+                            format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US);
+                            format.setTimeZone(TimeZone.getTimeZone("GMT"));
+                            format.setLenient(false);
+                        }
+                        if (format.parse(tokens.nextToken()).getTime() <
+                            System.currentTimeMillis()) {
+                            currency = tokens.nextToken();
+                            numeric = tokens.nextToken();
+                            minorUnit = tokens.nextToken();
+                            testCurrencies.add(Currency.getInstance(currency));
+                        }
                     }
                 }
+                int index = toIndex(country);
+                testCountryCurrency(country, currency, Integer.parseInt(numeric),
+                    Integer.parseInt(minorUnit), index);
             }
-            int index = toIndex(country);
-            testCountryCurrency(country, currency, Integer.parseInt(numeric),
-                Integer.parseInt(minorUnit), index);
         }
-        in.close();
 
         for (int i = 0; i < additionalCodes.length; i++) {
             int index = toIndex(additionalCodes[i][0]);
--- a/jdk/test/java/util/Formatter/FailingConstructors.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/Formatter/FailingConstructors.java	Thu Mar 10 20:49:43 2011 -0800
@@ -34,6 +34,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
+import java.nio.file.Files;
 import java.util.Formatter;
 
 public class FailingConstructors {
@@ -47,9 +48,7 @@
         /* create the file and write its contents */
         File file = File.createTempFile(fileName, null);
         file.deleteOnExit();
-        FileOutputStream fos = new FileOutputStream(file);
-        fos.write(FILE_CONTENTS.getBytes());
-        fos.close();
+        Files.write(file.toPath(), FILE_CONTENTS.getBytes());
 
         test(true, file);
         file.delete();
--- a/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1204,14 +1204,12 @@
                 locale = new Locale(lang, country, variant);
             }
 
-            // desrialize
-            try {
-                FileInputStream fis = new FileInputStream(testfile);
-                ObjectInputStream ois = new ObjectInputStream(fis);
-
+            // deserialize
+            try (FileInputStream fis = new FileInputStream(testfile);
+                 ObjectInputStream ois = new ObjectInputStream(fis))
+            {
                 Object o = ois.readObject();
                 assertEquals("Deserialize Java 6 Locale " + locale, o, locale);
-                ois.close();
             } catch (Exception e) {
                 errln("Exception while reading " + testfile.getAbsolutePath() + " - " + e.getMessage());
             }
--- a/jdk/test/java/util/PriorityQueue/NoNulls.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/PriorityQueue/NoNulls.java	Thu Mar 10 20:49:43 2011 -0800
@@ -53,7 +53,7 @@
 public class NoNulls {
     void test(String[] args) throws Throwable {
         final Comparator<String> nullTolerantComparator
-            = new Comparator<>() {
+            = new Comparator<String>() {
             public int compare(String x, String y) {
                 return (x == null ? -1 :
                         y == null ? 1 :
@@ -65,7 +65,7 @@
         nullSortedSet.add(null);
 
         final PriorityQueue<String> nullPriorityQueue
-            = new PriorityQueue<>() {
+            = new PriorityQueue<String>() {
             public Object[] toArray() { return new Object[] { null };}};
 
         final Collection<String> nullCollection = new ArrayList<>();
--- a/jdk/test/java/util/ResourceBundle/Bug6204853.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/ResourceBundle/Bug6204853.java	Thu Mar 10 20:49:43 2011 -0800
@@ -39,24 +39,19 @@
 public final class Bug6204853 {
 
     public Bug6204853() {
-        try {
-            String srcDir = System.getProperty("test.src", ".");
-            FileInputStream  fis8859_1 =
-                new FileInputStream(new File(srcDir, "Bug6204853.properties"));
-            FileInputStream fisUtf8 =
-                new FileInputStream(new File(srcDir, "Bug6204853_Utf8.properties"));
-            InputStreamReader isrUtf8 = new InputStreamReader(fisUtf8, "UTF-8");
-
+        String srcDir = System.getProperty("test.src", ".");
+        try (FileInputStream fis8859_1 =
+                 new FileInputStream(new File(srcDir, "Bug6204853.properties"));
+             FileInputStream fisUtf8 =
+                 new FileInputStream(new File(srcDir, "Bug6204853_Utf8.properties"));
+             InputStreamReader isrUtf8 = new InputStreamReader(fisUtf8, "UTF-8"))
+        {
             PropertyResourceBundle bundleUtf8 = new PropertyResourceBundle(isrUtf8);
             PropertyResourceBundle bundle = new PropertyResourceBundle(fis8859_1);
 
             String[] arrayUtf8 = createKeyValueArray(bundleUtf8);
             String[] array = createKeyValueArray(bundle);
 
-            isrUtf8.close();
-            fisUtf8.close();
-            fis8859_1.close();
-
             if (!Arrays.equals(arrayUtf8, array)) {
                 throw new RuntimeException("PropertyResourceBundle constructed from a UTF-8 encoded property file is not equal to the one constructed from ISO-8859-1 encoded property file.");
             }
--- a/jdk/test/java/util/Scanner/FailingConstructors.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/Scanner/FailingConstructors.java	Thu Mar 10 20:49:43 2011 -0800
@@ -33,6 +33,7 @@
 import java.io.FileOutputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.nio.file.Files;
 import java.util.Scanner;
 
 public class FailingConstructors {
@@ -46,9 +47,7 @@
         /* create the file and write its contents */
         File file = File.createTempFile(fileName, null);
         file.deleteOnExit();
-        FileOutputStream fos = new FileOutputStream(file);
-        fos.write(FILE_CONTENTS.getBytes());
-        fos.close();
+        Files.write(file.toPath(), FILE_CONTENTS.getBytes());
 
         test(true, file);
         file.delete();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/TimeZone/Bug6772689.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2011, 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 6772689
+ * @summary Test for standard-to-daylight transitions at midnight:
+ * date stays on the given day.
+ */
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+import static java.util.GregorianCalendar.*;
+
+public class Bug6772689 {
+    private static final int BEGIN_YEAR = 2035;
+    private static final int END_YEAR = BEGIN_YEAR + 28;
+
+    public static void main(String[] args) {
+        TimeZone defaultTimeZone = TimeZone.getDefault();
+        int errors = 0;
+
+        Calendar cal = new GregorianCalendar(BEGIN_YEAR, MARCH, 1);
+        String[] tzids = TimeZone.getAvailableIDs();
+        try {
+            for (String id : tzids) {
+                TimeZone tz = TimeZone.getTimeZone(id);
+                if (!tz.useDaylightTime()) {
+                    continue;
+                }
+                TimeZone.setDefault(tz);
+
+              dateloop:
+                // Use future dates because sun.util.calendar.ZoneInfo
+                // delegates offset transition calculations to a SimpleTimeZone
+                // (after 2038 as of JDK7).
+                for (int year = BEGIN_YEAR; year < END_YEAR; year++) {
+                    for (int month = MARCH; month <= NOVEMBER; month++) {
+                        cal.set(year, month, 1, 15, 0, 0);
+                        int maxDom = cal.getActualMaximum(DAY_OF_MONTH);
+                        for (int dom = 1; dom <= maxDom; dom++) {
+                            Date date = new Date(year - 1900, month, dom);
+                            if (date.getYear()+1900 != year
+                                || date.getMonth() != month
+                                || date.getDate() != dom) {
+                                System.err.printf("%s: got %04d-%02d-%02d, expected %04d-%02d-%02d%n",
+                                                  id,
+                                                  date.getYear() + 1900,
+                                                  date.getMonth() + 1,
+                                                  date.getDate(),
+                                                  year,
+                                                  month + 1,
+                                                  dom);
+                                errors++;
+                                break dateloop;
+                            }
+                        }
+                    }
+                }
+            }
+        } finally {
+            // Restore the default TimeZone.
+            TimeZone.setDefault(defaultTimeZone);
+        }
+        if (errors > 0) {
+            throw new RuntimeException("Transition test failed");
+        }
+    }
+}
--- a/jdk/test/java/util/jar/JarEntry/GetMethodsReturnClones.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/jar/JarEntry/GetMethodsReturnClones.java	Thu Mar 10 20:49:43 2011 -0800
@@ -40,22 +40,21 @@
         System.getProperty("file.separator");
 
     public static void main(String[] args) throws Exception {
-        JarFile jf = new JarFile(BASE + "test.jar", true);
-
-        byte[] buffer = new byte[8192];
-        Enumeration<JarEntry> e = jf.entries();
-        List<JarEntry> entries = new ArrayList<JarEntry>();
-        while (e.hasMoreElements()) {
-            JarEntry je = e.nextElement();
-            entries.add(je);
-            InputStream is = jf.getInputStream(je);
-            while (is.read(buffer, 0, buffer.length) != -1) {
-                // we just read. this will throw a SecurityException
-                // if  a signature/digest check fails.
+        List<JarEntry> entries = new ArrayList<>();
+        try (JarFile jf = new JarFile(BASE + "test.jar", true)) {
+            byte[] buffer = new byte[8192];
+            Enumeration<JarEntry> e = jf.entries();
+            while (e.hasMoreElements()) {
+                JarEntry je = e.nextElement();
+                entries.add(je);
+                try (InputStream is = jf.getInputStream(je)) {
+                    while (is.read(buffer, 0, buffer.length) != -1) {
+                        // we just read. this will throw a SecurityException
+                        // if  a signature/digest check fails.
+                    }
+                }
             }
-            is.close();
         }
-        jf.close();
 
         for (JarEntry je : entries) {
             Certificate[] certs = je.getCertificates();
--- a/jdk/test/java/util/jar/JarFile/ScanSignedJar.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/jar/JarFile/ScanSignedJar.java	Thu Mar 10 20:49:43 2011 -0800
@@ -37,25 +37,25 @@
 public class ScanSignedJar {
 
     public static void main(String[] args) throws Exception {
-        JarFile file = new JarFile(new File(System.getProperty("test.src","."),
-            "bogus-signerinfo-attr.jar"));
-        byte[] buffer = new byte[8192];
         boolean isSigned = false;
+        try (JarFile file = new JarFile(new File(System.getProperty("test.src","."),
+                 "bogus-signerinfo-attr.jar"))) {
+            byte[] buffer = new byte[8192];
 
-        for (Enumeration entries = file.entries(); entries.hasMoreElements();) {
-            JarEntry entry = (JarEntry) entries.nextElement();
-            InputStream jis = file.getInputStream(entry);
-            while (jis.read(buffer, 0, buffer.length) != -1) {
-                // read the jar entry
+            for (Enumeration entries = file.entries(); entries.hasMoreElements();) {
+                JarEntry entry = (JarEntry) entries.nextElement();
+                try (InputStream jis = file.getInputStream(entry)) {
+                    while (jis.read(buffer, 0, buffer.length) != -1) {
+                        // read the jar entry
+                    }
+                }
+                if (entry.getCertificates() != null) {
+                    isSigned = true;
+                }
+                System.out.println((isSigned ? "[signed] " : "\t ") +
+                    entry.getName());
             }
-            jis.close();
-            if (entry.getCertificates() != null) {
-                isSigned = true;
-            }
-            System.out.println((isSigned ? "[signed] " : "\t ") +
-                entry.getName());
         }
-        file.close();
 
         if (isSigned) {
             System.out.println("\nJAR file has signed entries");
--- a/jdk/test/java/util/zip/Available.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/Available.java	Thu Mar 10 20:49:43 2011 -0800
@@ -44,14 +44,17 @@
         File f = new File(System.getProperty("test.src", "."), "input.jar");
 
         // test ZipInputStream
-        ZipInputStream z = new ZipInputStream(new FileInputStream(f));
-        z.getNextEntry();
-        tryAvail(z);
+        try (FileInputStream fis = new FileInputStream(f);
+             ZipInputStream z = new ZipInputStream(fis))
+        {
+            z.getNextEntry();
+            tryAvail(z);
+        }
 
         // test InflaterInputStream
-        ZipFile zfile = new ZipFile(f);
-        tryAvail(zfile.getInputStream(zfile.getEntry("Available.java")));
-        z.close();
+        try (ZipFile zfile = new ZipFile(f)) {
+            tryAvail(zfile.getInputStream(zfile.getEntry("Available.java")));
+        }
     }
 
     static void tryAvail(InputStream in) throws Exception {
@@ -67,20 +70,21 @@
     // To reproduce 4401122
     private static void test2() throws Exception {
         File f = new File(System.getProperty("test.src", "."), "input.jar");
-        ZipFile zf = new ZipFile(f);
-        InputStream in = zf.getInputStream(zf.getEntry("Available.java"));
+        try (ZipFile zf = new ZipFile(f)) {
+            InputStream in = zf.getInputStream(zf.getEntry("Available.java"));
 
-        int initialAvailable = in.available();
-        in.read();
-        if (in.available() != initialAvailable - 1)
-            throw new RuntimeException("Available not decremented.");
-        for(int j=0; j<initialAvailable-1; j++)
+            int initialAvailable = in.available();
             in.read();
-        if (in.available() != 0)
-            throw new RuntimeException();
-        in.close();
-        if (in.available() != 0)
-            throw new RuntimeException();
+            if (in.available() != initialAvailable - 1)
+                throw new RuntimeException("Available not decremented.");
+            for(int j=0; j<initialAvailable-1; j++)
+                in.read();
+            if (in.available() != 0)
+                throw new RuntimeException();
+            in.close();
+            if (in.available() != 0)
+                throw new RuntimeException();
+        }
     }
 
 }
--- a/jdk/test/java/util/zip/FileBuilder.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/FileBuilder.java	Thu Mar 10 20:49:43 2011 -0800
@@ -53,25 +53,24 @@
                filetype.equals("SlightlyCompressible")))
             usageError();
 
-        RandomAccessFile raf = new RandomAccessFile(filename, "rw");
+        try (RandomAccessFile raf = new RandomAccessFile(filename, "rw")) {
+            if (filetype.equals("SlightlyCompressible")) {
+                byte[] randomBytes = new byte[16384];
+                byte[] nullBytes   = new byte[randomBytes.length/10];
+                Random rand = new Random();
+                for (int i = 0; raf.length() < filesize; ++i) {
+                    rand.nextBytes(randomBytes);
+                    raf.write(nullBytes);
+                    raf.write(randomBytes);
+                }
+            }
 
-        if (filetype.equals("SlightlyCompressible")) {
-            byte[] randomBytes = new byte[16384];
-            byte[] nullBytes   = new byte[randomBytes.length/10];
-            Random rand = new Random();
-            for (int i = 0; raf.length() < filesize; ++i) {
-                rand.nextBytes(randomBytes);
-                raf.write(nullBytes);
-                raf.write(randomBytes);
-            }
+            // Make sure file is exactly the requested size, and that
+            // a unique identifying trailer is written.
+            byte[] filenameBytes = filename.getBytes("UTF8");
+            raf.seek(filesize-filenameBytes.length);
+            raf.write(filenameBytes);
+            raf.setLength(filesize);
         }
-
-        // Make sure file is exactly the requested size, and that
-        // a unique identifying trailer is written.
-        byte[] filenameBytes = filename.getBytes("UTF8");
-        raf.seek(filesize-filenameBytes.length);
-        raf.write(filenameBytes);
-        raf.setLength(filesize);
-        raf.close();
     }
 }
--- a/jdk/test/java/util/zip/GZIP/Accordion.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/GZIP/Accordion.java	Thu Mar 10 20:49:43 2011 -0800
@@ -64,16 +64,13 @@
         System.out.println("count="+count);
 
         Thread compressor = new Thread() { public void run() {
-            try {
-                final GZIPOutputStream s = new GZIPOutputStream(out);
+            try (GZIPOutputStream s = new GZIPOutputStream(out)) {
                 for (long i = 0; i < count; i++)
                     s.write(data, 0, data.length);
-                s.close();
             } catch (Throwable t) { trouble = t; }}};
 
         Thread uncompressor = new Thread() { public void run() {
-            try {
-                final GZIPInputStream s = new GZIPInputStream(in);
+            try (GZIPInputStream s = new GZIPInputStream(in)) {
                 final byte[] maybeBytes = new byte[data.length];
                 for (long i = 0; i < count; i++) {
                     readFully(s, maybeBytes);
@@ -82,7 +79,6 @@
                 }
                 if (s.read(maybeBytes, 0, 1) > 0)
                     throw new Exception("Unexpected NON-EOF");
-                s.close();
             } catch (Throwable t) { trouble = t; }}};
 
         compressor.start(); uncompressor.start();
--- a/jdk/test/java/util/zip/GZIP/GZIPInputStreamRead.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/GZIP/GZIPInputStreamRead.java	Thu Mar 10 20:49:43 2011 -0800
@@ -44,9 +44,9 @@
                 rnd.nextBytes(src);
                 srcBAOS.write(src);
 
-                GZIPOutputStream gzos = new GZIPOutputStream(dstBAOS);
-                gzos.write(src);
-                gzos.close();
+                try (GZIPOutputStream gzos = new GZIPOutputStream(dstBAOS)) {
+                    gzos.write(src);
+                }
             }
             byte[] srcBytes = srcBAOS.toByteArray();
             byte[] dstBytes = dstBAOS.toByteArray();
@@ -75,26 +75,26 @@
                              int readBufSize, int gzisBufSize)
         throws Throwable
     {
-        GZIPInputStream gzis = new GZIPInputStream(
-                                   new ByteArrayInputStream(dst),
-                                   gzisBufSize);
-        byte[] result = new byte[src.length + 10];
-        byte[] buf = new byte[readBufSize];
-        int n = 0;
-        int off = 0;
+        try (ByteArrayInputStream bais = new ByteArrayInputStream(dst);
+             GZIPInputStream gzis = new GZIPInputStream(bais, gzisBufSize))
+        {
+            byte[] result = new byte[src.length + 10];
+            byte[] buf = new byte[readBufSize];
+            int n = 0;
+            int off = 0;
 
-        while ((n = gzis.read(buf, 0, buf.length)) != -1) {
-            System.arraycopy(buf, 0, result, off, n);
-            off += n;
-            // no range check, if overflow, let it fail
+            while ((n = gzis.read(buf, 0, buf.length)) != -1) {
+                System.arraycopy(buf, 0, result, off, n);
+                off += n;
+                // no range check, if overflow, let it fail
+            }
+            if (off != src.length || gzis.available() != 0 ||
+                !Arrays.equals(src, Arrays.copyOf(result, off))) {
+                throw new RuntimeException(
+                    "GZIPInputStream reading failed! " +
+                    ", src.len=" + src.length +
+                    ", read=" + off);
+            }
         }
-        if (off != src.length || gzis.available() != 0 ||
-            !Arrays.equals(src, Arrays.copyOf(result, off))) {
-            throw new RuntimeException(
-                "GZIPInputStream reading failed! " +
-                ", src.len=" + src.length +
-                ", read=" + off);
-        }
-        gzis.close();
     }
 }
--- a/jdk/test/java/util/zip/InflateIn_DeflateOut.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/InflateIn_DeflateOut.java	Thu Mar 10 20:49:43 2011 -0800
@@ -134,14 +134,14 @@
 
         PairedOutputStream pos = new PairedOutputStream(pis);
         pis.setPairedOutputStream(pos);
-        DeflaterOutputStream dos = new DeflaterOutputStream(pos, true);
 
         byte[] data = new byte[random.nextInt(1024 * 1024)];
         byte[] buf = new byte[data.length];
         random.nextBytes(data);
 
-        dos.write(data);
-        dos.close();
+        try (DeflaterOutputStream dos = new DeflaterOutputStream(pos, true)) {
+            dos.write(data);
+        }
         check(readFully(iis, buf, buf.length));
         check(Arrays.equals(data, buf));
     }
--- a/jdk/test/java/util/zip/InfoZip.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/InfoZip.java	Thu Mar 10 20:49:43 2011 -0800
@@ -85,41 +85,37 @@
         //----------------------------------------------------------------
         File f = new File("InfoZip.zip");
 
-        OutputStream os = new FileOutputStream(f);
-        os.write(new byte[]
-            {'P', 'K', 3, 4, 10, 0, 0, 0, 0, 0, -68, 8, 'k',
-             '2', 'V', -7, 'm', 9, 20, 0, 0, 0, 20, 0, 0, 0,
-             8, 0, 21, 0, 's', 'o', 'm', 'e', 'F', 'i', 'l', 'e', 'U',
-             'T', 9, 0, 3, 't', '_', '1', 'B', 't', '_', '1', 'B', 'U',
-             'x', 4, 0, -14, 'v', 26, 4, 'M', 'e', 's', 's', 'a', 'g',
-             'e', ' ', 'i', 'n', ' ', 'a', ' ', 'B', 'o', 't', 't', 'l', 'e',
-             10, 'P', 'K', 1, 2, 23, 3, 10, 0, 0, 0, 0, 0,
-             -68, 8, 'k', '2', 'V', -7, 'm', 9, 20, 0, 0, 0, 20,
-             0, 0, 0, 8, 0, 13, 0, 0, 0, 0, 0, 1, 0,
-             0, 0, -92, -127, 0, 0, 0, 0, 's', 'o', 'm', 'e', 'F',
-             'i', 'l', 'e', 'U', 'T', 5, 0, 3, 't', '_', '1', 'B', 'U',
-             'x', 0, 0, 'P', 'K', 5, 6, 0, 0, 0, 0, 1, 0,
-             1, 0, 'C', 0, 0, 0, 'O', 0, 0, 0, 0, 0, });
-        os.close();
+        try (OutputStream os = new FileOutputStream(f)) {
+            os.write(new byte[]
+                {'P', 'K', 3, 4, 10, 0, 0, 0, 0, 0, -68, 8, 'k',
+                 '2', 'V', -7, 'm', 9, 20, 0, 0, 0, 20, 0, 0, 0,
+                 8, 0, 21, 0, 's', 'o', 'm', 'e', 'F', 'i', 'l', 'e', 'U',
+                 'T', 9, 0, 3, 't', '_', '1', 'B', 't', '_', '1', 'B', 'U',
+                 'x', 4, 0, -14, 'v', 26, 4, 'M', 'e', 's', 's', 'a', 'g',
+                 'e', ' ', 'i', 'n', ' ', 'a', ' ', 'B', 'o', 't', 't', 'l', 'e',
+                 10, 'P', 'K', 1, 2, 23, 3, 10, 0, 0, 0, 0, 0,
+                 -68, 8, 'k', '2', 'V', -7, 'm', 9, 20, 0, 0, 0, 20,
+                 0, 0, 0, 8, 0, 13, 0, 0, 0, 0, 0, 1, 0,
+                 0, 0, -92, -127, 0, 0, 0, 0, 's', 'o', 'm', 'e', 'F',
+                 'i', 'l', 'e', 'U', 'T', 5, 0, 3, 't', '_', '1', 'B', 'U',
+                 'x', 0, 0, 'P', 'K', 5, 6, 0, 0, 0, 0, 1, 0,
+                 1, 0, 'C', 0, 0, 0, 'O', 0, 0, 0, 0, 0, });
+        }
 
-        ZipFile zf = new ZipFile(f);
         ZipEntry ze = null;
-        try {
+        try (ZipFile zf = new ZipFile(f)) {
             Enumeration<? extends ZipEntry> entries = zf.entries();
             ze = entries.nextElement();
             check(! entries.hasMoreElements());
             checkZipEntry(ze, contents(zf, ze));
-        } finally {
-            zf.close();
         }
 
-        ZipInputStream is = new ZipInputStream(new FileInputStream(f));
-        try {
+        try (FileInputStream fis = new FileInputStream(f);
+             ZipInputStream is = new ZipInputStream(fis))
+        {
             ze = is.getNextEntry();
             checkZipEntry(ze, contents(is));
             check(is.getNextEntry() == null);
-        } finally {
-            is.close();
         }
         f.delete();
         System.out.printf("passed = %d, failed = %d%n", passed, failed);
--- a/jdk/test/java/util/zip/LargeZip.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/LargeZip.java	Thu Mar 10 20:49:43 2011 -0800
@@ -98,19 +98,21 @@
         }
         data = baos.toByteArray();
 
-        ZipOutputStream zos = new ZipOutputStream(
-            new BufferedOutputStream(new FileOutputStream(largeFile)));
-        long length = 0;
-        while (length < fileSize) {
-            ZipEntry ze = new ZipEntry("entry-" + length);
-            lastEntryName = ze.getName();
-            zos.putNextEntry(ze);
-            zos.write(data, 0, data.length);
-            zos.closeEntry();
-            length = largeFile.length();
+        try (FileOutputStream fos = new FileOutputStream(largeFile);
+             BufferedOutputStream bos = new BufferedOutputStream(fos);
+             ZipOutputStream zos = new ZipOutputStream(bos))
+        {
+            long length = 0;
+            while (length < fileSize) {
+                ZipEntry ze = new ZipEntry("entry-" + length);
+                lastEntryName = ze.getName();
+                zos.putNextEntry(ze);
+                zos.write(data, 0, data.length);
+                zos.closeEntry();
+                length = largeFile.length();
+            }
+            System.out.println("Last entry written is " + lastEntryName);
         }
-        System.out.println("Last entry written is " + lastEntryName);
-        zos.close();
     }
 
     static void readLargeZip1() throws Throwable {
@@ -143,33 +145,35 @@
 
 
     static void readLargeZip2() throws Throwable {
-        ZipInputStream zis = new ZipInputStream(
-            new BufferedInputStream(new FileInputStream(largeFile)));
-        ZipEntry entry = null;
-        String entryName = null;
-        int count = 0;
-        while ((entry = zis.getNextEntry()) != null) {
-            entryName = entry.getName();
-            if (entryName.equals(lastEntryName)) {
-                break;
+        try (FileInputStream fis = new FileInputStream(largeFile);
+             BufferedInputStream bis = new BufferedInputStream(fis);
+             ZipInputStream zis = new ZipInputStream(bis))
+        {
+            ZipEntry entry = null;
+            String entryName = null;
+            int count = 0;
+            while ((entry = zis.getNextEntry()) != null) {
+                entryName = entry.getName();
+                if (entryName.equals(lastEntryName)) {
+                    break;
+                }
+                count++;
             }
-            count++;
+            System.out.println("Number of entries read: " + count);
+            System.out.println("Last entry read is " + entryName);
+            check(!entry.isDirectory());
+
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+            byte buf[] = new byte[4096];
+            int len;
+            while ((len = zis.read(buf)) >= 0) {
+                baos.write(buf, 0, len);
+            }
+            baos.close();
+            check(Arrays.equals(data, baos.toByteArray()));
+            check(zis.getNextEntry() == null);
         }
-        System.out.println("Number of entries read: " + count);
-        System.out.println("Last entry read is " + entryName);
-        check(!entry.isDirectory());
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
-        byte buf[] = new byte[4096];
-        int len;
-        while ((len = zis.read(buf)) >= 0) {
-            baos.write(buf, 0, len);
-        }
-        baos.close();
-        check(Arrays.equals(data, baos.toByteArray()));
-        check(zis.getNextEntry() == null);
-        zis.close();
     }
 
 
--- a/jdk/test/java/util/zip/TestEmptyZip.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/TestEmptyZip.java	Thu Mar 10 20:49:43 2011 -0800
@@ -78,67 +78,49 @@
                 pass();
             }
         }
-        ZipInputStream zis = null;
-        try {
-            zis = new ZipInputStream(new FileInputStream(f));
+        try (FileInputStream fis = new FileInputStream(f);
+             ZipInputStream zis = new ZipInputStream(fis))
+        {
             ZipEntry ze = zis.getNextEntry();
             check(ze == null);
         } catch (IOException ex) {
             unexpected(ex);
-        } finally {
-            if (zis != null) zis.close();
         }
     }
 
     static void write(File f) throws Exception {
-        ZipOutputStream zos = null;
-        try {
-            zos = new ZipOutputStream(new FileOutputStream(f));
+        try (FileOutputStream fis = new FileOutputStream(f);
+             ZipOutputStream zos = new ZipOutputStream(fis))
+        {
             zos.finish();
-            zos.close();
             pass();
         } catch (Exception ex) {
             unexpected(ex);
-        } finally {
-            if (zos != null) {
-                zos.close();
-            }
         }
     }
 
     static void readFile(File f) throws Exception {
-        ZipFile zf = null;
-        try {
-            zf = new ZipFile(f);
+        try (ZipFile zf = new ZipFile(f)) {
 
             Enumeration e = zf.entries();
             while (e.hasMoreElements()) {
                 ZipEntry entry = (ZipEntry) e.nextElement();
                 fail();
             }
-            zf.close();
             pass();
         } catch (Exception ex) {
             unexpected(ex);
-        } finally {
-            if (zf != null) {
-                zf.close();
-            }
         }
     }
 
     static void readStream(File f) throws Exception {
-        ZipInputStream zis = null;
-        try {
-            zis = new ZipInputStream(new FileInputStream(f));
+        try (FileInputStream fis = new FileInputStream(f);
+             ZipInputStream zis = new ZipInputStream(fis))
+        {
             ZipEntry ze = zis.getNextEntry();
             check(ze == null);
             byte[] buf = new byte[1024];
             check(zis.read(buf, 0, 1024) == -1);
-        } finally {
-            if (zis != null) {
-                zis.close();
-            }
         }
     }
 
--- a/jdk/test/java/util/zip/ZipCoding.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipCoding.java	Thu Mar 10 20:49:43 2011 -0800
@@ -57,59 +57,58 @@
                                    String name, String comment, byte[] bb)
         throws Exception
     {
-        ZipInputStream zis = new ZipInputStream(is, cs);
-        ZipEntry e = zis.getNextEntry();
-        if (e == null || ! name.equals(e.getName()))
-            throw new RuntimeException("ZipIS name doesn't match!");
-        byte[] bBuf = new byte[bb.length << 1];
-        int n = zis.read(bBuf, 0, bBuf.length);
-        if (n != bb.length ||
-            !Arrays.equals(bb, Arrays.copyOf(bBuf, n))) {
-            throw new RuntimeException("ZipIS content doesn't match!");
+        try (ZipInputStream zis = new ZipInputStream(is, cs)) {
+            ZipEntry e = zis.getNextEntry();
+            if (e == null || ! name.equals(e.getName()))
+                throw new RuntimeException("ZipIS name doesn't match!");
+            byte[] bBuf = new byte[bb.length << 1];
+            int n = zis.read(bBuf, 0, bBuf.length);
+            if (n != bb.length ||
+                !Arrays.equals(bb, Arrays.copyOf(bBuf, n))) {
+                throw new RuntimeException("ZipIS content doesn't match!");
+            }
         }
-        zis.close();
     }
 
     static void testZipFile(File f, Charset cs,
                             String name, String comment, byte[] bb)
         throws Exception
     {
-        ZipFile zf = new ZipFile(f, cs);
-        Enumeration<? extends ZipEntry> zes = zf.entries();
-        ZipEntry e = (ZipEntry)zes.nextElement();
-        if (! name.equals(e.getName()) ||
-            ! comment.equals(e.getComment()))
-            throw new RuntimeException("ZipFile: name/comment doesn't match!");
-        InputStream is = zf.getInputStream(e);
-        if (is == null)
-            throw new RuntimeException("ZipFile: getIS failed!");
-        byte[] bBuf = new byte[bb.length << 1];
-        int n = 0;
-        int nn =0;
-        while ((nn = is.read(bBuf, n, bBuf.length-n)) != -1) {
-            n += nn;
+        try (ZipFile zf = new ZipFile(f, cs)) {
+            Enumeration<? extends ZipEntry> zes = zf.entries();
+            ZipEntry e = (ZipEntry)zes.nextElement();
+            if (! name.equals(e.getName()) ||
+                ! comment.equals(e.getComment()))
+                throw new RuntimeException("ZipFile: name/comment doesn't match!");
+            InputStream is = zf.getInputStream(e);
+            if (is == null)
+                throw new RuntimeException("ZipFile: getIS failed!");
+            byte[] bBuf = new byte[bb.length << 1];
+            int n = 0;
+            int nn =0;
+            while ((nn = is.read(bBuf, n, bBuf.length-n)) != -1) {
+                n += nn;
+            }
+            if (n != bb.length ||
+                !Arrays.equals(bb, Arrays.copyOf(bBuf, n))) {
+                throw new RuntimeException("ZipFile content doesn't match!");
+            }
         }
-        if (n != bb.length ||
-            !Arrays.equals(bb, Arrays.copyOf(bBuf, n))) {
-            throw new RuntimeException("ZipFile content doesn't match!");
-        }
-        zf.close();
     }
 
     static void test(String csn, String name, String comment)
         throws Exception
     {
-        byte[] bb = "This is the conent of the zipfile".getBytes("ISO-8859-1");
+        byte[] bb = "This is the content of the zipfile".getBytes("ISO-8859-1");
         Charset cs = Charset.forName(csn);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        ZipOutputStream zos = new ZipOutputStream(baos, cs);
-
-        ZipEntry e = new ZipEntry(name);
-        e.setComment(comment);
-        zos.putNextEntry(e);
-        zos.write(bb, 0, bb.length);
-        zos.closeEntry();
-        zos.close();
+        try (ZipOutputStream zos = new ZipOutputStream(baos, cs)) {
+            ZipEntry e = new ZipEntry(name);
+            e.setComment(comment);
+            zos.putNextEntry(e);
+            zos.write(bb, 0, bb.length);
+            zos.closeEntry();
+        }
         ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
         testZipInputStream(bis, cs, name, comment, bb);
 
@@ -121,9 +120,9 @@
 
         File f = new File(new File(System.getProperty("test.dir", ".")),
                           "zfcoding.zip");
-        FileOutputStream fos = new FileOutputStream(f);
-        baos.writeTo(fos);
-        fos.close();
+        try (FileOutputStream fos = new FileOutputStream(f)) {
+            baos.writeTo(fos);
+        }
         testZipFile(f, cs, name, comment, bb);
         if ("utf-8".equals(csn)) {
             testZipFile(f, Charset.forName("MS932"), name, comment, bb);
--- a/jdk/test/java/util/zip/ZipFile/Assortment.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/Assortment.java	Thu Mar 10 20:49:43 2011 -0800
@@ -201,13 +201,12 @@
         //----------------------------------------------------------------
         // Write zip file using ZipOutputStream
         //----------------------------------------------------------------
-        ZipOutputStream zos = new ZipOutputStream(
-            new FileOutputStream(zipName));
-
-        for (Entry e : entries)
-            e.write(zos);
-
-        zos.close();
+        try (FileOutputStream fos = new FileOutputStream(zipName);
+             ZipOutputStream zos = new ZipOutputStream(fos))
+        {
+            for (Entry e : entries)
+                e.write(zos);
+        }
 
         //----------------------------------------------------------------
         // Verify zip file contents using JarFile class
--- a/jdk/test/java/util/zip/ZipFile/Comment.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/Comment.java	Thu Mar 10 20:49:43 2011 -0800
@@ -57,16 +57,15 @@
     private static void writeZipFile(String name, String comment)
         throws IOException
     {
-        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(name));
-        try {
+        try (FileOutputStream fos = new FileOutputStream(name);
+             ZipOutputStream zos = new ZipOutputStream(fos))
+        {
             zos.setComment(comment);
             ZipEntry ze = new ZipEntry(entryName);
             ze.setMethod(ZipEntry.DEFLATED);
             zos.putNextEntry(ze);
             new DataOutputStream(zos).writeUTF(entryContents);
             zos.closeEntry();
-        } finally {
-            zos.close();
         }
     }
 
@@ -74,30 +73,30 @@
         throws Exception
     {
         // Check that Zip entry was correctly written.
-        ZipFile zipFile = new ZipFile(name);
-        ZipEntry zipEntry = zipFile.getEntry(entryName);
-        InputStream is = zipFile.getInputStream(zipEntry);
-        String result = new DataInputStream(is).readUTF();
-        if (!result.equals(entryContents))
-            throw new Exception("Entry contents corrupted");
+        try (ZipFile zipFile = new ZipFile(name)) {
+            ZipEntry zipEntry = zipFile.getEntry(entryName);
+            InputStream is = zipFile.getInputStream(zipEntry);
+            String result = new DataInputStream(is).readUTF();
+            if (!result.equals(entryContents))
+                throw new Exception("Entry contents corrupted");
+        }
 
-        // Check that comment length was correctly written.
-        RandomAccessFile file = new RandomAccessFile(name, "r");
-        file.seek(file.length() - comment.length()
-                  - ZipFile.ENDHDR + ZipFile.ENDCOM);
-        int b1 = file.readUnsignedByte();
-        int b2 = file.readUnsignedByte();
-        if (b1 + (b2 << 8) != comment.length())
-            throw new Exception("Zip file comment length corrupted");
+        try (RandomAccessFile file = new RandomAccessFile(name, "r")) {
+            // Check that comment length was correctly written.
+            file.seek(file.length() - comment.length()
+                      - ZipFile.ENDHDR + ZipFile.ENDCOM);
+            int b1 = file.readUnsignedByte();
+            int b2 = file.readUnsignedByte();
+            if (b1 + (b2 << 8) != comment.length())
+                throw new Exception("Zip file comment length corrupted");
 
-        // Check that comment was correctly written.
-        file.seek(file.length() - comment.length());
-        byte [] bytes = new byte [comment.length()];
-        file.readFully(bytes);
-        zipFile.close();
-        file.close();
-        if (! comment.equals(new String(bytes, "UTF8")))
-            throw new Exception("Zip file comment corrupted");
+            // Check that comment was correctly written.
+            file.seek(file.length() - comment.length());
+            byte [] bytes = new byte [comment.length()];
+            file.readFully(bytes);
+            if (! comment.equals(new String(bytes, "UTF8")))
+                throw new Exception("Zip file comment corrupted");
+        }
     }
 
     private static String buildComment(int length) {
--- a/jdk/test/java/util/zip/ZipFile/CopyJar.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/CopyJar.java	Thu Mar 10 20:49:43 2011 -0800
@@ -31,18 +31,18 @@
 
 public class CopyJar {
     public static void main(String args[]) throws Exception {
-        ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
-                                          "input.jar"));
-        ZipEntry ze = zf.getEntry("ReleaseInflater.java");
-        ZipOutputStream zos = new ZipOutputStream(new ByteArrayOutputStream());
-        InputStream in = zf.getInputStream(ze);
-        byte[] b = new byte[128];
-        int n;
-        zos.putNextEntry(ze);
-        while((n = in.read(b)) != -1) {
-            zos.write(b, 0, n);
+        try (ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
+                                               "input.jar"))) {
+            ZipEntry ze = zf.getEntry("ReleaseInflater.java");
+            ZipOutputStream zos = new ZipOutputStream(new ByteArrayOutputStream());
+            InputStream in = zf.getInputStream(ze);
+            byte[] b = new byte[128];
+            int n;
+            zos.putNextEntry(ze);
+            while((n = in.read(b)) != -1) {
+                zos.write(b, 0, n);
+            }
+            zos.close();
         }
-        zos.close();
-        zf.close();
     }
 }
--- a/jdk/test/java/util/zip/ZipFile/CorruptedZipFiles.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/CorruptedZipFiles.java	Thu Mar 10 20:49:43 2011 -0800
@@ -47,21 +47,19 @@
     }
 
     public static void main(String[] args) throws Exception {
-        ZipOutputStream zos = new ZipOutputStream(new FileOutputStream("x.zip"));
-        try {
+        try (FileOutputStream fos = new FileOutputStream("x.zip");
+             ZipOutputStream zos = new ZipOutputStream(fos))
+        {
             ZipEntry e = new ZipEntry("x");
             zos.putNextEntry(e);
             zos.write((int)'x');
-        } finally {
-            zos.close();
         }
 
         int len = (int)(new File("x.zip").length());
         byte[] good = new byte[len];
-        FileInputStream fis = new FileInputStream("x.zip");
-        fis.read(good);
-        fis.close();
-        fis = null;
+        try (FileInputStream fis = new FileInputStream("x.zip")) {
+            fis.read(good);
+        }
         new File("x.zip").delete();
 
         int endpos = len - ENDHDR;
@@ -150,17 +148,14 @@
                                       boolean getInputStream) {
         String zipName = "bad" + (uniquifier++) + ".zip";
         try {
-            FileOutputStream fos = new FileOutputStream(zipName);
-            fos.write(data);
-            fos.close();
-            ZipFile zf = new ZipFile(zipName);
-            try {
+            try (FileOutputStream fos = new FileOutputStream(zipName)) {
+                fos.write(data);
+            }
+            try (ZipFile zf = new ZipFile(zipName)) {
                 if (getInputStream) {
                     InputStream is = zf.getInputStream(new ZipEntry("x"));
                     is.read();
                 }
-            } finally {
-                zf.close();
             }
             fail("Failed to throw expected ZipException");
         } catch (ZipException e) {
@@ -170,8 +165,7 @@
                 unexpected(e);
         } catch (Throwable t) {
             unexpected(t);
-        }
-        finally {
+        } finally {
             new File(zipName).delete();
         }
     }
--- a/jdk/test/java/util/zip/ZipFile/DeleteTempJar.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/DeleteTempJar.java	Thu Mar 10 20:49:43 2011 -0800
@@ -53,34 +53,34 @@
     {
         final File zf = File.createTempFile("deletetemp", ".jar");
         zf.deleteOnExit();
-        JarOutputStream jos = new JarOutputStream(
-                new FileOutputStream(zf));
-        JarEntry je = new JarEntry("entry");
-        jos.putNextEntry(je);
-        jos.write("hello, world".getBytes("ASCII"));
-        jos.close();
+        try (FileOutputStream fos = new FileOutputStream(zf);
+             JarOutputStream jos = new JarOutputStream(fos))
+        {
+            JarEntry je = new JarEntry("entry");
+            jos.putNextEntry(je);
+            jos.write("hello, world".getBytes("ASCII"));
+        }
 
         HttpServer server = HttpServer.create(
                 new InetSocketAddress((InetAddress) null, 0), 0);
         HttpContext context = server.createContext("/",
             new HttpHandler() {
                 public void handle(HttpExchange e) {
-                try {
-                    FileInputStream fis = new FileInputStream(zf);
-                    e.sendResponseHeaders(200, zf.length());
-                    OutputStream os = e.getResponseBody();
-                    byte[] buf = new byte[1024];
-                    int count = 0;
-                    while ((count = fis.read(buf)) != -1) {
-                        os.write(buf, 0, count);
+                    try (FileInputStream fis = new FileInputStream(zf)) {
+                        e.sendResponseHeaders(200, zf.length());
+                        OutputStream os = e.getResponseBody();
+                        byte[] buf = new byte[1024];
+                        int count = 0;
+                        while ((count = fis.read(buf)) != -1) {
+                            os.write(buf, 0, count);
+                        }
+                    } catch (Exception ex) {
+                        unexpected(ex);
+                    } finally {
+                        e.close();
                     }
-                    fis.close();
-                    e.close();
-                } catch (Exception ex) {
-                    unexpected(ex);
                 }
-            }
-        });
+            });
         server.start();
 
         URL url = new URL("jar:http://localhost:"
--- a/jdk/test/java/util/zip/ZipFile/EnumAfterClose.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/EnumAfterClose.java	Thu Mar 10 20:49:43 2011 -0800
@@ -33,10 +33,12 @@
 
 public class EnumAfterClose {
     public static void main(String args[]) throws Exception {
-        ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
-                                          "input.zip"));
-        Enumeration e = zf.entries();
-        zf.close();
+        Enumeration e;
+        try (ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
+                                               "input.zip"))) {
+            e = zf.entries();
+        }
+        // ensure that the ZipFile is closed before checking the Enumeration
         try {
             if (e.hasMoreElements()) {
                 ZipEntry ze = (ZipEntry)e.nextElement();
--- a/jdk/test/java/util/zip/ZipFile/GetDirEntry.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/GetDirEntry.java	Thu Mar 10 20:49:43 2011 -0800
@@ -32,12 +32,12 @@
 
 public class GetDirEntry {
     public static void main(String args[]) throws Exception {
-        ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
-                                          "input.jar"));
-        ZipEntry ze = zf.getEntry("META-INF");
-        if (ze == null) {
-            throw new Exception("failed to find a directory entry");
+        try (ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
+                                               "input.jar"))) {
+            ZipEntry ze = zf.getEntry("META-INF");
+            if (ze == null) {
+                throw new Exception("failed to find a directory entry");
+            }
         }
-        zf.close();
     }
 }
--- a/jdk/test/java/util/zip/ZipFile/LargeZipFile.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/LargeZipFile.java	Thu Mar 10 20:49:43 2011 -0800
@@ -93,51 +93,50 @@
             baos.write(bb.array(), 0, DATA_SIZE);
         }
         data = baos.toByteArray();
-
-        ZipOutputStream zos = new ZipOutputStream(
-            new BufferedOutputStream(new FileOutputStream(largeFile)));
-        long length = 0;
-        while (length < fileSize) {
-            ZipEntry ze = new ZipEntry("entry-" + length);
-            lastEntryName = ze.getName();
-            zos.putNextEntry(ze);
-            zos.write(data, 0, data.length);
-            zos.closeEntry();
-            length = largeFile.length();
+        try (FileOutputStream fos = new FileOutputStream(largeFile);
+             BufferedOutputStream bos = new BufferedOutputStream(fos);
+             ZipOutputStream zos = new ZipOutputStream(bos))
+        {
+            long length = 0;
+            while (length < fileSize) {
+                ZipEntry ze = new ZipEntry("entry-" + length);
+                lastEntryName = ze.getName();
+                zos.putNextEntry(ze);
+                zos.write(data, 0, data.length);
+                zos.closeEntry();
+                length = largeFile.length();
+            }
+            System.out.println("Last entry written is " + lastEntryName);
         }
-        System.out.println("Last entry written is " + lastEntryName);
-        zos.close();
     }
 
     static void readLargeZip() throws Throwable {
-        ZipFile zipFile = new ZipFile(largeFile);
-        ZipEntry entry = null;
-        String entryName = null;
-        int count = 0;
-        Enumeration<? extends ZipEntry> entries = zipFile.entries();
-        while (entries.hasMoreElements()) {
-            entry = entries.nextElement();
-            entryName = entry.getName();
-            count++;
+        try (ZipFile zipFile = new ZipFile(largeFile)) {
+            ZipEntry entry = null;
+            String entryName = null;
+            int count = 0;
+            Enumeration<? extends ZipEntry> entries = zipFile.entries();
+            while (entries.hasMoreElements()) {
+                entry = entries.nextElement();
+                entryName = entry.getName();
+                count++;
+            }
+            System.out.println("Number of entries read: " + count);
+            System.out.println("Last entry read is " + entryName);
+            check(!entry.isDirectory());
+            if (check(entryName.equals(lastEntryName))) {
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                InputStream is = zipFile.getInputStream(entry);
+                byte buf[] = new byte[4096];
+                int len;
+                while ((len = is.read(buf)) >= 0) {
+                    baos.write(buf, 0, len);
+                }
+                baos.close();
+                is.close();
+                check(Arrays.equals(data, baos.toByteArray()));
+            }
         }
-        System.out.println("Number of entries read: " + count);
-        System.out.println("Last entry read is " + entryName);
-        check(!entry.isDirectory());
-        if (check(entryName.equals(lastEntryName))) {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            InputStream is = zipFile.getInputStream(entry);
-            byte buf[] = new byte[4096];
-            int len;
-            while ((len = is.read(buf)) >= 0) {
-                baos.write(buf, 0, len);
-            }
-            baos.close();
-            is.close();
-            check(Arrays.equals(data, baos.toByteArray()));
-        }
-        try {
-          zipFile.close();
-        } catch (IOException ioe) {/* what can you do */ }
     }
 
     //--------------------- Infrastructure ---------------------------
--- a/jdk/test/java/util/zip/ZipFile/ManyEntries.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/ManyEntries.java	Thu Mar 10 20:49:43 2011 -0800
@@ -55,10 +55,10 @@
         File zipFile = new File(++uniquifier + ".zip");
         try {
             zipFile.delete();
-            ZipOutputStream zos = new ZipOutputStream(
-                new BufferedOutputStream(
-                    new FileOutputStream(zipFile)));
-            try {
+            try (FileOutputStream fos = new FileOutputStream(zipFile);
+                 BufferedOutputStream bos = new BufferedOutputStream(fos);
+                 ZipOutputStream zos = new ZipOutputStream(bos))
+            {
                 for (int i = 0; i < N; i++) {
                     ZipEntry e = new ZipEntry("DIR/"+i);
                     e.setMethod(method);
@@ -75,13 +75,9 @@
                     zos.putNextEntry(e);
                     zos.write(i);
                 }
-            } finally {
-                zos.close();
-                zos = null;
             }
 
-            ZipFile zip = zip = new ZipFile(zipFile);
-            try {
+            try (ZipFile zip = new ZipFile(zipFile)) {
                 if (! (zip.size() == N))
                     throw new Exception("Bad ZipFile size: " + zip.size());
                 Enumeration entries = zip.entries();
@@ -104,11 +100,8 @@
                 }
                 if (entries.hasMoreElements())
                     throw new Exception("too many elements");
-            } finally {
-                zip.close();
             }
-        }
-        finally {
+        } finally {
             zipFile.delete();
         }
     }
--- a/jdk/test/java/util/zip/ZipFile/ManyZipFiles.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/ManyZipFiles.java	Thu Mar 10 20:49:43 2011 -0800
@@ -51,14 +51,14 @@
 
         // Create some zip data
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        ZipOutputStream zos = new ZipOutputStream(baos);
-        ZipEntry ze = new ZipEntry("test");
-        zos.putNextEntry(ze);
-        byte[] hello = "hello, world".getBytes("ASCII");
-        zos.write(hello, 0, hello.length);
-        zos.closeEntry();
-        zos.finish();
-        zos.close();
+        try (ZipOutputStream zos = new ZipOutputStream(baos)) {
+            ZipEntry ze = new ZipEntry("test");
+            zos.putNextEntry(ze);
+            byte[] hello = "hello, world".getBytes("ASCII");
+            zos.write(hello, 0, hello.length);
+            zos.closeEntry();
+            zos.finish();
+        }
         byte[] data = baos.toByteArray();
 
         ZipFile zips[] = new ZipFile[numFiles];
@@ -90,9 +90,9 @@
             for (int i = 0; i < numFiles; i++) {
                 File f = File.createTempFile("test", ".zip", tmpdir);
                 f.deleteOnExit();
-                FileOutputStream fos = new FileOutputStream(f);
-                fos.write(data, 0, data.length);
-                fos.close();
+                try (FileOutputStream fos = new FileOutputStream(f)) {
+                    fos.write(data, 0, data.length);
+                }
                 try {
                     zips[i] = new ZipFile(f);
                 } catch (Throwable t) {
@@ -102,11 +102,12 @@
                 }
             }
         } finally {
-            // This finally block is due to bug 4171239.  On windows, if the
+            // This finally block is due to bug 4171239.  On Windows, if the
             // file is still open at the end of the VM, deleteOnExit won't
             // take place.  "new ZipFile(...)" opens the zip file, so we have
-            // to explicity close those opened above.  This finally block can
-            // be removed when 4171239 is fixed.
+            // to explicitly close those opened above.  This finally block can
+            // be removed when 4171239 is fixed. See also 6357433, against which
+            // 4171239 was closed as a duplicate.
             for (int i = 0; i < numFiles; i++) {
                 if (zips[i] != null) {
                     try {
--- a/jdk/test/java/util/zip/ZipFile/ReadAfterClose.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/ReadAfterClose.java	Thu Mar 10 20:49:43 2011 -0800
@@ -34,10 +34,13 @@
 
 public class ReadAfterClose {
     public static void main(String[] argv) throws Exception {
-        ZipFile zf = new ZipFile(new File(System.getProperty("test.src","."),"crash.jar"));
-        ZipEntry zent = zf.getEntry("Test.java");
-        InputStream in = zf.getInputStream(zent);
-        zf.close();
+        InputStream in;
+        try (ZipFile zf = new ZipFile(
+                 new File(System.getProperty("test.src","."),"crash.jar"))) {
+            ZipEntry zent = zf.getEntry("Test.java");
+            in = zf.getInputStream(zent);
+        }
+        // ensure zf is closed at this point
         try {
             in.read();
         } catch (IOException e) {
--- a/jdk/test/java/util/zip/ZipFile/ReadZip.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/ReadZip.java	Thu Mar 10 20:49:43 2011 -0800
@@ -27,6 +27,10 @@
  */
 
 import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
 import java.util.zip.*;
 
 public class ReadZip {
@@ -38,71 +42,62 @@
     }
 
     public static void main(String args[]) throws Exception {
-        ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
-                                          "input.zip"));
-
-        // Make sure we throw NPE on null objects
-        try { unreached (zf.getEntry(null)); }
-        catch (NullPointerException e) {}
+        try (ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."),
+                                               "input.zip"))) {
+            // Make sure we throw NPE on null objects
+            try { unreached (zf.getEntry(null)); }
+            catch (NullPointerException e) {}
 
-        try { unreached (zf.getInputStream(null)); }
-        catch (NullPointerException e) {}
+            try { unreached (zf.getInputStream(null)); }
+            catch (NullPointerException e) {}
 
-        ZipEntry ze = zf.getEntry("ReadZip.java");
-        if (ze == null) {
-            throw new Exception("cannot read from zip file");
+            ZipEntry ze = zf.getEntry("ReadZip.java");
+            if (ze == null) {
+                throw new Exception("cannot read from zip file");
+            }
         }
-        zf.close();
 
         // Make sure we can read the zip file that has some garbage
         // bytes padded at the end.
-        FileInputStream fis = new FileInputStream(
-                                   new File(System.getProperty("test.src", "."),
-                                            "input.zip"));
-        File newZip = new File(System.getProperty("test.dir", "."),
-                               "input2.zip");
-        FileOutputStream fos = new FileOutputStream(newZip);
+        File newZip = new File(System.getProperty("test.dir", "."), "input2.zip");
+        Files.copy(Paths.get(System.getProperty("test.src", ""), "input.zip"),
+                   newZip.toPath(), StandardCopyOption.REPLACE_EXISTING);
 
-        byte[] buf = new byte[1024];
-        int n = 0;
-        while ((n = fis.read(buf)) != -1) {
-            fos.write(buf, 0, n);
+        // pad some bytes
+        try (OutputStream os = Files.newOutputStream(newZip.toPath(),
+                                                     StandardOpenOption.APPEND)) {
+            os.write(1); os.write(3); os.write(5); os.write(7);
         }
-        fis.close();
-        // pad some bytes
-        fos.write(1); fos.write(3); fos.write(5); fos.write(7);
-        fos.close();
-        try {
-            zf = new ZipFile(newZip);
-            ze = zf.getEntry("ReadZip.java");
+
+        try (ZipFile zf = new ZipFile(newZip)) {
+            ZipEntry ze = zf.getEntry("ReadZip.java");
             if (ze == null) {
                 throw new Exception("cannot read from zip file");
             }
         } finally {
-            zf.close();
             newZip.delete();
         }
 
         // Read zip file comment
         try {
+            try (FileOutputStream fos = new FileOutputStream(newZip);
+                 ZipOutputStream zos = new ZipOutputStream(fos))
+            {
+                ZipEntry ze = new ZipEntry("ZipEntry");
+                zos.putNextEntry(ze);
+                zos.write(1); zos.write(2); zos.write(3); zos.write(4);
+                zos.closeEntry();
+                zos.setComment("This is the comment for testing");
+            }
 
-            ZipOutputStream zos = new ZipOutputStream(
-                                      new FileOutputStream(newZip));
-            ze = new ZipEntry("ZipEntry");
-            zos.putNextEntry(ze);
-            zos.write(1); zos.write(2); zos.write(3); zos.write(4);
-            zos.closeEntry();
-            zos.setComment("This is the comment for testing");
-            zos.close();
-
-            zf = new ZipFile(newZip);
-            ze = zf.getEntry("ZipEntry");
-            if (ze == null)
-                throw new Exception("cannot read entry from zip file");
-            if (!"This is the comment for testing".equals(zf.getComment()))
-                throw new Exception("cannot read comment from zip file");
+            try (ZipFile zf = new ZipFile(newZip)) {
+                ZipEntry ze = zf.getEntry("ZipEntry");
+                if (ze == null)
+                    throw new Exception("cannot read entry from zip file");
+                if (!"This is the comment for testing".equals(zf.getComment()))
+                    throw new Exception("cannot read comment from zip file");
+            }
         } finally {
-            zf.close();
             newZip.delete();
         }
 
--- a/jdk/test/java/util/zip/ZipFile/ShortRead.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/ShortRead.java	Thu Mar 10 20:49:43 2011 -0800
@@ -38,27 +38,29 @@
         try {
             final String entryName = "abc";
             final String data = "Data disponible";
-            final ZipOutputStream zos =
-                new ZipOutputStream(new FileOutputStream(zFile));
-            zos.putNextEntry(new ZipEntry(entryName));
-            zos.write(data.getBytes("ASCII"));
-            zos.closeEntry();
-            zos.close();
+            try (FileOutputStream fos = new FileOutputStream(zFile);
+                 ZipOutputStream zos = new ZipOutputStream(fos))
+            {
+                zos.putNextEntry(new ZipEntry(entryName));
+                zos.write(data.getBytes("ASCII"));
+                zos.closeEntry();
+            }
 
-            final ZipFile zipFile = new ZipFile(zFile);
-            final ZipEntry zentry = zipFile.getEntry(entryName);
-            final InputStream inputStream = zipFile.getInputStream(zentry);
-            System.out.printf("size=%d csize=%d available=%d%n",
-                              zentry.getSize(),
-                              zentry.getCompressedSize(),
-                              inputStream.available());
-            byte[] buf = new byte[data.length()];
-            final int count = inputStream.read(buf);
-            if (! new String(buf, "ASCII").equals(data) ||
-                count != data.length())
-                throw new Exception("short read?");
-            zipFile.close();
+            try (ZipFile zipFile = new ZipFile(zFile)) {
+                final ZipEntry zentry = zipFile.getEntry(entryName);
+                final InputStream inputStream = zipFile.getInputStream(zentry);
+                System.out.printf("size=%d csize=%d available=%d%n",
+                                  zentry.getSize(),
+                                  zentry.getCompressedSize(),
+                                  inputStream.available());
+                byte[] buf = new byte[data.length()];
+                final int count = inputStream.read(buf);
+                if (! new String(buf, "ASCII").equals(data) ||
+                    count != data.length())
+                    throw new Exception("short read?");
+            }
+        } finally {
+            zFile.delete();
         }
-        finally { zFile.delete(); }
     }
 }
--- a/jdk/test/java/util/zip/zip.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/java/util/zip/zip.java	Thu Mar 10 20:49:43 2011 -0800
@@ -322,57 +322,57 @@
 
     void create(OutputStream out) throws IOException
     {
-        ZipOutputStream zos = new ZipOutputStream(out, cs);
-        if (flag0) {
-            zos.setMethod(ZipOutputStream.STORED);
+        try (ZipOutputStream zos = new ZipOutputStream(out, cs)) {
+            if (flag0) {
+                zos.setMethod(ZipOutputStream.STORED);
+            }
+            for (File file: entries) {
+                addFile(zos, file);
+            }
         }
-        for (File file: entries) {
-            addFile(zos, file);
-        }
-        zos.close();
     }
 
     boolean update(InputStream in, OutputStream out) throws IOException
     {
-        ZipInputStream zis = new ZipInputStream(in, cs);
-        ZipOutputStream zos = new ZipOutputStream(out, cs);
-        ZipEntry e = null;
-        byte[] buf = new byte[1024];
-        int n = 0;
-        boolean updateOk = true;
+        try (ZipInputStream zis = new ZipInputStream(in, cs);
+             ZipOutputStream zos = new ZipOutputStream(out, cs))
+        {
+            ZipEntry e = null;
+            byte[] buf = new byte[1024];
+            int n = 0;
+            boolean updateOk = true;
 
-        // put the old entries first, replace if necessary
-        while ((e = zis.getNextEntry()) != null) {
-            String name = e.getName();
-            if (!entryMap.containsKey(name)) { // copy the old stuff
-                // do our own compression
-                ZipEntry e2 = new ZipEntry(name);
-                e2.setMethod(e.getMethod());
-                e2.setTime(e.getTime());
-                e2.setComment(e.getComment());
-                e2.setExtra(e.getExtra());
-                if (e.getMethod() == ZipEntry.STORED) {
-                    e2.setSize(e.getSize());
-                    e2.setCrc(e.getCrc());
+            // put the old entries first, replace if necessary
+            while ((e = zis.getNextEntry()) != null) {
+                String name = e.getName();
+                if (!entryMap.containsKey(name)) { // copy the old stuff
+                    // do our own compression
+                    ZipEntry e2 = new ZipEntry(name);
+                    e2.setMethod(e.getMethod());
+                    e2.setTime(e.getTime());
+                    e2.setComment(e.getComment());
+                    e2.setExtra(e.getExtra());
+                    if (e.getMethod() == ZipEntry.STORED) {
+                        e2.setSize(e.getSize());
+                        e2.setCrc(e.getCrc());
+                    }
+                    zos.putNextEntry(e2);
+                    while ((n = zis.read(buf, 0, buf.length)) != -1) {
+                        zos.write(buf, 0, n);
+                    }
+                } else { // replace with the new files
+                    File f = entryMap.get(name);
+                    addFile(zos, f);
+                    entryMap.remove(name);
+                    entries.remove(f);
                 }
-                zos.putNextEntry(e2);
-                while ((n = zis.read(buf, 0, buf.length)) != -1) {
-                    zos.write(buf, 0, n);
-                }
-            } else { // replace with the new files
-                File f = entryMap.get(name);
+            }
+
+            // add the remaining new files
+            for (File f: entries) {
                 addFile(zos, f);
-                entryMap.remove(name);
-                entries.remove(f);
             }
         }
-
-        // add the remaining new files
-        for (File f: entries) {
-            addFile(zos, f);
-        }
-        zis.close();
-        zos.close();
         return updateOk;
     }
 
@@ -517,25 +517,25 @@
     }
 
     void extract(String fname, String files[]) throws IOException {
-        ZipFile zf = new ZipFile(fname, cs);
-        Set<ZipEntry> dirs = newDirSet();
-        Enumeration<? extends ZipEntry> zes = zf.entries();
-        while (zes.hasMoreElements()) {
-            ZipEntry e = zes.nextElement();
-            InputStream is;
-            if (files == null) {
-                dirs.add(extractFile(zf.getInputStream(e), e));
-            } else {
-                String name = e.getName();
-                for (String file : files) {
-                    if (name.startsWith(file)) {
-                        dirs.add(extractFile(zf.getInputStream(e), e));
-                        break;
+        try (ZipFile zf = new ZipFile(fname, cs)) {
+            Set<ZipEntry> dirs = newDirSet();
+            Enumeration<? extends ZipEntry> zes = zf.entries();
+            while (zes.hasMoreElements()) {
+                ZipEntry e = zes.nextElement();
+                InputStream is;
+                if (files == null) {
+                    dirs.add(extractFile(zf.getInputStream(e), e));
+                } else {
+                    String name = e.getName();
+                    for (String file : files) {
+                        if (name.startsWith(file)) {
+                            dirs.add(extractFile(zf.getInputStream(e), e));
+                            break;
+                        }
                     }
                 }
             }
         }
-        zf.close();
         updateLastModifiedTime(dirs);
     }
 
@@ -607,12 +607,12 @@
     }
 
     void list(String fname, String files[]) throws IOException {
-        ZipFile zf = new ZipFile(fname, cs);
-        Enumeration<? extends ZipEntry> zes = zf.entries();
-        while (zes.hasMoreElements()) {
-            printEntry(zes.nextElement(), files);
+        try (ZipFile zf = new ZipFile(fname, cs)) {
+            Enumeration<? extends ZipEntry> zes = zf.entries();
+            while (zes.hasMoreElements()) {
+                printEntry(zes.nextElement(), files);
+            }
         }
-        zf.close();
     }
 
     void printEntry(ZipEntry e, String[] files) throws IOException {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/File/SMPTESequence.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,75 @@
+/**
+ * @test
+ * @bug 6835393
+ * @summary Tests that MidiFileReader correctly reads sequences with different division types
+ * @author Alex Menkov
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import javax.sound.midi.InvalidMidiDataException;
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.Sequence;
+
+public class SMPTESequence {
+
+    static int failed = 0;
+
+    public static void main(String[] args) {
+        test(Sequence.PPQ);
+        test(Sequence.SMPTE_24);
+        test(Sequence.SMPTE_25);
+        test(Sequence.SMPTE_30);
+        test(Sequence.SMPTE_30DROP);
+
+        if (failed > 0) {
+            throw new RuntimeException("" + failed + " tests failed");
+        }
+    }
+
+    static boolean test(float divisionType) {
+        boolean result = false;
+        try {
+            log("Testing divisionType == " + divisionType);
+            Sequence sequence = new Sequence(divisionType, 16, 1);
+            float div1 = sequence.getDivisionType();
+
+            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+            MidiSystem.write(sequence, 1, outStream);
+
+            InputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+
+            sequence = MidiSystem.getSequence(inStream);
+            float div2 = sequence.getDivisionType();
+
+            log("After write/read got divisionType == " + div2);
+            if (Math.abs(div2 - div1) < 0.001f) {
+                result = true;
+            }
+        } catch (InvalidMidiDataException ex) {
+            log(ex);
+        } catch (IOException ex) {
+            log(ex);
+        } catch (IllegalArgumentException ex) {
+            log(ex);
+        }
+        if (result) {
+            log("OK");
+        } else {
+            log("FAIL");
+            failed++;
+        }
+        return result;
+    }
+
+    static void log(String s) {
+        System.out.println(s);
+    }
+
+    static void log(Exception ex) {
+        log("got exception (" + ex.getClass().getSimpleName() + "): " + ex.getMessage());
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/Sequencer/SequencerImplicitSynthOpen.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,110 @@
+/**
+ * @test
+ * @bug 6660470
+ * @summary Tests that sequencer correctly opens/closes (implicitly) devices
+ * @author Alex Menkov
+ */
+
+import java.util.List;
+import javax.sound.midi.MidiDevice;
+import javax.sound.midi.MidiDeviceReceiver;
+import javax.sound.midi.MidiSystem;
+import javax.sound.midi.MidiUnavailableException;
+import javax.sound.midi.Receiver;
+import javax.sound.midi.Sequencer;
+import javax.sound.midi.Transmitter;
+
+public class SequencerImplicitSynthOpen {
+
+    static int TEST_COUNT   = 5;
+
+    public static void main(String[] args) {
+        try {
+            log("getting sequencer...");
+            Sequencer sequencer = MidiSystem.getSequencer();
+            log("  - got " + getDeviceStr(sequencer));
+
+            // obtain connected device (usually synthesizer)
+            MidiDevice synth = getConnectedDevice(sequencer);
+            if (synth == null) {
+                log("could not get connected device, returning");
+                return;
+            }
+
+            log("connected device: " + getDeviceStr(synth));
+
+            int success = 0;
+            for (int i=0; i<TEST_COUNT; i++) {
+                if (test(sequencer)) {
+                    success++;
+                }
+            }
+
+            if (success != TEST_COUNT) {
+                throw new RuntimeException("test FAILS");
+            }
+        } catch (MidiUnavailableException ex) {
+            // this is not a failure
+            log("Could not get Sequencer");
+        }
+        log("test PASSED.");
+    }
+
+    static boolean test(Sequencer sequencer) throws MidiUnavailableException {
+        log("");
+        log("opening sequencer...");
+        sequencer.open();   // opens connected synthesizer implicitly
+        MidiDevice synth = getConnectedDevice(sequencer);
+        log("  connected device: " + getDeviceStr(synth));
+
+        log("closing sequencer...");
+        sequencer.close();  // closes the synth implicitly
+        log("  synth is " + getDeviceStr(synth));
+        MidiDevice synth2 = getConnectedDevice(sequencer);
+        log("  currently connected device: " + getDeviceStr(synth2));
+
+        if (synth != null && synth.isOpen()) {
+            log("FAIL.");
+            return false;
+        }
+        log("OK.");
+        return true;
+    }
+
+    static MidiDevice getConnectedDevice(Sequencer sequencer) {
+        List<Transmitter> trans = sequencer.getTransmitters();
+        log("  sequencer has " + trans.size() + " opened transmitters:");
+        for (Transmitter tr: trans) {
+            Receiver r = tr.getReceiver();
+            log("    " + getClassStr(tr) + " connected to " + getClassStr(r));
+            if (r instanceof MidiDeviceReceiver) {
+                MidiDeviceReceiver recv = (MidiDeviceReceiver)r;
+                MidiDevice dev = recv.getMidiDevice();
+                log("      - receiver of " + getClassStr(dev));
+                return dev;
+            } else {
+                log("      - does NOT implement MidiDeviceReceiver");
+            }
+        }
+        return null;
+    }
+
+    static String getClassStr(Object o) {
+        if (o == null) {
+            return "<null>";
+        }
+        return o.getClass().getName();
+    }
+
+    static String getDeviceStr(MidiDevice dev) {
+        if (dev == null) {
+            return "NULL";
+        }
+        return getClassStr(dev) + ", " + (dev.isOpen() ? "OPENED" : "CLOSED");
+    }
+
+    static void log(String s) {
+        System.out.println(s);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/Clip/ClipSetPos.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6801206
+ * @summary Tests that Clip sets frame position
+ * @author Alex Menkov
+ */
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.Clip;
+import javax.sound.sampled.LineUnavailableException;
+
+public class ClipSetPos {
+
+    final static AudioFormat audioFormat = new AudioFormat(44100f, 16, 2, true, true);
+    final static int frameLength = 44100 * 2; // 2 seconds
+    final static byte[] dataBuffer
+            = new byte[frameLength * (audioFormat.getSampleSizeInBits()/8)
+                       * audioFormat.getChannels()];
+    final static int MAX_FRAME_DELTA = 20;
+
+    public static void main(String[] args) {
+        boolean testPassed = true;
+        Clip clip = null;
+        try {
+            clip = AudioSystem.getClip();
+            clip.open(audioFormat, dataBuffer, 0, dataBuffer.length);
+        } catch (LineUnavailableException ex) {
+            log(ex);
+            log("Cannot test (this is not failure)");
+            return;
+        }
+
+        log("clip: " + clip.getClass().getName());
+
+        int len = clip.getFrameLength();
+        for (int pos=0; pos < len; pos += (len /100)) {
+            clip.setFramePosition(pos);
+            int curPos = clip.getFramePosition();
+            if (Math.abs(pos - curPos) > MAX_FRAME_DELTA) {
+                log("Tried to set pos to " + pos + ", but got back " + curPos);
+                testPassed = false;
+            } else {
+                log("Sucessfully set pos to " + pos);
+            }
+        }
+        clip.close();
+
+        if (testPassed) {
+            log("Test PASSED.");
+        } else {
+            log("Test FAILED.");
+            throw new RuntimeException("Test FAILED (see log)");
+        }
+    }
+
+    static void log(String s) {
+        System.out.println(s);
+    }
+
+    static void log(Exception ex) {
+        ex.printStackTrace(System.out);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/FileWriter/AlawEncoderSync.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,113 @@
+/**
+ * @test
+ * @bug 6938426
+ * @summary Tests that Alaw encoder works properly in multithreaded environment
+ * @author Alex Menkov
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.util.Arrays;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+
+public class AlawEncoderSync {
+
+    static final int THREAD_COUNT   = 20;
+
+    static final AudioFormat pcmFormat = new AudioFormat(8000f, 16, 2, true, false);
+    static final int STREAM_LENGTH = 10;    // in seconds
+    static byte[] pcmBuffer;
+    static final AudioFormat alawFormat
+            = new AudioFormat(AudioFormat.Encoding.ALAW, 8000f, 8, 2, 2, 8000f, false);
+
+    static final ConversionThread[] threads = new ConversionThread[THREAD_COUNT];
+
+    public static void main(String[] args) {
+        preparePCMBuffer();
+        log("pcmStream size: " + pcmBuffer.length);
+
+        for (int i=0; i<THREAD_COUNT; i++) {
+            threads[i] = new ConversionThread(i);
+            threads[i].start();
+        }
+
+        for (int i=1; i<THREAD_COUNT; i++) {
+            try {
+                threads[i].join();
+            } catch (InterruptedException ex) {
+                log("Main thread was interrupted, exiting.");
+                return;
+            }
+        }
+
+        int failed = 0;
+        log("comparing result arrays...");
+        for (int i=1; i<THREAD_COUNT; i++) {
+            if (!Arrays.equals(threads[0].resultArray, threads[i].resultArray)) {
+                failed++;
+                log("NOT equals: 0 and " + i);
+            }
+        }
+        if (failed > 0) {
+            throw new RuntimeException("test FAILED");
+        }
+        log("test PASSED.");
+    }
+
+
+    static void preparePCMBuffer() {
+        pcmBuffer = new byte[STREAM_LENGTH * (int)pcmFormat.getSampleRate()
+                * (pcmFormat.getSampleSizeInBits() / 8) * pcmFormat.getChannels()];
+        for (int i=0; i<pcmBuffer.length; i++) {
+            pcmBuffer[i] = (byte)(Math.random() * 256.0 - 128.0);
+        }
+    }
+
+    static AudioInputStream createPCMStream() {
+        InputStream byteStream = new ByteArrayInputStream(pcmBuffer);
+        return new AudioInputStream(byteStream, pcmFormat, AudioSystem.NOT_SPECIFIED);
+    }
+
+    static class ConversionThread extends Thread {
+        public final int num;
+        public byte[] resultArray = null;
+        public ConversionThread(int num) {
+            this.num = num;
+        }
+        @Override
+        public void run() {
+            log("ConversionThread[" + num + "] started.");
+            try {
+                InputStream inStream = new ByteArrayInputStream(pcmBuffer);
+
+                AudioInputStream pcmStream = new AudioInputStream(
+                        inStream, pcmFormat, AudioSystem.NOT_SPECIFIED);
+                AudioInputStream alawStream = AudioSystem.getAudioInputStream(alawFormat, pcmStream);
+
+                ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+                int read = 0;
+                byte[] data = new byte[4096];
+                while((read = alawStream.read(data)) != -1) {
+                    outStream.write(data, 0, read);
+               }
+               alawStream.close();
+               resultArray = outStream.toByteArray();
+            } catch (Exception ex) {
+                log("ConversionThread[" + num + "] exception:");
+                log(ex);
+            }
+            log("ConversionThread[" + num + "] completed.");
+        }
+    }
+
+    static void log(String s) {
+        System.out.println(s);
+    }
+
+    static void log(Exception ex) {
+        ex.printStackTrace(System.out);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/sampled/FileWriter/WriterCloseInput.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,127 @@
+/**
+ * @test
+ * @bug 7013521
+ * @summary AIFF/AU/WAVE writers close input audio stream
+ * @author Alex Menkov
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import javax.sound.sampled.AudioFileFormat;
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioInputStream;
+import javax.sound.sampled.AudioSystem;
+
+
+public class WriterCloseInput {
+
+    final static AudioFormat audioFormat = new AudioFormat(44100f, 16, 2, true, true);
+    //final static AudioFormat audioFormat = new AudioFormat(AudioFormat.Encoding.ULAW, 44100f, 8, 2, 2, 44100f, true);
+    final static int frameLength = 44100 * 2; // 2 seconds
+    final static byte[] dataBuffer
+            = new byte[frameLength * (audioFormat.getSampleSizeInBits()/8)
+                       * audioFormat.getChannels()];
+
+    static int testTotal = 0;
+    static int testFailed = 0;
+
+    public static void main(String[] args) throws Exception {
+        test(AudioFileFormat.Type.AIFF);
+        test(AudioFileFormat.Type.AU);
+        test(AudioFileFormat.Type.WAVE);
+
+        if (testFailed == 0) {
+            out("All tests passed.");
+        } else {
+            out("" + testFailed + " of " + testTotal + " tests FAILED.");
+            System.out.flush();
+            throw new RuntimeException("Test FAILED.");
+        }
+    }
+
+    static void test(AudioFileFormat.Type fileType) {
+        test(fileType, frameLength);
+        test(fileType, AudioSystem.NOT_SPECIFIED);
+    }
+
+    static void test(AudioFileFormat.Type fileType, int length) {
+        test(fileType, length, false);
+        test(fileType, length, true);
+    }
+
+    static void test(AudioFileFormat.Type fileType, int length, boolean isFile) {
+        testTotal++;
+        out("Testing fileType: " + fileType
+                + ", frameLength: " + (length >= 0 ? length : "unspecified")
+                + ", output: " + (isFile ? "File" : "OutputStream"));
+        AudioInputStream inStream = new ThrowAfterCloseStream(
+                new ByteArrayInputStream(dataBuffer), audioFormat, length);
+
+        AudioSystem.isFileTypeSupported(fileType, inStream);
+
+        try {
+            if (isFile) {
+                File f = File.createTempFile("WriterCloseInput" + testTotal, "tmp");
+                AudioSystem.write(inStream, fileType, f);
+                f.delete();
+            } else {
+                OutputStream outStream = new NullOutputStream();
+                AudioSystem.write(inStream, fileType, outStream);
+            }
+        } catch (Exception ex) {
+            // this is not failure
+            out("SKIPPED (AudioSystem.write exception): " + ex.getMessage());
+            //out(ex);
+            inStream = null;
+        }
+
+        if (inStream != null) {
+            try {
+                // test if the stream is closed
+                inStream.available();
+                out("PASSED");
+            } catch (IOException ex) {
+                testFailed++;
+                out("FAILED: " + ex.getMessage());
+                //out(ex);
+            }
+        }
+        out("");
+    }
+
+    static class ThrowAfterCloseStream extends AudioInputStream {
+        private boolean closed = false;
+        public ThrowAfterCloseStream(InputStream in, AudioFormat format, long length) {
+            super(in, format, length);
+        }
+        @Override
+        public void close() {
+            closed = true;
+        }
+        @Override
+        public int available() throws IOException {
+            if (closed) {
+                throw new IOException("The stream has been closed");
+            }
+            return 1;
+        }
+    }
+
+    static class NullOutputStream extends OutputStream {
+        @Override
+        public void write(int b) throws IOException {
+            // nop
+        }
+    }
+
+    static void out(String s) {
+        System.out.println(s);
+    }
+
+    static void out(Exception ex) {
+        ex.printStackTrace(System.out);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011, 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 javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+/**
+ * <p>This class contains utilities useful for regression testing.
+ * <p>When using jtreg you would include this class via something like:
+ * <pre>
+ *
+ * @library ../../regtesthelpers
+ * @build Util
+ * </pre>
+ */
+
+public class Util {
+    /**
+     * Convert a rectangle from coordinate system of Component c to
+     * screen coordinate system.
+     *
+     * @param r a non-null Rectangle
+     * @param c a Component whose coordinate system is used for conversion
+     */
+    public static void convertRectToScreen(Rectangle r, Component c) {
+        Point p = new Point(r.x, r.y);
+        SwingUtilities.convertPointToScreen(p, c);
+        r.x = p.x;
+        r.y = p.y;
+    }
+
+    /**
+     * Compares two bufferedImages pixel-by-pixel.
+     * return true if all pixels in the two areas are identical
+     */
+    public static boolean compareBufferedImages(BufferedImage bufferedImage0, BufferedImage bufferedImage1) {
+        int width = bufferedImage0.getWidth();
+        int height = bufferedImage0.getHeight();
+
+        if (width != bufferedImage1.getWidth() || height != bufferedImage1.getHeight()) {
+            return false;
+        }
+
+        for (int y = 0; y < height; y++) {
+            for (int x = 0; x < width; x++) {
+                if (bufferedImage0.getRGB(x, y) != bufferedImage1.getRGB(x, y)) {
+                    return false;
+                }
+            }
+        }
+
+        return true;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/CSSBorder/6796710/bug6796710.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2011, 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 6796710
+ * @summary Html content in JEditorPane is overlapping on swing components while resizing the application.
+ * @library ../../../regtesthelpers
+ * @build Util
+ * @author Pavel Porvatov
+   @run main bug6796710
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public class bug6796710 {
+    // The page is inlined because we want to be sure that the JEditorPane filled synchronously
+    public static final String TEXT = "<html>" +
+            "<body>" +
+            "<table cellpadding=\"0\" cellspacing=\"0\" border=\"1\">" +
+            "    <tbody>" +
+            "        <tr>" +
+            "            <td>Col1</td>" +
+            "            <td>Col2</td>" +
+            "            <td>Col3</td>" +
+            "        </tr>" +
+            "        <tr>" +
+            "            <td>1. It's a regression from CR 4419748. The problem is in the CSSBorder#paintBorder, which ignores clip area while painting.</td>" +
+            "            <td>2. It's a regression from CR 4419748. The problem is in the CSSBorder#paintBorder, which ignores clip area while painting.</td>" +
+            "            <td>3. It's a regression from CR 4419748. The problem is in the CSSBorder#paintBorder, which ignores clip area while painting.</td>" +
+            "        </tr>" +
+            "    </tbody>" +
+            "</table>" +
+            "</body>" +
+            "</html>";
+
+    private static Robot robot;
+
+    private static JFrame frame;
+
+    private static JPanel pnBottom;
+
+    public static void main(String[] args) throws Exception {
+        robot = new Robot();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame = new JFrame();
+
+                pnBottom = new JPanel();
+                pnBottom.add(new JLabel("Some label"));
+                pnBottom.add(new JButton("A button"));
+
+                JEditorPane editorPane = new JEditorPane();
+
+                editorPane.setContentType("text/html");
+                editorPane.setText(TEXT);
+                editorPane.setEditable(false);
+
+                JPanel pnContent = new JPanel(new BorderLayout());
+
+                pnContent.add(new JScrollPane(editorPane), BorderLayout.CENTER);
+                pnContent.add(pnBottom, BorderLayout.SOUTH);
+
+                frame.setContentPane(pnContent);
+                frame.setSize(400, 600);
+                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                frame.setVisible(true);
+            }
+        });
+
+        robot.waitForIdle();
+
+        BufferedImage bufferedImage = getPnBottomImage();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame.setSize(400, 150);
+            }
+        });
+
+        robot.waitForIdle();
+
+        if (!Util.compareBufferedImages(bufferedImage, getPnBottomImage())) {
+            throw new RuntimeException("The test failed");
+        }
+
+        System.out.println("The test bug6796710 passed.");
+    }
+
+    private static BufferedImage getPnBottomImage() {
+        Rectangle rect = pnBottom.getBounds();
+
+        Util.convertRectToScreen(rect, pnBottom.getParent());
+
+        return robot.createScreenCapture(rect);
+    }
+}
--- a/jdk/test/sun/misc/BootClassLoaderHook/TestHook.java	Thu Mar 10 17:11:08 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.File;
-import java.util.TreeSet;
-import java.util.Set;
-import java.net.URLStreamHandlerFactory;
-import sun.misc.BootClassLoaderHook;
-import sun.misc.URLClassPath;
-
-
-/* @test
- * @bug     6888802
- * @summary Sanity test of BootClassLoaderHook interface
- *
- * @build TestHook
- * @run main TestHook
- */
-
-public class TestHook extends BootClassLoaderHook {
-
-    private static final TestHook hook = new TestHook();
-    private static Set<String> names = new TreeSet<String>();
-    private static final String LOGRECORD_CLASS =
-        "java.util.logging.LogRecord";
-    private static final String NONEXIST_RESOURCE =
-        "non.exist.resource";
-    private static final String LIBHELLO = "hello";
-
-    public static void main(String[] args) throws Exception {
-        BootClassLoaderHook.setHook(hook);
-        if (BootClassLoaderHook.getHook() == null) {
-           throw new RuntimeException("Null boot classloader hook ");
-        }
-
-        testHook();
-
-        if (!names.contains(LOGRECORD_CLASS)) {
-           throw new RuntimeException("loadBootstrapClass for " + LOGRECORD_CLASS + " not called");
-        }
-
-        if (!names.contains(NONEXIST_RESOURCE)) {
-           throw new RuntimeException("getBootstrapResource for " + NONEXIST_RESOURCE + " not called");
-        }
-        if (!names.contains(LIBHELLO)) {
-           throw new RuntimeException("loadLibrary for " + LIBHELLO + " not called");
-        }
-
-        Set<String> copy = new TreeSet<String>();
-        copy.addAll(names);
-        for (String s : copy) {
-            System.out.println("  Loaded " + s);
-        }
-    }
-
-    private static void testHook() throws Exception {
-        Class.forName(LOGRECORD_CLASS);
-        ClassLoader.getSystemResource(NONEXIST_RESOURCE);
-        try {
-          System.loadLibrary(LIBHELLO);
-        } catch (UnsatisfiedLinkError e) {
-        }
-    }
-
-    public String loadBootstrapClass(String className) {
-        names.add(className);
-        return null;
-    }
-
-    public String getBootstrapResource(String resourceName) {
-        names.add(resourceName);
-        return null;
-    }
-
-    public boolean loadLibrary(String libname) {
-        names.add(libname);
-        return false;
-    }
-
-    public URLClassPath getBootstrapClassPath(URLClassPath bcp,
-            URLStreamHandlerFactory factory) {
-        return bcp;
-    }
-
-    public boolean isCurrentThreadPrefetching() {
-        return false;
-    }
-
-    public boolean prefetchFile(String name) {
-        return false;
-    }
-}
--- a/jdk/test/sun/security/pkcs11/Cipher/TestRSACipher.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipher.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 4898468
+ * @bug 4898468 6994008
  * @summary basic test for RSA cipher
  * @author Andreas Sterbenz
  * @library ..
@@ -38,9 +38,12 @@
 
 public class TestRSACipher extends PKCS11Test {
 
+    private static final String[] RSA_ALGOS =
+        { "RSA/ECB/PKCS1Padding", "RSA" };
+
     public void main(Provider p) throws Exception {
         try {
-            Cipher.getInstance("RSA/ECB/PKCS1Padding", p);
+            Cipher.getInstance(RSA_ALGOS[0], p);
         } catch (GeneralSecurityException e) {
             System.out.println("Not supported by provider, skipping");
             return;
@@ -55,57 +58,58 @@
         b = new byte[16];
         random.nextBytes(b);
 
-        Cipher c1 = Cipher.getInstance("RSA/ECB/PKCS1Padding", p);
-        Cipher c2 = Cipher.getInstance("RSA/ECB/PKCS1Padding", "SunJCE");
+        for (String rsaAlgo: RSA_ALGOS) {
+            Cipher c1 = Cipher.getInstance(rsaAlgo, p);
+            Cipher c2 = Cipher.getInstance(rsaAlgo, "SunJCE");
 
-        c1.init(Cipher.ENCRYPT_MODE, publicKey);
-        e = c1.doFinal(b);
-        c1.init(Cipher.DECRYPT_MODE, privateKey);
-        d = c1.doFinal(e);
-        match(b, d);
-        c2.init(Cipher.DECRYPT_MODE, privateKey);
-        d = c2.doFinal(e);
-        match(b, d);
+            c1.init(Cipher.ENCRYPT_MODE, publicKey);
+            e = c1.doFinal(b);
+            c1.init(Cipher.DECRYPT_MODE, privateKey);
+            d = c1.doFinal(e);
+            match(b, d);
+            c2.init(Cipher.DECRYPT_MODE, privateKey);
+            d = c2.doFinal(e);
+            match(b, d);
 
-        // invalid data
-        c1.init(Cipher.DECRYPT_MODE, publicKey);
-        try {
-            d = c1.doFinal(e);
-            throw new Exception("completed call");
-        } catch (BadPaddingException ee) {
-            ee.printStackTrace();
-        }
+            // invalid data
+            c1.init(Cipher.DECRYPT_MODE, publicKey);
+            try {
+                d = c1.doFinal(e);
+                throw new Exception("completed call");
+            } catch (BadPaddingException ee) {
+                ee.printStackTrace();
+            }
 
-        c1.init(Cipher.ENCRYPT_MODE, privateKey);
-        e = c1.doFinal(b);
-        c1.init(Cipher.DECRYPT_MODE, publicKey);
-        d = c1.doFinal(e);
-        match(b, d);
-        c2.init(Cipher.DECRYPT_MODE, publicKey);
-        d = c2.doFinal(e);
-        match(b, d);
+            c1.init(Cipher.ENCRYPT_MODE, privateKey);
+            e = c1.doFinal(b);
+            c1.init(Cipher.DECRYPT_MODE, publicKey);
+            d = c1.doFinal(e);
+            match(b, d);
+            c2.init(Cipher.DECRYPT_MODE, publicKey);
+            d = c2.doFinal(e);
+            match(b, d);
 
-        // reinit tests
-        c1.init(Cipher.ENCRYPT_MODE, privateKey);
-        c1.init(Cipher.ENCRYPT_MODE, privateKey);
-        e = c1.doFinal(b);
-        e = c1.doFinal(b);
-        c1.update(b);
-        c1.update(b);
-        c1.init(Cipher.ENCRYPT_MODE, privateKey);
-        e = c1.doFinal();
-        e = c1.doFinal();
-        c1.update(b);
-        e = c1.doFinal();
+            // reinit tests
+            c1.init(Cipher.ENCRYPT_MODE, privateKey);
+            c1.init(Cipher.ENCRYPT_MODE, privateKey);
+            e = c1.doFinal(b);
+            e = c1.doFinal(b);
+            c1.update(b);
+            c1.update(b);
+            c1.init(Cipher.ENCRYPT_MODE, privateKey);
+            e = c1.doFinal();
+            e = c1.doFinal();
+            c1.update(b);
+            e = c1.doFinal();
 
-        c1.update(new byte[256]);
-        try {
-            e = c1.doFinal();
-            throw new Exception("completed call");
-        } catch (IllegalBlockSizeException ee) {
-            System.out.println(ee);
+            c1.update(new byte[256]);
+            try {
+                e = c1.doFinal();
+                throw new Exception("completed call");
+            } catch (IllegalBlockSizeException ee) {
+                System.out.println(ee);
+            }
         }
-
     }
 
     private static void match(byte[] b1, byte[] b2) throws Exception {
--- a/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, 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
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 6572331
+ * @bug 6572331 6994008
  * @summary basic test for RSA cipher key wrapping functionality
  * @author Valerie Peng
  * @library ..
@@ -38,47 +38,48 @@
 
 public class TestRSACipherWrap extends PKCS11Test {
 
-    private static final String RSA_ALGO = "RSA/ECB/PKCS1Padding";
+    private static final String[] RSA_ALGOS =
+        { "RSA/ECB/PKCS1Padding", "RSA" };
 
     public void main(Provider p) throws Exception {
         try {
-            Cipher.getInstance(RSA_ALGO, p);
+            Cipher.getInstance(RSA_ALGOS[0], p);
         } catch (GeneralSecurityException e) {
-            System.out.println("Not supported by provider, skipping");
+            System.out.println(RSA_ALGOS[0] + " unsupported, skipping");
             return;
         }
         KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p);
         kpg.initialize(1024);
         KeyPair kp = kpg.generateKeyPair();
-        PublicKey publicKey = kp.getPublic();
-        PrivateKey privateKey = kp.getPrivate();
 
-        Cipher cipherPKCS11 = Cipher.getInstance(RSA_ALGO, p);
-        Cipher cipherJce = Cipher.getInstance(RSA_ALGO, "SunJCE");
+        for (String rsaAlgo: RSA_ALGOS) {
+            Cipher cipherPKCS11 = Cipher.getInstance(rsaAlgo, p);
+            Cipher cipherJce = Cipher.getInstance(rsaAlgo, "SunJCE");
 
-        String algos[] = {"AES", "RC2", "Blowfish"};
-        int keySizes[] = {128, 256};
+            String algos[] = {"AES", "RC2", "Blowfish"};
+            int keySizes[] = {128, 256};
 
-        for (int j = 0; j < algos.length; j++) {
-            String algorithm = algos[j];
-            KeyGenerator keygen =
+            for (int j = 0; j < algos.length; j++) {
+                String algorithm = algos[j];
+                KeyGenerator keygen =
                     KeyGenerator.getInstance(algorithm);
 
-            for (int i = 0; i < keySizes.length; i++) {
-                SecretKey secretKey = null;
-                System.out.print("Generate " + keySizes[i] + "-bit " +
+                for (int i = 0; i < keySizes.length; i++) {
+                    SecretKey secretKey = null;
+                    System.out.print("Generate " + keySizes[i] + "-bit " +
                         algorithm + " key using ");
-                try {
-                    keygen.init(keySizes[i]);
-                    secretKey = keygen.generateKey();
-                    System.out.println(keygen.getProvider().getName());
-                } catch (InvalidParameterException ipe) {
-                    secretKey = new SecretKeySpec(new byte[32], algorithm);
-                    System.out.println("SecretKeySpec class");
+                    try {
+                        keygen.init(keySizes[i]);
+                        secretKey = keygen.generateKey();
+                        System.out.println(keygen.getProvider().getName());
+                    } catch (InvalidParameterException ipe) {
+                        secretKey = new SecretKeySpec(new byte[32], algorithm);
+                        System.out.println("SecretKeySpec class");
+                    }
+                    test(kp, secretKey, cipherPKCS11, cipherJce);
+                    test(kp, secretKey, cipherPKCS11, cipherPKCS11);
+                    test(kp, secretKey, cipherJce, cipherPKCS11);
                 }
-                test(kp, secretKey, cipherPKCS11, cipherJce);
-                test(kp, secretKey, cipherPKCS11, cipherPKCS11);
-                test(kp, secretKey, cipherJce, cipherPKCS11);
             }
         }
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/Cipher/TestRawRSACipher.java	Thu Mar 10 20:49:43 2011 -0800
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011, 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 6994008
+ * @summary basic test for RSA/ECB/NoPadding cipher
+ * @author Valerie Peng
+ * @library ..
+ */
+
+import javax.crypto.*;
+import java.io.*;
+import javax.crypto.spec.SecretKeySpec;
+import java.security.*;
+import java.util.*;
+
+public class TestRawRSACipher extends PKCS11Test {
+
+    public void main(Provider p) throws Exception {
+        try {
+            Cipher.getInstance("RSA/ECB/NoPadding", p);
+        } catch (GeneralSecurityException e) {
+            System.out.println("Not supported by provider, skipping");
+            return;
+        }
+
+        final int KEY_LEN = 1024;
+        KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", p);
+        kpGen.initialize(KEY_LEN);
+        KeyPair kp = kpGen.generateKeyPair();
+        Random random = new Random();
+        byte[] plainText, cipherText, recoveredText;
+        plainText = new byte[KEY_LEN/8];
+        random.nextBytes(plainText);
+        plainText[0] = 0; // to ensure that it's less than modulus
+
+        Cipher c1 = Cipher.getInstance("RSA/ECB/NoPadding", p);
+        Cipher c2 = Cipher.getInstance("RSA/ECB/NoPadding", "SunJCE");
+
+        c1.init(Cipher.ENCRYPT_MODE, kp.getPublic());
+        c2.init(Cipher.DECRYPT_MODE, kp.getPrivate());
+
+        cipherText = c1.doFinal(plainText);
+        recoveredText = c2.doFinal(cipherText);
+        if (!Arrays.equals(plainText, recoveredText)) {
+            throw new RuntimeException("E/D Test against SunJCE Failed!");
+        }
+
+        c2.init(Cipher.ENCRYPT_MODE, kp.getPublic());
+        c1.init(Cipher.DECRYPT_MODE, kp.getPrivate());
+        cipherText = c2.doFinal(plainText);
+        recoveredText = c1.doFinal(cipherText);
+        if (!Arrays.equals(plainText, recoveredText)) {
+            throw new RuntimeException("D/E Test against SunJCE Failed!");
+        }
+
+        System.out.println("Test Passed");
+    }
+
+    public static void main(String[] args) throws Exception {
+        main(new TestRawRSACipher());
+    }
+}
--- a/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphers.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, 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
@@ -23,7 +23,7 @@
 
 /**
  * @test %I% %E%
- * @bug 4898461
+ * @bug 4898461 6604496
  * @summary basic test for symmetric ciphers with padding
  * @author Valerie Peng
  * @library ..
@@ -70,9 +70,13 @@
         new CI("DES/ECB/PKCS5Padding", "DES", 6400),
         new CI("DESede/ECB/PKCS5Padding", "DESede", 400),
         new CI("AES/ECB/PKCS5Padding", "AES", 64),
+
         new CI("DES", "DES", 6400),
         new CI("DESede", "DESede", 408),
-        new CI("AES", "AES", 128)
+        new CI("AES", "AES", 128),
+
+        new CI("AES/CTR/NoPadding", "AES", 3200)
+
     };
     private static StringBuffer debugBuf = new StringBuffer();
 
--- a/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, 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
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 4898484
+ * @bug 4898484 6604496
  * @summary basic test for symmetric ciphers with no padding
  * @author Valerie Peng
  * @library ..
@@ -59,7 +59,8 @@
         new CI("DES/CBC/NoPadding", "DES", 400),
         new CI("DESede/CBC/NoPadding", "DESede", 160),
         new CI("AES/CBC/NoPadding", "AES", 4800),
-        new CI("Blowfish/CBC/NoPadding", "Blowfish", 24)
+        new CI("Blowfish/CBC/NoPadding", "Blowfish", 24),
+        new CI("AES/CTR/NoPadding", "AES", 1600)
     };
 
     private static StringBuffer debugBuf;
--- a/jdk/test/sun/security/tools/jarsigner/crl.sh	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/sun/security/tools/jarsigner/crl.sh	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2011, 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
@@ -32,9 +32,6 @@
 fi
 
 # set platform-dependent variables
-# PF: platform name, say, solaris-sparc
-
-PF=""
 
 OS=`uname -s`
 case "$OS" in
@@ -47,54 +44,28 @@
 esac
 
 KS=crl.jks
-JFILE=crl.jar
 
 KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
-JAR=$TESTJAVA${FS}bin${FS}jar
-JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
 
-rm $KS $JFILE 2> /dev/null
+rm $KS 2> /dev/null
 
-# Generates some crl files, each containing two entries
+# Test keytool -gencrl
 
 $KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
-$KT -alias a -gencrl -id 1:1 -id 2:2 -file crl1
-$KT -alias a -gencrl -id 3:3 -id 4:4 -file crl2
-$KT -alias b -dname CN=b -keyalg rsa -genkey -validity 300
-$KT -alias b -gencrl -id 5:1 -id 6:2 -file crl3
+$KT -alias a -gencrl -id 1:1 -id 2:2 -file crl1 || exit 1
+$KT -alias a -gencrl -id 3:3 -id 4:4 -file crl2 || exit 2
+$KT -alias a -gencrl -id 5:1 -id 6:2 -file crl3 || exit 4
 
-cat > ToURI.java <<EOF
-class ToURI {
-    public static void main(String[] args) throws Exception {
-        System.out.println(new java.io.File("crl1").toURI());
-    }
-}
-EOF
-$TESTJAVA${FS}bin${FS}javac ToURI.java
-$TESTJAVA${FS}bin${FS}java ToURI > uri
-$KT -alias c -dname CN=c -keyalg rsa -genkey -validity 300 \
-    -ext crl=uri:`cat uri`
-
-echo A > A
+# Test keytool -printcrl
 
-# Test -crl:auto, cRLDistributionPoints is a local file
+$KT -printcrl -file crl1 || exit 5
+$KT -printcrl -file crl2 || exit 6
+$KT -printcrl -file crl3 || exit 7
 
-$JAR cvf $JFILE A
-$JARSIGNER -keystore $KS -storepass changeit $JFILE c \
-        -crl:auto || exit 1
-$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 6
-$KT -printcert -jarfile $JFILE | grep CRLs || exit 7
-
-# Test -crl <file>
 
-$JAR cvf $JFILE A
-$JARSIGNER -keystore $KS -storepass changeit $JFILE a \
-        -crl crl1 -crl crl2 || exit 2
-$JARSIGNER -keystore $KS -storepass changeit $JFILE b \
-        -crl crl3 -crl crl2 || exit 3
-$JARSIGNER -keystore $KS -verify -debug -strict $JFILE || exit 3
-$KT -printcert -jarfile $JFILE | grep CRLs || exit 4
-CRLCOUNT=`$KT -printcert -jarfile $JFILE | grep SerialNumber | wc -l`
-if [ $CRLCOUNT != 8 ]; then exit 5; fi
+# Test keytool -ext crl
+
+$KT -alias b -dname CN=c -keyalg rsa -genkey -validity 300 \
+    -ext crl=uri:http://www.example.com/crl || exit 10
 
 exit 0
--- a/jdk/test/sun/security/tools/keytool/NewSize7.java	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/sun/security/tools/keytool/NewSize7.java	Thu Mar 10 20:49:43 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, 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.io.File;
 import java.io.FileInputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.security.KeyStore;
 import java.security.cert.X509Certificate;
 import java.security.interfaces.RSAPublicKey;
@@ -42,8 +44,10 @@
                 " -alias a -dname cn=c -storepass changeit" +
                 " -keypass changeit -keyalg rsa").split(" "));
         KeyStore ks = KeyStore.getInstance("JKS");
-        ks.load(new FileInputStream(FILE), null);
-        new File(FILE).delete();
+        try (FileInputStream fin = new FileInputStream(FILE)) {
+            ks.load(fin, null);
+        }
+        Files.delete(Paths.get(FILE));
         RSAPublicKey r = (RSAPublicKey)ks.getCertificate("a").getPublicKey();
         if (r.getModulus().bitLength() != 2048) {
             throw new Exception("Bad keysize");
--- a/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh	Thu Mar 10 17:11:08 2011 -0800
+++ b/jdk/test/sun/tools/native2ascii/Native2AsciiTests.sh	Thu Mar 10 20:49:43 2011 -0800
@@ -24,7 +24,7 @@
 #
 
 # @test
-# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817
+# @bug 4630463 4630971 4636448 4701617 4721296 4710890 6247817 7021987
 # @summary Tests miscellaneous native2ascii bugfixes and regressions
 
 
@@ -100,6 +100,15 @@
 $N2A -reverse -encoding MS932 $TESTSRC/A2N_4701617 x.out
 check 4701617 $TESTSRC/A2N_4701617.expected x.out
 
+# Check that the inputfile appears in the error message when not found
+
+badin="DoesNotExist"
+$N2A $badin x.out | grep "$badin" > /dev/null
+if [ $? != 0 ]; then
+    echo "\"$badin\" expected to appear in error message"
+    exit 1
+fi
+
 # for win32 only ensure when output file pre-exists that
 # native2ascii tool will simply overwrite with the expected
 # output file (fixed bugID 4710890)