Merge
authorlana
Wed, 19 Jan 2011 21:51:10 -0800
changeset 7963 024332536ac3
parent 7962 fbf25bae06b1 (current diff)
parent 7852 f1df06807698 (diff)
child 7964 fda4ca3f7b24
Merge
jdk/test/java/awt/Insets/WindowWithWarningTest/WindowWithWarningTest.html
jdk/test/java/awt/Insets/WindowWithWarningTest/WindowWithWarningTest.java
jdk/test/javax/script/E4XErrorTest.java
jdk/test/javax/swing/SwingWorker/6480289/bug6480289.java
jdk/test/sun/security/krb5/auto/basic.sh
langtools/test/tools/javac/meth/InvokeDyn.java
langtools/test/tools/javac/meth/InvokeDynTrans.java
--- a/.hgtags	Wed Jan 19 17:01:50 2011 +0300
+++ b/.hgtags	Wed Jan 19 21:51:10 2011 -0800
@@ -98,3 +98,5 @@
 0ce0a2c3a6926677dc507839a820ab6625541e5a jdk7-b121
 6f09ea1c034f087916d2a8cf0d22be768400118f jdk7-b122
 142129d8599d1f56b29387e7f9a5fad53b6d61df jdk7-b123
+aa894c225b1a517b665ac2a58295217ea2245134 jdk7-b124
+f658ec2730fa29323c36d23c27e54c7219ef5e16 jdk7-b125
--- a/.hgtags-top-repo	Wed Jan 19 17:01:50 2011 +0300
+++ b/.hgtags-top-repo	Wed Jan 19 21:51:10 2011 -0800
@@ -98,3 +98,5 @@
 2c2d4f88637b488014c37e1a2eb401f68bca8838 jdk7-b121
 f1591eed71f64f6eba79fb7426f5616cc4dfea73 jdk7-b122
 ed6950da30cf1e8904b4bdb034d471647942271f jdk7-b123
+024a6755895bf91b5a3c98984c89ee018efbf538 jdk7-b124
+5c4df7e992775c102f08e9f1c0a124b324641b70 jdk7-b125
--- a/corba/.hgtags	Wed Jan 19 17:01:50 2011 +0300
+++ b/corba/.hgtags	Wed Jan 19 21:51:10 2011 -0800
@@ -98,3 +98,5 @@
 2cc9f32992101732b23730b737740e64ebc5fa89 jdk7-b121
 1523a060032c8a5b7840198da8911abeff88118f jdk7-b122
 a230c142628cea22475ab9dc5cd544266ddf2466 jdk7-b123
+f90b3e014e831eb4f32ef035a1dad2b8ba87949f jdk7-b124
+1ce58c72b7892cb813eb920276c7e7f17a1b79fe jdk7-b125
--- a/hotspot/.hgtags	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/.hgtags	Wed Jan 19 21:51:10 2011 -0800
@@ -138,3 +138,6 @@
 5484e7c53fa7da5e869902437ee08a9ae10c1c69 hs20-b03
 9669f9b284108a9ee0a0ccbe215c37a130c9dcf5 jdk7-b123
 9669f9b284108a9ee0a0ccbe215c37a130c9dcf5 hs20-b04
+0a8e0d4345b37b71ec49dda08ee03b68c4f1b592 jdk7-b124
+0a8e0d4345b37b71ec49dda08ee03b68c4f1b592 hs20-b05
+e24ab3fa6aafad3efabbe7dba9918c5f461a20b1 jdk7-b125
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/HotSpotTypeDataBase.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -99,15 +99,8 @@
     long typeEntrySizeOffset;
     long typeEntryArrayStride;
 
-    typeEntryTypeNameOffset       = getLongValueFromProcess("gHotSpotVMTypeEntryTypeNameOffset");
-    typeEntrySuperclassNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySuperclassNameOffset");
-    typeEntryIsOopTypeOffset      = getLongValueFromProcess("gHotSpotVMTypeEntryIsOopTypeOffset");
-    typeEntryIsIntegerTypeOffset  = getLongValueFromProcess("gHotSpotVMTypeEntryIsIntegerTypeOffset");
-    typeEntryIsUnsignedOffset     = getLongValueFromProcess("gHotSpotVMTypeEntryIsUnsignedOffset");
-    typeEntrySizeOffset           = getLongValueFromProcess("gHotSpotVMTypeEntrySizeOffset");
-    typeEntryArrayStride          = getLongValueFromProcess("gHotSpotVMTypeEntryArrayStride");
-
-    // Fetch the address of the VMTypeEntry*
+    // Fetch the address of the VMTypeEntry*. We get this symbol first
+    // and try to use it to make sure that symbol lookup is working.
     Address entryAddr = lookupInProcess("gHotSpotVMTypes");
     //    System.err.println("gHotSpotVMTypes address = " + entryAddr);
     // Dereference this once to get the pointer to the first VMTypeEntry
@@ -118,6 +111,14 @@
       throw new RuntimeException("gHotSpotVMTypes was not initialized properly in the remote process; can not continue");
     }
 
+    typeEntryTypeNameOffset       = getLongValueFromProcess("gHotSpotVMTypeEntryTypeNameOffset");
+    typeEntrySuperclassNameOffset = getLongValueFromProcess("gHotSpotVMTypeEntrySuperclassNameOffset");
+    typeEntryIsOopTypeOffset      = getLongValueFromProcess("gHotSpotVMTypeEntryIsOopTypeOffset");
+    typeEntryIsIntegerTypeOffset  = getLongValueFromProcess("gHotSpotVMTypeEntryIsIntegerTypeOffset");
+    typeEntryIsUnsignedOffset     = getLongValueFromProcess("gHotSpotVMTypeEntryIsUnsignedOffset");
+    typeEntrySizeOffset           = getLongValueFromProcess("gHotSpotVMTypeEntrySizeOffset");
+    typeEntryArrayStride          = getLongValueFromProcess("gHotSpotVMTypeEntryArrayStride");
+
     // Start iterating down it until we find an entry with no name
     Address typeNameAddr = null;
     do {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/COFFFileParser.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -122,10 +122,14 @@
       private MemoizedObject[] sectionHeaders;
       private MemoizedObject[] symbols;
 
+      // Init stringTable at decl time since other fields init'ed in the
+      // constructor need the String Table.
       private MemoizedObject stringTable = new MemoizedObject() {
           public Object computeValue() {
+            // the String Table follows the Symbol Table
             int ptr = getPointerToSymbolTable();
             if (ptr == 0) {
+              // no Symbol Table so no String Table
               return new StringTable(0);
             } else {
               return new StringTable(ptr + SYMBOL_SIZE * getNumberOfSymbols());
@@ -140,6 +144,8 @@
         timeDateStamp = readInt();
         pointerToSymbolTable = readInt();
         numberOfSymbols = readInt();
+        // String Table can be accessed at this point because
+        // pointerToSymbolTable and numberOfSymbols fields are set.
         sizeOfOptionalHeader = readShort();
         characteristics = readShort();
 
@@ -222,6 +228,8 @@
         private MemoizedObject windowsSpecificFields;
         private MemoizedObject dataDirectories;
 
+        // We use an offset of 2 because OptionalHeaderStandardFieldsImpl doesn't
+        // include the 'magic' field.
         private static final int STANDARD_FIELDS_OFFSET = 2;
         private static final int PE32_WINDOWS_SPECIFIC_FIELDS_OFFSET = 28;
         private static final int PE32_DATA_DIRECTORIES_OFFSET = 96;
@@ -288,7 +296,7 @@
         private int sizeOfUninitializedData;
         private int addressOfEntryPoint;
         private int baseOfCode;
-        private int baseOfData;
+        private int baseOfData;  // only set in PE32
 
         OptionalHeaderStandardFieldsImpl(int offset,
                                          boolean isPE32Plus) {
@@ -301,7 +309,8 @@
           sizeOfUninitializedData = readInt();
           addressOfEntryPoint = readInt();
           baseOfCode = readInt();
-          if (isPE32Plus) {
+          if (!isPE32Plus) {
+            // only available in PE32
             baseOfData = readInt();
           }
         }
@@ -433,7 +442,10 @@
                 if (dir.getRVA() == 0 || dir.getSize() == 0) {
                   return null;
                 }
-                return new ExportDirectoryTableImpl(rvaToFileOffset(dir.getRVA()), dir.getSize());
+                // ExportDirectoryTableImpl needs both the RVA and the
+                // RVA converted to a file offset.
+                return new
+                    ExportDirectoryTableImpl(dir.getRVA(), dir.getSize());
               }
             };
 
@@ -526,6 +538,7 @@
       }
 
       class ExportDirectoryTableImpl implements ExportDirectoryTable {
+        private int exportDataDirRVA;
         private int offset;
         private int size;
 
@@ -548,8 +561,9 @@
         private MemoizedObject exportOrdinalTable;
         private MemoizedObject exportAddressTable;
 
-        ExportDirectoryTableImpl(int offset, int size) {
-          this.offset = offset;
+        ExportDirectoryTableImpl(int exportDataDirRVA, int size) {
+          this.exportDataDirRVA = exportDataDirRVA;
+          offset = rvaToFileOffset(exportDataDirRVA);
           this.size   = size;
           seek(offset);
           exportFlags = readInt();
@@ -595,6 +609,7 @@
 
           exportOrdinalTable = new MemoizedObject() {
               public Object computeValue() {
+                // number of ordinals is same as the number of name pointers
                 short[] ordinals = new short[getNumberOfNamePointers()];
                 seek(rvaToFileOffset(getOrdinalTableRVA()));
                 for (int i = 0; i < ordinals.length; i++) {
@@ -608,14 +623,18 @@
               public Object computeValue() {
                 int[] addresses = new int[getNumberOfAddressTableEntries()];
                 seek(rvaToFileOffset(getExportAddressTableRVA()));
-                // Must make two passes to avoid rvaToFileOffset
-                // destroying seek() position
+                // The Export Address Table values are a union of two
+                // possible values:
+                //   Export RVA - The address of the exported symbol when
+                //       loaded into memory, relative to the image base.
+                //       This value doesn't get converted into a file offset.
+                //   Forwarder RVA - The pointer to a null-terminated ASCII
+                //       string in the export section. This value gets
+                //       converted into a file offset because we have to
+                //       fetch the string.
                 for (int i = 0; i < addresses.length; i++) {
                   addresses[i] = readInt();
                 }
-                for (int i = 0; i < addresses.length; i++) {
-                  addresses[i] = rvaToFileOffset(addresses[i]);
-                }
                 return addresses;
               }
             };
@@ -648,11 +667,12 @@
 
         public boolean isExportAddressForwarder(short ordinal) {
           int addr = getExportAddress(ordinal);
-          return ((offset <= addr) && (addr < (offset + size)));
+          return ((exportDataDirRVA <= addr) &&
+              (addr < (exportDataDirRVA + size)));
         }
 
         public String getExportAddressForwarder(short ordinal) {
-          seek(getExportAddress(ordinal));
+          seek(rvaToFileOffset(getExportAddress(ordinal)));
           return readCString();
         }
 
@@ -3371,10 +3391,17 @@
               throw new COFFException(e);
             }
             // Look up in string table
+            // FIXME: this index value is assumed to be in the valid range
             name = getStringTable().get(index);
           } else {
             try {
-              name = new String(tmpName, US_ASCII);
+              int length = 0;
+              // find last non-NULL
+              for (; length < tmpName.length && tmpName[length] != '\0';) {
+                length++;
+              }
+              // don't include NULL chars in returned name String
+              name = new String(tmpName, 0, length, US_ASCII);
             } catch (UnsupportedEncodingException e) {
               throw new COFFException(e);
             }
@@ -3487,6 +3514,7 @@
                                 tmpName[5] << 16 |
                                 tmpName[6] <<  8 |
                                 tmpName[7]);
+            // FIXME: stringOffset is assumed to be in the valid range
             name = getStringTable().getAtOffset(stringOffset);
           }
 
@@ -3698,12 +3726,13 @@
 
         StringTable(int offset) {
           if (offset == 0) {
+            // no String Table
             strings = new COFFString[0];
             return;
           }
 
           seek(offset);
-          int length = readInt();
+          int length = readInt();  // length includes itself
           byte[] data = new byte[length - 4];
           int numBytesRead = readBytes(data);
           if (numBytesRead != data.length) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/DumpExports.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/DumpExports.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -37,35 +37,48 @@
 
     String filename = args[0];
     COFFFile file   = COFFFileParser.getParser().parse(filename);
-    ExportDirectoryTable exports =
-      file.getHeader().
-        getOptionalHeader().
-          getDataDirectories().
-            getExportDirectoryTable();
+
+    // get common point for both things we want to dump
+    OptionalHeaderDataDirectories dataDirs = file.getHeader().getOptionalHeader().
+        getDataDirectories();
+
+    // dump the header data directory for the Export Table:
+    DataDirectory dir = dataDirs.getExportTable();
+    System.out.println("Export table: RVA = " + dir.getRVA() + "/0x" +
+        Integer.toHexString(dir.getRVA()) + ", size = " + dir.getSize() + "/0x" +
+        Integer.toHexString(dir.getSize()));
+
+    System.out.println(file.getHeader().getNumberOfSections() + " sections in file");
+    for (int i = 1; i <= file.getHeader().getNumberOfSections(); i++) {
+      SectionHeader sec = file.getHeader().getSectionHeader(i);
+      System.out.println("  Section " + i + ":");
+      System.out.println("    Name = '" + sec.getName() + "'");
+      System.out.println("    VirtualSize = " + sec.getSize() + "/0x" +
+          Integer.toHexString(sec.getSize()));
+      System.out.println("    VirtualAddress = " + sec.getVirtualAddress() + "/0x" +
+          Integer.toHexString(sec.getVirtualAddress()));
+      System.out.println("    SizeOfRawData = " + sec.getSizeOfRawData() + "/0x" +
+          Integer.toHexString(sec.getSizeOfRawData()));
+      System.out.println("    PointerToRawData = " + sec.getPointerToRawData() + "/0x" +
+          Integer.toHexString(sec.getPointerToRawData()));
+    }
+
+    ExportDirectoryTable exports = dataDirs.getExportDirectoryTable();
     if (exports == null) {
       System.out.println("No exports found.");
     } else {
-      System.out.println(file.getHeader().getNumberOfSections() + " sections in file");
-      for (int i = 0; i < file.getHeader().getNumberOfSections(); i++) {
-        System.out.println("  Section " + i + ": " + file.getHeader().getSectionHeader(1 + i).getName());
-      }
-
-      DataDirectory dir = file.getHeader().getOptionalHeader().getDataDirectories().getExportTable();
-      System.out.println("Export table: RVA = 0x" + Integer.toHexString(dir.getRVA()) +
-                         ", size = 0x" + Integer.toHexString(dir.getSize()));
-
       System.out.println("DLL name: " + exports.getDLLName());
       System.out.println("Time/date stamp 0x" + Integer.toHexString(exports.getTimeDateStamp()));
       System.out.println("Major version 0x" + Integer.toHexString(exports.getMajorVersion() & 0xFFFF));
       System.out.println("Minor version 0x" + Integer.toHexString(exports.getMinorVersion() & 0xFFFF));
-      System.out.println(exports.getNumberOfNamePointers() + " functions found");
+      System.out.println(exports.getNumberOfNamePointers() + " exports found");
       for (int i = 0; i < exports.getNumberOfNamePointers(); i++) {
-        System.out.println("  0x" +
-                           Integer.toHexString(exports.getExportAddress(exports.getExportOrdinal(i))) +
-                           "  " +
-                           (exports.isExportAddressForwarder(exports.getExportOrdinal(i))  ?
-                            ("Forwarded to " + exports.getExportAddressForwarder(exports.getExportOrdinal(i))) :
-                            exports.getExportName(i)));
+        short ordinal = exports.getExportOrdinal(i);
+        System.out.print("[" + i + "] '" + exports.getExportName(i) + "': [" +
+            ordinal + "] = 0x" + Integer.toHexString(exports.getExportAddress(ordinal)));
+        System.out.println(exports.isExportAddressForwarder(ordinal)
+            ? "  Forwarded to '" + exports.getExportAddressForwarder(ordinal) + "'"
+            : "");
       }
     }
   }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/TestParser.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/win32/coff/TestParser.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -42,8 +42,8 @@
       COFFHeader header = file.getHeader();
       int numSections = header.getNumberOfSections();
       System.out.println(numSections + " sections detected.");
-      for (int i = 0; i < numSections; i++) {
-        SectionHeader secHeader = header.getSectionHeader(1 + i);
+      for (int i = 1; i <= numSections; i++) {
+        SectionHeader secHeader = header.getSectionHeader(i);
         System.out.println(secHeader.getName());
       }
 
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/windbg/WindbgDebuggerLocal.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -506,7 +506,6 @@
     throw new DebuggerException("Unimplemented");
   }
 
-  private static String  DTFWHome;
   private static String  imagePath;
   private static String  symbolPath;
   private static boolean useNativeLookup;
@@ -514,81 +513,143 @@
     static {
 
      /*
-      * sawindbg.dll depends on dbgeng.dll which
-      * itself depends on dbghelp.dll. dbgeng.dll and dbghelp.dll.
-      * On systems newer than Windows 2000, these two .dlls are
-      * in the standard system directory so we will find them there.
-      * On Windows 2000 and earlier, these files do not exist.
-      * The user must download Debugging Tools For Windows (DTFW)
-      * and install it in order to use SA.
+      * sawindbg.dll depends on dbgeng.dll which itself depends on
+      * dbghelp.dll. We have to make sure that the dbgeng.dll and
+      * dbghelp.dll that we load are compatible with each other. We
+      * load both of those libraries from the same directory based
+      * on the theory that co-located libraries are compatible.
+      *
+      * On Windows 2000 and earlier, dbgeng.dll and dbghelp.dll were
+      * not included as part of the standard system directory. On
+      * systems newer than Windows 2000, dbgeng.dll and dbghelp.dll
+      * are included in the standard system directory. However, the
+      * versions included in the standard system directory may not
+      * be able to handle symbol information for the newer compilers.
+      *
+      * We search for and explicitly load the libraries using the
+      * following directory search order:
       *
-      * We have to make sure we use the two files from the same directory
-      * in case there are more than one copy on the system because
-      * one version of dbgeng.dll might not be compatible with a
-      * different version of dbghelp.dll.
-      * We first look for them in the directory pointed at by
-      * env. var. DEBUGGINGTOOLSFORWINDOWS, next in the default
-      * installation dir for DTFW, and lastly in the standard
-      * system directory.  We expect that that we will find
-      * them in the standard system directory on all systems
-      * newer than Windows 2000.
+      * - java.home/bin (same as $JAVA_HOME/jre/bin)
+      * - dir named by DEBUGGINGTOOLSFORWINDOWS environment variable
+      * - various "Debugging Tools For Windows" program directories
+      * - the system directory ($SYSROOT/system32)
+      *
+      * If SA is invoked with -Dsun.jvm.hotspot.loadLibrary.DEBUG=1,
+      * then debug messages about library loading are printed to
+      * System.err.
       */
-    String dirName = null;
-    DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS");
 
-    if (DTFWHome == null) {
-      // See if we have the files in the default location.
-      String sysRoot = System.getenv("SYSTEMROOT");
-      DTFWHome = sysRoot + File.separator +
-          ".." + File.separator + "Program Files" +
-          File.separator + "Debugging Tools For Windows";
-    }
+    String dbgengPath   = null;
+    String dbghelpPath  = null;
+    String sawindbgPath = null;
+    List   searchList   = new ArrayList();
+
+    boolean loadLibraryDEBUG =
+        System.getProperty("sun.jvm.hotspot.loadLibrary.DEBUG") != null;
 
     {
-      String dbghelp = DTFWHome + File.separator + "dbghelp.dll";
-      String dbgeng = DTFWHome + File.separator + "dbgeng.dll";
-      File fhelp = new File(dbghelp);
-      File feng = new File(dbgeng);
-      if (fhelp.exists() && feng.exists()) {
-        // found both, we are happy.
-        // NOTE: The order of loads is important! If we load dbgeng.dll
-        // first, then the dependency - dbghelp.dll - will be loaded
-        // from usual DLL search thereby defeating the purpose!
-        System.load(dbghelp);
-        System.load(dbgeng);
-      } else if (! fhelp.exists() && ! feng.exists()) {
-        // neither exist. We will ignore this dir and assume
-        // they are in the system dir.
-        DTFWHome = null;
-      } else {
-        // one exists but not the other
-        //System.err.println("Error: Both files dbghelp.dll and dbgeng.dll "
-        //                   "must exist in directory " + DTFWHome);
-        throw new UnsatisfiedLinkError("Both files dbghelp.dll and " +
-                                       "dbgeng.dll must exist in " +
-                                       "directory " + DTFWHome);
+      // First place to search is co-located with sawindbg.dll in
+      // $JAVA_HOME/jre/bin (java.home property is set to $JAVA_HOME/jre):
+      searchList.add(System.getProperty("java.home") + File.separator + "bin");
+      sawindbgPath = (String) searchList.get(0) + File.separator +
+          "sawindbg.dll";
+
+      // second place to search is specified by an environment variable:
+      String DTFWHome = System.getenv("DEBUGGINGTOOLSFORWINDOWS");
+      if (DTFWHome != null) {
+        searchList.add(DTFWHome);
       }
-    }
-    if (DTFWHome == null) {
-      // The files better be in the system dir.
-      String sysDir = System.getenv("SYSTEMROOT") +
-          File.separator + "system32";
 
-      File feng = new File(sysDir + File.separator + "dbgeng.dll");
-      if (!feng.exists()) {
-        throw new UnsatisfiedLinkError("File dbgeng.dll does not exist in " +
-                                        sysDir + ".  Please search microsoft.com " +
-                                       "for Debugging Tools For Windows, and " +
-                                       "either download it to the default " +
-                                       "location, or download it to a custom " +
-                                       "location and set environment variable " +
-                                       "   DEBUGGINGTOOLSFORWINDOWS  "  +
-                                       "to the pathname of that location.");
-      }
+      // The third place to search is the install directory for the
+      // "Debugging Tools For Windows" package; so far there are three
+      // name variations that we know of:
+      String sysRoot = System.getenv("SYSTEMROOT");
+      DTFWHome = sysRoot + File.separator + ".." + File.separator +
+          "Program Files" + File.separator + "Debugging Tools For Windows";
+      searchList.add(DTFWHome);
+      searchList.add(DTFWHome + " (x86)");
+      searchList.add(DTFWHome + " (x64)");
+
+      // The last place to search is the system directory:
+      searchList.add(sysRoot + File.separator + "system32");
     }
 
+    for (int i = 0; i < searchList.size(); i++) {
+      File dir = new File((String) searchList.get(i));
+      if (!dir.exists()) {
+        if (loadLibraryDEBUG) {
+          System.err.println("DEBUG: '" + searchList.get(i) +
+              "': directory does not exist.");
+        }
+        // this search directory doesn't exist so skip it
+        continue;
+      }
+
+      dbgengPath = (String) searchList.get(i) + File.separator + "dbgeng.dll";
+      dbghelpPath = (String) searchList.get(i) + File.separator + "dbghelp.dll";
+
+      File feng = new File(dbgengPath);
+      File fhelp = new File(dbghelpPath);
+      if (feng.exists() && fhelp.exists()) {
+        // both files exist so we have a match
+        break;
+      }
+
+      // At least one of the files does not exist; no warning if both
+      // don't exist. If just one doesn't exist then we don't check
+      // loadLibraryDEBUG because we have a mis-configured system.
+      if (feng.exists()) {
+        System.err.println("WARNING: found '" + dbgengPath +
+            "' but did not find '" + dbghelpPath + "'; ignoring '" +
+            dbgengPath + "'.");
+      } else if (fhelp.exists()) {
+        System.err.println("WARNING: found '" + dbghelpPath +
+            "' but did not find '" + dbgengPath + "'; ignoring '" +
+            dbghelpPath + "'.");
+      } else if (loadLibraryDEBUG) {
+        System.err.println("DEBUG: searched '" + searchList.get(i) +
+          "': dbgeng.dll and dbghelp.dll were not found.");
+      }
+      dbgengPath = null;
+      dbghelpPath = null;
+    }
+
+    if (dbgengPath == null || dbghelpPath == null) {
+      // at least one of the files wasn't found anywhere we searched
+      String mesg = null;
+
+      if (dbgengPath == null && dbghelpPath == null) {
+        mesg = "dbgeng.dll and dbghelp.dll cannot be found. ";
+      } else if (dbgengPath == null) {
+        mesg = "dbgeng.dll cannot be found (dbghelp.dll was found). ";
+      } else {
+        mesg = "dbghelp.dll cannot be found (dbgeng.dll was found). ";
+      }
+      throw new UnsatisfiedLinkError(mesg +
+          "Please search microsoft.com for 'Debugging Tools For Windows', " +
+          "and either download it to the default location, or download it " +
+          "to a custom location and set environment variable " +
+          "'DEBUGGINGTOOLSFORWINDOWS' to the pathname of that location.");
+    }
+
+    // NOTE: The order of loads is important! If we load dbgeng.dll
+    // first, then the dependency - dbghelp.dll - will be loaded
+    // from usual DLL search thereby defeating the purpose!
+    if (loadLibraryDEBUG) {
+      System.err.println("DEBUG: loading '" + dbghelpPath + "'.");
+    }
+    System.load(dbghelpPath);
+    if (loadLibraryDEBUG) {
+      System.err.println("DEBUG: loading '" + dbgengPath + "'.");
+    }
+    System.load(dbgengPath);
+
     // Now, load sawindbg.dll
-    System.loadLibrary("sawindbg");
+    if (loadLibraryDEBUG) {
+      System.err.println("DEBUG: loading '" + sawindbgPath + "'.");
+    }
+    System.load(sawindbgPath);
+
     // where do I find '.exe', '.dll' files?
     imagePath = System.getProperty("sun.jvm.hotspot.debugger.windbg.imagePath");
     if (imagePath == null) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/classbrowser/HTMLGenerator.java	Wed Jan 19 21:51:10 2011 -0800
@@ -30,6 +30,7 @@
 import sun.jvm.hotspot.asm.sparc.*;
 import sun.jvm.hotspot.asm.x86.*;
 import sun.jvm.hotspot.asm.ia64.*;
+import sun.jvm.hotspot.asm.amd64.*;
 import sun.jvm.hotspot.code.*;
 import sun.jvm.hotspot.compiler.*;
 import sun.jvm.hotspot.debugger.*;
@@ -198,6 +199,8 @@
          cpuHelper = new SPARCHelper();
       } else if (cpu.equals("x86")) {
          cpuHelper = new X86Helper();
+      } else if (cpu.equals("amd64")) {
+         cpuHelper = new AMD64Helper();
       } else if (cpu.equals("ia64")) {
          cpuHelper = new IA64Helper();
       } else {
--- a/hotspot/make/hotspot_version	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/make/hotspot_version	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 # 
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 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
@@ -31,11 +31,11 @@
 #
 
 # Don't put quotes (fail windows build).
-HOTSPOT_VM_COPYRIGHT=Copyright 2010
+HOTSPOT_VM_COPYRIGHT=Copyright 2011
 
 HS_MAJOR_VER=20
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=05
+HS_BUILD_NUMBER=06
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=7
--- a/hotspot/make/jprt.properties	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/make/jprt.properties	Wed Jan 19 21:51:10 2011 -0800
@@ -150,6 +150,7 @@
 
 jprt.my.solaris.sparc.test.targets= \
     ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jvm98, \
+    ${jprt.my.solaris.sparc}-{product|fastdebug}-c2-jvm98_tiered, \
     ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-scimark, \
     ${jprt.my.solaris.sparc}-product-{c1|c2}-runThese, \
     ${jprt.my.solaris.sparc}-fastdebug-c1-runThese_Xshare, \
@@ -168,6 +169,7 @@
     ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_G1, \
     ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-GCOld_ParOldGC, \
     ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_default, \
+    ${jprt.my.solaris.sparc}-{product|fastdebug}-c2-jbb_default_tiered, \
     ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_SerialGC, \
     ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_ParallelGC, \
     ${jprt.my.solaris.sparc}-{product|fastdebug}-{c1|c2}-jbb_CMS, \
@@ -176,6 +178,7 @@
 
 jprt.my.solaris.sparcv9.test.targets= \
     ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jvm98, \
+    ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jvm98_tiered, \
     ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-scimark, \
     ${jprt.my.solaris.sparcv9}-product-c2-runThese, \
     ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GCBasher_default, \
@@ -193,6 +196,7 @@
     ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GCOld_G1, \
     ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-GCOld_ParOldGC, \
     ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_default, \
+    ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_default_tiered, \
     ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_SerialGC, \
     ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_ParallelGC, \
     ${jprt.my.solaris.sparcv9}-{product|fastdebug}-c2-jbb_CMS, \
@@ -201,6 +205,7 @@
 
 jprt.my.solaris.x64.test.targets= \
     ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jvm98, \
+    ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jvm98_tiered, \
     ${jprt.my.solaris.x64}-{product|fastdebug}-c2-scimark, \
     ${jprt.my.solaris.x64}-product-c2-runThese, \
     ${jprt.my.solaris.x64}-product-c2-runThese_Xcomp, \
@@ -219,6 +224,7 @@
     ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GCOld_G1, \
     ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GCOld_ParOldGC, \
     ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jbb_default, \
+    ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jbb_default_tiered, \
     ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jbb_SerialGC, \
     ${jprt.my.solaris.x64}-{product|fastdebug}-c2-jbb_ParallelGC, \
     ${jprt.my.solaris.x64}-{product|fastdebug}-c2-GCOld_CMS, \
@@ -227,6 +233,7 @@
 
 jprt.my.solaris.i586.test.targets= \
     ${jprt.my.solaris.i586}-{product|fastdebug}-{c1|c2}-jvm98, \
+    ${jprt.my.solaris.i586}-{product|fastdebug}-c2-jvm98_tiered, \
     ${jprt.my.solaris.i586}-{product|fastdebug}-{c1|c2}-scimark, \
     ${jprt.my.solaris.i586}-product-{c1|c2}-runThese_Xcomp, \
     ${jprt.my.solaris.i586}-fastdebug-c1-runThese_Xcomp, \
@@ -253,6 +260,7 @@
     ${jprt.my.solaris.i586}-product-c1-GCOld_G1, \
     ${jprt.my.solaris.i586}-product-c1-GCOld_ParOldGC, \
     ${jprt.my.solaris.i586}-fastdebug-c2-jbb_default, \
+    ${jprt.my.solaris.i586}-fastdebug-c2-jbb_default_tiered, \
     ${jprt.my.solaris.i586}-fastdebug-c2-jbb_ParallelGC, \
     ${jprt.my.solaris.i586}-fastdebug-c2-jbb_CMS, \
     ${jprt.my.solaris.i586}-fastdebug-c2-jbb_G1, \
@@ -260,6 +268,7 @@
 
 jprt.my.linux.i586.test.targets = \
     ${jprt.my.linux.i586}-{product|fastdebug}-{c1|c2}-jvm98, \
+    ${jprt.my.linux.i586}-{product|fastdebug}-c2-jvm98_tiered, \
     ${jprt.my.linux.i586}-{product|fastdebug}-{c1|c2}-scimark, \
     ${jprt.my.linux.i586}-product-c1-runThese_Xcomp, \
     ${jprt.my.linux.i586}-fastdebug-c1-runThese_Xshare, \
@@ -279,6 +288,7 @@
     ${jprt.my.linux.i586}-product-{c1|c2}-GCOld_G1, \
     ${jprt.my.linux.i586}-product-{c1|c2}-GCOld_ParOldGC, \
     ${jprt.my.linux.i586}-{product|fastdebug}-c1-jbb_default, \
+    ${jprt.my.linux.i586}-{product|fastdebug}-c2-jbb_default_tiered, \
     ${jprt.my.linux.i586}-{product|fastdebug}-c1-jbb_ParallelGC, \
     ${jprt.my.linux.i586}-{product|fastdebug}-c1-jbb_CMS, \
     ${jprt.my.linux.i586}-{product|fastdebug}-c1-jbb_G1, \
@@ -286,6 +296,7 @@
 
 jprt.my.linux.x64.test.targets = \
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-jvm98, \
+    ${jprt.my.linux.x64}-{product|fastdebug}-c2-jvm98_tiered, \
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-scimark, \
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-GCBasher_default, \
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-GCBasher_SerialGC, \
@@ -302,12 +313,14 @@
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-GCOld_G1, \
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-GCOld_ParOldGC, \
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_default, \
+    ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_default_tiered, \
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_ParallelGC, \
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_G1, \
     ${jprt.my.linux.x64}-{product|fastdebug}-c2-jbb_ParOldGC
 
 jprt.my.windows.i586.test.targets = \
     ${jprt.my.windows.i586}-{product|fastdebug}-{c1|c2}-jvm98, \
+    ${jprt.my.windows.i586}-{product|fastdebug}-c2-jvm98_tiered, \
     ${jprt.my.windows.i586}-{product|fastdebug}-{c1|c2}-scimark, \
     ${jprt.my.windows.i586}-product-{c1|c2}-runThese, \
     ${jprt.my.windows.i586}-product-{c1|c2}-runThese_Xcomp, \
@@ -327,6 +340,7 @@
     ${jprt.my.windows.i586}-product-{c1|c2}-GCOld_G1, \
     ${jprt.my.windows.i586}-product-{c1|c2}-GCOld_ParOldGC, \
     ${jprt.my.windows.i586}-{product|fastdebug}-{c1|c2}-jbb_default, \
+    ${jprt.my.windows.i586}-{product|fastdebug}-c2-jbb_default_tiered, \
     ${jprt.my.windows.i586}-product-{c1|c2}-jbb_ParallelGC, \
     ${jprt.my.windows.i586}-product-{c1|c2}-jbb_CMS, \
     ${jprt.my.windows.i586}-product-{c1|c2}-jbb_G1, \
@@ -334,6 +348,7 @@
 
 jprt.my.windows.x64.test.targets = \
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-jvm98, \
+    ${jprt.my.windows.x64}-{product|fastdebug}-c2-jvm98_tiered, \
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-scimark, \
     ${jprt.my.windows.x64}-product-c2-runThese, \
     ${jprt.my.windows.x64}-product-c2-runThese_Xcomp, \
@@ -351,6 +366,7 @@
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCOld_G1, \
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCOld_ParOldGC, \
     ${jprt.my.windows.x64}-{product|fastdebug}-c2-jbb_default, \
+    ${jprt.my.windows.x64}-{product|fastdebug}-c2-jbb_default_tiered, \
     ${jprt.my.windows.x64}-product-c2-jbb_CMS, \
     ${jprt.my.windows.x64}-product-c2-jbb_ParallelGC, \
     ${jprt.my.windows.x64}-product-c2-jbb_G1, \
--- a/hotspot/make/solaris/makefiles/buildtree.make	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/make/solaris/makefiles/buildtree.make	Wed Jan 19 21:51:10 2011 -0800
@@ -61,7 +61,7 @@
 QUIETLY$(MAKE_VERBOSE)	= @
 
 # For now, until the compiler is less wobbly:
-TESTFLAGS	= -Xbatch -showversion
+TESTFLAGS	= -Xbatch -Xmx32m -showversion
 
 ### maye ARCH_XXX instead?
 ifdef USE_GCC
--- a/hotspot/make/solaris/makefiles/vm.make	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/make/solaris/makefiles/vm.make	Wed Jan 19 21:51:10 2011 -0800
@@ -119,6 +119,10 @@
 LIBS += -lsocket -lsched -ldl $(LIBM) -lthread -lc -ldemangle
 endif # sparcWorks
 
+ifeq ("${Platform_arch}", "sparc")
+LIBS += -lkstat
+endif
+
 # By default, link the *.o into the library, not the executable.
 LINK_INTO$(LINK_INTO) = LIBJVM
 
--- a/hotspot/make/windows/makefiles/compile.make	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/make/windows/makefiles/compile.make	Wed Jan 19 21:51:10 2011 -0800
@@ -152,7 +152,7 @@
 !endif
 
 # Always add the _STATIC_CPPLIB flag
-STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB
+STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
 MS_RUNTIME_OPTION = $(MS_RUNTIME_OPTION) $(STATIC_CPPLIB_OPTION)
 CPP_FLAGS=$(CPP_FLAGS) $(MS_RUNTIME_OPTION)
 
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp	Wed Jan 19 21:51:10 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
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "asm/assembler.hpp"
 #include "assembler_sparc.inline.hpp"
 #include "gc_interface/collectedHeap.inline.hpp"
 #include "interpreter/interpreter.hpp"
@@ -1327,37 +1328,38 @@
 }
 
 
-int MacroAssembler::size_of_sethi(address a, bool worst_case) {
+int MacroAssembler::insts_for_sethi(address a, bool worst_case) {
 #ifdef _LP64
-  if (worst_case) return 7;
-  intptr_t iaddr = (intptr_t)a;
-  int hi32 = (int)(iaddr >> 32);
-  int lo32 = (int)(iaddr);
-  int inst_count;
-  if (hi32 == 0 && lo32 >= 0)
-    inst_count = 1;
-  else if (hi32 == -1)
-    inst_count = 2;
+  if (worst_case)  return 7;
+  intptr_t iaddr = (intptr_t) a;
+  int msb32 = (int) (iaddr >> 32);
+  int lsb32 = (int) (iaddr);
+  int count;
+  if (msb32 == 0 && lsb32 >= 0)
+    count = 1;
+  else if (msb32 == -1)
+    count = 2;
   else {
-    inst_count = 2;
-    if ( hi32 & 0x3ff )
-      inst_count++;
-    if ( lo32 & 0xFFFFFC00 ) {
-      if( (lo32 >> 20) & 0xfff ) inst_count += 2;
-      if( (lo32 >> 10) & 0x3ff ) inst_count += 2;
+    count = 2;
+    if (msb32 & 0x3ff)
+      count++;
+    if (lsb32 & 0xFFFFFC00 ) {
+      if ((lsb32 >> 20) & 0xfff)  count += 2;
+      if ((lsb32 >> 10) & 0x3ff)  count += 2;
     }
   }
-  return BytesPerInstWord * inst_count;
+  return count;
 #else
-  return BytesPerInstWord;
+  return 1;
 #endif
 }
 
-int MacroAssembler::worst_case_size_of_set() {
-  return size_of_sethi(NULL, true) + 1;
+int MacroAssembler::worst_case_insts_for_set() {
+  return insts_for_sethi(NULL, true) + 1;
 }
 
 
+// Keep in sync with MacroAssembler::insts_for_internal_set
 void MacroAssembler::internal_set(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) {
   intptr_t value = addrlit.value();
 
@@ -1379,6 +1381,23 @@
   }
 }
 
+// Keep in sync with MacroAssembler::internal_set
+int MacroAssembler::insts_for_internal_set(intptr_t value) {
+  // can optimize
+  if (-4096 <= value && value <= 4095) {
+    return 1;
+  }
+  if (inv_hi22(hi22(value)) == value) {
+    return insts_for_sethi((address) value);
+  }
+  int count = insts_for_sethi((address) value);
+  AddressLiteral al(value);
+  if (al.low10() != 0) {
+    count++;
+  }
+  return count;
+}
+
 void MacroAssembler::set(const AddressLiteral& al, Register d) {
   internal_set(al, d, false);
 }
@@ -1443,11 +1462,11 @@
   }
 }
 
-int MacroAssembler::size_of_set64(jlong value) {
+int MacroAssembler::insts_for_set64(jlong value) {
   v9_dep();
 
-  int hi = (int)(value >> 32);
-  int lo = (int)(value & ~0);
+  int hi = (int) (value >> 32);
+  int lo = (int) (value & ~0);
   int count = 0;
 
   // (Matcher::isSimpleConstant64 knows about the following optimizations.)
@@ -4083,11 +4102,15 @@
   store_klass(t2, top);
   verify_oop(top);
 
+  ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t1);
+  sub(top, t1, t1); // size of tlab's allocated portion
+  incr_allocated_bytes(t1, 0, t2);
+
   // refill the tlab with an eden allocation
   bind(do_refill);
   ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t1);
   sll_ptr(t1, LogHeapWordSize, t1);
-  // add object_size ??
+  // allocate new tlab, address returned in top
   eden_allocate(top, t1, 0, t2, t3, slow_case);
 
   st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_start_offset()));
@@ -4115,6 +4138,22 @@
   delayed()->nop();
 }
 
+void MacroAssembler::incr_allocated_bytes(Register var_size_in_bytes,
+                                          int con_size_in_bytes,
+                                          Register t1) {
+  // Bump total bytes allocated by this thread
+  assert(t1->is_global(), "must be global reg"); // so all 64 bits are saved on a context switch
+  assert_different_registers(var_size_in_bytes, t1);
+  // v8 support has gone the way of the dodo
+  ldx(G2_thread, in_bytes(JavaThread::allocated_bytes_offset()), t1);
+  if (var_size_in_bytes->is_valid()) {
+    add(t1, var_size_in_bytes, t1);
+  } else {
+    add(t1, con_size_in_bytes, t1);
+  }
+  stx(t1, G2_thread, in_bytes(JavaThread::allocated_bytes_offset()));
+}
+
 Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
   switch (cond) {
     // Note some conditions are synonyms for others
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp	Wed Jan 19 21:51:10 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
@@ -1884,23 +1884,24 @@
   void sethi(const AddressLiteral& addrlit, Register d);
   void patchable_sethi(const AddressLiteral& addrlit, Register d);
 
-  // compute the size of a sethi/set
-  static int  size_of_sethi( address a, bool worst_case = false );
-  static int  worst_case_size_of_set();
+  // compute the number of instructions for a sethi/set
+  static int  insts_for_sethi( address a, bool worst_case = false );
+  static int  worst_case_insts_for_set();
 
   // set may be either setsw or setuw (high 32 bits may be zero or sign)
 private:
   void internal_set(const AddressLiteral& al, Register d, bool ForceRelocatable);
+  static int insts_for_internal_set(intptr_t value);
 public:
   void set(const AddressLiteral& addrlit, Register d);
   void set(intptr_t value, Register d);
   void set(address addr, Register d, RelocationHolder const& rspec);
+  static int insts_for_set(intptr_t value) { return insts_for_internal_set(value); }
+
   void patchable_set(const AddressLiteral& addrlit, Register d);
   void patchable_set(intptr_t value, Register d);
   void set64(jlong value, Register d, Register tmp);
-
-  // Compute size of set64.
-  static int size_of_set64(jlong value);
+  static int insts_for_set64(jlong value);
 
   // sign-extend 32 to 64
   inline void signx( Register s, Register d ) { sra( s, G0, d); }
@@ -2388,6 +2389,7 @@
     Label&   slow_case                 // continuation point if fast allocation fails
   );
   void tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case);
+  void incr_allocated_bytes(Register var_size_in_bytes, int con_size_in_bytes, Register t1);
 
   // interface method calling
   void lookup_interface_method(Register recv_klass,
--- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -1705,8 +1705,7 @@
 }
 
 
-void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result) {
-
+void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
   Assembler::Condition acond;
   switch (condition) {
     case lir_cond_equal:        acond = Assembler::equal;        break;
@@ -1737,7 +1736,12 @@
     ShouldNotReachHere();
   }
   Label skip;
-  __ br(acond, false, Assembler::pt, skip);
+#ifdef _LP64
+    if  (type == T_INT) {
+      __ br(acond, false, Assembler::pt, skip);
+    } else
+#endif
+      __ brx(acond, false, Assembler::pt, skip); // checks icc on 32bit and xcc on 64bit
   if (opr1->is_constant() && opr1->type() == T_INT) {
     Register dest = result->as_register();
     if (Assembler::is_simm13(opr1->as_jint())) {
@@ -2688,6 +2692,11 @@
 #ifdef _LP64
     __ mov(cmp_value_lo, t1);
     __ mov(new_value_lo, t2);
+    // perform the compare and swap operation
+    __ casx(addr, t1, t2);
+    // generate condition code - if the swap succeeded, t2 ("new value" reg) was
+    // overwritten with the original value in "addr" and will be equal to t1.
+    __ cmp(t1, t2);
 #else
     // move high and low halves of long values into single registers
     __ sllx(cmp_value_hi, 32, t1);         // shift high half into temp reg
@@ -2696,13 +2705,15 @@
     __ sllx(new_value_hi, 32, t2);
     __ srl(new_value_lo, 0, new_value_lo);
     __ or3(t2, new_value_lo, t2);          // t2 holds 64-bit value to swap
-#endif
     // perform the compare and swap operation
     __ casx(addr, t1, t2);
     // generate condition code - if the swap succeeded, t2 ("new value" reg) was
     // overwritten with the original value in "addr" and will be equal to t1.
-    __ cmp(t1, t2);
-
+    // Produce icc flag for 32bit.
+    __ sub(t1, t2, t2);
+    __ srlx(t2, 32, t1);
+    __ orcc(t2, t1, G0);
+#endif
   } else if (op->code() == lir_cas_int || op->code() == lir_cas_obj) {
     Register addr = op->addr()->as_pointer_register();
     Register cmp_value = op->cmp_value()->as_register();
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -662,7 +662,7 @@
 
   // generate conditional move of boolean result
   LIR_Opr result = rlock_result(x);
-  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result);
+  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result, T_LONG);
 }
 
 
@@ -699,10 +699,10 @@
   else {
     ShouldNotReachHere();
   }
-
   // generate conditional move of boolean result
   LIR_Opr result = rlock_result(x);
-  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result);
+  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0),
+           result, as_BasicType(type));
   if (type == objectType) {  // Write-barrier needed for Object fields.
     // Precise card mark since could either be object or array
     post_barrier(addr, val.result());
--- a/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -166,7 +166,7 @@
   Register obj,                        // result: pointer to object after successful allocation
   Register var_size_in_bytes,          // object size in bytes if unknown at compile time; invalid otherwise
   int      con_size_in_bytes,          // object size in bytes if   known at compile time
-  Register t1,                         // temp register
+  Register t1,                         // temp register, must be global register for incr_allocated_bytes
   Register t2,                         // temp register
   Label&   slow_case                   // continuation point if fast allocation fails
 ) {
@@ -174,6 +174,7 @@
     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case);
   } else {
     eden_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
+    incr_allocated_bytes(var_size_in_bytes, con_size_in_bytes, t1);
   }
 }
 
@@ -214,7 +215,7 @@
 void C1_MacroAssembler::allocate_object(
   Register obj,                        // result: pointer to object after successful allocation
   Register t1,                         // temp register
-  Register t2,                         // temp register
+  Register t2,                         // temp register, must be a global register for try_allocate
   Register t3,                         // temp register
   int      hdr_size,                   // object header size in words
   int      obj_size,                   // object size in words
--- a/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/c1_MacroAssembler_sparc.hpp	Wed Jan 19 21:51:10 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
--- a/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/c1_Runtime1_sparc.cpp	Wed Jan 19 21:51:10 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
@@ -448,7 +448,9 @@
 
           // get the instance size
           __ ld(G5_klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes(), G1_obj_size);
+
           __ tlab_allocate(O0_obj, G1_obj_size, 0, G3_t1, slow_path);
+
           __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2);
           __ verify_oop(O0_obj);
           __ mov(O0, I0);
@@ -459,6 +461,8 @@
           // get the instance size
           __ ld(G5_klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes(), G1_obj_size);
           __ eden_allocate(O0_obj, G1_obj_size, 0, G3_t1, G4_t2, slow_path);
+          __ incr_allocated_bytes(G1_obj_size, 0, G3_t1);
+
           __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2);
           __ verify_oop(O0_obj);
           __ mov(O0, I0);
@@ -573,6 +577,7 @@
           __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size);
 
           __ eden_allocate(O0_obj, G1_arr_size, 0, G3_t1, O1_t2, slow_path);  // preserves G1_arr_size
+          __ incr_allocated_bytes(G1_arr_size, 0, G3_t1);
 
           __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2);
           __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset);
--- a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -395,18 +395,23 @@
 //
 // Generate an "entry" field for a method handle.
 // This determines how the method handle will respond to calls.
-void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) {
+void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek, TRAPS) {
   // Here is the register state during an interpreted call,
   // as set up by generate_method_handle_interpreter_entry():
   // - G5: garbage temp (was MethodHandle.invoke methodOop, unused)
   // - G3: receiver method handle
   // - O5_savedSP: sender SP (must preserve)
 
-  Register O0_argslot = O0;
-  Register O1_scratch = O1;
-  Register O2_scratch = O2;
-  Register O3_scratch = O3;
-  Register G5_index   = G5;
+  const Register O0_argslot = O0;
+  const Register O1_scratch = O1;
+  const Register O2_scratch = O2;
+  const Register O3_scratch = O3;
+  const Register G5_index   = G5;
+
+  // Argument registers for _raise_exception.
+  const Register O0_code     = O0;
+  const Register O1_actual   = O1;
+  const Register O2_required = O2;
 
   guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
 
@@ -439,48 +444,36 @@
   case _raise_exception:
     {
       // Not a real MH entry, but rather shared code for raising an
-      // exception.  Extra local arguments are passed in scratch
-      // registers, as required type in O3, failing object (or NULL)
-      // in O2, failing bytecode type in O1.
+      // exception.  Since we use a C2I adapter to set up the
+      // interpreter state, arguments are expected in compiler
+      // argument registers.
+      methodHandle mh(raise_exception_method());
+      address c2i_entry = methodOopDesc::make_adapters(mh, CATCH);
 
       __ mov(O5_savedSP, SP);  // Cut the stack back to where the caller started.
 
-      // Push arguments as if coming from the interpreter.
-      Register O0_scratch = O0_argslot;
-      int stackElementSize = Interpreter::stackElementSize;
-
-      // Make space on the stack for the arguments and set Gargs
-      // correctly.
-      __ sub(SP, 4*stackElementSize, SP);  // Keep stack aligned.
-      __ add(SP, (frame::varargs_offset)*wordSize - 1*Interpreter::stackElementSize + STACK_BIAS + BytesPerWord, Gargs);
-
-      // void raiseException(int code, Object actual, Object required)
-      __ st(    O1_scratch, Address(Gargs, 2*stackElementSize));  // code
-      __ st_ptr(O2_scratch, Address(Gargs, 1*stackElementSize));  // actual
-      __ st_ptr(O3_scratch, Address(Gargs, 0*stackElementSize));  // required
-
-      Label no_method;
+      Label L_no_method;
       // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
       __ set(AddressLiteral((address) &_raise_exception_method), G5_method);
       __ ld_ptr(Address(G5_method, 0), G5_method);
       __ tst(G5_method);
-      __ brx(Assembler::zero, false, Assembler::pn, no_method);
+      __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
       __ delayed()->nop();
 
-      int jobject_oop_offset = 0;
+      const int jobject_oop_offset = 0;
       __ ld_ptr(Address(G5_method, jobject_oop_offset), G5_method);
       __ tst(G5_method);
-      __ brx(Assembler::zero, false, Assembler::pn, no_method);
+      __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
       __ delayed()->nop();
 
       __ verify_oop(G5_method);
-      __ jump_indirect_to(G5_method_fie, O1_scratch);
+      __ jump_to(AddressLiteral(c2i_entry), O3_scratch);
       __ delayed()->nop();
 
       // If we get here, the Java runtime did not do its job of creating the exception.
       // Do something that is at least causes a valid throw from the interpreter.
-      __ bind(no_method);
-      __ unimplemented("_raise_exception no method");
+      __ bind(L_no_method);
+      __ unimplemented("call throw_WrongMethodType_entry");
     }
     break;
 
@@ -570,10 +563,10 @@
       // Throw an exception.
       // For historical reasons, it will be IncompatibleClassChangeError.
       __ unimplemented("not tested yet");
-      __ ld_ptr(Address(O1_intf, java_mirror_offset), O3_scratch);  // required interface
-      __ mov(O0_klass, O2_scratch);  // bad receiver
-      __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O0_argslot);
-      __ delayed()->mov(Bytecodes::_invokeinterface, O1_scratch);  // who is complaining?
+      __ ld_ptr(Address(O1_intf, java_mirror_offset), O2_required);  // required interface
+      __ mov(   O0_klass,                             O1_actual);    // bad receiver
+      __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O3_scratch);
+      __ delayed()->mov(Bytecodes::_invokeinterface,  O0_code);      // who is complaining?
     }
     break;
 
@@ -663,11 +656,10 @@
       __ check_klass_subtype(O1_scratch, G5_klass, O0_argslot, O2_scratch, done);
 
       // If we get here, the type check failed!
-      __ ldsw(G3_amh_vmargslot, O0_argslot);  // reload argslot field
-      __ load_heap_oop(G3_amh_argument, O3_scratch);  // required class
-      __ ld_ptr(vmarg, O2_scratch);  // bad object
-      __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O0_argslot);
-      __ delayed()->mov(Bytecodes::_checkcast, O1_scratch);  // who is complaining?
+      __ load_heap_oop(G3_amh_argument,        O2_required);  // required class
+      __ ld_ptr(       vmarg,                  O1_actual);    // bad object
+      __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O3_scratch);
+      __ delayed()->mov(Bytecodes::_checkcast, O0_code);      // who is complaining?
 
       __ bind(done);
       // Get the new MH:
--- a/hotspot/src/cpu/sparc/vm/sparc.ad	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad	Wed Jan 19 21:51:10 2011 -0800
@@ -1086,9 +1086,9 @@
 uint MachConstantBaseNode::size(PhaseRegAlloc*) const {
   if (UseRDPCForConstantTableBase) {
     // This is really the worst case but generally it's only 1 instruction.
-    return 4 /*rdpc*/ + 4 /*sub*/ + MacroAssembler::worst_case_size_of_set();
+    return (1 /*rdpc*/ + 1 /*sub*/ + MacroAssembler::worst_case_insts_for_set()) * BytesPerInstWord;
   } else {
-    return MacroAssembler::worst_case_size_of_set();
+    return MacroAssembler::worst_case_insts_for_set() * BytesPerInstWord;
   }
 }
 
@@ -1240,7 +1240,7 @@
 
 int MachEpilogNode::safepoint_offset() const {
   assert( do_polling(), "no return for this epilog node");
-  return MacroAssembler::size_of_sethi(os::get_polling_page());
+  return MacroAssembler::insts_for_sethi(os::get_polling_page()) * BytesPerInstWord;
 }
 
 //=============================================================================
@@ -3553,9 +3553,10 @@
   interface(CONST_INTER);
 %}
 
-// Pointer Immediate: 32 or 64-bit
+#ifdef _LP64
+// Pointer Immediate: 64-bit
 operand immP_set() %{
-  predicate(!VM_Version::is_niagara1_plus());
+  predicate(!VM_Version::is_niagara_plus());
   match(ConP);
 
   op_cost(5);
@@ -3564,10 +3565,10 @@
   interface(CONST_INTER);
 %}
 
-// Pointer Immediate: 32 or 64-bit
+// Pointer Immediate: 64-bit
 // From Niagara2 processors on a load should be better than materializing.
 operand immP_load() %{
-  predicate(VM_Version::is_niagara1_plus());
+  predicate(VM_Version::is_niagara_plus() && (n->bottom_type()->isa_oop_ptr() || (MacroAssembler::insts_for_set(n->get_ptr()) > 3)));
   match(ConP);
 
   op_cost(5);
@@ -3576,6 +3577,18 @@
   interface(CONST_INTER);
 %}
 
+// Pointer Immediate: 64-bit
+operand immP_no_oop_cheap() %{
+  predicate(VM_Version::is_niagara_plus() && !n->bottom_type()->isa_oop_ptr() && (MacroAssembler::insts_for_set(n->get_ptr()) <= 3));
+  match(ConP);
+
+  op_cost(5);
+  // formats are generated automatically for constants and base registers
+  format %{ %}
+  interface(CONST_INTER);
+%}
+#endif
+
 operand immP13() %{
   predicate((-4096 < n->get_ptr()) && (n->get_ptr() <= 4095));
   match(ConP);
@@ -3673,7 +3686,7 @@
 
 // Long Immediate: cheap (materialize in <= 3 instructions)
 operand immL_cheap() %{
-  predicate(!VM_Version::is_niagara1_plus() || MacroAssembler::size_of_set64(n->get_long()) <= 3);
+  predicate(!VM_Version::is_niagara_plus() || MacroAssembler::insts_for_set64(n->get_long()) <= 3);
   match(ConL);
   op_cost(0);
 
@@ -3683,7 +3696,7 @@
 
 // Long Immediate: expensive (materialize in > 3 instructions)
 operand immL_expensive() %{
-  predicate(VM_Version::is_niagara1_plus() && MacroAssembler::size_of_set64(n->get_long()) > 3);
+  predicate(VM_Version::is_niagara_plus() && MacroAssembler::insts_for_set64(n->get_long()) > 3);
   match(ConL);
   op_cost(0);
 
@@ -6094,8 +6107,18 @@
   ins_cost(MEMORY_REF_COST);
   format %{ "LD     [$constanttablebase + $constantoffset],$dst\t! load from constant table: ptr=$con" %}
   ins_encode %{
-      RegisterOrConstant con_offset = __ ensure_simm13_or_reg($constantoffset($con), $dst$$Register);
-     __ ld_ptr($constanttablebase, con_offset, $dst$$Register);
+    RegisterOrConstant con_offset = __ ensure_simm13_or_reg($constantoffset($con), $dst$$Register);
+    __ ld_ptr($constanttablebase, con_offset, $dst$$Register);
+  %}
+  ins_pipe(loadConP);
+%}
+
+instruct loadConP_no_oop_cheap(iRegP dst, immP_no_oop_cheap con) %{
+  match(Set dst con);
+  ins_cost(DEFAULT_COST * 3/2);
+  format %{ "SET    $con,$dst\t! non-oop ptr" %}
+  ins_encode %{
+    __ set($con$$constant, $dst$$Register);
   %}
   ins_pipe(loadConP);
 %}
--- a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp	Wed Jan 19 21:51:10 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
@@ -3393,21 +3393,21 @@
     __ delayed()->st_ptr(RnewTopValue, G2_thread, in_bytes(JavaThread::tlab_top_offset()));
 
     if (allow_shared_alloc) {
-    // Check if tlab should be discarded (refill_waste_limit >= free)
-    __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), RtlabWasteLimitValue);
-    __ sub(RendValue, RoldTopValue, RfreeValue);
+      // Check if tlab should be discarded (refill_waste_limit >= free)
+      __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), RtlabWasteLimitValue);
+      __ sub(RendValue, RoldTopValue, RfreeValue);
 #ifdef _LP64
-    __ srlx(RfreeValue, LogHeapWordSize, RfreeValue);
+      __ srlx(RfreeValue, LogHeapWordSize, RfreeValue);
 #else
-    __ srl(RfreeValue, LogHeapWordSize, RfreeValue);
+      __ srl(RfreeValue, LogHeapWordSize, RfreeValue);
 #endif
-    __ cmp(RtlabWasteLimitValue, RfreeValue);
-    __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, slow_case); // tlab waste is small
-    __ delayed()->nop();
-
-    // increment waste limit to prevent getting stuck on this slow path
-    __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue);
-    __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
+      __ cmp(RtlabWasteLimitValue, RfreeValue);
+      __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, slow_case); // tlab waste is small
+      __ delayed()->nop();
+
+      // increment waste limit to prevent getting stuck on this slow path
+      __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue);
+      __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
     } else {
       // No allocation in the shared eden.
       __ br(Assembler::always, false, Assembler::pt, slow_case);
@@ -3445,6 +3445,9 @@
     __ cmp(RoldTopValue, RnewTopValue);
     __ brx(Assembler::notEqual, false, Assembler::pn, retry);
     __ delayed()->nop();
+
+    // bump total bytes allocated by this thread
+    __ incr_allocated_bytes(Roffset, 0, G1_scratch);
   }
 
   if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -38,12 +38,6 @@
 int VM_Version::_features = VM_Version::unknown_m;
 const char* VM_Version::_features_str = "";
 
-bool VM_Version::is_niagara1_plus() {
-  // This is a placeholder until the real test is determined.
-  return is_niagara1() &&
-    (os::processor_count() > maximum_niagara1_processor_count());
-}
-
 void VM_Version::initialize() {
   _features = determine_features();
   PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
@@ -69,11 +63,21 @@
 
   _supports_cx8               = has_v9();
 
-  if (is_niagara1()) {
+  if (is_niagara()) {
     // Indirect branch is the same cost as direct
     if (FLAG_IS_DEFAULT(UseInlineCaches)) {
       FLAG_SET_DEFAULT(UseInlineCaches, false);
     }
+    // Align loops on a single instruction boundary.
+    if (FLAG_IS_DEFAULT(OptoLoopAlignment)) {
+      FLAG_SET_DEFAULT(OptoLoopAlignment, 4);
+    }
+    // When using CMS, we cannot use memset() in BOT updates because
+    // the sun4v/CMT version in libc_psr uses BIS which exposes
+    // "phantom zeros" to concurrent readers. See 6948537.
+    if (FLAG_IS_DEFAULT(UseMemSetInBOT) && UseConcMarkSweepGC) {
+      FLAG_SET_DEFAULT(UseMemSetInBOT, false);
+    }
 #ifdef _LP64
     // 32-bit oops don't make sense for the 64-bit VM on sparc
     // since the 32-bit VM has the same registers and smaller objects.
@@ -89,7 +93,7 @@
     if (FLAG_IS_DEFAULT(InteriorEntryAlignment)) {
       FLAG_SET_DEFAULT(InteriorEntryAlignment, 4);
     }
-    if (is_niagara1_plus()) {
+    if (is_niagara_plus()) {
       if (has_blk_init() && AllocatePrefetchStyle > 0 &&
           FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
         // Use BIS instruction for allocation prefetch.
@@ -105,15 +109,6 @@
       }
     }
 #endif
-    if (FLAG_IS_DEFAULT(OptoLoopAlignment)) {
-      FLAG_SET_DEFAULT(OptoLoopAlignment, 4);
-    }
-    // When using CMS, we cannot use memset() in BOT updates because
-    // the sun4v/CMT version in libc_psr uses BIS which exposes
-    // "phantom zeros" to concurrent readers. See 6948537.
-    if (FLAG_IS_DEFAULT(UseMemSetInBOT) && UseConcMarkSweepGC) {
-      FLAG_SET_DEFAULT(UseMemSetInBOT, false);
-    }
   }
 
   // Use hardware population count instruction if available.
@@ -129,17 +124,18 @@
 #endif
 
   char buf[512];
-  jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+  jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
                (has_v8() ? ", has_v8" : ""),
                (has_v9() ? ", has_v9" : ""),
                (has_hardware_popc() ? ", popc" : ""),
                (has_vis1() ? ", has_vis1" : ""),
                (has_vis2() ? ", has_vis2" : ""),
+               (has_vis3() ? ", has_vis3" : ""),
                (has_blk_init() ? ", has_blk_init" : ""),
                (is_ultra3() ? ", is_ultra3" : ""),
                (is_sun4v() ? ", is_sun4v" : ""),
-               (is_niagara1() ? ", is_niagara1" : ""),
-               (is_niagara1_plus() ? ", is_niagara1_plus" : ""),
+               (is_niagara() ? ", is_niagara" : ""),
+               (is_niagara_plus() ? ", is_niagara_plus" : ""),
                (is_sparc64() ? ", is_sparc64" : ""),
                (!has_hardware_mul32() ? ", no-mul32" : ""),
                (!has_hardware_div32() ? ", no-div32" : ""),
@@ -190,17 +186,18 @@
     warning("Cannot recognize SPARC version. Default to V9");
   }
 
-  if (UseNiagaraInstrs) {
-    if (is_niagara1(features)) {
+  assert(is_T_family(features) == is_niagara(features), "Niagara should be T series");
+  if (UseNiagaraInstrs) { // Force code generation for Niagara
+    if (is_T_family(features)) {
       // Happy to accomodate...
     } else {
       NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Niagara");)
-      features = niagara1_m;
+      features |= T_family_m;
     }
   } else {
-    if (is_niagara1(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) {
+    if (is_T_family(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) {
       NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Not-Niagara");)
-      features &= ~niagara1_unique_m;
+      features &= ~(T_family_m | T1_model_m);
     } else {
       // Happy to accomodate...
     }
@@ -222,7 +219,7 @@
 
 unsigned int VM_Version::calc_parallel_worker_threads() {
   unsigned int result;
-  if (is_niagara1_plus()) {
+  if (is_niagara_plus()) {
     result = nof_parallel_worker_threads(5, 16, 8);
   } else {
     result = nof_parallel_worker_threads(5, 8, 8);
--- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.hpp	Wed Jan 19 21:51:10 2011 -0800
@@ -41,7 +41,12 @@
     vis2_instructions  = 7,
     sun4v_instructions = 8,
     blk_init_instructions = 9,
-    fmaf_instructions  = 10
+    fmaf_instructions  = 10,
+    fmau_instructions  = 11,
+    vis3_instructions  = 12,
+    sparc64_family     = 13,
+    T_family           = 14,
+    T1_model           = 15
   };
 
   enum Feature_Flag_Set {
@@ -59,6 +64,11 @@
     sun4v_m             = 1 << sun4v_instructions,
     blk_init_instructions_m = 1 << blk_init_instructions,
     fmaf_instructions_m = 1 << fmaf_instructions,
+    fmau_instructions_m = 1 << fmau_instructions,
+    vis3_instructions_m = 1 << vis3_instructions,
+    sparc64_family_m    = 1 << sparc64_family,
+    T_family_m          = 1 << T_family,
+    T1_model_m          = 1 << T1_model,
 
     generic_v8_m        = v8_instructions_m | hardware_mul32_m | hardware_div32_m | hardware_fsmuld_m,
     generic_v9_m        = generic_v8_m | v9_instructions_m,
@@ -76,8 +86,13 @@
   static int  determine_features();
   static int  platform_features(int features);
 
-  static bool is_niagara1(int features) { return (features & sun4v_m) != 0; }
-  static bool  is_sparc64(int features) { return (features & fmaf_instructions_m) != 0; }
+  // Returns true if the platform is in the niagara line (T series)
+  static bool is_T_family(int features) { return (features & T_family_m) != 0; }
+  static bool is_niagara() { return is_T_family(_features); }
+  DEBUG_ONLY( static bool is_niagara(int features)  { return (features & sun4v_m) != 0; } )
+
+  // Returns true if it is niagara1 (T1).
+  static bool is_T1_model(int features) { return is_T_family(features) && ((features & T1_model_m) != 0); }
 
   static int maximum_niagara1_processor_count() { return 32; }
 
@@ -94,6 +109,7 @@
   static bool has_hardware_popc()       { return (_features & hardware_popc_m) != 0; }
   static bool has_vis1()                { return (_features & vis1_instructions_m) != 0; }
   static bool has_vis2()                { return (_features & vis2_instructions_m) != 0; }
+  static bool has_vis3()                { return (_features & vis3_instructions_m) != 0; }
   static bool has_blk_init()            { return (_features & blk_init_instructions_m) != 0; }
 
   static bool supports_compare_and_exchange()
@@ -101,14 +117,14 @@
 
   static bool is_ultra3()               { return (_features & ultra3_m) == ultra3_m; }
   static bool is_sun4v()                { return (_features & sun4v_m) != 0; }
-  static bool is_niagara1()             { return is_niagara1(_features); }
-  // Returns true if the platform is in the niagara line and
-  // newer than the niagara1.
-  static bool is_niagara1_plus();
-  static bool is_sparc64()              { return is_sparc64(_features); }
+  // Returns true if the platform is in the niagara line (T series)
+  // and newer than the niagara1.
+  static bool is_niagara_plus()         { return is_T_family(_features) && !is_T1_model(_features); }
+  // Fujitsu SPARC64
+  static bool is_sparc64()              { return (_features & sparc64_family_m) != 0; }
 
-  static bool has_fast_fxtof()          { return has_v9() && !is_ultra3(); }
-  static bool has_fast_idiv()           { return is_niagara1_plus() || is_sparc64(); }
+  static bool has_fast_fxtof()          { return is_niagara() || is_sparc64() || has_v9() && !is_ultra3(); }
+  static bool has_fast_idiv()           { return is_niagara_plus() || is_sparc64(); }
 
   static const char* cpu_features()     { return _features_str; }
 
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp	Wed Jan 19 21:51:10 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
@@ -820,7 +820,20 @@
 }
 
 
-// Now the Assembler instruction (identical for 32/64 bits)
+// Now the Assembler instructions (identical for 32/64 bits)
+
+void Assembler::adcl(Address dst, int32_t imm32) {
+  InstructionMark im(this);
+  prefix(dst);
+  emit_arith_operand(0x81, rdx, dst, imm32);
+}
+
+void Assembler::adcl(Address dst, Register src) {
+  InstructionMark im(this);
+  prefix(dst, src);
+  emit_byte(0x11);
+  emit_operand(src, dst);
+}
 
 void Assembler::adcl(Register dst, int32_t imm32) {
   prefix(dst);
@@ -2195,9 +2208,7 @@
 void Assembler::orl(Address dst, int32_t imm32) {
   InstructionMark im(this);
   prefix(dst);
-  emit_byte(0x81);
-  emit_operand(rcx, dst, 4);
-  emit_long(imm32);
+  emit_arith_operand(0x81, rcx, dst, imm32);
 }
 
 void Assembler::orl(Register dst, int32_t imm32) {
@@ -2205,7 +2216,6 @@
   emit_arith(0x81, 0xC8, dst, imm32);
 }
 
-
 void Assembler::orl(Register dst, Address src) {
   InstructionMark im(this);
   prefix(src, dst);
@@ -2213,7 +2223,6 @@
   emit_operand(dst, src);
 }
 
-
 void Assembler::orl(Register dst, Register src) {
   (void) prefix_and_encode(dst->encoding(), src->encoding());
   emit_arith(0x0B, 0xC0, dst, src);
@@ -2692,20 +2701,7 @@
 void Assembler::subl(Address dst, int32_t imm32) {
   InstructionMark im(this);
   prefix(dst);
-  if (is8bit(imm32)) {
-    emit_byte(0x83);
-    emit_operand(rbp, dst, 1);
-    emit_byte(imm32 & 0xFF);
-  } else {
-    emit_byte(0x81);
-    emit_operand(rbp, dst, 4);
-    emit_long(imm32);
-  }
-}
-
-void Assembler::subl(Register dst, int32_t imm32) {
-  prefix(dst);
-  emit_arith(0x81, 0xE8, dst, imm32);
+  emit_arith_operand(0x81, rbp, dst, imm32);
 }
 
 void Assembler::subl(Address dst, Register src) {
@@ -2715,6 +2711,11 @@
   emit_operand(src, dst);
 }
 
+void Assembler::subl(Register dst, int32_t imm32) {
+  prefix(dst);
+  emit_arith(0x81, 0xE8, dst, imm32);
+}
+
 void Assembler::subl(Register dst, Address src) {
   InstructionMark im(this);
   prefix(src, dst);
@@ -4333,6 +4334,7 @@
   emit_byte(0xD3);
   emit_byte(0xF8 | encode);
 }
+
 void Assembler::sbbq(Address dst, int32_t imm32) {
   InstructionMark im(this);
   prefixq(dst);
@@ -4392,20 +4394,7 @@
 void Assembler::subq(Address dst, int32_t imm32) {
   InstructionMark im(this);
   prefixq(dst);
-  if (is8bit(imm32)) {
-    emit_byte(0x83);
-    emit_operand(rbp, dst, 1);
-    emit_byte(imm32 & 0xFF);
-  } else {
-    emit_byte(0x81);
-    emit_operand(rbp, dst, 4);
-    emit_long(imm32);
-  }
-}
-
-void Assembler::subq(Register dst, int32_t imm32) {
-  (void) prefixq_and_encode(dst->encoding());
-  emit_arith(0x81, 0xE8, dst, imm32);
+  emit_arith_operand(0x81, rbp, dst, imm32);
 }
 
 void Assembler::subq(Address dst, Register src) {
@@ -4415,6 +4404,11 @@
   emit_operand(src, dst);
 }
 
+void Assembler::subq(Register dst, int32_t imm32) {
+  (void) prefixq_and_encode(dst->encoding());
+  emit_arith(0x81, 0xE8, dst, imm32);
+}
+
 void Assembler::subq(Register dst, Address src) {
   InstructionMark im(this);
   prefixq(src, dst);
@@ -7136,9 +7130,9 @@
 }
 
 // Preserves rbx, and rdx.
-void MacroAssembler::tlab_refill(Label& retry,
-                                 Label& try_eden,
-                                 Label& slow_case) {
+Register MacroAssembler::tlab_refill(Label& retry,
+                                     Label& try_eden,
+                                     Label& slow_case) {
   Register top = rax;
   Register t1  = rcx;
   Register t2  = rsi;
@@ -7185,7 +7179,7 @@
 
   // if tlab is currently allocated (top or end != null) then
   // fill [top, end + alignment_reserve) with array object
-  testptr (top, top);
+  testptr(top, top);
   jcc(Assembler::zero, do_refill);
 
   // set up the mark word
@@ -7197,16 +7191,20 @@
   movl(Address(top, arrayOopDesc::length_offset_in_bytes()), t1);
   // set klass to intArrayKlass
   // dubious reloc why not an oop reloc?
-  movptr(t1, ExternalAddress((address) Universe::intArrayKlassObj_addr()));
+  movptr(t1, ExternalAddress((address)Universe::intArrayKlassObj_addr()));
   // store klass last.  concurrent gcs assumes klass length is valid if
   // klass field is not null.
   store_klass(top, t1);
 
+  movptr(t1, top);
+  subptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_start_offset())));
+  incr_allocated_bytes(thread_reg, t1, 0);
+
   // refill the tlab with an eden allocation
   bind(do_refill);
   movptr(t1, Address(thread_reg, in_bytes(JavaThread::tlab_size_offset())));
   shlptr(t1, LogHeapWordSize);
-  // add object_size ??
+  // allocate new tlab, address returned in top
   eden_allocate(top, t1, 0, t2, slow_case);
 
   // Check that t1 was preserved in eden_allocate.
@@ -7234,6 +7232,34 @@
   movptr(Address(thread_reg, in_bytes(JavaThread::tlab_end_offset())), top);
   verify_tlab();
   jmp(retry);
+
+  return thread_reg; // for use by caller
+}
+
+void MacroAssembler::incr_allocated_bytes(Register thread,
+                                          Register var_size_in_bytes,
+                                          int con_size_in_bytes,
+                                          Register t1) {
+#ifdef _LP64
+  if (var_size_in_bytes->is_valid()) {
+    addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
+  } else {
+    addq(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
+  }
+#else
+  if (!thread->is_valid()) {
+    assert(t1->is_valid(), "need temp reg");
+    thread = t1;
+    get_thread(thread);
+  }
+
+  if (var_size_in_bytes->is_valid()) {
+    addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), var_size_in_bytes);
+  } else {
+    addl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())), con_size_in_bytes);
+  }
+  adcl(Address(thread, in_bytes(JavaThread::allocated_bytes_offset())+4), 0);
+#endif
 }
 
 static const double     pi_4 =  0.7853981633974483;
--- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp	Wed Jan 19 21:51:10 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
@@ -674,12 +674,14 @@
   // Utilities
 
 #ifdef _LP64
- static bool is_simm(int64_t x, int nbits) { return -( CONST64(1) << (nbits-1) )  <= x   &&   x  <  ( CONST64(1) << (nbits-1) ); }
+ static bool is_simm(int64_t x, int nbits) { return -(CONST64(1) << (nbits-1)) <= x &&
+                                                    x < (CONST64(1) << (nbits-1)); }
  static bool is_simm32(int64_t x) { return x == (int64_t)(int32_t)x; }
 #else
- static bool is_simm(int32_t x, int nbits) { return -( 1 << (nbits-1) )  <= x   &&   x  <  ( 1 << (nbits-1) ); }
+ static bool is_simm(int32_t x, int nbits) { return -(1 << (nbits-1)) <= x &&
+                                                    x < (1 << (nbits-1)); }
  static bool is_simm32(int32_t x) { return true; }
-#endif // LP64
+#endif // _LP64
 
   // Generic instructions
   // Does 32bit or 64bit as needed for the platform. In some sense these
@@ -705,7 +707,6 @@
   void push(void* v);
   void pop(void* v);
 
-
   // These do register sized moves/scans
   void rep_mov();
   void rep_set();
@@ -716,6 +717,8 @@
 
   // Vanilla instructions in lexical order
 
+  void adcl(Address dst, int32_t imm32);
+  void adcl(Address dst, Register src);
   void adcl(Register dst, int32_t imm32);
   void adcl(Register dst, Address src);
   void adcl(Register dst, Register src);
@@ -724,7 +727,6 @@
   void adcq(Register dst, Address src);
   void adcq(Register dst, Register src);
 
-
   void addl(Address dst, int32_t imm32);
   void addl(Address dst, Register src);
   void addl(Register dst, int32_t imm32);
@@ -737,7 +739,6 @@
   void addq(Register dst, Address src);
   void addq(Register dst, Register src);
 
-
   void addr_nop_4();
   void addr_nop_5();
   void addr_nop_7();
@@ -759,7 +760,6 @@
   void andq(Register dst, Address src);
   void andq(Register dst, Register src);
 
-
   // Bitwise Logical AND of Packed Double-Precision Floating-Point Values
   void andpd(XMMRegister dst, Address src);
   void andpd(XMMRegister dst, XMMRegister src);
@@ -1151,7 +1151,7 @@
 #ifdef _LP64
   void movq(Register dst, Register src);
   void movq(Register dst, Address src);
-  void movq(Address dst, Register src);
+  void movq(Address  dst, Register src);
 #endif
 
   void movq(Address     dst, MMXRegister src );
@@ -1177,7 +1177,7 @@
   void movsbq(Register dst, Register src);
 
   // Move signed 32bit immediate to 64bit extending sign
-  void movslq(Address dst, int32_t imm64);
+  void movslq(Address  dst, int32_t imm64);
   void movslq(Register dst, int32_t imm64);
 
   void movslq(Register dst, Address src);
@@ -1857,7 +1857,10 @@
     Register t2,                       // temp register
     Label&   slow_case                 // continuation point if fast allocation fails
   );
-  void tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case);
+  Register tlab_refill(Label& retry_tlab, Label& try_eden, Label& slow_case); // returns TLS address
+  void incr_allocated_bytes(Register thread,
+                            Register var_size_in_bytes, int con_size_in_bytes,
+                            Register t1 = noreg);
 
   // interface method calling
   void lookup_interface_method(Register recv_klass,
@@ -2180,9 +2183,9 @@
   void divss(XMMRegister dst, Address src)        { Assembler::divss(dst, src); }
   void divss(XMMRegister dst, AddressLiteral src) { Assembler::divss(dst, as_Address(src)); }
 
-  void movsd(XMMRegister dst, XMMRegister src)    { Assembler::movsd(dst, src); }
-  void movsd(Address dst, XMMRegister src)        { Assembler::movsd(dst, src); }
-  void movsd(XMMRegister dst, Address src)        { Assembler::movsd(dst, src); }
+  void movsd(XMMRegister dst, XMMRegister src) { Assembler::movsd(dst, src); }
+  void movsd(Address dst, XMMRegister src)     { Assembler::movsd(dst, src); }
+  void movsd(XMMRegister dst, Address src)     { Assembler::movsd(dst, src); }
   void movsd(XMMRegister dst, AddressLiteral src) { Assembler::movsd(dst, as_Address(src)); }
 
   void mulsd(XMMRegister dst, XMMRegister src)    { Assembler::mulsd(dst, src); }
--- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -2036,7 +2036,7 @@
   }
 }
 
-void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result) {
+void LIR_Assembler::cmove(LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type) {
   Assembler::Condition acond, ncond;
   switch (condition) {
     case lir_cond_equal:        acond = Assembler::equal;        ncond = Assembler::notEqual;     break;
--- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -741,7 +741,7 @@
 
   // generate conditional move of boolean result
   LIR_Opr result = rlock_result(x);
-  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result);
+  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result, T_LONG);
 }
 
 
@@ -810,7 +810,8 @@
 
   // generate conditional move of boolean result
   LIR_Opr result = rlock_result(x);
-  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result);
+  __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0),
+           result, as_BasicType(type));
   if (type == objectType) {   // Write-barrier needed for Object fields.
     // Seems to be precise
     post_barrier(addr, val.result());
--- a/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp	Wed Jan 19 21:51:10 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
@@ -141,6 +141,7 @@
     tlab_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
   } else {
     eden_allocate(obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case);
+    incr_allocated_bytes(noreg, var_size_in_bytes, con_size_in_bytes, t1);
   }
 }
 
@@ -234,7 +235,7 @@
 
 void C1_MacroAssembler::allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case) {
   assert(obj == rax, "obj must be in rax, for cmpxchg");
-  assert(obj != t1 && obj != t2 && t1 != t2, "registers must be different"); // XXX really?
+  assert_different_registers(obj, t1, t2); // XXX really?
   assert(header_size >= 0 && object_size >= header_size, "illegal sizes");
 
   try_allocate(obj, noreg, object_size * BytesPerWord, t1, t2, slow_case);
--- a/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Wed Jan 19 21:51:10 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
@@ -977,7 +977,6 @@
         // verify that that there is really a valid exception in rax,
         __ verify_not_null_oop(exception_oop);
 
-
         oop_maps = new OopMapSet();
         OopMap* oop_map = generate_oop_map(sasm, 1);
         generate_handle_exception(sasm, oop_maps, oop_map);
@@ -1037,13 +1036,16 @@
           // if we got here then the TLAB allocation failed, so try
           // refilling the TLAB or allocating directly from eden.
           Label retry_tlab, try_eden;
-          __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy rdx (klass)
+          const Register thread =
+            __ tlab_refill(retry_tlab, try_eden, slow_path); // does not destroy rdx (klass), returns rdi
 
           __ bind(retry_tlab);
 
           // get the instance size (size is postive so movl is fine for 64bit)
           __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
+
           __ tlab_allocate(obj, obj_size, 0, t1, t2, slow_path);
+
           __ initialize_object(obj, klass, obj_size, 0, t1, t2);
           __ verify_oop(obj);
           __ pop(rbx);
@@ -1053,7 +1055,10 @@
           __ bind(try_eden);
           // get the instance size (size is postive so movl is fine for 64bit)
           __ movl(obj_size, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
+
           __ eden_allocate(obj, obj_size, 0, t1, slow_path);
+          __ incr_allocated_bytes(thread, obj_size, 0);
+
           __ initialize_object(obj, klass, obj_size, 0, t1, t2);
           __ verify_oop(obj);
           __ pop(rbx);
@@ -1143,12 +1148,13 @@
           // if we got here then the TLAB allocation failed, so try
           // refilling the TLAB or allocating directly from eden.
           Label retry_tlab, try_eden;
-          __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves rbx, & rdx
+          const Register thread =
+            __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves rbx & rdx, returns rdi
 
           __ bind(retry_tlab);
 
           // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F))
-          // since size is postive movl does right thing on 64bit
+          // since size is positive movl does right thing on 64bit
           __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
           // since size is postive movl does right thing on 64bit
           __ movl(arr_size, length);
@@ -1175,7 +1181,7 @@
 
           __ bind(try_eden);
           // get the allocation size: round_up(hdr + length << (layout_helper & 0x1F))
-          // since size is postive movl does right thing on 64bit
+          // since size is positive movl does right thing on 64bit
           __ movl(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes()));
           // since size is postive movl does right thing on 64bit
           __ movl(arr_size, length);
@@ -1188,6 +1194,7 @@
           __ andptr(arr_size, ~MinObjAlignmentInBytesMask);
 
           __ eden_allocate(obj, arr_size, 0, t1, slow_path);  // preserves arr_size
+          __ incr_allocated_bytes(thread, arr_size, 0);
 
           __ initialize_header(obj, klass, length, t1, t2);
           __ movb(t1, Address(klass, klassOopDesc::header_size() * HeapWordSize + Klass::layout_helper_offset_in_bytes() + (Klass::_lh_header_size_shift / BitsPerByte)));
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -385,9 +385,12 @@
   // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS.
 }
 
+//------------------------------------------------------------------------------
+// MethodHandles::generate_method_handle_stub
+//
 // Generate an "entry" field for a method handle.
 // This determines how the method handle will respond to calls.
-void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek) {
+void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek, TRAPS) {
   // Here is the register state during an interpreted call,
   // as set up by generate_method_handle_interpreter_entry():
   // - rbx: garbage temp (was MethodHandle.invoke methodOop, unused)
@@ -396,14 +399,21 @@
   // - rsi/r13: sender SP (must preserve; see prepare_to_jump_from_interpreted)
   // - rdx: garbage temp, can blow away
 
-  Register rcx_recv    = rcx;
-  Register rax_argslot = rax;
-  Register rbx_temp    = rbx;
-  Register rdx_temp    = rdx;
+  const Register rcx_recv    = rcx;
+  const Register rax_argslot = rax;
+  const Register rbx_temp    = rbx;
+  const Register rdx_temp    = rdx;
 
   // This guy is set up by prepare_to_jump_from_interpreted (from interpreted calls)
   // and gen_c2i_adapter (from compiled calls):
-  Register saved_last_sp = LP64_ONLY(r13) NOT_LP64(rsi);
+  const Register saved_last_sp = LP64_ONLY(r13) NOT_LP64(rsi);
+
+  // Argument registers for _raise_exception.
+  // 32-bit: Pass first two oop/int args in registers ECX and EDX.
+  const Register rarg0_code     = LP64_ONLY(j_rarg0) NOT_LP64(rcx);
+  const Register rarg1_actual   = LP64_ONLY(j_rarg1) NOT_LP64(rdx);
+  const Register rarg2_required = LP64_ONLY(j_rarg2) NOT_LP64(rdi);
+  assert_different_registers(rarg0_code, rarg1_actual, rarg2_required, saved_last_sp);
 
   guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
 
@@ -437,47 +447,41 @@
   switch ((int) ek) {
   case _raise_exception:
     {
-      // Not a real MH entry, but rather shared code for raising an exception.
-      // Extra local arguments are pushed on stack, as required type at TOS+8,
-      // failing object (or NULL) at TOS+4, failing bytecode type at TOS.
-      // Beyond those local arguments are the PC, of course.
-      Register rdx_code = rdx_temp;
-      Register rcx_fail = rcx_recv;
-      Register rax_want = rax_argslot;
-      Register rdi_pc   = rdi;
-      __ pop(rdx_code);  // TOS+0
-      __ pop(rcx_fail);  // TOS+4
-      __ pop(rax_want);  // TOS+8
-      __ pop(rdi_pc);    // caller PC
+      // Not a real MH entry, but rather shared code for raising an
+      // exception.  Since we use a C2I adapter to set up the
+      // interpreter state, arguments are expected in compiler
+      // argument registers.
+      methodHandle mh(raise_exception_method());
+      address c2i_entry = methodOopDesc::make_adapters(mh, CHECK);
 
-      __ mov(rsp, rsi);   // cut the stack back to where the caller started
-
-      // Repush the arguments as if coming from the interpreter.
-      __ push(rdx_code);
-      __ push(rcx_fail);
-      __ push(rax_want);
+      const Register rdi_pc = rax;
+      __ pop(rdi_pc);  // caller PC
+      __ mov(rsp, saved_last_sp);  // cut the stack back to where the caller started
 
       Register rbx_method = rbx_temp;
-      Label no_method;
+      Label L_no_method;
       // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
       __ movptr(rbx_method, ExternalAddress((address) &_raise_exception_method));
       __ testptr(rbx_method, rbx_method);
-      __ jccb(Assembler::zero, no_method);
-      int jobject_oop_offset = 0;
+      __ jccb(Assembler::zero, L_no_method);
+
+      const int jobject_oop_offset = 0;
       __ movptr(rbx_method, Address(rbx_method, jobject_oop_offset));  // dereference the jobject
       __ testptr(rbx_method, rbx_method);
-      __ jccb(Assembler::zero, no_method);
+      __ jccb(Assembler::zero, L_no_method);
       __ verify_oop(rbx_method);
-      __ push(rdi_pc);          // and restore caller PC
-      __ jmp(rbx_method_fie);
+
+      // 32-bit: push remaining arguments as if coming from the compiler.
+      NOT_LP64(__ push(rarg2_required));
+
+      __ push(rdi_pc);  // restore caller PC
+      __ jump(ExternalAddress(c2i_entry));  // do C2I transition
 
       // If we get here, the Java runtime did not do its job of creating the exception.
       // Do something that is at least causes a valid throw from the interpreter.
-      __ bind(no_method);
-      __ pop(rax_want);
-      __ pop(rcx_fail);
-      __ push(rax_want);
-      __ push(rcx_fail);
+      __ bind(L_no_method);
+      __ push(rarg2_required);
+      __ push(rarg1_actual);
       __ jump(ExternalAddress(Interpreter::throw_WrongMethodType_entry()));
     }
     break;
@@ -572,9 +576,11 @@
       __ bind(no_such_interface);
       // Throw an exception.
       // For historical reasons, it will be IncompatibleClassChangeError.
-      __ pushptr(Address(rdx_intf, java_mirror_offset));  // required interface
-      __ push(rcx_recv);        // bad receiver
-      __ push((int)Bytecodes::_invokeinterface);  // who is complaining?
+      __ mov(rbx_temp, rcx_recv);  // rarg2_required might be RCX
+      assert_different_registers(rarg2_required, rbx_temp);
+      __ movptr(rarg2_required, Address(rdx_intf, java_mirror_offset));  // required interface
+      __ mov(   rarg1_actual,   rbx_temp);                               // bad receiver
+      __ movl(  rarg0_code,     (int) Bytecodes::_invokeinterface);      // who is complaining?
       __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
     }
     break;
@@ -669,10 +675,10 @@
       __ movl(rax_argslot, rcx_amh_vmargslot);  // reload argslot field
       __ movptr(rdx_temp, vmarg);
 
-      __ load_heap_oop(rbx_klass, rcx_amh_argument); // required class
-      __ push(rbx_klass);
-      __ push(rdx_temp);                             // bad object
-      __ push((int)Bytecodes::_checkcast);           // who is complaining?
+      assert_different_registers(rarg2_required, rdx_temp);
+      __ load_heap_oop(rarg2_required, rcx_amh_argument);             // required class
+      __ mov(          rarg1_actual,   rdx_temp);                     // bad object
+      __ movl(         rarg0_code,     (int) Bytecodes::_checkcast);  // who is complaining?
       __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
 
       __ bind(done);
@@ -1189,16 +1195,18 @@
 
       __ bind(bad_array_klass);
       UNPUSH_RSI_RDI;
-      __ pushptr(Address(rdx_array_klass, java_mirror_offset)); // required type
-      __ pushptr(vmarg);                // bad array
-      __ push((int)Bytecodes::_aaload); // who is complaining?
+      assert(!vmarg.uses(rarg2_required), "must be different registers");
+      __ movptr(rarg2_required, Address(rdx_array_klass, java_mirror_offset));  // required type
+      __ movptr(rarg1_actual,   vmarg);                                         // bad array
+      __ movl(  rarg0_code,     (int) Bytecodes::_aaload);                      // who is complaining?
       __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
 
       __ bind(bad_array_length);
       UNPUSH_RSI_RDI;
-      __ push(rcx_recv);        // AMH requiring a certain length
-      __ pushptr(vmarg);        // bad array
-      __ push((int)Bytecodes::_arraylength); // who is complaining?
+      assert(!vmarg.uses(rarg2_required), "must be different registers");
+      __ mov   (rarg2_required, rcx_recv);                       // AMH requiring a certain length
+      __ movptr(rarg1_actual,   vmarg);                          // bad array
+      __ movl(  rarg0_code,     (int) Bytecodes::_arraylength);  // who is complaining?
       __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
 
 #undef UNPUSH_RSI_RDI
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp	Wed Jan 19 21:51:10 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
@@ -3203,10 +3203,12 @@
   const bool allow_shared_alloc =
     Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode;
 
+  const Register thread = rcx;
+  if (UseTLAB || allow_shared_alloc) {
+    __ get_thread(thread);
+  }
+
   if (UseTLAB) {
-    const Register thread = rcx;
-
-    __ get_thread(thread);
     __ movptr(rax, Address(thread, in_bytes(JavaThread::tlab_top_offset())));
     __ lea(rbx, Address(rax, rdx, Address::times_1));
     __ cmpptr(rbx, Address(thread, in_bytes(JavaThread::tlab_end_offset())));
@@ -3247,6 +3249,8 @@
 
     // if someone beat us on the allocation, try again, otherwise continue
     __ jcc(Assembler::notEqual, retry);
+
+    __ incr_allocated_bytes(thread, rdx, 0);
   }
 
   if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
@@ -3256,12 +3260,12 @@
     __ decrement(rdx, sizeof(oopDesc));
     __ jcc(Assembler::zero, initialize_header);
 
-  // Initialize topmost object field, divide rdx by 8, check if odd and
-  // test if zero.
+    // Initialize topmost object field, divide rdx by 8, check if odd and
+    // test if zero.
     __ xorl(rcx, rcx);    // use zero reg to clear memory (shorter code)
     __ shrl(rdx, LogBytesPerLong); // divide by 2*oopSize and set carry flag if odd
 
-  // rdx must have been multiple of 8
+    // rdx must have been multiple of 8
 #ifdef ASSERT
     // make sure rdx was multiple of 8
     Label L;
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp	Wed Jan 19 21:51:10 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
@@ -3266,6 +3266,8 @@
 
     // if someone beat us on the allocation, try again, otherwise continue
     __ jcc(Assembler::notEqual, retry);
+
+    __ incr_allocated_bytes(r15_thread, rdx, 0);
   }
 
   if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
--- a/hotspot/src/os/linux/vm/perfMemory_linux.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/os/linux/vm/perfMemory_linux.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -635,7 +635,29 @@
     return -1;
   }
 
-  return fd;
+  // Verify that we have enough disk space for this file.
+  // We'll get random SIGBUS crashes on memory accesses if
+  // we don't.
+
+  for (size_t seekpos = 0; seekpos < size; seekpos += os::vm_page_size()) {
+    int zero_int = 0;
+    result = (int)os::seek_to_file_offset(fd, (jlong)(seekpos));
+    if (result == -1 ) break;
+    RESTARTABLE(::write(fd, &zero_int, 1), result);
+    if (result != 1) {
+      if (errno == ENOSPC) {
+        warning("Insufficient space for shared memory file:\n   %s\nTry using the -Djava.io.tmpdir= option to select an alternate temp location.\n", filename);
+      }
+      break;
+    }
+  }
+
+  if (result != -1) {
+    return fd;
+  } else {
+    RESTARTABLE(::close(fd), result);
+    return -1;
+  }
 }
 
 // open the shared memory file for the given user and vmid. returns
--- a/hotspot/src/os/posix/launcher/java_md.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/os/posix/launcher/java_md.c	Wed Jan 19 21:51:10 2011 -0800
@@ -28,7 +28,6 @@
 #include <dlfcn.h>
 #include <fcntl.h>
 #include <inttypes.h>
-#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Jan 19 21:51:10 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
@@ -80,6 +80,7 @@
 // put OS-includes here
 # include <dlfcn.h>
 # include <errno.h>
+# include <exception>
 # include <link.h>
 # include <poll.h>
 # include <pthread.h>
@@ -282,7 +283,7 @@
                is_error_reported(),
               "sp must be inside of selected thread stack");
 
-    thread->_self_raw_id = raw_id;  // mark for quick retrieval
+    thread->set_self_raw_id(raw_id);  // mark for quick retrieval
     _get_thread_cache[ index ] = thread;
   }
   return thread;
@@ -1475,6 +1476,13 @@
   return &allowdebug_blocked_sigs;
 }
 
+
+void _handle_uncaught_cxx_exception() {
+  VMError err("An uncaught C++ exception");
+  err.report_and_die();
+}
+
+
 // First crack at OS-specific initialization, from inside the new thread.
 void os::initialize_thread() {
   int r = thr_main() ;
@@ -1564,6 +1572,7 @@
    // use the dynamic check for T2 libthread.
 
   os::Solaris::init_thread_fpu_state();
+  std::set_terminate(_handle_uncaught_cxx_exception);
 }
 
 
@@ -3081,7 +3090,7 @@
     if (addr == NULL) {
       jio_snprintf(buf, sizeof(buf), ": %s", strerror(err));
     }
-    warning("attempt_reserve_memory_at: couldn't reserve %d bytes at "
+    warning("attempt_reserve_memory_at: couldn't reserve " SIZE_FORMAT " bytes at "
             PTR_FORMAT ": reserve_memory_helper returned " PTR_FORMAT
             "%s", bytes, requested_addr, addr, buf);
   }
@@ -5188,7 +5197,7 @@
   int o_delete = (oflag & O_DELETE);
   oflag = oflag & ~O_DELETE;
 
-  fd = ::open(path, oflag, mode);
+  fd = ::open64(path, oflag, mode);
   if (fd == -1) return -1;
 
   //If the open succeeded, the file might still be a directory
--- a/hotspot/src/os/solaris/vm/thread_solaris.inline.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/os/solaris/vm/thread_solaris.inline.hpp	Wed Jan 19 21:51:10 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
@@ -53,10 +53,10 @@
 
   uintptr_t raw = pd_raw_thread_id();
   int ix = pd_cache_index(raw);
-  Thread *Candidate = ThreadLocalStorage::_get_thread_cache[ix];
-  if (Candidate->_self_raw_id == raw) {
+  Thread* candidate = ThreadLocalStorage::_get_thread_cache[ix];
+  if (candidate->self_raw_id() == raw) {
     // hit
-    return Candidate;
+    return candidate;
   } else {
     return ThreadLocalStorage::get_thread_via_cache_slowly(raw, ix);
   }
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * CopyrighT (c) 1997, 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
@@ -2004,6 +2004,16 @@
   int   number;
 };
 
+// All Visual C++ exceptions thrown from code generated by the Microsoft Visual
+// C++ compiler contain this error code. Because this is a compiler-generated
+// error, the code is not listed in the Win32 API header files.
+// The code is actually a cryptic mnemonic device, with the initial "E"
+// standing for "exception" and the final 3 bytes (0x6D7363) representing the
+// ASCII values of "msc".
+
+#define EXCEPTION_UNCAUGHT_CXX_EXCEPTION    0xE06D7363
+
+
 struct siglabel exceptlabels[] = {
     def_excpt(EXCEPTION_ACCESS_VIOLATION),
     def_excpt(EXCEPTION_DATATYPE_MISALIGNMENT),
@@ -2028,6 +2038,7 @@
     def_excpt(EXCEPTION_INVALID_DISPOSITION),
     def_excpt(EXCEPTION_GUARD_PAGE),
     def_excpt(EXCEPTION_INVALID_HANDLE),
+    def_excpt(EXCEPTION_UNCAUGHT_CXX_EXCEPTION),
     NULL, 0
 };
 
@@ -2261,7 +2272,6 @@
     }
   }
 
-
   if (t != NULL && t->is_Java_thread()) {
     JavaThread* thread = (JavaThread*) t;
     bool in_java = thread->thread_state() == _thread_in_Java;
@@ -2465,8 +2475,9 @@
       } // switch
     }
 #ifndef _WIN64
-    if ((thread->thread_state() == _thread_in_Java) ||
-        (thread->thread_state() == _thread_in_native) )
+    if (((thread->thread_state() == _thread_in_Java) ||
+        (thread->thread_state() == _thread_in_native)) &&
+        exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION)
     {
       LONG result=Handle_FLT_Exception(exceptionInfo);
       if (result==EXCEPTION_CONTINUE_EXECUTION) return result;
@@ -2490,6 +2501,7 @@
       case EXCEPTION_ILLEGAL_INSTRUCTION_2:
       case EXCEPTION_INT_OVERFLOW:
       case EXCEPTION_INT_DIVIDE_BY_ZERO:
+      case EXCEPTION_UNCAUGHT_CXX_EXCEPTION:
       {  report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord,
                        exceptionInfo->ContextRecord);
       }
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -585,6 +585,13 @@
   sigaddset(&newset, sig);
   sigprocmask(SIG_UNBLOCK, &newset, NULL);
 
+  // Determine which sort of error to throw.  Out of swap may signal
+  // on the thread stack, which could get a mapping error when touched.
+  address addr = (address) info->si_addr;
+  if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) {
+    vm_exit_out_of_memory(0, "Out of swap space to map in thread stack.");
+  }
+
   VMError err(t, sig, pc, info, ucVoid);
   err.report_and_die();
 
--- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -29,6 +29,7 @@
 # include <sys/auxv.h>
 # include <sys/auxv_SPARC.h>
 # include <sys/systeminfo.h>
+# include <kstat.h>
 
 // We need to keep these here as long as we have to build on Solaris
 // versions before 10.
@@ -96,11 +97,23 @@
 #ifndef AV_SPARC_ASI_BLK_INIT
 #define AV_SPARC_ASI_BLK_INIT 0x0080  /* ASI_BLK_INIT_xxx ASI */
 #endif
+    if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
+
 #ifndef AV_SPARC_FMAF
-#define AV_SPARC_FMAF 0x0100  /* Sparc64 Fused Multiply-Add */
+#define AV_SPARC_FMAF 0x0100        /* Fused Multiply-Add */
 #endif
-    if (av & AV_SPARC_ASI_BLK_INIT) features |= blk_init_instructions_m;
     if (av & AV_SPARC_FMAF)         features |= fmaf_instructions_m;
+
+#ifndef AV_SPARC_FMAU
+#define    AV_SPARC_FMAU    0x0200  /* Unfused Multiply-Add */
+#endif
+    if (av & AV_SPARC_FMAU)         features |= fmau_instructions_m;
+
+#ifndef AV_SPARC_VIS3
+#define    AV_SPARC_VIS3    0x0400  /* VIS3 instruction set extensions */
+#endif
+    if (av & AV_SPARC_VIS3)         features |= vis3_instructions_m;
+
   } else {
     // getisax(2) failed, use the old legacy code.
 #ifndef PRODUCT
@@ -140,5 +153,59 @@
   // Determine the machine type.
   do_sysinfo(SI_MACHINE, "sun4v", &features, sun4v_m);
 
+  {
+    // Using kstat to determine the machine type.
+    kstat_ctl_t* kc = kstat_open();
+    kstat_t* ksp = kstat_lookup(kc, (char*)"cpu_info", -1, NULL);
+    const char* implementation = "UNKNOWN";
+    if (ksp != NULL) {
+      if (kstat_read(kc, ksp, NULL) != -1 && ksp->ks_data != NULL) {
+        kstat_named_t* knm = (kstat_named_t *)ksp->ks_data;
+        for (int i = 0; i < ksp->ks_ndata; i++) {
+          if (strcmp((const char*)&(knm[i].name),"implementation") == 0) {
+#ifndef KSTAT_DATA_STRING
+#define KSTAT_DATA_STRING   9
+#endif
+            if (knm[i].data_type == KSTAT_DATA_CHAR) {
+              // VM is running on Solaris 8 which does not have value.str.
+              implementation = &(knm[i].value.c[0]);
+            } else if (knm[i].data_type == KSTAT_DATA_STRING) {
+              // VM is running on Solaris 10.
+#ifndef KSTAT_NAMED_STR_PTR
+              // Solaris 8 was used to build VM, define the structure it misses.
+              struct str_t {
+                union {
+                  char *ptr;     /* NULL-term string */
+                  char __pad[8]; /* 64-bit padding */
+                } addr;
+                uint32_t len;    /* # bytes for strlen + '\0' */
+              };
+#define KSTAT_NAMED_STR_PTR(knptr) (( (str_t*)&((knptr)->value) )->addr.ptr)
+#endif
+              implementation = KSTAT_NAMED_STR_PTR(&knm[i]);
+            }
+#ifndef PRODUCT
+            if (PrintMiscellaneous && Verbose) {
+              tty->print_cr("cpu_info.implementation: %s", implementation);
+            }
+#endif
+            if (strncmp(implementation, "SPARC64", 7) == 0) {
+              features |= sparc64_family_m;
+            } else if (strncmp(implementation, "UltraSPARC-T", 12) == 0) {
+              features |= T_family_m;
+              if (strncmp(implementation, "UltraSPARC-T1", 13) == 0) {
+                features |= T1_model_m;
+              }
+            }
+            break;
+          }
+        } // for(
+      }
+    }
+    assert(strcmp(implementation, "UNKNOWN") != 0,
+           "unknown cpu info (changed kstat interface?)");
+    kstat_close(kc);
+  }
+
   return features;
 }
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -742,6 +742,13 @@
   sigaddset(&newset, sig);
   sigprocmask(SIG_UNBLOCK, &newset, NULL);
 
+  // Determine which sort of error to throw.  Out of swap may signal
+  // on the thread stack, which could get a mapping error when touched.
+  address addr = (address) info->si_addr;
+  if (sig == SIGBUS && info->si_code == BUS_OBJERR && info->si_errno == ENOMEM) {
+    vm_exit_out_of_memory(0, "Out of swap space to map in thread stack.");
+  }
+
   VMError err(t, sig, pc, info, ucVoid);
   err.report_and_die();
 
--- a/hotspot/src/share/vm/adlc/dict2.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/adlc/dict2.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -34,7 +34,7 @@
 #define MAXID 20
 static char initflag = 0;       // True after 1st initialization
 static char shft[MAXID] = {1,2,3,4,5,6,7,1,2,3,4,5,6,7,1,2,3,4,5,6};
-static short xsum[MAXID + 1];
+static short xsum[MAXID];
 
 //------------------------------bucket---------------------------------------
 class bucket {
@@ -66,7 +66,7 @@
   // Precompute table of null character hashes
   if( !initflag ) {             // Not initializated yet?
     xsum[0] = (1<<shft[0])+1;   // Initialize
-    for( i = 1; i < MAXID + 1; i++) {
+    for( i = 1; i < MAXID; i++) {
       xsum[i] = (1<<shft[i])+1+xsum[i-1];
     }
     initflag = 1;               // Never again
@@ -291,7 +291,7 @@
     c = (c<<1)+1;               // Characters are always odd!
     sum += c + (c<<shft[k++]);  // Universal hash function
   }
-  assert( k < (MAXID + 1), "Exceeded maximum name length");
+  assert( k < (MAXID), "Exceeded maximum name length");
   return (int)((sum+xsum[k]) >> 1); // Hash key, un-modulo'd table size
 }
 
--- a/hotspot/src/share/vm/c1/c1_Compilation.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -245,7 +245,7 @@
 }
 
 
-void Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) {
+bool Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) {
   // Preinitialize the consts section to some large size:
   int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo));
   char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
@@ -253,15 +253,20 @@
                                         locs_buffer_size / sizeof(relocInfo));
   code->initialize_consts_size(Compilation::desired_max_constant_size());
   // Call stubs + two deopt handlers (regular and MH) + exception handler
-  code->initialize_stubs_size((call_stub_estimate * LIR_Assembler::call_stub_size) +
-                              LIR_Assembler::exception_handler_size +
-                              2 * LIR_Assembler::deopt_handler_size);
+  int stub_size = (call_stub_estimate * LIR_Assembler::call_stub_size) +
+                   LIR_Assembler::exception_handler_size +
+                   (2 * LIR_Assembler::deopt_handler_size);
+  if (stub_size >= code->insts_capacity()) return false;
+  code->initialize_stubs_size(stub_size);
+  return true;
 }
 
 
 int Compilation::emit_code_body() {
   // emit code
-  setup_code_buffer(code(), allocator()->num_calls());
+  if (!setup_code_buffer(code(), allocator()->num_calls())) {
+    BAILOUT_("size requested greater than avail code buffer size", 0);
+  }
   code()->initialize_oop_recorder(env()->oop_recorder());
 
   _masm = new C1_MacroAssembler(code());
--- a/hotspot/src/share/vm/c1/c1_Compilation.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp	Wed Jan 19 21:51:10 2011 -0800
@@ -192,7 +192,7 @@
     return desired_max_code_buffer_size() / 10;
   }
 
-  static void setup_code_buffer(CodeBuffer* cb, int call_stub_estimate);
+  static bool setup_code_buffer(CodeBuffer* cb, int call_stub_estimate);
 
   // timers
   static void print_timers();
--- a/hotspot/src/share/vm/c1/c1_FrameMap.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/c1/c1_FrameMap.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -92,7 +92,7 @@
     if (opr->is_address()) {
       LIR_Address* addr = opr->as_address_ptr();
       assert(addr->disp() == (int)addr->disp(), "out of range value");
-      out_preserve = MAX2(out_preserve, (intptr_t)addr->disp() / 4);
+      out_preserve = MAX2(out_preserve, (intptr_t)(addr->disp() - STACK_BIAS) / 4);
     }
     i += type2size[t];
   }
@@ -143,7 +143,7 @@
     args->append(opr);
     if (opr->is_address()) {
       LIR_Address* addr = opr->as_address_ptr();
-      out_preserve = MAX2(out_preserve, (intptr_t)addr->disp() / 4);
+      out_preserve = MAX2(out_preserve, (intptr_t)(addr->disp() - STACK_BIAS) / 4);
     }
     i += type2size[t];
   }
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp	Wed Jan 19 21:51:10 2011 -0800
@@ -1568,15 +1568,16 @@
     assert(code == lir_cmp, "code check");
   }
 
-  LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result)
+  LIR_Op2(LIR_Code code, LIR_Condition condition, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result, BasicType type)
     : LIR_Op(code, result, NULL)
     , _opr1(opr1)
     , _opr2(opr2)
-    , _type(T_ILLEGAL)
+    , _type(type)
     , _condition(condition)
     , _fpu_stack_size(0)
     , _tmp(LIR_OprFact::illegalOpr) {
     assert(code == lir_cmove, "code check");
+    assert(type != T_ILLEGAL, "cmove should have type");
   }
 
   LIR_Op2(LIR_Code code, LIR_Opr opr1, LIR_Opr opr2, LIR_Opr result = LIR_OprFact::illegalOpr,
@@ -1993,8 +1994,8 @@
   void cmp_mem_int(LIR_Condition condition, LIR_Opr base, int disp, int c, CodeEmitInfo* info);
   void cmp_reg_mem(LIR_Condition condition, LIR_Opr reg, LIR_Address* addr, CodeEmitInfo* info);
 
-  void cmove(LIR_Condition condition, LIR_Opr src1, LIR_Opr src2, LIR_Opr dst) {
-    append(new LIR_Op2(lir_cmove, condition, src1, src2, dst));
+  void cmove(LIR_Condition condition, LIR_Opr src1, LIR_Opr src2, LIR_Opr dst, BasicType type) {
+    append(new LIR_Op2(lir_cmove, condition, src1, src2, dst, type));
   }
 
   void cas_long(LIR_Opr addr, LIR_Opr cmp_value, LIR_Opr new_value,
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -685,7 +685,7 @@
       break;
 
     case lir_cmove:
-      cmove(op->condition(), op->in_opr1(), op->in_opr2(), op->result_opr());
+      cmove(op->condition(), op->in_opr1(), op->in_opr2(), op->result_opr(), op->type());
       break;
 
     case lir_shl:
--- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp	Wed Jan 19 21:51:10 2011 -0800
@@ -217,7 +217,7 @@
   void volatile_move_op(LIR_Opr src, LIR_Opr result, BasicType type, CodeEmitInfo* info);
   void comp_mem_op(LIR_Opr src, LIR_Opr result, BasicType type, CodeEmitInfo* info);  // info set for null exceptions
   void comp_fl2i(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr result, LIR_Op2* op);
-  void cmove(LIR_Condition code, LIR_Opr left, LIR_Opr right, LIR_Opr result);
+  void cmove(LIR_Condition code, LIR_Opr left, LIR_Opr right, LIR_Opr result, BasicType type);
 
   void call(        LIR_OpJavaCall* op, relocInfo::relocType rtype);
   void ic_call(     LIR_OpJavaCall* op);
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -856,7 +856,7 @@
     __ cmove(lir_cond(cond),
              LIR_OprFact::intptrConst(taken_count_offset),
              LIR_OprFact::intptrConst(not_taken_count_offset),
-             data_offset_reg);
+             data_offset_reg, as_BasicType(if_instr->x()->type()));
 
     // MDO cells are intptr_t, so the data_reg width is arch-dependent.
     LIR_Opr data_reg = new_pointer_register();
@@ -2591,7 +2591,7 @@
   LIR_Opr reg = rlock_result(x);
 
   __ cmp(lir_cond(x->cond()), left.result(), right.result());
-  __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg);
+  __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
 }
 
 
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -90,6 +90,7 @@
  , _intervals(0)   // initialized later with correct length
  , _new_intervals_from_allocation(new IntervalList())
  , _sorted_intervals(NULL)
+ , _needs_full_resort(false)
  , _lir_ops(0)     // initialized later with correct length
  , _block_of_op(0) // initialized later with correct length
  , _has_info(0)
@@ -1520,6 +1521,14 @@
 void LinearScan::sort_intervals_before_allocation() {
   TIME_LINEAR_SCAN(timer_sort_intervals_before);
 
+  if (_needs_full_resort) {
+    // There is no known reason why this should occur but just in case...
+    assert(false, "should never occur");
+    // Re-sort existing interval list because an Interval::from() has changed
+    _sorted_intervals->sort(interval_cmp);
+    _needs_full_resort = false;
+  }
+
   IntervalList* unsorted_list = &_intervals;
   int unsorted_len = unsorted_list->length();
   int sorted_len = 0;
@@ -1559,11 +1568,18 @@
     }
   }
   _sorted_intervals = sorted_list;
+  assert(is_sorted(_sorted_intervals), "intervals unsorted");
 }
 
 void LinearScan::sort_intervals_after_allocation() {
   TIME_LINEAR_SCAN(timer_sort_intervals_after);
 
+  if (_needs_full_resort) {
+    // Re-sort existing interval list because an Interval::from() has changed
+    _sorted_intervals->sort(interval_cmp);
+    _needs_full_resort = false;
+  }
+
   IntervalArray* old_list      = _sorted_intervals;
   IntervalList*  new_list      = _new_intervals_from_allocation;
   int old_len = old_list->length();
@@ -1571,6 +1587,7 @@
 
   if (new_len == 0) {
     // no intervals have been added during allocation, so sorted list is already up to date
+    assert(is_sorted(_sorted_intervals), "intervals unsorted");
     return;
   }
 
@@ -1593,6 +1610,7 @@
   }
 
   _sorted_intervals = combined_list;
+  assert(is_sorted(_sorted_intervals), "intervals unsorted");
 }
 
 
@@ -1825,6 +1843,8 @@
       interval = interval->split(from_op_id);
       interval->assign_reg(reg, regHi);
       append_interval(interval);
+    } else {
+      _needs_full_resort = true;
     }
     assert(interval->from() == from_op_id, "must be true now");
 
@@ -4492,7 +4512,8 @@
     }
   } else {
     type_name = type2name(type());
-    if (assigned_reg() != -1) {
+    if (assigned_reg() != -1 &&
+        (LinearScan::num_physical_regs(type()) == 1 || assigned_regHi() != -1)) {
       opr = LinearScan::calc_operand_for_interval(this);
     }
   }
--- a/hotspot/src/share/vm/c1/c1_LinearScan.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.hpp	Wed Jan 19 21:51:10 2011 -0800
@@ -148,6 +148,7 @@
   IntervalList              _intervals;         // mapping from register number to interval
   IntervalList*             _new_intervals_from_allocation; // list with all intervals created during allocation when an existing interval is split
   IntervalArray*            _sorted_intervals;  // intervals sorted by Interval::from()
+  bool                      _needs_full_resort; // set to true if an Interval::from() is changed and _sorted_intervals must be resorted
 
   LIR_OpArray               _lir_ops;           // mapping from LIR_Op id to LIR_Op node
   BlockBeginArray           _block_of_op;       // mapping from LIR_Op id to the BlockBegin containing this instruction
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -2386,19 +2386,21 @@
       valid_cp_range(bootstrap_method_index, cp_size) &&
       cp->tag_at(bootstrap_method_index).is_method_handle(),
       "bootstrap_method_index %u has bad constant type in class file %s",
+      bootstrap_method_index,
       CHECK);
     operands->short_at_put(operand_fill_index++, bootstrap_method_index);
     operands->short_at_put(operand_fill_index++, argument_count);
 
     cfs->guarantee_more(sizeof(u2) * argument_count, CHECK);  // argv[argc]
     for (int j = 0; j < argument_count; j++) {
-      u2 arg_index = cfs->get_u2_fast();
+      u2 argument_index = cfs->get_u2_fast();
       check_property(
-        valid_cp_range(arg_index, cp_size) &&
-        cp->tag_at(arg_index).is_loadable_constant(),
+        valid_cp_range(argument_index, cp_size) &&
+        cp->tag_at(argument_index).is_loadable_constant(),
         "argument_index %u has bad constant type in class file %s",
+        argument_index,
         CHECK);
-      operands->short_at_put(operand_fill_index++, arg_index);
+      operands->short_at_put(operand_fill_index++, argument_index);
     }
   }
 
--- a/hotspot/src/share/vm/code/codeCache.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/code/codeCache.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -939,7 +939,9 @@
                _heap->high(),
                _heap->high_boundary());
   st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
-               " adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT,
+               " adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT
+               " largest_free_block=" SIZE_FORMAT,
                CodeCache::nof_blobs(), CodeCache::nof_nmethods(),
-               CodeCache::nof_adapters(), CodeCache::unallocated_capacity());
+               CodeCache::nof_adapters(), CodeCache::unallocated_capacity(),
+               CodeCache::largest_free_block());
 }
--- a/hotspot/src/share/vm/code/codeCache.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/code/codeCache.hpp	Wed Jan 19 21:51:10 2011 -0800
@@ -158,6 +158,7 @@
   static size_t  capacity()                      { return _heap->capacity(); }
   static size_t  max_capacity()                  { return _heap->max_capacity(); }
   static size_t  unallocated_capacity()          { return _heap->unallocated_capacity(); }
+  static size_t  largest_free_block()            { return _heap->largest_free_block(); }
   static bool    needs_flushing()                { return unallocated_capacity() < CodeCacheFlushingMinimumFreeSpace; }
 
   static bool needs_cache_clean()                { return _needs_cache_clean; }
--- a/hotspot/src/share/vm/code/nmethod.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -811,9 +811,11 @@
     _stub_offset             = content_offset()      + code_buffer->total_offset_of(code_buffer->stubs());
 
     // Exception handler and deopt handler are in the stub section
+    assert(offsets->value(CodeOffsets::Exceptions) != -1, "must be set");
+    assert(offsets->value(CodeOffsets::Deopt     ) != -1, "must be set");
     _exception_offset        = _stub_offset          + offsets->value(CodeOffsets::Exceptions);
     _deoptimize_offset       = _stub_offset          + offsets->value(CodeOffsets::Deopt);
-    if (has_method_handle_invokes()) {
+    if (offsets->value(CodeOffsets::DeoptMH) != -1) {
       _deoptimize_mh_offset  = _stub_offset          + offsets->value(CodeOffsets::DeoptMH);
     } else {
       _deoptimize_mh_offset  = -1;
@@ -1909,6 +1911,7 @@
       break;
     }
   }
+  assert(has_method_handle_invokes() == (_deoptimize_mh_offset != -1), "must have deopt mh handler");
 
   int size = count * sizeof(PcDesc);
   assert(scopes_pcs_size() >= size, "oob");
--- a/hotspot/src/share/vm/compiler/abstractCompiler.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/compiler/abstractCompiler.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -33,6 +33,7 @@
     bool do_initialization = false;
     {
       ThreadInVMfromNative tv(thread);
+      ResetNoHandleMark rnhm;
       MutexLocker only_one(CompileThread_lock, thread);
       if ( *state == uninitialized) {
         do_initialization = true;
@@ -53,6 +54,7 @@
       // To in_vm so we can use the lock
 
       ThreadInVMfromNative tv(thread);
+      ResetNoHandleMark rnhm;
       MutexLocker only_one(CompileThread_lock, thread);
       assert(*state == initializing, "wrong state");
       *state = initialized;
--- a/hotspot/src/share/vm/compiler/compilerOracle.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/compiler/compilerOracle.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -332,7 +332,7 @@
          "command_names size mismatch");
 
   *bytes_read = 0;
-  char command[32];
+  char command[33];
   int result = sscanf(line, "%32[a-z]%n", command, bytes_read);
   for (uint i = 0; i < ARRAY_SIZE(command_names); i++) {
     if (strcmp(command, command_names[i]) == 0) {
@@ -470,6 +470,12 @@
   OracleCommand command = parse_command_name(line, &bytes_read);
   line += bytes_read;
 
+  if (command == UnknownCommand) {
+    tty->print_cr("CompilerOracle: unrecognized line");
+    tty->print_cr("  \"%s\"", original_line);
+    return;
+  }
+
   if (command == QuietCommand) {
     _quiet = true;
     return;
@@ -498,7 +504,7 @@
     line += bytes_read;
     // there might be a signature following the method.
     // signatures always begin with ( so match that by hand
-    if (1 == sscanf(line, "%*[ \t](%254[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
+    if (1 == sscanf(line, "%*[ \t](%254[[);/" RANGEBASE "]%n", sig + 1, &bytes_read)) {
       sig[0] = '(';
       line += bytes_read;
       signature = oopFactory::new_symbol_handle(sig, CHECK);
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.inline.hpp	Wed Jan 19 21:51:10 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
@@ -153,6 +153,7 @@
       check_for_non_bad_heap_word_value(result, size));
     assert(!HAS_PENDING_EXCEPTION,
            "Unexpected exception, will result in uninitialized storage");
+    THREAD->incr_allocated_bytes(size * HeapWordSize);
     return result;
   }
 
--- a/hotspot/src/share/vm/memory/heap.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/memory/heap.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -315,6 +315,15 @@
   return l;
 }
 
+size_t CodeHeap::largest_free_block() const {
+  size_t len = 0;
+  for (FreeBlock* b = _freelist; b != NULL; b = b->link()) {
+    if (b->length() > len)
+      len = b->length();
+  }
+  return size(len);
+}
+
 // Free list management
 
 FreeBlock *CodeHeap::following_block(FreeBlock *b) {
--- a/hotspot/src/share/vm/memory/heap.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/memory/heap.hpp	Wed Jan 19 21:51:10 2011 -0800
@@ -161,6 +161,7 @@
   size_t max_capacity() const;
   size_t allocated_capacity() const;
   size_t unallocated_capacity() const            { return max_capacity() - allocated_capacity(); }
+  size_t largest_free_block() const;
 
   // Debugging
   void verify();
--- a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.cpp	Wed Jan 19 21:51:10 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
@@ -114,6 +114,11 @@
 void ThreadLocalAllocBuffer::make_parsable(bool retire) {
   if (end() != NULL) {
     invariants();
+
+    if (retire) {
+      myThread()->incr_allocated_bytes(used_bytes());
+    }
+
     CollectedHeap::fill_with_object(top(), hard_end(), retire);
 
     if (retire || ZeroTLAB) {  // "Reset" the TLAB
--- a/hotspot/src/share/vm/memory/threadLocalAllocBuffer.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/memory/threadLocalAllocBuffer.hpp	Wed Jan 19 21:51:10 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
@@ -112,6 +112,8 @@
   HeapWord* top() const                          { return _top; }
   HeapWord* pf_top() const                       { return _pf_top; }
   size_t desired_size() const                    { return _desired_size; }
+  size_t used() const                            { return pointer_delta(top(), start()); }
+  size_t used_bytes() const                      { return pointer_delta(top(), start(), 1); }
   size_t free() const                            { return pointer_delta(end(), top()); }
   // Don't discard tlab if remaining space is larger than this.
   size_t refill_waste_limit() const              { return _refill_waste_limit; }
--- a/hotspot/src/share/vm/memory/universe.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/memory/universe.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -934,7 +934,8 @@
     // See needs_explicit_null_check.
     // Only set the heap base for compressed oops because it indicates
     // compressed oops for pstack code.
-    if (PrintCompressedOopsMode) {
+    bool verbose = PrintCompressedOopsMode || (PrintMiscellaneous && Verbose);
+    if (verbose) {
       tty->cr();
       tty->print("heap address: " PTR_FORMAT ", size: " SIZE_FORMAT " MB",
                  Universe::heap()->base(), Universe::heap()->reserved_region().byte_size()/M);
@@ -943,12 +944,12 @@
       // Can't reserve heap below 32Gb.
       Universe::set_narrow_oop_base(Universe::heap()->base() - os::vm_page_size());
       Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
-      if (PrintCompressedOopsMode) {
+      if (verbose) {
         tty->print(", Compressed Oops with base: "PTR_FORMAT, Universe::narrow_oop_base());
       }
     } else {
       Universe::set_narrow_oop_base(0);
-      if (PrintCompressedOopsMode) {
+      if (verbose) {
         tty->print(", zero based Compressed Oops");
       }
 #ifdef _WIN64
@@ -963,12 +964,12 @@
         Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
       } else {
         Universe::set_narrow_oop_shift(0);
-        if (PrintCompressedOopsMode) {
+        if (verbose) {
           tty->print(", 32-bits Oops");
         }
       }
     }
-    if (PrintCompressedOopsMode) {
+    if (verbose) {
       tty->cr();
       tty->cr();
     }
--- a/hotspot/src/share/vm/opto/compile.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/opto/compile.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -444,22 +444,32 @@
 }
 
 
+//-----------------------init_scratch_buffer_blob------------------------------
+// Construct a temporary BufferBlob and cache it for this compile.
 void Compile::init_scratch_buffer_blob(int const_size) {
-  if (scratch_buffer_blob() != NULL)  return;
+  // If there is already a scratch buffer blob allocated and the
+  // constant section is big enough, use it.  Otherwise free the
+  // current and allocate a new one.
+  BufferBlob* blob = scratch_buffer_blob();
+  if ((blob != NULL) && (const_size <= _scratch_const_size)) {
+    // Use the current blob.
+  } else {
+    if (blob != NULL) {
+      BufferBlob::free(blob);
+    }
 
-  // Construct a temporary CodeBuffer to have it construct a BufferBlob
-  // Cache this BufferBlob for this compile.
-  ResourceMark rm;
-  _scratch_const_size = const_size;
-  int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size);
-  BufferBlob* blob = BufferBlob::create("Compile::scratch_buffer", size);
-  // Record the buffer blob for next time.
-  set_scratch_buffer_blob(blob);
-  // Have we run out of code space?
-  if (scratch_buffer_blob() == NULL) {
-    // Let CompilerBroker disable further compilations.
-    record_failure("Not enough space for scratch buffer in CodeCache");
-    return;
+    ResourceMark rm;
+    _scratch_const_size = const_size;
+    int size = (MAX_inst_size + MAX_stubs_size + _scratch_const_size);
+    blob = BufferBlob::create("Compile::scratch_buffer", size);
+    // Record the buffer blob for next time.
+    set_scratch_buffer_blob(blob);
+    // Have we run out of code space?
+    if (scratch_buffer_blob() == NULL) {
+      // Let CompilerBroker disable further compilations.
+      record_failure("Not enough space for scratch buffer in CodeCache");
+      return;
+    }
   }
 
   // Initialize the relocation buffers
@@ -468,13 +478,6 @@
 }
 
 
-void Compile::clear_scratch_buffer_blob() {
-  assert(scratch_buffer_blob(), "no BufferBlob set");
-  set_scratch_buffer_blob(NULL);
-  set_scratch_locs_memory(NULL);
-}
-
-
 //-----------------------scratch_emit_size-------------------------------------
 // Helper function that computes size by emitting code
 uint Compile::scratch_emit_size(const Node* n) {
--- a/hotspot/src/share/vm/opto/escape.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/opto/escape.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -1609,10 +1609,11 @@
   //
   // Normally only 1-3 passes needed to build
   // Connection Graph depending on graph complexity.
-  // Set limit to 10 to catch situation when something
+  // Observed 8 passes in jvm2008 compiler.compiler.
+  // Set limit to 20 to catch situation when something
   // did go wrong and recompile the method without EA.
 
-#define CG_BUILD_ITER_LIMIT 10
+#define CG_BUILD_ITER_LIMIT 20
 
   uint length = worklist.length();
   int iterations = 0;
--- a/hotspot/src/share/vm/opto/macro.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/opto/macro.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -1158,7 +1158,7 @@
     // Note: We set the control input on "eden_end" and "old_eden_top" when using
     //       a TLAB to work around a bug where these values were being moved across
     //       a safepoint.  These are not oops, so they cannot be include in the oop
-    //       map, but the can be changed by a GC.   The proper way to fix this would
+    //       map, but they can be changed by a GC.   The proper way to fix this would
     //       be to set the raw memory state when generating a  SafepointNode.  However
     //       this will require extensive changes to the loop optimization in order to
     //       prevent a degradation of the optimization.
@@ -1167,24 +1167,24 @@
 
     // allocate the Region and Phi nodes for the result
     result_region = new (C, 3) RegionNode(3);
-    result_phi_rawmem = new (C, 3) PhiNode( result_region, Type::MEMORY, TypeRawPtr::BOTTOM );
-    result_phi_rawoop = new (C, 3) PhiNode( result_region, TypeRawPtr::BOTTOM );
-    result_phi_i_o    = new (C, 3) PhiNode( result_region, Type::ABIO ); // I/O is used for Prefetch
+    result_phi_rawmem = new (C, 3) PhiNode(result_region, Type::MEMORY, TypeRawPtr::BOTTOM);
+    result_phi_rawoop = new (C, 3) PhiNode(result_region, TypeRawPtr::BOTTOM);
+    result_phi_i_o    = new (C, 3) PhiNode(result_region, Type::ABIO); // I/O is used for Prefetch
 
     // We need a Region for the loop-back contended case.
     enum { fall_in_path = 1, contended_loopback_path = 2 };
     Node *contended_region;
     Node *contended_phi_rawmem;
-    if( UseTLAB ) {
+    if (UseTLAB) {
       contended_region = toobig_false;
       contended_phi_rawmem = mem;
     } else {
       contended_region = new (C, 3) RegionNode(3);
-      contended_phi_rawmem = new (C, 3) PhiNode( contended_region, Type::MEMORY, TypeRawPtr::BOTTOM);
+      contended_phi_rawmem = new (C, 3) PhiNode(contended_region, Type::MEMORY, TypeRawPtr::BOTTOM);
       // Now handle the passing-too-big test.  We fall into the contended
       // loop-back merge point.
-      contended_region    ->init_req( fall_in_path, toobig_false );
-      contended_phi_rawmem->init_req( fall_in_path, mem );
+      contended_region    ->init_req(fall_in_path, toobig_false);
+      contended_phi_rawmem->init_req(fall_in_path, mem);
       transform_later(contended_region);
       transform_later(contended_phi_rawmem);
     }
@@ -1192,78 +1192,101 @@
     // Load(-locked) the heap top.
     // See note above concerning the control input when using a TLAB
     Node *old_eden_top = UseTLAB
-      ? new (C, 3) LoadPNode     ( ctrl, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM )
-      : new (C, 3) LoadPLockedNode( contended_region, contended_phi_rawmem, eden_top_adr );
+      ? new (C, 3) LoadPNode      (ctrl, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, TypeRawPtr::BOTTOM)
+      : new (C, 3) LoadPLockedNode(contended_region, contended_phi_rawmem, eden_top_adr);
 
     transform_later(old_eden_top);
     // Add to heap top to get a new heap top
-    Node *new_eden_top = new (C, 4) AddPNode( top(), old_eden_top, size_in_bytes );
+    Node *new_eden_top = new (C, 4) AddPNode(top(), old_eden_top, size_in_bytes);
     transform_later(new_eden_top);
     // Check for needing a GC; compare against heap end
-    Node *needgc_cmp = new (C, 3) CmpPNode( new_eden_top, eden_end );
+    Node *needgc_cmp = new (C, 3) CmpPNode(new_eden_top, eden_end);
     transform_later(needgc_cmp);
-    Node *needgc_bol = new (C, 2) BoolNode( needgc_cmp, BoolTest::ge );
+    Node *needgc_bol = new (C, 2) BoolNode(needgc_cmp, BoolTest::ge);
     transform_later(needgc_bol);
-    IfNode *needgc_iff = new (C, 2) IfNode(contended_region, needgc_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN );
+    IfNode *needgc_iff = new (C, 2) IfNode(contended_region, needgc_bol, PROB_UNLIKELY_MAG(4), COUNT_UNKNOWN);
     transform_later(needgc_iff);
 
     // Plug the failing-heap-space-need-gc test into the slow-path region
-    Node *needgc_true = new (C, 1) IfTrueNode( needgc_iff );
+    Node *needgc_true = new (C, 1) IfTrueNode(needgc_iff);
     transform_later(needgc_true);
-    if( initial_slow_test ) {
-      slow_region    ->init_req( need_gc_path, needgc_true );
+    if (initial_slow_test) {
+      slow_region->init_req(need_gc_path, needgc_true);
       // This completes all paths into the slow merge point
       transform_later(slow_region);
     } else {                      // No initial slow path needed!
       // Just fall from the need-GC path straight into the VM call.
-      slow_region    = needgc_true;
+      slow_region = needgc_true;
     }
     // No need for a GC.  Setup for the Store-Conditional
-    Node *needgc_false = new (C, 1) IfFalseNode( needgc_iff );
+    Node *needgc_false = new (C, 1) IfFalseNode(needgc_iff);
     transform_later(needgc_false);
 
     // Grab regular I/O before optional prefetch may change it.
     // Slow-path does no I/O so just set it to the original I/O.
-    result_phi_i_o->init_req( slow_result_path, i_o );
+    result_phi_i_o->init_req(slow_result_path, i_o);
 
     i_o = prefetch_allocation(i_o, needgc_false, contended_phi_rawmem,
                               old_eden_top, new_eden_top, length);
 
+    // Name successful fast-path variables
+    Node* fast_oop = old_eden_top;
+    Node* fast_oop_ctrl;
+    Node* fast_oop_rawmem;
+
     // Store (-conditional) the modified eden top back down.
     // StorePConditional produces flags for a test PLUS a modified raw
     // memory state.
-    Node *store_eden_top;
-    Node *fast_oop_ctrl;
-    if( UseTLAB ) {
-      store_eden_top = new (C, 4) StorePNode( needgc_false, contended_phi_rawmem, eden_top_adr, TypeRawPtr::BOTTOM, new_eden_top );
+    if (UseTLAB) {
+      Node* store_eden_top =
+        new (C, 4) StorePNode(needgc_false, contended_phi_rawmem, eden_top_adr,
+                              TypeRawPtr::BOTTOM, new_eden_top);
       transform_later(store_eden_top);
       fast_oop_ctrl = needgc_false; // No contention, so this is the fast path
+      fast_oop_rawmem = store_eden_top;
     } else {
-      store_eden_top = new (C, 5) StorePConditionalNode( needgc_false, contended_phi_rawmem, eden_top_adr, new_eden_top, old_eden_top );
+      Node* store_eden_top =
+        new (C, 5) StorePConditionalNode(needgc_false, contended_phi_rawmem, eden_top_adr,
+                                         new_eden_top, fast_oop/*old_eden_top*/);
       transform_later(store_eden_top);
-      Node *contention_check = new (C, 2) BoolNode( store_eden_top, BoolTest::ne );
+      Node *contention_check = new (C, 2) BoolNode(store_eden_top, BoolTest::ne);
       transform_later(contention_check);
       store_eden_top = new (C, 1) SCMemProjNode(store_eden_top);
       transform_later(store_eden_top);
 
       // If not using TLABs, check to see if there was contention.
-      IfNode *contention_iff = new (C, 2) IfNode ( needgc_false, contention_check, PROB_MIN, COUNT_UNKNOWN );
+      IfNode *contention_iff = new (C, 2) IfNode (needgc_false, contention_check, PROB_MIN, COUNT_UNKNOWN);
       transform_later(contention_iff);
-      Node *contention_true = new (C, 1) IfTrueNode( contention_iff );
+      Node *contention_true = new (C, 1) IfTrueNode(contention_iff);
       transform_later(contention_true);
       // If contention, loopback and try again.
-      contended_region->init_req( contended_loopback_path, contention_true );
-      contended_phi_rawmem->init_req( contended_loopback_path, store_eden_top );
+      contended_region->init_req(contended_loopback_path, contention_true);
+      contended_phi_rawmem->init_req(contended_loopback_path, store_eden_top);
 
       // Fast-path succeeded with no contention!
-      Node *contention_false = new (C, 1) IfFalseNode( contention_iff );
+      Node *contention_false = new (C, 1) IfFalseNode(contention_iff);
       transform_later(contention_false);
       fast_oop_ctrl = contention_false;
+
+      // Bump total allocated bytes for this thread
+      Node* thread = new (C, 1) ThreadLocalNode();
+      transform_later(thread);
+      Node* alloc_bytes_adr = basic_plus_adr(top()/*not oop*/, thread,
+                                             in_bytes(JavaThread::allocated_bytes_offset()));
+      Node* alloc_bytes = make_load(fast_oop_ctrl, store_eden_top, alloc_bytes_adr,
+                                    0, TypeLong::LONG, T_LONG);
+#ifdef _LP64
+      Node* alloc_size = size_in_bytes;
+#else
+      Node* alloc_size = new (C, 2) ConvI2LNode(size_in_bytes);
+      transform_later(alloc_size);
+#endif
+      Node* new_alloc_bytes = new (C, 3) AddLNode(alloc_bytes, alloc_size);
+      transform_later(new_alloc_bytes);
+      fast_oop_rawmem = make_store(fast_oop_ctrl, store_eden_top, alloc_bytes_adr,
+                                   0, new_alloc_bytes, T_LONG);
     }
 
-    // Rename successful fast-path variables to make meaning more obvious
-    Node* fast_oop        = old_eden_top;
-    Node* fast_oop_rawmem = store_eden_top;
     fast_oop_rawmem = initialize_object(alloc,
                                         fast_oop_ctrl, fast_oop_rawmem, fast_oop,
                                         klass_node, length, size_in_bytes);
@@ -1282,11 +1305,11 @@
 
       call->init_req(TypeFunc::Parms+0, thread);
       call->init_req(TypeFunc::Parms+1, fast_oop);
-      call->init_req( TypeFunc::Control, fast_oop_ctrl );
-      call->init_req( TypeFunc::I_O    , top() )        ;   // does no i/o
-      call->init_req( TypeFunc::Memory , fast_oop_rawmem );
-      call->init_req( TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr) );
-      call->init_req( TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr) );
+      call->init_req(TypeFunc::Control, fast_oop_ctrl);
+      call->init_req(TypeFunc::I_O    , top()); // does no i/o
+      call->init_req(TypeFunc::Memory , fast_oop_rawmem);
+      call->init_req(TypeFunc::ReturnAdr, alloc->in(TypeFunc::ReturnAdr));
+      call->init_req(TypeFunc::FramePtr, alloc->in(TypeFunc::FramePtr));
       transform_later(call);
       fast_oop_ctrl = new (C, 1) ProjNode(call,TypeFunc::Control);
       transform_later(fast_oop_ctrl);
@@ -1295,10 +1318,10 @@
     }
 
     // Plug in the successful fast-path into the result merge point
-    result_region    ->init_req( fast_result_path, fast_oop_ctrl );
-    result_phi_rawoop->init_req( fast_result_path, fast_oop );
-    result_phi_i_o   ->init_req( fast_result_path, i_o );
-    result_phi_rawmem->init_req( fast_result_path, fast_oop_rawmem );
+    result_region    ->init_req(fast_result_path, fast_oop_ctrl);
+    result_phi_rawoop->init_req(fast_result_path, fast_oop);
+    result_phi_i_o   ->init_req(fast_result_path, i_o);
+    result_phi_rawmem->init_req(fast_result_path, fast_oop_rawmem);
   } else {
     slow_region = ctrl;
   }
--- a/hotspot/src/share/vm/opto/output.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/opto/output.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -1746,9 +1746,6 @@
   // Walk backwards over each basic block, computing the needed alignment
   // Walk over all the basic blocks
   scheduling.DoScheduling();
-
-  // Clear the BufferBlob used for scheduling.
-  clear_scratch_buffer_blob();
 }
 
 //------------------------------ComputeLocalLatenciesForward-------------------
--- a/hotspot/src/share/vm/opto/stringopts.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/opto/stringopts.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -59,7 +59,8 @@
   enum {
     StringMode,
     IntMode,
-    CharMode
+    CharMode,
+    StringNullCheckMode
   };
 
   StringConcat(PhaseStringOpts* stringopts, CallStaticJavaNode* end):
@@ -114,6 +115,9 @@
   void push_string(Node* value) {
     push(value, StringMode);
   }
+  void push_string_null_check(Node* value) {
+    push(value, StringNullCheckMode);
+  }
   void push_int(Node* value) {
     push(value, IntMode);
   }
@@ -416,7 +420,19 @@
             if (sig == ciSymbol::string_void_signature()) {
               // StringBuilder(String) so pick this up as the first argument
               assert(use->in(TypeFunc::Parms + 1) != NULL, "what?");
-              sc->push_string(use->in(TypeFunc::Parms + 1));
+              const Type* type = _gvn->type(use->in(TypeFunc::Parms + 1));
+              if (type == TypePtr::NULL_PTR) {
+                // StringBuilder(null) throws exception.
+#ifndef PRODUCT
+                if (PrintOptimizeStringConcat) {
+                  tty->print("giving up because StringBuilder(null) throws exception");
+                  alloc->jvms()->dump_spec(tty); tty->cr();
+                }
+#endif
+                return NULL;
+              }
+              // StringBuilder(str) argument needs null check.
+              sc->push_string_null_check(use->in(TypeFunc::Parms + 1));
             }
             // The int variant takes an initial size for the backing
             // array so just treat it like the void version.
@@ -436,7 +452,7 @@
 #ifndef PRODUCT
         if (PrintOptimizeStringConcat) {
           tty->print("giving up because couldn't find constructor ");
-          alloc->jvms()->dump_spec(tty);
+          alloc->jvms()->dump_spec(tty); tty->cr();
         }
 #endif
         break;
@@ -1269,6 +1285,25 @@
         string_sizes->init_req(argi, string_size);
         break;
       }
+      case StringConcat::StringNullCheckMode: {
+        const Type* type = kit.gvn().type(arg);
+        assert(type != TypePtr::NULL_PTR, "missing check");
+        if (!type->higher_equal(TypeInstPtr::NOTNULL)) {
+          // Null check with uncommont trap since
+          // StringBuilder(null) throws exception.
+          // Use special uncommon trap instead of
+          // calling normal do_null_check().
+          Node* p = __ Bool(__ CmpP(arg, kit.null()), BoolTest::ne);
+          IfNode* iff = kit.create_and_map_if(kit.control(), p, PROB_MIN, COUNT_UNKNOWN);
+          overflow->add_req(__ IfFalse(iff));
+          Node* notnull = __ IfTrue(iff);
+          kit.set_control(notnull); // set control for the cast_not_null
+          arg = kit.cast_not_null(arg, false);
+          sc->set_argument(argi, arg);
+        }
+        assert(kit.gvn().type(arg)->higher_equal(TypeInstPtr::NOTNULL), "sanity");
+        // Fallthrough to add string length.
+      }
       case StringConcat::StringMode: {
         const Type* type = kit.gvn().type(arg);
         if (type == TypePtr::NULL_PTR) {
@@ -1328,6 +1363,7 @@
     // Hook
     PreserveJVMState pjvms(&kit);
     kit.set_control(overflow);
+    C->record_for_igvn(overflow);
     kit.uncommon_trap(Deoptimization::Reason_intrinsic,
                       Deoptimization::Action_make_not_entrant);
   }
@@ -1363,6 +1399,7 @@
         start = end;
         break;
       }
+      case StringConcat::StringNullCheckMode:
       case StringConcat::StringMode: {
         start = copy_string(kit, arg, char_array, start);
         break;
--- a/hotspot/src/share/vm/prims/jvmti.xml	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/prims/jvmti.xml	Wed Jan 19 21:51:10 2011 -0800
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <?xml-stylesheet type="text/xsl" href="jvmti.xsl"?>
 <!--
- 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
@@ -10697,7 +10697,7 @@
 	    <internallink id="mUTF">modified UTF-8</internallink> string.
 	  </description>
 	</param>
-        <param id="value">
+        <param id="value_ptr">
 	  <inbuf>
 	    <char/>
 	    <nullok>
--- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp	Wed Jan 19 21:51:10 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
@@ -1802,7 +1802,7 @@
 // depth - pre-checked as non-negative
 // value - pre-checked for NULL
 jvmtiError
-JvmtiEnv::GetLocalInstance(JavaThread* java_thread, jint depth, jobject* value){
+JvmtiEnv::GetLocalInstance(JavaThread* java_thread, jint depth, jobject* value_ptr){
   JavaThread* current_thread = JavaThread::current();
   // rm object is created to clean up the javaVFrame created in
   // doit_prologue(), but after doit() is finished with it.
@@ -1814,7 +1814,7 @@
   if (err != JVMTI_ERROR_NONE) {
     return err;
   } else {
-    *value = op.value().l;
+    *value_ptr = op.value().l;
     return JVMTI_ERROR_NONE;
   }
 } /* end GetLocalInstance */
@@ -3440,12 +3440,12 @@
 // property - pre-checked for NULL
 // value - NULL is a valid value, must be checked
 jvmtiError
-JvmtiEnv::SetSystemProperty(const char* property, const char* value) {
+JvmtiEnv::SetSystemProperty(const char* property, const char* value_ptr) {
   jvmtiError err =JVMTI_ERROR_NOT_AVAILABLE;
 
   for (SystemProperty* p = Arguments::system_properties(); p != NULL; p = p->next()) {
     if (strcmp(property, p->key()) == 0) {
-      if (p->set_value((char *)value)) {
+      if (p->set_value((char *)value_ptr)) {
         err =  JVMTI_ERROR_NONE;
       }
     }
--- a/hotspot/src/share/vm/prims/methodHandles.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/prims/methodHandles.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -111,7 +111,7 @@
 //------------------------------------------------------------------------------
 // MethodHandles::generate_adapters
 //
-void MethodHandles::generate_adapters() {
+void MethodHandles::generate_adapters(TRAPS) {
   if (!EnableMethodHandles || SystemDictionary::MethodHandle_klass() == NULL)  return;
 
   assert(_adapter_code == NULL, "generate only once");
@@ -123,20 +123,20 @@
     vm_exit_out_of_memory(_adapter_code_size, "CodeCache: no room for MethodHandles adapters");
   CodeBuffer code(_adapter_code);
   MethodHandlesAdapterGenerator g(&code);
-  g.generate();
+  g.generate(CHECK);
 }
 
 
 //------------------------------------------------------------------------------
 // MethodHandlesAdapterGenerator::generate
 //
-void MethodHandlesAdapterGenerator::generate() {
+void MethodHandlesAdapterGenerator::generate(TRAPS) {
   // Generate generic method handle adapters.
   for (MethodHandles::EntryKind ek = MethodHandles::_EK_FIRST;
        ek < MethodHandles::_EK_LIMIT;
        ek = MethodHandles::EntryKind(1 + (int)ek)) {
     StubCodeMark mark(this, "MethodHandle", MethodHandles::entry_name(ek));
-    MethodHandles::generate_method_handle_stub(_masm, ek);
+    MethodHandles::generate_method_handle_stub(_masm, ek, CHECK);
   }
 }
 
@@ -2645,5 +2645,10 @@
       MethodHandles::set_enabled(true);
     }
   }
+
+  // Generate method handles adapters if enabled.
+  if (MethodHandles::enabled()) {
+    MethodHandles::generate_adapters(CHECK);
+  }
 }
 JVM_END
--- a/hotspot/src/share/vm/prims/methodHandles.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/prims/methodHandles.hpp	Wed Jan 19 21:51:10 2011 -0800
@@ -294,11 +294,11 @@
   enum { _suppress_defc = 1, _suppress_name = 2, _suppress_type = 4 };
 
   // Generate MethodHandles adapters.
-  static void generate_adapters();
+  static void generate_adapters(TRAPS);
 
   // Called from InterpreterGenerator and MethodHandlesAdapterGenerator.
   static address generate_method_handle_interpreter_entry(MacroAssembler* _masm);
-  static void generate_method_handle_stub(MacroAssembler* _masm, EntryKind ek);
+  static void generate_method_handle_stub(MacroAssembler* _masm, EntryKind ek, TRAPS);
 
   // argument list parsing
   static int argument_slot(oop method_type, int arg);
@@ -530,7 +530,7 @@
 public:
   MethodHandlesAdapterGenerator(CodeBuffer* code) : StubCodeGenerator(code) {}
 
-  void generate();
+  void generate(TRAPS);
 };
 
 #endif // SHARE_VM_PRIMS_METHODHANDLES_HPP
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -2297,14 +2297,15 @@
     } else if (match_option(option, "-Xoss", &tail)) {
           // HotSpot does not have separate native and Java stacks, ignore silently for compatibility
     // -Xmaxjitcodesize
-    } else if (match_option(option, "-Xmaxjitcodesize", &tail)) {
+    } else if (match_option(option, "-Xmaxjitcodesize", &tail) ||
+               match_option(option, "-XX:ReservedCodeCacheSize=", &tail)) {
       julong long_ReservedCodeCacheSize = 0;
       ArgsRange errcode = parse_memory_size(tail, &long_ReservedCodeCacheSize,
                                             (size_t)InitialCodeCacheSize);
       if (errcode != arg_in_range) {
         jio_fprintf(defaultStream::error_stream(),
-                    "Invalid maximum code cache size: %s\n",
-                    option->optionString);
+                    "Invalid maximum code cache size: %s. Should be greater than InitialCodeCacheSize=%dK\n",
+                    option->optionString, InitialCodeCacheSize/K);
         describe_range_error(errcode);
         return JNI_EINVAL;
       }
--- a/hotspot/src/share/vm/runtime/init.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/runtime/init.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -125,9 +125,6 @@
   javaClasses_init();  // must happen after vtable initialization
   stubRoutines_init2(); // note: StubRoutines need 2-phase init
 
-  // Generate MethodHandles adapters.
-  MethodHandles::generate_adapters();
-
   // Although we'd like to, we can't easily do a heap verify
   // here because the main thread isn't yet a JavaThread, so
   // its TLAB may not be made parseable from the usual interfaces.
--- a/hotspot/src/share/vm/runtime/java.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/runtime/java.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -515,8 +515,8 @@
 }
 
 void vm_exit(int code) {
-  Thread* thread = ThreadLocalStorage::thread_index() == -1 ? NULL
-    : ThreadLocalStorage::get_thread_slow();
+  Thread* thread = ThreadLocalStorage::is_initialized() ?
+    ThreadLocalStorage::get_thread_slow() : NULL;
   if (thread == NULL) {
     // we have serious problems -- just exit
     vm_direct_exit(code);
@@ -553,8 +553,9 @@
   // Calling 'exit_globals()' will disable thread-local-storage and cause all
   // kinds of assertions to trigger in debug mode.
   if (is_init_completed()) {
-    Thread* thread = Thread::current();
-    if (thread->is_Java_thread()) {
+    Thread* thread = ThreadLocalStorage::is_initialized() ?
+                     ThreadLocalStorage::get_thread_slow() : NULL;
+    if (thread != NULL && thread->is_Java_thread()) {
       // We are leaving the VM, set state to native (in case any OS exit
       // handlers call back to the VM)
       JavaThread* jt = (JavaThread*)thread;
--- a/hotspot/src/share/vm/runtime/thread.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Jan 19 21:51:10 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
@@ -177,20 +177,19 @@
 
 
 Thread::Thread() {
-  // stack
-  _stack_base   = NULL;
-  _stack_size   = 0;
-  _self_raw_id  = 0;
-  _lgrp_id      = -1;
-  _osthread     = NULL;
+  // stack and get_thread
+  set_stack_base(NULL);
+  set_stack_size(0);
+  set_self_raw_id(0);
+  set_lgrp_id(-1);
 
   // allocated data structures
+  set_osthread(NULL);
   set_resource_area(new ResourceArea());
   set_handle_area(new HandleArea(NULL));
   set_active_handles(NULL);
   set_free_handle_block(NULL);
   set_last_handle_mark(NULL);
-  set_osthread(NULL);
 
   // This initial value ==> never claimed.
   _oops_do_parity = 0;
@@ -205,6 +204,7 @@
   NOT_PRODUCT(_skip_gcalot = false;)
   CHECK_UNHANDLED_OOPS_ONLY(_gc_locked_out_count = 0;)
   _jvmti_env_iteration_count = 0;
+  set_allocated_bytes(0);
   _vm_operation_started_count = 0;
   _vm_operation_completed_count = 0;
   _current_pending_monitor = NULL;
@@ -3231,7 +3231,7 @@
       warning("java.lang.ArithmeticException has not been initialized");
       warning("java.lang.StackOverflowError has not been initialized");
     }
-  }
+    }
 
   // See        : bugid 4211085.
   // Background : the static initializer of java.lang.Compiler tries to read
--- a/hotspot/src/share/vm/runtime/thread.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/runtime/thread.hpp	Wed Jan 19 21:51:10 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
@@ -60,7 +60,7 @@
 class JvmtiGetLoadedClassesClosure;
 class ThreadStatistics;
 class ConcurrentLocksDump;
-class ParkEvent ;
+class ParkEvent;
 class Parker;
 
 class ciEnv;
@@ -170,7 +170,7 @@
   //
 
   // suspend/resume lock: used for self-suspend
-  Monitor*    _SR_lock;
+  Monitor* _SR_lock;
 
  protected:
   enum SuspendFlags {
@@ -194,7 +194,7 @@
  public:
   void enter_signal_handler() { _num_nested_signal++; }
   void leave_signal_handler() { _num_nested_signal--; }
-  bool is_inside_signal_handler() const  { return _num_nested_signal > 0; }
+  bool is_inside_signal_handler() const { return _num_nested_signal > 0; }
 
  private:
   // Debug tracing
@@ -215,7 +215,7 @@
 
   public:
    void set_last_handle_mark(HandleMark* mark)   { _last_handle_mark = mark; }
-    HandleMark* last_handle_mark() const          { return _last_handle_mark; }
+   HandleMark* last_handle_mark() const          { return _last_handle_mark; }
   private:
 
   // debug support for checking if code does allow safepoints or not
@@ -227,11 +227,11 @@
   //
   // The two classes No_Safepoint_Verifier and No_Allocation_Verifier are used to set these counters.
   //
-  NOT_PRODUCT(int _allow_safepoint_count;)       // If 0, thread allow a safepoint to happen
-  debug_only (int _allow_allocation_count;)      // If 0, the thread is allowed to allocate oops.
+  NOT_PRODUCT(int _allow_safepoint_count;)      // If 0, thread allow a safepoint to happen
+  debug_only (int _allow_allocation_count;)     // If 0, the thread is allowed to allocate oops.
 
   // Used by SkipGCALot class.
-  NOT_PRODUCT(bool _skip_gcalot;)                // Should we elide gc-a-lot?
+  NOT_PRODUCT(bool _skip_gcalot;)               // Should we elide gc-a-lot?
 
   // Record when GC is locked out via the GC_locker mechanism
   CHECK_UNHANDLED_OOPS_ONLY(int _gc_locked_out_count;)
@@ -242,24 +242,26 @@
   friend class ThreadLocalStorage;
   friend class GC_locker;
 
-  ThreadLocalAllocBuffer _tlab;                  // Thread-local eden
+  ThreadLocalAllocBuffer _tlab;                 // Thread-local eden
+  jlong _allocated_bytes;                       // Cumulative number of bytes allocated on
+                                                // the Java heap
 
-  int   _vm_operation_started_count;             // VM_Operation support
-  int   _vm_operation_completed_count;           // VM_Operation support
+  int   _vm_operation_started_count;            // VM_Operation support
+  int   _vm_operation_completed_count;          // VM_Operation support
 
-  ObjectMonitor* _current_pending_monitor;       // ObjectMonitor this thread
-                                                 // is waiting to lock
-  bool _current_pending_monitor_is_from_java;    // locking is from Java code
+  ObjectMonitor* _current_pending_monitor;      // ObjectMonitor this thread
+                                                // is waiting to lock
+  bool _current_pending_monitor_is_from_java;   // locking is from Java code
 
   // ObjectMonitor on which this thread called Object.wait()
   ObjectMonitor* _current_waiting_monitor;
 
   // Private thread-local objectmonitor list - a simple cache organized as a SLL.
  public:
-  ObjectMonitor * omFreeList ;
-  int omFreeCount ;                             // length of omFreeList
-  int omFreeProvision ;                         // reload chunk size
-  ObjectMonitor * omInUseList;                  // SLL to track monitors in circulation
+  ObjectMonitor* omFreeList;
+  int omFreeCount;                              // length of omFreeList
+  int omFreeProvision;                          // reload chunk size
+  ObjectMonitor* omInUseList;                   // SLL to track monitors in circulation
   int omInUseCount;                             // length of omInUseList
 
  public:
@@ -280,7 +282,6 @@
   // Testers
   virtual bool is_VM_thread()       const            { return false; }
   virtual bool is_Java_thread()     const            { return false; }
-  // Remove this ifdef when C1 is ported to the compiler interface.
   virtual bool is_Compiler_thread() const            { return false; }
   virtual bool is_hidden_from_external_view() const  { return false; }
   virtual bool is_jvmti_agent_thread() const         { return false; }
@@ -344,15 +345,15 @@
   // Support for Unhandled Oop detection
 #ifdef CHECK_UNHANDLED_OOPS
  private:
-  UnhandledOops *_unhandled_oops;
+  UnhandledOops* _unhandled_oops;
  public:
-  UnhandledOops* unhandled_oops()               { return _unhandled_oops; }
+  UnhandledOops* unhandled_oops() { return _unhandled_oops; }
   // Mark oop safe for gc.  It may be stack allocated but won't move.
-  void allow_unhandled_oop(oop *op)              {
+  void allow_unhandled_oop(oop *op) {
     if (CheckUnhandledOops) unhandled_oops()->allow_unhandled_oop(op);
   }
   // Clear oops at safepoint so crashes point to unhandled oop violator
-  void clear_unhandled_oops()                   {
+  void clear_unhandled_oops() {
     if (CheckUnhandledOops) unhandled_oops()->clear_unhandled_oops();
   }
   bool is_gc_locked_out() { return _gc_locked_out_count > 0; }
@@ -392,6 +393,22 @@
     }
   }
 
+  jlong allocated_bytes()               { return _allocated_bytes; }
+  void set_allocated_bytes(jlong value) { _allocated_bytes = value; }
+  void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
+  jlong cooked_allocated_bytes() {
+    jlong allocated_bytes = OrderAccess::load_acquire(&_allocated_bytes);
+    if (UseTLAB) {
+      size_t used_bytes = tlab().used_bytes();
+      if ((ssize_t)used_bytes > 0) {
+        // More-or-less valid tlab.  The load_acquire above should ensure
+        // that the result of the add is <= the instantaneous value
+        return allocated_bytes + used_bytes;
+      }
+    }
+    return allocated_bytes;
+  }
+
   // VM operation support
   int vm_operation_ticket()                      { return ++_vm_operation_started_count; }
   int vm_operation_completed_count()             { return _vm_operation_completed_count; }
@@ -489,8 +506,11 @@
     return (_stack_base >= adr && adr >= (_stack_base - _stack_size));
   }
 
-  int     lgrp_id() const                 { return _lgrp_id; }
-  void    set_lgrp_id(int value)          { _lgrp_id = value; }
+  uintptr_t self_raw_id()                    { return _self_raw_id; }
+  void      set_self_raw_id(uintptr_t value) { _self_raw_id = value; }
+
+  int     lgrp_id() const        { return _lgrp_id; }
+  void    set_lgrp_id(int value) { _lgrp_id = value; }
 
   // Printing
   void print_on(outputStream* st) const;
@@ -502,7 +522,7 @@
 #ifdef ASSERT
  private:
   // Deadlock detection support for Mutex locks. List of locks own by thread.
-  Monitor *_owned_locks;
+  Monitor* _owned_locks;
   // Mutex::set_owner_implementation is the only place where _owned_locks is modified,
   // thus the friendship
   friend class Mutex;
@@ -511,7 +531,7 @@
  public:
   void print_owned_locks_on(outputStream* st) const;
   void print_owned_locks() const                 { print_owned_locks_on(tty);    }
-  Monitor * owned_locks() const                  { return _owned_locks;          }
+  Monitor* owned_locks() const                   { return _owned_locks;          }
   bool owns_locks() const                        { return owned_locks() != NULL; }
   bool owns_locks_but_compiled_lock() const;
 
@@ -538,7 +558,7 @@
   static ByteSize stack_size_offset()            { return byte_offset_of(Thread, _stack_size ); }
 
 #define TLAB_FIELD_OFFSET(name) \
-  static ByteSize tlab_##name##_offset()            { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::name##_offset(); }
+  static ByteSize tlab_##name##_offset()         { return byte_offset_of(Thread, _tlab) + ThreadLocalAllocBuffer::name##_offset(); }
 
   TLAB_FIELD_OFFSET(start)
   TLAB_FIELD_OFFSET(end)
@@ -552,6 +572,8 @@
 
 #undef TLAB_FIELD_OFFSET
 
+  static ByteSize allocated_bytes_offset()       { return byte_offset_of(Thread, _allocated_bytes ); }
+
  public:
   volatile intptr_t _Stalled ;
   volatile int _TypeTag ;
--- a/hotspot/src/share/vm/services/jmm.h	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/services/jmm.h	Wed Jan 19 21:51:10 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
@@ -60,7 +60,8 @@
   unsigned int isBootClassPathSupported : 1;
   unsigned int isObjectMonitorUsageSupported : 1;
   unsigned int isSynchronizerUsageSupported : 1;
-  unsigned int : 24;
+  unsigned int isThreadAllocatedMemorySupported : 1;
+  unsigned int : 23;
 } jmmOptionalSupport;
 
 typedef enum {
@@ -105,7 +106,8 @@
   JMM_VERBOSE_GC                     = 21,
   JMM_VERBOSE_CLASS                  = 22,
   JMM_THREAD_CONTENTION_MONITORING   = 23,
-  JMM_THREAD_CPU_TIME                = 24
+  JMM_THREAD_CPU_TIME                = 24,
+  JMM_THREAD_ALLOCATED_MEMORY        = 25
 } jmmBoolAttribute;
 
 
@@ -213,7 +215,10 @@
   jobject      (JNICALL *GetMemoryPoolUsage)     (JNIEnv* env, jobject pool);
   jobject      (JNICALL *GetPeakMemoryPoolUsage) (JNIEnv* env, jobject pool);
 
-  void*        reserved4;
+  void         (JNICALL *GetThreadAllocatedMemory)
+                                                 (JNIEnv *env,
+                                                  jlongArray ids,
+                                                  jlongArray sizeArray);
 
   jobject      (JNICALL *GetMemoryUsage)         (JNIEnv* env, jboolean heap);
 
@@ -228,6 +233,8 @@
                                                   jlong* result);
 
   jobjectArray (JNICALL *FindCircularBlockedThreads) (JNIEnv *env);
+
+  // Not used in JDK 6 or JDK 7
   jlong        (JNICALL *GetThreadCpuTime)       (JNIEnv *env, jlong thread_id);
 
   jobjectArray (JNICALL *GetVMGlobalNames)       (JNIEnv *env);
@@ -262,14 +269,22 @@
   void         (JNICALL *GetLastGCStat)          (JNIEnv *env,
                                                   jobject mgr,
                                                   jmmGCStat *gc_stat);
-  jlong        (JNICALL *GetThreadCpuTimeWithKind) (JNIEnv *env,
-                                                    jlong thread_id,
-                                                    jboolean user_sys_cpu_time);
-  void*        reserved5;
+
+  jlong        (JNICALL *GetThreadCpuTimeWithKind)
+                                                 (JNIEnv *env,
+                                                  jlong thread_id,
+                                                  jboolean user_sys_cpu_time);
+  void         (JNICALL *GetThreadCpuTimesWithKind)
+                                                 (JNIEnv *env,
+                                                  jlongArray ids,
+                                                  jlongArray timeArray,
+                                                  jboolean user_sys_cpu_time);
+
   jint         (JNICALL *DumpHeap0)              (JNIEnv *env,
                                                   jstring outputfile,
                                                   jboolean live);
-  jobjectArray (JNICALL *FindDeadlocks)             (JNIEnv *env, jboolean object_monitors_only);
+  jobjectArray (JNICALL *FindDeadlocks)          (JNIEnv *env,
+                                                  jboolean object_monitors_only);
   void         (JNICALL *SetVMGlobal)            (JNIEnv *env,
                                                   jstring flag_name,
                                                   jvalue  new_value);
--- a/hotspot/src/share/vm/services/management.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/services/management.cpp	Wed Jan 19 21:51:10 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
@@ -101,12 +101,14 @@
     _optional_support.isCurrentThreadCpuTimeSupported = 0;
     _optional_support.isOtherThreadCpuTimeSupported = 0;
   }
+
   _optional_support.isBootClassPathSupported = 1;
   _optional_support.isObjectMonitorUsageSupported = 1;
 #ifndef SERVICES_KERNEL
   // This depends on the heap inspector
   _optional_support.isSynchronizerUsageSupported = 1;
 #endif // SERVICES_KERNEL
+  _optional_support.isThreadAllocatedMemorySupported = 1;
 }
 
 void Management::initialize(TRAPS) {
@@ -386,11 +388,6 @@
 
 static void validate_thread_id_array(typeArrayHandle ids_ah, TRAPS) {
   int num_threads = ids_ah->length();
-  // should be non-empty array
-  if (num_threads == 0) {
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-              "Empty array of thread IDs");
-  }
 
   // Validate input thread IDs
   int i = 0;
@@ -402,11 +399,9 @@
                 "Invalid thread ID entry");
     }
   }
-
 }
 
 static void validate_thread_info_array(objArrayHandle infoArray_h, TRAPS) {
-
   // check if the element of infoArray is of type ThreadInfo class
   klassOop threadinfo_klass = Management::java_lang_management_ThreadInfo_klass(CHECK);
   klassOop element_klass = objArrayKlass::cast(infoArray_h->klass())->element_klass();
@@ -414,7 +409,6 @@
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "infoArray element type is not ThreadInfo class");
   }
-
 }
 
 
@@ -770,6 +764,45 @@
   return prev;
 JVM_END
 
+// Gets an array containing the amount of memory allocated on the Java
+// heap for a set of threads (in bytes).  Each element of the array is
+// the amount of memory allocated for the thread ID specified in the
+// corresponding entry in the given array of thread IDs; or -1 if the
+// thread does not exist or has terminated.
+JVM_ENTRY(void, jmm_GetThreadAllocatedMemory(JNIEnv *env, jlongArray ids,
+                                             jlongArray sizeArray))
+  // Check if threads is null
+  if (ids == NULL || sizeArray == NULL) {
+    THROW(vmSymbols::java_lang_NullPointerException());
+  }
+
+  ResourceMark rm(THREAD);
+  typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(ids));
+  typeArrayHandle ids_ah(THREAD, ta);
+
+  typeArrayOop sa = typeArrayOop(JNIHandles::resolve_non_null(sizeArray));
+  typeArrayHandle sizeArray_h(THREAD, sa);
+
+  // validate the thread id array
+  validate_thread_id_array(ids_ah, CHECK);
+
+  // sizeArray must be of the same length as the given array of thread IDs
+  int num_threads = ids_ah->length();
+  if (num_threads != sizeArray_h->length()) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "The length of the given long array does not match the length of "
+              "the given array of thread IDs");
+  }
+
+  MutexLockerEx ml(Threads_lock);
+  for (int i = 0; i < num_threads; i++) {
+    JavaThread* java_thread = find_java_thread_from_id(ids_ah->long_at(i));
+    if (java_thread != NULL) {
+      sizeArray_h->long_at_put(i, java_thread->cooked_allocated_bytes());
+    }
+  }
+JVM_END
+
 // Returns a java/lang/management/MemoryUsage object representing
 // the memory usage for the heap or non-heap memory.
 JVM_ENTRY(jobject, jmm_GetMemoryUsage(JNIEnv* env, jboolean heap))
@@ -834,6 +867,8 @@
     return ThreadService::is_thread_monitoring_contention();
   case JMM_THREAD_CPU_TIME:
     return ThreadService::is_thread_cpu_time_enabled();
+  case JMM_THREAD_ALLOCATED_MEMORY:
+    return ThreadService::is_thread_allocated_memory_enabled();
   default:
     assert(0, "Unrecognized attribute");
     return false;
@@ -851,6 +886,8 @@
     return ThreadService::set_thread_monitoring_contention(flag != 0);
   case JMM_THREAD_CPU_TIME:
     return ThreadService::set_thread_cpu_time_enabled(flag != 0);
+  case JMM_THREAD_ALLOCATED_MEMORY:
+    return ThreadService::set_thread_allocated_memory_enabled(flag != 0);
   default:
     assert(0, "Unrecognized attribute");
     return false;
@@ -1096,6 +1133,7 @@
 //               maxDepth == 0  requests no stack trace.
 //   infoArray - array of ThreadInfo objects
 //
+// QQQ - Why does this method return a value instead of void?
 JVM_ENTRY(jint, jmm_GetThreadInfo(JNIEnv *env, jlongArray ids, jint maxDepth, jobjectArray infoArray))
   // Check if threads is null
   if (ids == NULL || infoArray == NULL) {
@@ -1159,7 +1197,6 @@
     }
   } else {
     // obtain thread dump with the specific list of threads with stack trace
-
     do_thread_dump(&dump_result,
                    ids_ah,
                    num_threads,
@@ -1252,8 +1289,6 @@
       continue;
     }
 
-
-
     ThreadStackTrace* stacktrace = ts->get_stack_trace();
     assert(stacktrace != NULL, "Must have a stack trace dumped");
 
@@ -1500,6 +1535,49 @@
   return -1;
 JVM_END
 
+// Gets an array containing the CPU times consumed by a set of threads
+// (in nanoseconds).  Each element of the array is the CPU time for the
+// thread ID specified in the corresponding entry in the given array
+// of thread IDs; or -1 if the thread does not exist or has terminated.
+// If user_sys_cpu_time = true, the sum of user level and system CPU time
+// for the given thread is returned; otherwise, only user level CPU time
+// is returned.
+JVM_ENTRY(void, jmm_GetThreadCpuTimesWithKind(JNIEnv *env, jlongArray ids,
+                                              jlongArray timeArray,
+                                              jboolean user_sys_cpu_time))
+  // Check if threads is null
+  if (ids == NULL || timeArray == NULL) {
+    THROW(vmSymbols::java_lang_NullPointerException());
+  }
+
+  ResourceMark rm(THREAD);
+  typeArrayOop ta = typeArrayOop(JNIHandles::resolve_non_null(ids));
+  typeArrayHandle ids_ah(THREAD, ta);
+
+  typeArrayOop tia = typeArrayOop(JNIHandles::resolve_non_null(timeArray));
+  typeArrayHandle timeArray_h(THREAD, tia);
+
+  // validate the thread id array
+  validate_thread_id_array(ids_ah, CHECK);
+
+  // timeArray must be of the same length as the given array of thread IDs
+  int num_threads = ids_ah->length();
+  if (num_threads != timeArray_h->length()) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "The length of the given long array does not match the length of "
+              "the given array of thread IDs");
+  }
+
+  MutexLockerEx ml(Threads_lock);
+  for (int i = 0; i < num_threads; i++) {
+    JavaThread* java_thread = find_java_thread_from_id(ids_ah->long_at(i));
+    if (java_thread != NULL) {
+      timeArray_h->long_at_put(i, os::thread_cpu_time((Thread*)java_thread,
+                                                      user_sys_cpu_time != 0));
+    }
+  }
+JVM_END
+
 // Returns a String array of all VM global flag names
 JVM_ENTRY(jobjectArray, jmm_GetVMGlobalNames(JNIEnv *env))
   // last flag entry is always NULL, so subtract 1
@@ -2020,7 +2098,7 @@
   jmm_GetMemoryManagers,
   jmm_GetMemoryPoolUsage,
   jmm_GetPeakMemoryPoolUsage,
-  NULL,
+  jmm_GetThreadAllocatedMemory,
   jmm_GetMemoryUsage,
   jmm_GetLongAttribute,
   jmm_GetBoolAttribute,
@@ -2038,7 +2116,7 @@
   jmm_GetGCExtAttributeInfo,
   jmm_GetLastGCStat,
   jmm_GetThreadCpuTimeWithKind,
-  NULL,
+  jmm_GetThreadCpuTimesWithKind,
   jmm_DumpHeap0,
   jmm_FindDeadlockedThreads,
   jmm_SetVMGlobal,
--- a/hotspot/src/share/vm/services/threadService.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/services/threadService.cpp	Wed Jan 19 21:51:10 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
@@ -46,6 +46,7 @@
 // Default is disabled.
 bool ThreadService::_thread_monitoring_contention_enabled = false;
 bool ThreadService::_thread_cpu_time_enabled = false;
+bool ThreadService::_thread_allocated_memory_enabled = false;
 
 PerfCounter*  ThreadService::_total_threads_count = NULL;
 PerfVariable* ThreadService::_live_threads_count = NULL;
@@ -84,6 +85,8 @@
   if (os::is_thread_cpu_time_supported()) {
     _thread_cpu_time_enabled = true;
   }
+
+  _thread_allocated_memory_enabled = true; // Always on, so enable it
 }
 
 void ThreadService::reset_peak_thread_count() {
@@ -181,6 +184,15 @@
   return prev;
 }
 
+bool ThreadService::set_thread_allocated_memory_enabled(bool flag) {
+  MutexLocker m(Management_lock);
+
+  bool prev = _thread_allocated_memory_enabled;
+  _thread_allocated_memory_enabled = flag;
+
+  return prev;
+}
+
 // GC support
 void ThreadService::oops_do(OopClosure* f) {
   for (ThreadDumpResult* dump = _threaddump_list; dump != NULL; dump = dump->next()) {
--- a/hotspot/src/share/vm/services/threadService.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/services/threadService.hpp	Wed Jan 19 21:51:10 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
@@ -65,6 +65,7 @@
 
   static bool          _thread_monitoring_contention_enabled;
   static bool          _thread_cpu_time_enabled;
+  static bool          _thread_allocated_memory_enabled;
 
   // Need to keep the list of thread dump result that
   // keep references to methodOop since thread dump can be
@@ -83,6 +84,9 @@
   static bool set_thread_cpu_time_enabled(bool flag);
   static bool is_thread_cpu_time_enabled()    { return _thread_cpu_time_enabled; }
 
+  static bool set_thread_allocated_memory_enabled(bool flag);
+  static bool is_thread_allocated_memory_enabled() { return _thread_cpu_time_enabled; }
+
   static jlong get_total_thread_count()       { return _total_threads_count->get_value(); }
   static jlong get_peak_thread_count()        { return _peak_threads_count->get_value(); }
   static jlong get_live_thread_count()        { return _live_threads_count->get_value() - _exiting_threads_count; }
--- a/hotspot/src/share/vm/utilities/debug.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/utilities/debug.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -226,7 +226,7 @@
 
 void report_vm_out_of_memory(const char* file, int line, size_t size,
                              const char* message) {
-  if (Debugging || error_is_suppressed(file, line)) return;
+  if (Debugging) return;
 
   // We try to gather additional information for the first out of memory
   // error only; gathering additional data might cause an allocation and a
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -67,7 +67,7 @@
 // threads are blocked forever inside report_and_die().
 
 // Constructor for crashes
-VMError::VMError(Thread* thread, int sig, address pc, void* siginfo, void* context) {
+VMError::VMError(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context) {
     _thread = thread;
     _id = sig;
     _pc   = pc;
@@ -322,29 +322,51 @@
 
   STEP(10, "(printing fatal error message)")
 
-     st->print_cr("#");
-     st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
+    st->print_cr("#");
+    if (should_report_bug(_id)) {
+      st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
+    } else {
+      st->print_cr("# There is insufficient memory for the Java "
+                   "Runtime Environment to continue.");
+    }
 
   STEP(15, "(printing type of error)")
 
      switch(_id) {
        case oom_error:
-         st->print_cr("#");
-         st->print("# java.lang.OutOfMemoryError: ");
          if (_size) {
-           st->print("requested ");
-           sprintf(buf,SIZE_FORMAT,_size);
+           st->print("# Native memory allocation (malloc) failed to allocate ");
+           jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
            st->print(buf);
            st->print(" bytes");
            if (_message != NULL) {
              st->print(" for ");
              st->print(_message);
            }
-           st->print_cr(". Out of swap space?");
+           st->cr();
          } else {
            if (_message != NULL)
+             st->print("# ");
              st->print_cr(_message);
          }
+         // In error file give some solutions
+         if (_verbose) {
+           st->print_cr("# Possible reasons:");
+           st->print_cr("#   The system is out of physical RAM or swap space");
+           st->print_cr("#   In 32 bit mode, the process size limit was hit");
+           st->print_cr("# Possible solutions:");
+           st->print_cr("#   Reduce memory load on the system");
+           st->print_cr("#   Increase physical memory or swap space");
+           st->print_cr("#   Check if swap backing store is full");
+           st->print_cr("#   Use 64 bit Java on a 64 bit OS");
+           st->print_cr("#   Decrease Java heap size (-Xmx/-Xms)");
+           st->print_cr("#   Decrease number of Java threads");
+           st->print_cr("#   Decrease Java thread stack sizes (-Xss)");
+           st->print_cr("#   Set larger code cache with -XX:ReservedCodeCacheSize=");
+           st->print_cr("# This output file may be truncated or incomplete.");
+         } else {
+           return;  // that's enough for the screen
+         }
          break;
        case internal_error:
        default:
@@ -361,7 +383,11 @@
        st->print(" (0x%x)", _id);                // signal number
        st->print(" at pc=" PTR_FORMAT, _pc);
      } else {
-       st->print("Internal Error");
+       if (should_report_bug(_id)) {
+         st->print("Internal Error");
+       } else {
+         st->print("Out of Memory Error");
+       }
        if (_filename != NULL && _lineno > 0) {
 #ifdef PRODUCT
          // In product mode chop off pathname?
@@ -393,12 +419,14 @@
 
   STEP(40, "(printing error message)")
 
-     // error message
-     if (_detail_msg) {
-       st->print_cr("#  %s: %s", _message ? _message : "Error", _detail_msg);
-     } else if (_message) {
-       st->print_cr("#  Error: %s", _message);
-     }
+     if (should_report_bug(_id)) {  // already printed the message.
+       // error message
+       if (_detail_msg) {
+         st->print_cr("#  %s: %s", _message ? _message : "Error", _detail_msg);
+       } else if (_message) {
+         st->print_cr("#  Error: %s", _message);
+       }
+    }
 
   STEP(50, "(printing Java version string)")
 
@@ -428,7 +456,9 @@
 
   STEP(65, "(printing bug submit message)")
 
-     if (_verbose) print_bug_submit_message(st, _thread);
+     if (should_report_bug(_id) && _verbose) {
+       print_bug_submit_message(st, _thread);
+     }
 
   STEP(70, "(printing thread)" )
 
@@ -906,7 +936,7 @@
     OnError = NULL;
   }
 
-  static bool skip_bug_url = false;
+  static bool skip_bug_url = !should_report_bug(first_error->_id);
   if (!skip_bug_url) {
     skip_bug_url = true;
 
@@ -919,7 +949,8 @@
     static bool skip_os_abort = false;
     if (!skip_os_abort) {
       skip_os_abort = true;
-      os::abort();
+      bool dump_core = should_report_bug(first_error->_id);
+      os::abort(dump_core);
     }
 
     // if os::abort() doesn't abort, try os::die();
--- a/hotspot/src/share/vm/utilities/vmError.hpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/hotspot/src/share/vm/utilities/vmError.hpp	Wed Jan 19 21:51:10 2011 -0800
@@ -87,10 +87,12 @@
   // accessor
   const char* message() const    { return _message; }
   const char* detail_msg() const { return _detail_msg; }
+  bool should_report_bug(unsigned int id) { return id != oom_error; }
 
 public:
   // Constructor for crashes
-  VMError(Thread* thread, int sig, address pc, void* siginfo, void* context);
+  VMError(Thread* thread, unsigned int sig, address pc, void* siginfo,
+          void* context);
   // Constructor for VM internal errors
   VMError(Thread* thread, const char* filename, int lineno,
           const char* message, const char * detail_msg);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6579789/Test6579789.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6579789
+ * @summary Internal error "c1_LinearScan.cpp:1429 Error: assert(false,"")" in debuggee with fastdebug VM
+ * @run main/othervm -Xcomp -XX:UseSSE=0 -XX:CompileOnly=Test6579789.bug Test6579789
+ */
+
+public class Test6579789 {
+    public static void main(String[] args) {
+        bug(4);
+    }
+    public static void bug(int n) {
+        float f = 1;
+        int i = 1;
+        try {
+            int x = 1 / n; // instruction that can trap
+            f = 2;
+            i = 2;
+            int y = 2 / n; // instruction that can trap
+        } catch (Exception ex) {
+            f++;
+            i++;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7009231/Test7009231.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 7009231
+ * @summary C1: Incorrect CAS code for longs on SPARC 32bit
+ *
+ * @run main/othervm -Xbatch Test7009231
+ *
+ */
+
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicLong;
+
+
+public class Test7009231 {
+    public static void main(String[] args) throws InterruptedException {
+        doTest(8);
+    }
+
+    private static void doTest(int nThreads) throws InterruptedException {
+        Thread[]         aThreads = new Thread[nThreads];
+        final AtomicLong atl      = new AtomicLong();
+
+        for (int i = 0; i < nThreads; i++) {
+          aThreads[i] = new RunnerThread(atl, 1L << (8 * i));
+        }
+
+        for (int i = 0; i < nThreads; i++) {
+          aThreads[i].start();
+        }
+
+        for (int i = 0; i < nThreads; i++) {
+          aThreads[i].join();
+        }
+    }
+
+    public static class RunnerThread extends Thread {
+        public RunnerThread(AtomicLong atomic, long lMask) {
+            m_lMask  = lMask;
+            m_atomic = atomic;
+        }
+
+        public void run() {
+            AtomicLong atomic = m_atomic;
+            long       lMask  = m_lMask;
+            for (int i = 0; i < 100000; i++) {
+                setBit(atomic, lMask);
+                clearBit(atomic, lMask);
+            }
+        }
+
+        protected void setBit(AtomicLong atomic, long lMask) {
+            long lWord;
+            do {
+                lWord = atomic.get();
+            } while (!atomic.compareAndSet(lWord, lWord | lMask));
+
+            if ((atomic.get() & lMask) == 0L) {
+                throw new InternalError();
+            }
+        }
+
+        protected void clearBit(AtomicLong atomic, long lMask) {
+            long lWord;
+            do {
+                lWord = atomic.get();
+            } while (!atomic.compareAndSet(lWord, lWord & ~lMask));
+
+            if ((atomic.get() & lMask) != 0L) {
+                throw new InternalError();
+            }
+        }
+
+        private long m_lMask;
+        private AtomicLong m_atomic;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7009359/Test7009359.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 7009359
+ * @summary HS with -XX:+AggressiveOpts optimize new StringBuffer(null) so it does not throw NPE as expected
+ *
+ * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeStringConcat -XX:CompileCommand=exclude,Test7009359,main Test7009359
+ *
+ */
+
+public class Test7009359 {
+    public static void main (String[] args) {
+        for(int i = 0; i < 1000000; i++) {
+            if(!stringmakerBUG(null).equals("NPE")) {
+                System.out.println("StringBuffer(null) does not throw NPE");
+                System.exit(97);
+            }
+        }
+    }
+
+    public static String stringmakerBUG(String str) {
+       try {
+           return new StringBuffer(str).toString();
+       } catch (NullPointerException e) {
+           return "NPE";
+       }
+    }
+}
+
--- a/jaxp/.hgtags	Wed Jan 19 17:01:50 2011 +0300
+++ b/jaxp/.hgtags	Wed Jan 19 21:51:10 2011 -0800
@@ -98,3 +98,5 @@
 63dae40fa19fd3bf4689ea2f3c1d9d690e1abcee jdk7-b121
 03ff13d19c8fa983cbab6542930a7f352e9b5b33 jdk7-b122
 e2aedea6495d61557326928de20dbb2d78fdd9aa jdk7-b123
+57ed1f3bec72924cdad102f9bf90f7449ea7bb83 jdk7-b124
+6c9bdee0cc3a8912acc5189cc092b8cba6851f9d jdk7-b125
--- a/jaxp/jaxp.properties	Wed Jan 19 17:01:50 2011 +0300
+++ b/jaxp/jaxp.properties	Wed Jan 19 21:51:10 2011 -0800
@@ -25,13 +25,13 @@
 
 drops.master.copy.base=${drops.dir}
 
-jaxp_src.bundle.name=jaxp-1_4_4.zip
-jaxp_src.bundle.md5.checksum=2c40a758392c4abf2d59f355240df46a
+jaxp_src.bundle.name=jaxp-1_4_5-dev.zip
+jaxp_src.bundle.md5.checksum=84e2c26853262c9144133c6ff7ef5dc9
 jaxp_src.master.bundle.dir=${drops.master.copy.base}
-jaxp_src.master.bundle.url.base=https://java.net/downloads/jaxp/jdk7
+jaxp_src.master.bundle.url.base=http://download.java.net/jaxp/1.4.5/dev
 
-#jaxp_tests.bundle.name=jaxp-unittests-1_4_4.zip
-#jaxp_tests.bundle.md5.checksum=51845e38b02920cf5374d0331ab3a4ee
-#jaxp_tests.master.bundle.dir=${drops.master.copy.base}
-#jaxp_tests.master.bundle.url.base=https://java.net/downloads/jaxp/jdk7
+jaxp_tests.bundle.name=jaxp-1_4_5-dev-unittests.zip
+jaxp_tests.bundle.md5.checksum=0377e715fa21814cb8006768c5967dc5
+jaxp_tests.master.bundle.dir=${drops.master.copy.base}
+jaxp_tests.master.bundle.url.base=http://download.java.net/jaxp/1.4.5/dev
 
--- a/jaxws/.hgtags	Wed Jan 19 17:01:50 2011 +0300
+++ b/jaxws/.hgtags	Wed Jan 19 21:51:10 2011 -0800
@@ -98,3 +98,5 @@
 0fa950117faac7bdbc94e6c46b88f6f892031c17 jdk7-b121
 17b6c48a344968880925dcef1178fec282feb335 jdk7-b122
 5a8e43bcce56b7cd5576419067a929b74575ae71 jdk7-b123
+86f60e5b3975840968f3147ddce047a27a9fc83e jdk7-b124
+d72eea121c3bc2b649272a37b80d9417855b7146 jdk7-b125
--- a/jaxws/jaxws.properties	Wed Jan 19 17:01:50 2011 +0300
+++ b/jaxws/jaxws.properties	Wed Jan 19 21:51:10 2011 -0800
@@ -25,10 +25,10 @@
 
 drops.master.copy.base=${drops.dir}
 
-jaxws_src.bundle.name= jdk7-jaxws2_2-2010_08_19.zip
-jaxws_src.bundle.md5.checksum=8775ccefd3b4fa2dde5155ec4b7e4ceb
+jaxws_src.bundle.name=jdk7-jaxws2_2_2-2010_12_14.zip
+jaxws_src.bundle.md5.checksum=fee9ac72fabc96719eefc66ecaff4bc3
 jaxws_src.master.bundle.dir=${drops.master.copy.base}
-jaxws_src.master.bundle.url.base=https://java.net/downloads/jax-ws/JDK7
+jaxws_src.master.bundle.url.base=http://download.java.net/glassfish/components/jax-ws/openjdk/jdk7
 
 jaf_src.bundle.name=jdk7-jaf-2010_08_19.zip
 jaf_src.bundle.md5.checksum=18d15dfd71117daadb332af003d08212
--- a/jdk/.hgtags	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/.hgtags	Wed Jan 19 21:51:10 2011 -0800
@@ -98,3 +98,5 @@
 a661d8587b5d8986aacae086f5df66af9e1a96b1 jdk7-b121
 ac311eb325bfc763698219252bf3cee9e091f3af jdk7-b122
 869190935eedee7750d955019ab2a1b80f0a13a8 jdk7-b123
+1c72adc9d5f331cb882cf5354ba0dcb118a60b23 jdk7-b124
+0a56bdd709d01c1663047e55201d19152ffd3d69 jdk7-b125
--- a/jdk/make/common/shared/Defs-java.gmk	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/make/common/shared/Defs-java.gmk	Wed Jan 19 21:51:10 2011 -0800
@@ -155,7 +155,7 @@
 		"-Xbootclasspath/p:$(JAVAC_JAR)" \
 		-jar $(JAVAC_JAR) $(JAVACFLAGS)
   JAVAH_CMD   = $(BOOT_JAVA_CMD) \
-		"-Xbootclasspath/p:$(JAVAH_JAR)$(CLASSPATH_SEPARATOR)$(JAVADOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)"  \
+		"-Xbootclasspath/p:$(JAVAH_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)"  \
 		-jar $(JAVAH_JAR) $(JAVAHFLAGS)
   JAVADOC_CMD = $(BOOT_JAVA_CMD) \
 		"-Xbootclasspath/p:$(JAVADOC_JAR)$(CLASSPATH_SEPARATOR)$(JAVAC_JAR)$(CLASSPATH_SEPARATOR)$(DOCLETS_JAR)" \
--- a/jdk/make/sun/Makefile	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/make/sun/Makefile	Wed Jan 19 21:51:10 2011 -0800
@@ -42,7 +42,15 @@
   ifndef OPENJDK
     ifeq ($(PLATFORM), solaris)
       ifneq ($(ARCH), amd64)
-        DGA_SUBDIR = jdga
+        # Solaris 11 does not have support for new compilation of DGA code.
+        OS_VERSION = $(shell uname -r)
+        OS_MAJOR_VERSION := $(call MajorVersion,$(OS_VERSION))
+        OS_MINOR_VERSION := $(call MinorVersion,$(OS_VERSION))
+        ifeq ($(shell $(EXPR) $(OS_MAJOR_VERSION) == 5), 1)
+          ifeq ($(shell $(EXPR) $(OS_MINOR_VERSION) \<= 10), 1)
+            DGA_SUBDIR = jdga
+          endif
+        endif
       endif
     endif
   endif
--- a/jdk/make/sun/awt/make.depend	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/make/sun/awt/make.depend	Wed Jan 19 21:51:10 2011 -0800
@@ -224,7 +224,7 @@
 
 $(OBJDIR)/DrawLine.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawLine.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
 
-$(OBJDIR)/DrawParallelogram.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawParallelogram.h $(CLASSHDRDIR)/sun_java2d_loops_FillParallelogram.h ../../../src/share/javavm/export/classfile_constants.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/LoopMacros.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
+$(OBJDIR)/DrawParallelogram.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawParallelogram.h ../../../src/share/javavm/export/classfile_constants.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/ParallelogramUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
 
 $(OBJDIR)/DrawPath.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawPath.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/DrawPath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/ProcessPath.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
 
@@ -232,7 +232,7 @@
 
 $(OBJDIR)/DrawRect.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_DrawRect.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
 
-$(OBJDIR)/FillParallelogram.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_FillParallelogram.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
+$(OBJDIR)/FillParallelogram.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_FillParallelogram.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/ParallelogramUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
 
 $(OBJDIR)/FillPath.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_FillPath.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/DrawPath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/LineUtils.h ../../../src/share/native/sun/java2d/loops/ProcessPath.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
 
@@ -284,7 +284,7 @@
 
 $(OBJDIR)/MaskBlit.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_MaskBlit.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/Region.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/awt/utility/rect.h ../../../src/windows/native/sun/java2d/j2d_md.h
 
-$(OBJDIR)/MaskFill.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_MaskFill.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
+$(OBJDIR)/MaskFill.obj::	$(CLASSHDRDIR)/java_awt_AlphaComposite.h $(CLASSHDRDIR)/sun_java2d_loops_MaskFill.h ../../../src/share/javavm/export/jni.h ../../../src/share/native/common/gdefs.h ../../../src/share/native/sun/java2d/loops/AlphaMath.h ../../../src/share/native/sun/java2d/loops/GlyphImageRef.h ../../../src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h ../../../src/share/native/sun/java2d/loops/ParallelogramUtils.h ../../../src/share/native/sun/java2d/pipe/SpanIterator.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/native/common/gdefs_md.h ../../../src/windows/native/sun/java2d/j2d_md.h
 
 $(OBJDIR)/MouseInfo.obj::	$(CLASSHDRDIR)/java_awt_AWTEvent.h $(CLASSHDRDIR)/java_awt_Component.h $(CLASSHDRDIR)/java_awt_Dimension.h $(CLASSHDRDIR)/java_awt_Event.h $(CLASSHDRDIR)/java_awt_event_FocusEvent.h $(CLASSHDRDIR)/java_awt_event_KeyEvent.h $(CLASSHDRDIR)/java_awt_event_MouseEvent.h $(CLASSHDRDIR)/java_awt_event_WindowEvent.h $(CLASSHDRDIR)/java_awt_Font.h $(CLASSHDRDIR)/sun_awt_FontDescriptor.h $(CLASSHDRDIR)/sun_awt_PlatformFont.h $(CLASSHDRDIR)/sun_awt_windows_WComponentPeer.h $(CLASSHDRDIR)/sun_awt_windows_WFontMetrics.h $(CLASSHDRDIR)/sun_awt_windows_WObjectPeer.h $(CLASSHDRDIR)/sun_awt_windows_WToolkit.h ../../../src/share/javavm/export/classfile_constants.h ../../../src/share/javavm/export/jni.h ../../../src/share/javavm/export/jvm.h ../../../src/share/native/common/jlong.h ../../../src/share/native/common/jni_util.h ../../../src/share/native/sun/awt/debug/debug_assert.h ../../../src/share/native/sun/awt/debug/debug_mem.h ../../../src/share/native/sun/awt/debug/debug_trace.h ../../../src/share/native/sun/awt/debug/debug_util.h ../../../src/share/native/sun/awt/image/cvutils/img_globals.h ../../../src/share/native/sun/java2d/SurfaceData.h ../../../src/share/native/sun/java2d/Trace.h ../../../src/windows/javavm/export/jni_md.h ../../../src/windows/javavm/export/jvm_md.h ../../../src/windows/native/common/jlong_md.h ../../../src/windows/native/sun/java2d/windows/GDIWindowSurfaceData.h ../../../src/windows/native/sun/windows/alloc.h ../../../src/windows/native/sun/windows/awt.h ../../../src/windows/native/sun/windows/awtmsg.h ../../../src/windows/native/sun/windows/awt_Brush.h ../../../src/windows/native/sun/windows/awt_Component.h ../../../src/windows/native/sun/windows/awt_Debug.h ../../../src/windows/native/sun/windows/awt_Font.h ../../../src/windows/native/sun/windows/awt_GDIObject.h ../../../src/windows/native/sun/windows/awt_Object.h ../../../src/windows/native/sun/windows/awt_Palette.h ../../../src/windows/native/sun/windows/awt_Pen.h ../../../src/windows/native/sun/windows/awt_Toolkit.h ../../../src/windows/native/sun/windows/awt_Win32GraphicsDevice.h ../../../src/windows/native/sun/windows/colordata.h ../../../src/windows/native/sun/windows/Devices.h ../../../src/windows/native/sun/windows/GDIHashtable.h ../../../src/windows/native/sun/windows/Hashtable.h ../../../src/windows/native/sun/windows/ObjectList.h ../../../src/windows/native/sun/windows/stdhdrs.h
 
--- a/jdk/make/sun/awt/mapfile-vers	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/make/sun/awt/mapfile-vers	Wed Jan 19 21:51:10 2011 -0800
@@ -118,6 +118,8 @@
 		Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops;
 		Java_sun_java2d_loops_MaskBlit_MaskBlit;
 		Java_sun_java2d_loops_MaskFill_MaskFill;
+		Java_sun_java2d_loops_MaskFill_FillAAPgram;
+		Java_sun_java2d_loops_MaskFill_DrawAAPgram;
 		Java_sun_java2d_loops_TransformHelper_Transform;
 		Java_sun_java2d_pipe_Region_initIDs;
 		Java_sun_java2d_pipe_SpanClipRenderer_initIDs;
--- a/jdk/make/sun/awt/mapfile-vers-linux	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/make/sun/awt/mapfile-vers-linux	Wed Jan 19 21:51:10 2011 -0800
@@ -115,6 +115,8 @@
 		Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops;
 		Java_sun_java2d_loops_MaskBlit_MaskBlit;
 		Java_sun_java2d_loops_MaskFill_MaskFill;
+		Java_sun_java2d_loops_MaskFill_FillAAPgram;
+		Java_sun_java2d_loops_MaskFill_DrawAAPgram;
                 Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans;
 		Java_sun_java2d_pipe_SpanClipRenderer_initIDs;
 		sun_awt_image_GifImageDecoder_initIDs;
--- a/jdk/src/share/bin/java.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/bin/java.c	Wed Jan 19 21:51:10 2011 -0800
@@ -158,8 +158,9 @@
  * Running Java code in primordial thread caused many problems. We will
  * create a new thread to invoke JVM. See 6316197 for more information.
  */
-static jlong threadStackSize = 0;  /* stack size of the new thread */
-static jlong heapSize        = 0;  /* heap size */
+static jlong threadStackSize    = 0;  /* stack size of the new thread */
+static jlong maxHeapSize        = 0;  /* max heap size */
+static jlong initialHeapSize    = 0;  /* inital heap size */
 
 int JNICALL JavaMain(void * args); /* entry point                  */
 
@@ -381,7 +382,7 @@
 
     if (showSettings != NULL) {
         ShowSettings(env, showSettings);
-        CHECK_EXCEPTION_LEAVE(0);
+        CHECK_EXCEPTION_LEAVE(1);
     }
     /* If the user specified neither a class name nor a JAR file */
     if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) {
@@ -689,7 +690,14 @@
     if (JLI_StrCCmp(str, "-Xmx") == 0) {
         jlong tmp;
         if (parse_size(str + 4, &tmp)) {
-            heapSize = tmp;
+            maxHeapSize = tmp;
+        }
+    }
+
+    if (JLI_StrCCmp(str, "-Xms") == 0) {
+        jlong tmp;
+        if (parse_size(str + 4, &tmp)) {
+            initialHeapSize = tmp;
         }
     }
 }
@@ -1506,12 +1514,13 @@
     jstring joptString;
     NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
     NULL_CHECK(showSettingsID = (*env)->GetStaticMethodID(env, cls,
-            "showSettings", "(ZLjava/lang/String;JJZ)V"));
+            "showSettings", "(ZLjava/lang/String;JJJZ)V"));
     joptString = (*env)->NewStringUTF(env, optString);
     (*env)->CallStaticVoidMethod(env, cls, showSettingsID,
                                  JNI_TRUE,
                                  joptString,
-                                 (jlong)heapSize,
+                                 (jlong)initialHeapSize,
+                                 (jlong)maxHeapSize,
                                  (jlong)threadStackSize,
                                  ServerClassMachine());
 }
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java	Wed Jan 19 21:51:10 2011 -0800
@@ -29,13 +29,14 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Adaptive coding.
  * See the section "Adaptive Encodings" in the Pack200 spec.
  * @author John Rose
  */
-class AdaptiveCoding implements Constants, CodingMethod {
+class AdaptiveCoding implements CodingMethod {
     CodingMethod headCoding;
     int          headLength;
     CodingMethod tailCoding;
@@ -147,7 +148,6 @@
         }
         if (KX == KX_MAX)  return Integer.MAX_VALUE;
         KX += 1;
-        int unit2 = 1      << (KX * KX_LG2BASE);
         int mask2 = KB_MAX << (KX * KX_LG2BASE);
         K1 |= (mask & ~mask2);
         K1 += unit;
@@ -250,7 +250,7 @@
         return m.toString();
     }
     public String toString() {
-        StringBuffer res = new StringBuffer(20);
+        StringBuilder res = new StringBuilder(20);
         AdaptiveCoding run = this;
         res.append("run(");
         for (;;) {
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java	Wed Jan 19 21:51:10 2011 -0800
@@ -36,6 +36,7 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Represents an attribute in a class-file.
@@ -44,7 +45,7 @@
  * attribute layouts.
  * @author John Rose
  */
-class Attribute implements Comparable, Constants {
+class Attribute implements Comparable {
     // Attribute instance fields.
 
     Layout def;     // the name and format of this attr
@@ -103,7 +104,6 @@
         return this.def.compareTo(that.def);
     }
 
-    private static final byte[] noBytes = {};
     private static final Map<List<Attribute>, List<Attribute>> canonLists = new HashMap<>();
     private static final Map<Layout, Attribute> attributes = new HashMap<>();
     private static final Map<Layout, Attribute> standardDefs = new HashMap<>();
@@ -112,7 +112,7 @@
     // are used by trimToSize, in order to reduce footprint
     // of some common cases.  (Note that Code attributes are
     // always zero size.)
-    public static List getCanonList(List<Attribute> al) {
+    public static List<Attribute> getCanonList(List<Attribute> al) {
         synchronized (canonLists) {
             List<Attribute> cl = canonLists.get(al);
             if (cl == null) {
@@ -465,7 +465,9 @@
             return ConstantPool.getUtf8Entry(name());
         }
 
-        public boolean isEmpty() { return layout == ""; }
+        public boolean isEmpty() {
+            return layout.isEmpty();
+        }
 
         public Layout(int ctype, String name, String layout) {
             this.ctype = ctype;
@@ -479,19 +481,19 @@
                 } else {
                     String[] bodies = splitBodies(layout);
                     // Make the callables now, so they can be linked immediately.
-                    Element[] elems = new Element[bodies.length];
-                    this.elems = elems;
-                    for (int i = 0; i < elems.length; i++) {
+                    Element[] lelems = new Element[bodies.length];
+                    this.elems = lelems;
+                    for (int i = 0; i < lelems.length; i++) {
                         Element ce = this.new Element();
                         ce.kind = EK_CBLE;
                         ce.removeBand();
                         ce.bandIndex = NO_BAND_INDEX;
                         ce.layout = bodies[i];
-                        elems[i] = ce;
+                        lelems[i] = ce;
                     }
                     // Next fill them in.
-                    for (int i = 0; i < elems.length; i++) {
-                        Element ce = elems[i];
+                    for (int i = 0; i < lelems.length; i++) {
+                        Element ce = lelems[i];
                         ce.body = tokenizeLayout(this, i, bodies[i]);
                     }
                     //System.out.println(Arrays.asList(elems));
@@ -525,11 +527,12 @@
         }
 
         public boolean equals(Object x) {
-            return x instanceof Layout && equals((Layout)x);
+            return ( x != null) && ( x.getClass() == Layout.class ) &&
+                    equals((Layout)x);
         }
         public boolean equals(Layout that) {
-            return this.name == that.name
-                && this.layout == that.layout
+            return this.name.equals(that.name)
+                && this.layout.equals(that.layout)
                 && this.ctype == that.ctype;
         }
         public int hashCode() {
@@ -589,14 +592,14 @@
                 return str;
             }
             private String stringForDebug() {
-                Element[] body = this.body;
+                Element[] lbody = this.body;
                 switch (kind) {
                 case EK_CALL:
-                    body = null;
+                    lbody = null;
                     break;
                 case EK_CASE:
                     if (flagTest(EF_BACK))
-                        body = null;
+                        lbody = null;
                     break;
                 }
                 return layout
@@ -604,7 +607,7 @@
                     + "<"+ (flags==0?"":""+flags)+kind+len
                     + (refKind==0?"":""+refKind) + ">"
                     + (value==0?"":"("+value+")")
-                    + (body==null?"": ""+Arrays.asList(body));
+                    + (lbody==null?"": ""+Arrays.asList(lbody));
             }
         }
 
@@ -613,16 +616,19 @@
         }
         static private final Element[] noElems = {};
         public Element[] getCallables() {
-            if (hasCallables())
-                return elems;
-            else
+            if (hasCallables()) {
+                Element[] nelems = Arrays.copyOf(elems, elems.length);
+                return nelems;
+            } else
                 return noElems;  // no callables at all
         }
         public Element[] getEntryPoint() {
             if (hasCallables())
                 return elems[0].body;  // body of first callable
-            else
-                return elems;  // no callables; whole body
+            else {
+                Element[] nelems = Arrays.copyOf(elems, elems.length);
+                return nelems;  // no callables; whole body
+            }
         }
 
         /** Return a sequence of tokens from the given attribute bytes.
@@ -674,7 +680,7 @@
         }
     }
 
-    void visitRefs(Holder holder, int mode, final Collection refs) {
+    void visitRefs(Holder holder, int mode, final Collection<Entry> refs) {
         if (mode == VRM_CLASSIC) {
             refs.add(getNameRef());
         }
@@ -720,7 +726,7 @@
      */
     static public
     String normalizeLayoutString(String layout) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         for (int i = 0, len = layout.length(); i < len; ) {
             char ch = layout.charAt(i++);
             if (ch <= ' ') {
@@ -832,14 +838,14 @@
     */
     static //private
     Layout.Element[] tokenizeLayout(Layout self, int curCble, String layout) {
-        ArrayList<Layout.Element> col = new ArrayList<>(layout.length());
+        List<Layout.Element> col = new ArrayList<>(layout.length());
         tokenizeLayout(self, curCble, layout, col);
         Layout.Element[] res = new Layout.Element[col.size()];
         col.toArray(res);
         return res;
     }
     static //private
-    void tokenizeLayout(Layout self, int curCble, String layout, ArrayList<Layout.Element> col) {
+    void tokenizeLayout(Layout self, int curCble, String layout, List<Layout.Element> col) {
         boolean prevBCI = false;
         for (int len = layout.length(), i = 0; i < len; ) {
             int start = i;
@@ -897,7 +903,7 @@
             case 'T': // union: 'T' any_int union_case* '(' ')' '[' body ']'
                 kind = EK_UN;
                 i = tokenizeSInt(e, layout, i);
-                ArrayList<Layout.Element> cases = new ArrayList<>();
+                List<Layout.Element> cases = new ArrayList<>();
                 for (;;) {
                     // Keep parsing cases until we hit the default case.
                     if (layout.charAt(i++) != '(')
@@ -1051,7 +1057,7 @@
     }
     static //private
     String[] splitBodies(String layout) {
-        ArrayList<String> bodies = new ArrayList<>();
+        List<String> bodies = new ArrayList<>();
         // Parse several independent layout bodies:  "[foo][bar]...[baz]"
         for (int i = 0; i < layout.length(); i++) {
             if (layout.charAt(i++) != '[')
@@ -1156,7 +1162,7 @@
     String expandCaseDashNotation(String layout) {
         int dash = findCaseDash(layout, 0);
         if (dash < 0)  return layout;  // no dashes (the common case)
-        StringBuffer result = new StringBuffer(layout.length() * 3);
+        StringBuilder result = new StringBuilder(layout.length() * 3);
         int sofar = 0;  // how far have we processed the layout?
         for (;;) {
             // for each dash, collect everything up to the dash
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java	Wed Jan 19 21:51:10 2011 -0800
@@ -44,16 +44,17 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.jar.Pack200;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Define the structure and ordering of "bands" in a packed file.
  * @author John Rose
  */
 abstract
-class BandStructure implements Constants {
+class BandStructure {
     static final int MAX_EFFORT = 9;
     static final int MIN_EFFORT = 1;
     static final int DEFAULT_EFFORT = 5;
@@ -251,18 +252,18 @@
 
         null
     };
-    final private static HashMap basicCodingIndexes;
+    final private static Map<Coding, Integer> basicCodingIndexes;
     static {
         assert(basicCodings[_meta_default] == null);
         assert(basicCodings[_meta_canon_min] != null);
         assert(basicCodings[_meta_canon_max] != null);
-        HashMap map = new HashMap();
+        Map<Coding, Integer> map = new HashMap<>();
         for (int i = 0; i < basicCodings.length; i++) {
             Coding c = basicCodings[i];
             if (c == null)  continue;
             assert(i >= _meta_canon_min);
             assert(i <= _meta_canon_max);
-            map.put(c, new Integer(i));
+            map.put(c, i);
         }
         basicCodingIndexes = map;
     }
@@ -270,12 +271,12 @@
         return i < basicCodings.length ? basicCodings[i] : null;
     }
     public static int indexOf(Coding c) {
-        Integer i = (Integer) basicCodingIndexes.get(c);
+        Integer i = basicCodingIndexes.get(c);
         if (i == null)  return 0;
         return i.intValue();
     }
     public static Coding[] getBasicCodings() {
-        return (Coding[]) basicCodings.clone();
+        return basicCodings.clone();
     }
 
     protected byte[] bandHeaderBytes;    // used for input only
@@ -687,7 +688,6 @@
             }
             bandCoding.writeArrayTo(out, values, 0, length);
             if (out == outputCounter) {
-                long len1 = outputCounter.getCount();
                 assert(outputSize == outputCounter.getCount() - len0)
                     : (outputSize+" != "+outputCounter.getCount()+"-"+len0);
             }
@@ -1050,8 +1050,8 @@
 
     // Bootstrap support for CPRefBands.  These are needed to record
     // intended CP indexes, before the CP has been created.
-    private ArrayList allKQBands = new ArrayList();
-    private ArrayList needPredefIndex = new ArrayList();
+    private final List<CPRefBand> allKQBands = new ArrayList<>();
+    private List<Object[]> needPredefIndex = new ArrayList<>();
 
 
     int encodeRef(Entry e, Index ix) {
@@ -1078,9 +1078,9 @@
                 && this instanceof PackageWriter) {
                 // Twist the random state based on my first file.
                 // This sends each segment off in a different direction.
-                List classes = ((PackageWriter)this).pkg.classes;
+                List<Package.Class> classes = ((PackageWriter)this).pkg.classes;
                 if (!classes.isEmpty()) {
-                    Package.Class cls = (Package.Class) classes.get(0);
+                    Package.Class cls = classes.get(0);
                     codingChooser.addStressSeed(cls.getName().hashCode());
                 }
             }
@@ -1619,8 +1619,7 @@
     /** Given CP indexes, distribute tag-specific indexes to bands. */
     protected void setBandIndexes() {
         // Handle prior calls to setBandIndex:
-        for (Iterator i = needPredefIndex.iterator(); i.hasNext(); ) {
-            Object[] need = (Object[]) i.next();
+        for (Object[] need : needPredefIndex) {
             CPRefBand b     = (CPRefBand) need[0];
             Byte      which = (Byte)      need[1];
             b.setIndex(getCPIndex(which.byteValue()));
@@ -1633,7 +1632,7 @@
     }
 
     protected void setBandIndex(CPRefBand b, byte which) {
-        Object[] need = { b, new Byte(which) };
+        Object[] need = { b, Byte.valueOf(which) };
         if (which == CONSTANT_Literal) {
             // I.e., attribute layouts KQ (no null) or KQN (null ok).
             allKQBands.add(b);
@@ -1645,7 +1644,7 @@
         }
     }
 
-    protected void setConstantValueIndex(com.sun.java.util.jar.pack.Package.Class.Field f) {
+    protected void setConstantValueIndex(Field f) {
         Index ix = null;
         if (f != null) {
             byte tag = f.getLiteralTag();
@@ -1655,8 +1654,7 @@
             assert(ix != null);
         }
         // Typically, allKQBands is the singleton of field_ConstantValue_KQ.
-        for (Iterator i = allKQBands.iterator(); i.hasNext(); ) {
-            CPRefBand xxx_KQ = (CPRefBand) i.next();
+        for (CPRefBand xxx_KQ : allKQBands) {
             xxx_KQ.setIndex(ix);
         }
     }
@@ -1688,7 +1686,7 @@
     protected int attrClassFileVersionMask;
 
     // Mapping from Attribute.Layout to Band[] (layout element bands).
-    protected HashMap attrBandTable = new HashMap();
+    protected Map<Attribute.Layout, Band[]> attrBandTable = new HashMap<>();
 
     // Well-known attributes:
     protected final Attribute.Layout attrCodeEmpty;
@@ -1697,15 +1695,18 @@
     protected final Attribute.Layout attrConstantValue;
 
     // Mapping from Attribute.Layout to Integer (inverse of attrDefs)
-    HashMap attrIndexTable = new HashMap();
+    Map<Attribute.Layout, Integer> attrIndexTable = new HashMap<>();
 
     // Mapping from attribute index (<32 are flag bits) to attributes.
-    protected ArrayList[] attrDefs = new ArrayList[ATTR_CONTEXT_LIMIT];
+    protected List<List<Attribute.Layout>> attrDefs =
+            new FixedList<>(ATTR_CONTEXT_LIMIT);
     {
         for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
             assert(attrIndexLimit[i] == 0);
             attrIndexLimit[i] = 32;  // just for the sake of predefs.
-            attrDefs[i] = new ArrayList(Collections.nCopies(attrIndexLimit[i], null));
+            attrDefs.set(i, new ArrayList<>(Collections.nCopies(
+                    attrIndexLimit[i], (Attribute.Layout)null)));
+
         }
 
         // Add predefined attribute definitions:
@@ -1867,9 +1868,10 @@
         for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
             assert(attrIndexLimit[i] == 0);  // decide on it now!
             attrIndexLimit[i] = (haveFlagsHi(i)? 63: 32);
-            assert(attrDefs[i].size() == 32);  // all predef indexes are <32
-            int addMore = attrIndexLimit[i] - attrDefs[i].size();
-            attrDefs[i].addAll(Collections.nCopies(addMore, null));
+            List<Attribute.Layout> defList = attrDefs.get(i);
+            assert(defList.size() == 32);  // all predef indexes are <32
+            int addMore = attrIndexLimit[i] - defList.size();
+            defList.addAll(Collections.nCopies(addMore, (Attribute.Layout) null));
         }
     }
 
@@ -1890,13 +1892,13 @@
         return testBit(archiveOptions, mask);
     }
 
-    protected ArrayList getPredefinedAttrs(int ctype) {
+    protected List getPredefinedAttrs(int ctype) {
         assert(attrIndexLimit[ctype] != 0);
-        ArrayList res = new ArrayList(attrIndexLimit[ctype]);
+        List<Attribute.Layout> res = new ArrayList<>(attrIndexLimit[ctype]);
         // Remove nulls and non-predefs.
         for (int ai = 0; ai < attrIndexLimit[ctype]; ai++) {
             if (testBit(attrDefSeen[ctype], 1L<<ai))  continue;
-            Attribute.Layout def = (Attribute.Layout) attrDefs[ctype].get(ai);
+            Attribute.Layout def = attrDefs.get(ctype).get(ai);
             if (def == null)  continue;  // unused flag bit
             assert(isPredefinedAttr(ctype, ai));
             res.add(def);
@@ -1910,7 +1912,7 @@
         if (ai >= attrIndexLimit[ctype])          return false;
         // If the bit is set, it was explicitly def'd.
         if (testBit(attrDefSeen[ctype], 1L<<ai))  return false;
-        return (attrDefs[ctype].get(ai) != null);
+        return (attrDefs.get(ctype).get(ai) != null);
     }
 
     protected void adjustSpecialAttrMasks() {
@@ -2050,8 +2052,8 @@
             System.out.println("Removing predefined "+ATTR_CONTEXT_NAME[ctype]+
                                " attribute on bit "+index);
         }
-        List defList = attrDefs[ctype];
-        Attribute.Layout def = (Attribute.Layout) defList.get(index);
+        List<Attribute.Layout> defList = attrDefs.get(ctype);
+        Attribute.Layout def = defList.get(index);
         assert(def != null);
         defList.set(index, null);
         attrIndexTable.put(def, null);
@@ -2059,7 +2061,7 @@
         assert(index < 64);
         attrDefSeen[ctype]  &= ~(1L<<index);
         attrFlagMask[ctype] &= ~(1L<<index);
-        Band[] ab = (Band[]) attrBandTable.get(def);
+        Band[] ab = attrBandTable.get(def);
         for (int j = 0; j < ab.length; j++) {
             ab[j].doneWithUnusedBand();
         }
@@ -2085,9 +2087,8 @@
             long defSeen = attrDefSeen[ctype];
             // Note: attrDefSeen is always a subset of attrFlagMask.
             assert((defSeen & ~attrFlagMask[ctype]) == 0);
-            for (int i = 0; i < attrDefs[ctype].size(); i++) {
-                Attribute.Layout def = (Attribute.Layout)
-                    attrDefs[ctype].get(i);
+            for (int i = 0; i < attrDefs.get(ctype).size(); i++) {
+                Attribute.Layout def = attrDefs.get(ctype).get(i);
                 if (def == null)  continue;  // unused flag bit
                 if (def.bandCount == 0)  continue;  // empty attr
                 if (i < attrIndexLimit[ctype] && !testBit(defSeen, 1L<<i)) {
@@ -2102,7 +2103,7 @@
                 Band[] newAB  = makeNewAttributeBands(pfx, def,
                                                       xxx_attr_bands);
                 assert(newAB.length == def.bandCount);
-                Band[] prevAB = (Band[]) attrBandTable.put(def, newAB);
+                Band[] prevAB = attrBandTable.put(def, newAB);
                 if (prevAB != null) {
                     // We won't be using these predefined bands.
                     for (int j = 0; j < prevAB.length; j++) {
@@ -2212,14 +2213,14 @@
     protected int setAttributeLayoutIndex(Attribute.Layout def, int index) {
         int ctype = def.ctype;
         assert(ATTR_INDEX_OVERFLOW <= index && index < attrIndexLimit[ctype]);
-        List defList = attrDefs[ctype];
+        List<Attribute.Layout> defList = attrDefs.get(ctype);
         if (index == ATTR_INDEX_OVERFLOW) {
             // Overflow attribute.
             index = defList.size();
             defList.add(def);
             if (verbose > 0)
                 Utils.log.info("Adding new attribute at "+def +": "+index);
-            attrIndexTable.put(def, new Integer(index));
+            attrIndexTable.put(def, index);
             return index;
         }
 
@@ -2240,7 +2241,7 @@
         // Remove index binding of any previous fixed attr.
         attrIndexTable.put(defList.get(index), null);
         defList.set(index, def);
-        attrIndexTable.put(def, new Integer(index));
+        attrIndexTable.put(def, index);
         return index;
     }
 
@@ -2361,7 +2362,7 @@
     ////////////////////////////////////////////////////////////////////
 
     static int nextSeqForDebug;
-    static File dumpDir;
+    static File dumpDir = null;
     static OutputStream getDumpStream(Band b, String ext) throws IOException {
         return getDumpStream(b.name, b.seqForDebug, ext, b);
     }
@@ -2512,19 +2513,19 @@
                            +", "+cstr+", "+ixS+"),");
     }
 
-    private HashMap prevForAssertMap;
+    private Map<Band, Band> prevForAssertMap;
 
     // DEBUG ONLY:  Record something about the band order.
     boolean notePrevForAssert(Band b, Band p) {
         if (prevForAssertMap == null)
-            prevForAssertMap = new HashMap();
+            prevForAssertMap = new HashMap<>();
         prevForAssertMap.put(b, p);
         return true;
     }
 
     // DEBUG ONLY:  Validate next input band.
     private boolean assertReadyToReadFrom(Band b, InputStream in) throws IOException {
-        Band p = (Band) prevForAssertMap.get(b);
+        Band p = prevForAssertMap.get(b);
         // Any previous band must be done reading before this one starts.
         if (p != null && phaseCmp(p.phase(), DISBURSE_PHASE) < 0) {
             Utils.log.warning("Previous band not done reading.");
@@ -2536,19 +2537,21 @@
         String name = b.name;
         if (optDebugBands && !name.startsWith("(")) {
             // Verify synchronization between reader & writer:
-            StringBuffer buf = new StringBuffer();
+            StringBuilder buf = new StringBuilder();
             int ch;
             while ((ch = in.read()) > 0)
                 buf.append((char)ch);
             String inName = buf.toString();
             if (!inName.equals(name)) {
-                StringBuffer sb = new StringBuffer();
+                StringBuilder sb = new StringBuilder();
                 sb.append("Expected "+name+" but read: ");
                 inName += (char)ch;
-                while (inName.length() < 10)
-                    inName += (char)in.read();
-                for (int i = 0; i < inName.length(); i++)
+                while (inName.length() < 10) {
+                    inName += (char) in.read();
+                }
+                for (int i = 0; i < inName.length(); i++) {
                     sb.append(inName.charAt(i));
+                }
                 Utils.log.warning(sb.toString());
                 return false;
             }
@@ -2573,7 +2576,7 @@
 
     // DEBUG ONLY:  Maybe write a debugging cookie to next output band.
     private boolean assertReadyToWriteTo(Band b, OutputStream out) throws IOException {
-        Band p = (Band) prevForAssertMap.get(b);
+        Band p = prevForAssertMap.get(b);
         // Any previous band must be done writing before this one starts.
         if (p != null && phaseCmp(p.phase(), DONE_PHASE) < 0) {
             Utils.log.warning("Previous band not done writing.");
@@ -2654,7 +2657,7 @@
     protected static Object[] realloc(Object[] a) {
         return realloc(a, Math.max(10, a.length*2));
     }
-    static private int[] noInts = {};
+
     protected static int[] realloc(int[] a, int len) {
         if (len == 0)  return noInts;
         if (a == null)  return new int[len];
@@ -2665,7 +2668,7 @@
     protected static int[] realloc(int[] a) {
         return realloc(a, Math.max(10, a.length*2));
     }
-    static private byte[] noBytes = {};
+
     protected static byte[] realloc(byte[] a, int len) {
         if (len == 0)  return noBytes;
         if (a == null)  return new byte[len];
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java	Wed Jan 19 21:51:10 2011 -0800
@@ -38,19 +38,20 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Map;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Reader for a class file that is being incorporated into a package.
  * @author John Rose
  */
-class ClassReader implements Constants {
+class ClassReader {
     int verbose;
 
     Package pkg;
     Class cls;
     long inPos;
     DataInputStream in;
-    Map attrDefs;
+    Map<Attribute.Layout, Attribute> attrDefs;
     Map attrCommands;
     String unknownAttrCommand = "error";;
 
@@ -77,7 +78,7 @@
         });
     }
 
-    public void setAttrDefs(Map attrDefs) {
+    public void setAttrDefs(Map<Attribute.Layout, Attribute> attrDefs) {
         this.attrDefs = attrDefs;
     }
 
@@ -211,27 +212,23 @@
                     break;
                 case CONSTANT_Integer:
                     {
-                        Comparable val = new Integer(in.readInt());
-                        cpMap[i] = ConstantPool.getLiteralEntry(val);
+                        cpMap[i] = ConstantPool.getLiteralEntry(in.readInt());
                     }
                     break;
                 case CONSTANT_Float:
                     {
-                        Comparable val = new Float(in.readFloat());
-                        cpMap[i] = ConstantPool.getLiteralEntry(val);
+                        cpMap[i] = ConstantPool.getLiteralEntry(in.readFloat());
                     }
                     break;
                 case CONSTANT_Long:
                     {
-                        Comparable val = new Long(in.readLong());
-                        cpMap[i] = ConstantPool.getLiteralEntry(val);
+                        cpMap[i] = ConstantPool.getLiteralEntry(in.readLong());
                         cpMap[++i] = null;
                     }
                     break;
                 case CONSTANT_Double:
                     {
-                        Comparable val = new Double(in.readDouble());
-                        cpMap[i] = ConstantPool.getLiteralEntry(val);
+                        cpMap[i] = ConstantPool.getLiteralEntry(in.readDouble());
                         cpMap[++i] = null;
                     }
                     break;
@@ -353,17 +350,18 @@
             if (attrCommands != null) {
                 Object lkey = Attribute.keyForLookup(ctype, name);
                 String cmd = (String) attrCommands.get(lkey);
-                if (cmd == "pass") {
-                    String message = "passing attribute bitwise in "+h;
-                    throw new Attribute.FormatException(message, ctype, name,
-                                                        cmd);
-                } else if (cmd == "error") {
-                    String message = "attribute not allowed in "+h;
-                    throw new Attribute.FormatException(message, ctype, name,
-                                                        cmd);
-                } else if (cmd == "strip") {
-                    skip(length, name+" attribute in "+h);
-                    continue;
+                if (cmd != null) {
+                    switch (cmd) {
+                        case "pass":
+                            String message1 = "passing attribute bitwise in " + h;
+                            throw new Attribute.FormatException(message1, ctype, name, cmd);
+                        case "error":
+                            String message2 = "attribute not allowed in " + h;
+                            throw new Attribute.FormatException(message2, ctype, name, cmd);
+                        case "strip":
+                            skip(length, name + " attribute in " + h);
+                            continue;
+                    }
                 }
             }
             // Find canonical instance of the requested attribute.
@@ -408,7 +406,7 @@
                     String message = "unsupported StackMap variant in "+h;
                     throw new Attribute.FormatException(message, ctype, name,
                                                         "pass");
-                } else if (unknownAttrCommand == "strip") {
+                } else if ("strip".equals(unknownAttrCommand)) {
                     // Skip the unknown attribute.
                     skip(length, "unknown "+name+" attribute in "+h);
                     continue;
@@ -422,7 +420,7 @@
                 a.layout() == Package.attrInnerClassesEmpty) {
                 // These are hardwired.
                 long pos0 = inPos;
-                if (a.name() == "Code") {
+                if ("Code".equals(a.name())) {
                     Class.Method m = (Class.Method) h;
                     m.code = new Code(m);
                     try {
@@ -471,7 +469,7 @@
 
     void readInnerClasses(Class cls) throws IOException {
         int nc = readUnsignedShort();
-        ArrayList ics = new ArrayList(nc);
+        ArrayList<InnerClass> ics = new ArrayList<>(nc);
         for (int i = 0; i < nc; i++) {
             InnerClass ic =
                 new InnerClass(readClassRef(),
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java	Wed Jan 19 21:51:10 2011 -0800
@@ -38,12 +38,12 @@
 import java.io.OutputStream;
 import java.util.Iterator;
 import java.util.List;
-
+import static com.sun.java.util.jar.pack.Constants.*;
 /**
  * Writer for a class file that is incorporated into a package.
  * @author John Rose
  */
-class ClassWriter implements Constants {
+class ClassWriter {
     int verbose;
 
     Package pkg;
@@ -196,8 +196,7 @@
             return;
         }
         writeShort(h.attributes.size());
-        for (Iterator i = h.attributes.iterator(); i.hasNext(); ) {
-            Attribute a = (Attribute) i.next();
+        for (Attribute a : h.attributes) {
             a.finishRefs(cpIndex);
             writeRef(a.getNameRef());
             if (a.layout() == Package.attrCodeEmpty ||
@@ -207,7 +206,7 @@
                 assert(out != bufOut);
                 buf.reset();
                 out = bufOut;
-                if (a.name() == "Code") {
+                if ("Code".equals(a.name())) {
                     Class.Method m = (Class.Method) h;
                     writeCode(m.code);
                 } else {
@@ -246,10 +245,9 @@
     }
 
     void writeInnerClasses(Class cls) throws IOException {
-        List ics = cls.getInnerClasses();
+        List<InnerClass> ics = cls.getInnerClasses();
         writeShort(ics.size());
-        for (Iterator i = ics.iterator(); i.hasNext(); ) {
-            InnerClass ic = (InnerClass) i.next();
+        for (InnerClass ic : ics) {
             writeRef(ic.thisClass);
             writeRef(ic.outerClass);
             writeRef(ic.name);
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java	Wed Jan 19 21:51:10 2011 -0800
@@ -29,12 +29,13 @@
 import java.lang.reflect.Modifier;
 import java.util.Arrays;
 import java.util.Collection;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Represents a chunk of bytecodes.
  * @author John Rose
  */
-class Code extends Attribute.Holder implements Constants {
+class Code extends Attribute.Holder {
     Class.Method m;
 
     public Code(Class.Method m) {
@@ -141,15 +142,12 @@
         super.trimToSize();
     }
 
-    protected void visitRefs(int mode, Collection refs) {
+    protected void visitRefs(int mode, Collection<ConstantPool.Entry> refs) {
         int verbose = getPackage().verbose;
         if (verbose > 2)
             System.out.println("Reference scan "+this);
         Class cls = thisClass();
-        Package pkg = cls.getPackage();
-        for (int i = 0; i < handler_class.length; i++) {
-            refs.add(handler_class[i]);
-        }
+        refs.addAll(Arrays.asList(handler_class));
         if (fixups != null) {
             fixups.visitRefs(refs);
         } else {
@@ -196,11 +194,8 @@
             map[mapLen] = (short)(PClimit + Short.MIN_VALUE);
             return map;
         } else {
-            int[] map = new int[mapLen+1];
-            for (int i = 0; i < mapLen; i++) {
-                map[i] = (int) insnMap[i];
-            }
-            map[mapLen] = (int) PClimit;
+            int[] map = Arrays.copyOf(insnMap, mapLen + 1);
+            map[mapLen] = PClimit;
             return map;
         }
     }
@@ -220,10 +215,7 @@
             }
         } else {
             int[] map = (int[]) map0;
-            imap = new int[map.length-1];
-            for (int i = 0; i < imap.length; i++) {
-                imap[i] = map[i];
-            }
+            imap = Arrays.copyOfRange(map, 0, map.length - 1);
         }
         return imap;
     }
@@ -266,7 +258,7 @@
         } else {
             int[] map = (int[]) map0;
             len = map.length;
-            i = Arrays.binarySearch(map, (int)bci);
+            i = Arrays.binarySearch(map, bci);
         }
         assert(i != -1);
         assert(i != 0);
@@ -322,7 +314,7 @@
             len = map.length;
             if (bciCode < len)
                 return map[bciCode];
-            i = Arrays.binarySearch(map, (int)bciCode);
+            i = Arrays.binarySearch(map, bciCode);
             if (i < 0)  i = -i-1;
             int key = bciCode-len;
             for (;; i--) {
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java	Wed Jan 19 21:51:10 2011 -0800
@@ -29,14 +29,15 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.HashMap;
-
+import java.util.Map;
+import static com.sun.java.util.jar.pack.Constants.*;
 /**
  * Define the conversions between sequences of small integers and raw bytes.
  * This is a schema of encodings which incorporates varying lengths,
  * varying degrees of length variability, and varying amounts of signed-ness.
  * @author John Rose
  */
-class Coding implements Constants, Comparable, CodingMethod, Histogram.BitMetric {
+class Coding implements Comparable, CodingMethod, Histogram.BitMetric {
     /*
       Coding schema for single integers, parameterized by (B,H,S):
 
@@ -191,7 +192,9 @@
         if (S == 0 || range >= (long)1<<32)
             return saturate32(range-1);
         long maxPos = range-1;
-        while (isNegativeCode(maxPos, S))  --maxPos;
+        while (isNegativeCode(maxPos, S)) {
+            --maxPos;
+        }
         if (maxPos < 0)  return -1;  // No positive codings at all.
         int smax = decodeSign32(maxPos, S);
         // check for 32-bit wraparound:
@@ -213,9 +216,10 @@
         if (S == 0) {
             return 0;
         }
-        int Smask = (1<<S)-1;
         long maxNeg = range-1;
-        while (!isNegativeCode(maxNeg, S))  --maxNeg;
+        while (!isNegativeCode(maxNeg, S))
+            --maxNeg;
+
         if (maxNeg < 0)  return 0;  // No negative codings at all.
         return decodeSign32(maxNeg, S);
     }
@@ -395,12 +399,12 @@
         return (del<<14)+(S<<11)+(B<<8)+(H<<0);
     }
 
-    private static HashMap codeMap;
+    private static Map<Coding, Coding> codeMap;
 
     private static synchronized Coding of(int B, int H, int S, int del) {
-        if (codeMap == null)  codeMap = new HashMap();
+        if (codeMap == null)  codeMap = new HashMap<>();
         Coding x0 = new Coding(B, H, S, del);
-        Coding x1 = (Coding) codeMap.get(x0);
+        Coding x1 = codeMap.get(x0);
         if (x1 == null)  codeMap.put(x0, x1 = x0);
         return x1;
     }
@@ -462,6 +466,7 @@
         // %%% use byte[] buffer
         for (int i = start; i < end; i++)
             a[i] = readFrom(in);
+
         for (int dstep = 0; dstep < del; dstep++) {
             long state = 0;
             for (int i = start; i < end; i++) {
@@ -750,14 +755,14 @@
         if (len == 0)       return true;
         if (isFullRange())  return true;
         // Calculate max, min:
-        int max = values[start];
-        int min = max;
+        int lmax = values[start];
+        int lmin = lmax;
         for (int i = 1; i < len; i++) {
             int value = values[start+i];
-            if (max < value)  max = value;
-            if (min > value)  min = value;
+            if (lmax < value)  lmax = value;
+            if (lmin > value)  lmin = value;
         }
-        return canRepresent(min, max);
+        return canRepresent(lmin, lmax);
     }
 
     public double getBitLength(int value) {  // implements BitMetric
@@ -800,21 +805,20 @@
             //return Coding.of(B, H, S).getLength(deltas, 0, len);
             values = deltas;
             start = 0;
-            end = values.length;
         }
         int sum = len;  // at least 1 byte per
         // add extra bytes for extra-long values
         for (int n = 1; n <= B; n++) {
             // what is the coding interval [min..max] for n bytes?
-            int max = byteMax[n-1];
-            int min = byteMin[n-1];
+            int lmax = byteMax[n-1];
+            int lmin = byteMin[n-1];
             int longer = 0;  // count of guys longer than n bytes
             for (int i = 0; i < len; i++) {
                 int value = values[start+i];
                 if (value >= 0) {
-                    if (value > max)  longer++;
+                    if (value > lmax)  longer++;
                 } else {
-                    if (value < min)  longer++;
+                    if (value < lmin)  longer++;
                 }
             }
             if (longer == 0)  break;  // no more passes needed
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java	Wed Jan 19 21:51:10 2011 -0800
@@ -34,15 +34,16 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Random;
+import java.util.Set;
 import java.util.zip.Deflater;
 import java.util.zip.DeflaterOutputStream;
-
+import static com.sun.java.util.jar.pack.Constants.*;
 /**
  * Heuristic chooser of basic encodings.
  * Runs "zip" to measure the apparent information content after coding.
  * @author John Rose
  */
-class CodingChooser implements Constants {
+class CodingChooser {
     int verbose;
     int effort;
     boolean optUseHistogram = true;
@@ -124,10 +125,10 @@
                 = !p200.getBoolean(Utils.COM_PREFIX+"no.population.coding");
             this.optUseAdaptiveCoding
                 = !p200.getBoolean(Utils.COM_PREFIX+"no.adaptive.coding");
-            int stress
+            int lstress
                 = p200.getInteger(Utils.COM_PREFIX+"stress.coding");
-            if (stress != 0)
-                this.stress = new Random(stress);
+            if (lstress != 0)
+                this.stress = new Random(lstress);
         }
 
         this.effort = effort;
@@ -376,9 +377,9 @@
                              " fewer bytes than regular "+regular+
                              "; win="+pct(zipSize1-bestZipSize, zipSize1));
         }
-        CodingMethod bestMethod = this.bestMethod;
+        CodingMethod lbestMethod = this.bestMethod;
         reset(null, 0, 0);  // for GC
-        return bestMethod;
+        return lbestMethod;
     }
     CodingMethod choose(int[] values, int start, int end, Coding regular) {
         return choose(values, start, end, regular, null);
@@ -742,9 +743,9 @@
         // Steps 1/2/3 are interdependent, and may be iterated.
         // Steps 4 and 5 may be decided independently afterward.
         int[] LValuesCoded = PopulationCoding.LValuesCoded;
-        ArrayList bestFits = new ArrayList();
-        ArrayList fullFits = new ArrayList();
-        ArrayList longFits = new ArrayList();
+        List<Coding> bestFits = new ArrayList<>();
+        List<Coding> fullFits = new ArrayList<>();
+        List<Coding> longFits = new ArrayList<>();
         final int PACK_TO_MAX_S = 1;
         if (bestPopFVC <= 255) {
             bestFits.add(BandStructure.BYTE1);
@@ -776,16 +777,16 @@
                 }
             }
             // interleave all B greater than bestB with best and full fits
-            for (Iterator i = bestFits.iterator(); i.hasNext(); ) {
-                Coding c = (Coding) i.next();
+            for (Iterator<Coding> i = bestFits.iterator(); i.hasNext(); ) {
+                Coding c = i.next();
                 if (c.B() > bestB) {
                     i.remove();
                     longFits.add(0, c);
                 }
             }
         }
-        ArrayList allFits = new ArrayList();
-        for (Iterator i = bestFits.iterator(),
+        List<Coding> allFits = new ArrayList<>();
+        for (Iterator<Coding> i = bestFits.iterator(),
                       j = fullFits.iterator(),
                       k = longFits.iterator();
              i.hasNext() || j.hasNext() || k.hasNext(); ) {
@@ -812,8 +813,7 @@
         }
         if (verbose > 3)
             Utils.log.info("allFits: "+allFits);
-        for (Iterator i = allFits.iterator(); i.hasNext(); ) {
-            Coding tc = (Coding) i.next();
+        for (Coding tc : allFits) {
             boolean packToMax = false;
             if (tc.S() == PACK_TO_MAX_S) {
                 // Kludge:  setS(PACK_TO_MAX_S) means packToMax here.
@@ -910,7 +910,7 @@
                              " tc="+pop.tokenCoding+
                              " uc="+pop.unfavoredCoding);
             //pop.hist.print("pop-hist", null, System.out);
-            StringBuffer sb = new StringBuffer();
+            StringBuilder sb = new StringBuilder();
             sb.append("fv = {");
             for (int i = 1; i <= fVlen; i++) {
                 if ((i % 10) == 0)
@@ -949,20 +949,20 @@
         // run occupies too much space.  ("Too much" means, say 5% more
         // than the average integer size of the band as a whole.)
         // Try to find a better coding for those segments.
-        int   start  = this.start;
-        int   end    = this.end;
-        int[] values = this.values;
-        int len = end-start;
+        int   lstart  = this.start;
+        int   lend    = this.end;
+        int[] lvalues = this.values;
+        int len = lend-lstart;
         if (plainCoding.isDelta()) {
-            values = getDeltas(0,0); //%%% not quite right!
-            start = 0;
-            end = values.length;
+            lvalues = getDeltas(0,0); //%%% not quite right!
+            lstart = 0;
+            lend = lvalues.length;
         }
         int[] sizes = new int[len+1];
         int fillp = 0;
         int totalSize = 0;
-        for (int i = start; i < end; i++) {
-            int val = values[i];
+        for (int i = lstart; i < lend; i++) {
+            int val = lvalues[i];
             sizes[fillp++] = totalSize;
             int size = plainCoding.getLength(val);
             assert(size < Integer.MAX_VALUE);
@@ -1013,22 +1013,23 @@
         double[] fuzzes   = new double[meshes.length];
         for (int i = 0; i < meshes.length; i++) {
             int mesh = meshes[i];
-            double fuzz;
+            double lfuzz;
             if (mesh < 10)
-                fuzz = sizeFuzz3;
+                lfuzz = sizeFuzz3;
             else if (mesh < 100)
-                fuzz = sizeFuzz2;
+                lfuzz = sizeFuzz2;
             else
-                fuzz = sizeFuzz;
-            fuzzes[i] = fuzz;
-            threshes[i] = BAND_HEADER + (int)Math.ceil(mesh * avgSize * fuzz);
+                lfuzz = sizeFuzz;
+            fuzzes[i] = lfuzz;
+            threshes[i] = BAND_HEADER + (int)Math.ceil(mesh * avgSize * lfuzz);
         }
         if (verbose > 1) {
             System.out.print("tryAdaptiveCoding ["+len+"]"+
                              " avgS="+avgSize+" fuzz="+sizeFuzz+
                              " meshes: {");
-            for (int i = 0; i < meshes.length; i++)
-                System.out.print(" "+meshes[i]+"("+threshes[i]+")");
+            for (int i = 0; i < meshes.length; i++) {
+                System.out.print(" " + meshes[i] + "(" + threshes[i] + ")");
+            }
             Utils.log.info(" }");
         }
         if (runHelper == null) {
@@ -1229,20 +1230,19 @@
         Histogram hist = getValueHistogram();
         int fVlen = stressLen(hist.getTotalLength());
         if (fVlen == 0)  return coding;
-        List popvals = new ArrayList();
+        List<Integer> popvals = new ArrayList<>();
         if (stress.nextBoolean()) {
             // Build the population from the value list.
-            HashSet popset = new HashSet();
+            Set<Integer> popset = new HashSet<>();
             for (int i = start; i < end; i++) {
-                Integer val = new Integer(values[i]);
-                if (popset.add(val))  popvals.add(val);
+                if (popset.add(values[i]))  popvals.add(values[i]);
             }
         } else {
             int[][] matrix = hist.getMatrix();
             for (int mrow = 0; mrow < matrix.length; mrow++) {
                 int[] row = matrix[mrow];
                 for (int mcol = 1; mcol < row.length; mcol++) {
-                    popvals.add(new Integer(row[mcol]));
+                    popvals.add(row[mcol]);
                 }
             }
         }
@@ -1269,7 +1269,7 @@
         fVlen = popvals.size();
         int[] fvals = new int[1+fVlen];
         for (int i = 0; i < fVlen; i++) {
-            fvals[1+i] = ((Integer)popvals.get(i)).intValue();
+            fvals[1+i] = (popvals.get(i)).intValue();
         }
         PopulationCoding pop = new PopulationCoding();
         pop.setFavoredValues(fvals, fVlen);
@@ -1283,13 +1283,13 @@
             }
         }
         if (pop.tokenCoding == null) {
-            int min = fvals[1], max = min;
+            int lmin = fvals[1], lmax = lmin;
             for (int i = 2; i <= fVlen; i++) {
                 int val = fvals[i];
-                if (min > val)  min = val;
-                if (max < val)  max = val;
+                if (lmin > val)  lmin = val;
+                if (lmax < val)  lmax = val;
             }
-            pop.tokenCoding = stressCoding(min, max);
+            pop.tokenCoding = stressCoding(lmin, lmax);
         }
 
         computePopSizePrivate(pop, valueCoding, valueCoding);
@@ -1310,13 +1310,13 @@
         try {
             assert(!disableRunCoding);
             disableRunCoding = true;  // temporary, while I decide spans
-            int[] allValues = (int[]) values.clone();
+            int[] allValues = values.clone();
             CodingMethod result = null;
             int scan  = this.end;
-            int start = this.start;
-            for (int split; scan > start; scan = split) {
+            int lstart = this.start;
+            for (int split; scan > lstart; scan = split) {
                 int thisspan;
-                int rand = (scan - start < 100)? -1: stress.nextInt();
+                int rand = (scan - lstart < 100)? -1: stress.nextInt();
                 if ((rand & 7) != 0) {
                     thisspan = (spanlen==1? spanlen: stressLen(spanlen-1)+1);
                 } else {
@@ -1325,7 +1325,7 @@
                     int KB = (rand >>>= 3) & AdaptiveCoding.KB_MAX;
                     for (;;) {
                         thisspan = AdaptiveCoding.decodeK(KX, KB);
-                        if (thisspan <= scan - start)  break;
+                        if (thisspan <= scan - lstart)  break;
                         // Try smaller and smaller codings:
                         if (KB != AdaptiveCoding.KB_DEFAULT)
                             KB = AdaptiveCoding.KB_DEFAULT;
@@ -1335,11 +1335,13 @@
                     //System.out.println("KX="+KX+" KB="+KB+" K="+thisspan);
                     assert(AdaptiveCoding.isCodableLength(thisspan));
                 }
-                if (thisspan > scan - start)  thisspan = scan - start;
-                while (!AdaptiveCoding.isCodableLength(thisspan))  --thisspan;
+                if (thisspan > scan - lstart)  thisspan = scan - lstart;
+                while (!AdaptiveCoding.isCodableLength(thisspan)) {
+                    --thisspan;
+                }
                 split = scan - thisspan;
                 assert(split < scan);
-                assert(split >= start);
+                assert(split >= lstart);
                 // Choose a coding for the span [split..scan).
                 CodingMethod sc = choose(allValues, split, scan, plainCoding);
                 if (result == null) {
@@ -1420,7 +1422,7 @@
                 case StreamTokenizer.TT_EOF:
                     throw new NoSuchElementException();
                 case StreamTokenizer.TT_NUMBER:
-                    return new Integer((int) in.nval);
+                    return Integer.valueOf((int) in.nval);
                 default:
                     assert(false);
                     return null;
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java	Wed Jan 19 21:51:10 2011 -0800
@@ -33,13 +33,14 @@
 import java.util.ListIterator;
 import java.util.Map;
 import java.util.Set;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Representation of constant pool entries and indexes.
  * @author John Rose
  */
 abstract
-class ConstantPool implements Constants {
+class ConstantPool {
     private ConstantPool() {}  // do not instantiate
 
     static int verbose() {
@@ -155,9 +156,6 @@
             return null;
         }
 
-        public boolean sameTagAs(Object o) {
-            return (o instanceof Entry) && ((Entry)o).tag == tag;
-        }
         public boolean eq(Entry that) {  // same reference
             assert(that != null);
             return this == that || this.equals(that);
@@ -219,9 +217,9 @@
             return value.hashCode();
         }
         public boolean equals(Object o) {
-            if (!sameTagAs(o))  return false;
             // Use reference equality of interned strings:
-            return ((Utf8Entry)o).value == value;
+            return (o != null && o.getClass() == Utf8Entry.class
+                    && ((Utf8Entry) o).value.equals(value));
         }
         public int compareTo(Object o) {
             int x = superCompareTo(o);
@@ -275,8 +273,9 @@
         }
 
         public boolean equals(Object o) {
-            if (!sameTagAs(o))  return false;
-            return (((NumberEntry)o).value).equals(value);
+            return (o != null && o.getClass() == NumberEntry.class
+                    && ((NumberEntry) o).value.equals(value));
+
         }
         public int compareTo(Object o) {
             int x = superCompareTo(o);
@@ -310,8 +309,8 @@
             return ref.hashCode() + tag;
         }
         public boolean equals(Object o) {
-            if (!sameTagAs(o))  return false;
-            return ((StringEntry)o).ref.eq(ref);
+            return (o != null && o.getClass() == StringEntry.class &&
+                    ((StringEntry)o).ref.eq(ref));
         }
         public int compareTo(Object o) {
             int x = superCompareTo(o);
@@ -342,8 +341,8 @@
             hashCode();  // force computation of valueHash
         }
         public boolean equals(Object o) {
-            if (!sameTagAs(o))  return false;
-            return ((ClassEntry)o).ref.eq(ref);
+            return (o != null && o.getClass() == ClassEntry.class
+                    && ((ClassEntry) o).ref.eq(ref));
         }
         public int compareTo(Object o) {
             int x = superCompareTo(o);
@@ -380,7 +379,9 @@
             return (nameRef.hashCode() + (hc2 << 8)) ^ hc2;
         }
         public boolean equals(Object o) {
-            if (!sameTagAs(o))  return false;
+            if (o == null || o.getClass() != DescriptorEntry.class) {
+                return false;
+            }
             DescriptorEntry that = (DescriptorEntry)o;
             return this.nameRef.eq(that.nameRef)
                 && this.typeRef.eq(that.typeRef);
@@ -439,7 +440,9 @@
             hashCode();  // force computation of valueHash
         }
         public boolean equals(Object o) {
-            if (!sameTagAs(o))  return false;
+            if (o == null || o.getClass() != MemberEntry.class) {
+                return false;
+            }
             MemberEntry that = (MemberEntry)o;
             return this.classRef.eq(that.classRef)
                 && this.descRef.eq(that.descRef);
@@ -511,8 +514,8 @@
         }
 
         public boolean equals(Object o) {
-            if (!sameTagAs(o))  return false;
-            return ((SignatureEntry)o).value == value;
+            return (o != null && o.getClass() == SignatureEntry.class &&
+                    ((SignatureEntry)o).value.equals(value));
         }
         public int compareTo(Object o) {
             int x = superCompareTo(o);
@@ -724,7 +727,7 @@
     protected static final ClassEntry[] noClassRefs = {};
 
     /** An Index is a mapping between CP entries and small integers. */
-    public static
+    public static final
     class Index extends AbstractList {
         protected String debugName;
         protected Entry[] cpMap;
@@ -894,7 +897,7 @@
     }
 
     public static
-    Index makeIndex(String debugName, Collection cpMapList) {
+    Index makeIndex(String debugName, Collection<Entry> cpMapList) {
         return new Index(debugName, cpMapList);
     }
 
@@ -916,7 +919,7 @@
     public static
     Index[] partition(Index ix, int[] keys) {
         // %%% Should move this into class Index.
-        ArrayList<List<Entry>> parts = new ArrayList<>();
+        List<List<Entry>> parts = new ArrayList<>();
         Entry[] cpMap = ix.cpMap;
         assert(keys.length == cpMap.length);
         for (int i = 0; i < keys.length; i++) {
@@ -1094,12 +1097,12 @@
 
         // Inverse of getOverloadingIndex
         public MemberEntry getOverloadingForIndex(byte tag, ClassEntry classRef, String name, int which) {
-            assert(name == name.intern());
+            assert(name.equals(name.intern()));
             Index ix = getMemberIndex(tag, classRef);
             int ord = 0;
             for (int i = 0; i < ix.cpMap.length; i++) {
                 MemberEntry e = (MemberEntry) ix.cpMap[i];
-                if (e.descRef.nameRef.stringValue() == name) {
+                if (e.descRef.nameRef.stringValue().equals(name)) {
                     if (ord == which)  return e;
                     ord++;
                 }
@@ -1133,10 +1136,10 @@
     public static
     void completeReferencesIn(Set<Entry> cpRefs, boolean flattenSigs) {
         cpRefs.remove(null);
-        for (ListIterator work =
-                 new ArrayList(cpRefs).listIterator(cpRefs.size());
+        for (ListIterator<Entry> work =
+                 new ArrayList<>(cpRefs).listIterator(cpRefs.size());
              work.hasPrevious(); ) {
-            Entry e = (Entry) work.previous();
+            Entry e = work.previous();
             work.remove();          // pop stack
             assert(e != null);
             if (flattenSigs && e.tag == CONSTANT_Signature) {
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java	Wed Jan 19 21:51:10 2011 -0800
@@ -32,7 +32,10 @@
  * Shared constants
  * @author John Rose
  */
-interface Constants {
+class Constants {
+
+    private Constants(){}
+
     public final static int JAVA_MAGIC = 0xCAFEBABE;
 
     /*
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java	Wed Jan 19 21:51:10 2011 -0800
@@ -59,12 +59,11 @@
                 ResourceBundle.getBundle("com.sun.java.util.jar.pack.DriverResource");
 
     public static void main(String[] ava) throws IOException {
-        ArrayList<String> av = new ArrayList<>(Arrays.asList(ava));
+        List<String> av = new ArrayList<>(Arrays.asList(ava));
 
         boolean doPack   = true;
         boolean doUnpack = false;
         boolean doRepack = false;
-        boolean doForceRepack = false;
         boolean doZip = true;
         String logFile = null;
         String verboseProp = Utils.DEBUG_VERBOSE;
@@ -72,17 +71,20 @@
         {
             // Non-standard, undocumented "--unpack" switch enables unpack mode.
             String arg0 = av.isEmpty() ? "" : av.get(0);
-            if (arg0.equals("--pack")) {
+            switch (arg0) {
+                case "--pack":
                 av.remove(0);
-            } else if (arg0.equals("--unpack")) {
+                    break;
+                case "--unpack":
                 av.remove(0);
                 doPack = false;
                 doUnpack = true;
+                    break;
             }
         }
 
         // Collect engine properties here:
-        HashMap<String,String> engProps = new HashMap<>();
+        Map<String,String> engProps = new HashMap<>();
         engProps.put(verboseProp, System.getProperty(verboseProp));
 
         String optionMap;
@@ -96,7 +98,7 @@
         }
 
         // Collect argument properties here:
-        HashMap<String,String> avProps = new HashMap<>();
+        Map<String,String> avProps = new HashMap<>();
         try {
             for (;;) {
                 String state = parseCommandOptions(av, optionMap, avProps);
@@ -146,7 +148,7 @@
                 }
 
                 // See if there is any other action to take.
-                if (state == "--config-file=") {
+                if ("--config-file=".equals(state)) {
                     String propFile = av.remove(0);
                     InputStream propIn = new FileInputStream(propFile);
                     Properties fileProps = new Properties();
@@ -157,10 +159,10 @@
                     for (Map.Entry<Object,Object> me : fileProps.entrySet()) {
                         engProps.put((String) me.getKey(), (String) me.getValue());
                     }
-                } else if (state == "--version") {
+                } else if ("--version".equals(state)) {
                         System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.VERSION), Driver.class.getName(), "1.31, 07/05/05"));
                     return;
-                } else if (state == "--help") {
+                } else if ("--help".equals(state)) {
                     printUsage(doPack, true, System.out);
                     System.exit(1);
                     return;
@@ -178,14 +180,20 @@
         // Deal with remaining non-engine properties:
         for (String opt : avProps.keySet()) {
             String val = avProps.get(opt);
-            if (opt == "--repack") {
-                doRepack = true;
-            } else if (opt == "--no-gzip") {
-                doZip = (val == null);
-            } else if (opt == "--log-file=") {
-                logFile = val;
-            } else {
-            throw new InternalError(MessageFormat.format(RESOURCE.getString(DriverResource.BAD_OPTION), opt, avProps.get(opt)));
+            switch (opt) {
+                case "--repack":
+                    doRepack = true;
+                    break;
+                case "--no-gzip":
+                    doZip = (val == null);
+                    break;
+                case "--log-file=":
+                    logFile = val;
+                    break;
+                default:
+                    throw new InternalError(MessageFormat.format(
+                            RESOURCE.getString(DriverResource.BAD_OPTION),
+                            opt, avProps.get(opt)));
             }
         }
 
@@ -219,7 +227,9 @@
             if (packfile.toLowerCase().endsWith(".pack") ||
                 packfile.toLowerCase().endsWith(".pac") ||
                 packfile.toLowerCase().endsWith(".gz")) {
-            System.err.println(MessageFormat.format(RESOURCE.getString(DriverResource.BAD_REPACK_OUTPUT),packfile));
+                System.err.println(MessageFormat.format(
+                        RESOURCE.getString(DriverResource.BAD_REPACK_OUTPUT),
+                        packfile));
                 printUsage(doPack, false, System.err);
                 System.exit(2);
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/FixedList.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,174 @@
+/*
+ * 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 com.sun.java.util.jar.pack;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+/*
+ * @author ksrini
+ */
+
+/*
+ * This class provides an ArrayList implementation which has a fixed size,
+ * thus all the operations which modifies the size have been rendered
+ * inoperative. This essentially allows us to use generified array
+ * lists in lieu of arrays.
+ */
+final class FixedList<E> implements List<E> {
+
+    private final ArrayList<E> flist;
+
+    protected FixedList(int capacity) {
+        flist = new ArrayList<>(capacity);
+        // initialize the list to null
+        for (int i = 0 ; i < capacity ; i++) {
+            flist.add(null);
+        }
+    }
+    @Override
+    public int size() {
+        return flist.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return flist.isEmpty();
+    }
+
+    @Override
+    public boolean contains(Object o) {
+        return flist.contains(o);
+    }
+
+    @Override
+    public Iterator<E> iterator() {
+        return flist.iterator();
+    }
+
+    @Override
+    public Object[] toArray() {
+        return flist.toArray();
+    }
+
+    @Override
+    public <T> T[] toArray(T[] a) {
+        return flist.toArray(a);
+    }
+
+    @Override
+    public boolean add(E e) throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("operation not permitted");
+    }
+
+    @Override
+    public boolean remove(Object o) throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("operation not permitted");
+    }
+
+    @Override
+    public boolean containsAll(Collection<?> c) {
+        return flist.containsAll(c);
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends E> c) throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("operation not permitted");
+    }
+
+    @Override
+    public boolean addAll(int index, Collection<? extends E> c) throws UnsupportedOperationException {
+         throw new UnsupportedOperationException("operation not permitted");
+    }
+
+    @Override
+    public boolean removeAll(Collection<?> c)  throws UnsupportedOperationException  {
+         throw new UnsupportedOperationException("operation not permitted");
+    }
+
+    @Override
+    public boolean retainAll(Collection<?> c)  throws UnsupportedOperationException  {
+        throw new UnsupportedOperationException("operation not permitted");
+    }
+
+    @Override
+    public void clear()  throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("operation not permitted");
+    }
+
+    @Override
+    public E get(int index) {
+        return flist.get(index);
+    }
+
+    @Override
+    public E set(int index, E element) {
+        return flist.set(index, element);
+    }
+
+    @Override
+    public void add(int index, E element)  throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("operation not permitted");
+    }
+
+    @Override
+    public E remove(int index)   throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("operation not permitted");
+    }
+
+    @Override
+    public int indexOf(Object o) {
+        return flist.indexOf(o);
+    }
+
+    @Override
+    public int lastIndexOf(Object o) {
+        return flist.lastIndexOf(o);
+    }
+
+    @Override
+    public ListIterator<E> listIterator() {
+        return flist.listIterator();
+    }
+
+    @Override
+    public ListIterator<E> listIterator(int index) {
+        return flist.listIterator(index);
+    }
+
+    @Override
+    public List<E> subList(int fromIndex, int toIndex) {
+        return flist.subList(fromIndex, toIndex);
+    }
+
+    @Override
+    public String toString() {
+        return "FixedList{" + "plist=" + flist + '}';
+    }
+}
+
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java	Wed Jan 19 21:51:10 2011 -0800
@@ -42,7 +42,7 @@
  *
  * @author John Rose
  */
-class Fixups extends AbstractCollection implements Constants {
+final class Fixups extends AbstractCollection {
     byte[] bytes;    // the subject of the relocations
     int head;        // desc locating first reloc
     int tail;        // desc locating last reloc
@@ -99,7 +99,7 @@
         }
     }
 
-    public void visitRefs(Collection refs) {
+    public void visitRefs(Collection<Entry> refs) {
         for (int i = 0; i < size; i++) {
             refs.add(entries[i]);
         }
@@ -124,6 +124,7 @@
         return bytes;
     }
 
+    @SuppressWarnings("unchecked")
     public void setBytes(byte[] newBytes) {
         if (bytes == newBytes)  return;
         ArrayList old = null;
@@ -278,7 +279,7 @@
             return new Fixup(nextDesc(), entries[thisIndex]);
         }
         int nextDesc() {
-            int thisIndex = index++;
+            index++;
             int thisDesc = next;
             if (index < size) {
                 // Fetch next desc eagerly, in case this fixup gets finalized.
@@ -310,6 +311,7 @@
     public boolean add(Object fixup) {
         return add((Fixup) fixup);
     }
+    @SuppressWarnings("unchecked")
     public boolean addAll(Collection c) {
         if (c instanceof Fixups) {
             // Use knowledge of Itr structure to avoid building little structs.
@@ -420,7 +422,7 @@
 
     // Iterate over all the references in this set of fixups.
     public static
-    void visitRefs(Object fixups, Collection refs) {
+    void visitRefs(Object fixups, Collection<Entry> refs) {
         if (fixups == null) {
         } else if (!(fixups instanceof Fixups)) {
             // Special convention; see above.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java	Wed Jan 19 21:51:10 2011 -0800
@@ -34,7 +34,7 @@
  * Histogram derived from an integer array of events (int[]).
  * @author John Rose
  */
-class Histogram {
+final class Histogram {
     // Compact histogram representation:  4 bytes per distinct value,
     // plus 5 words per distinct count.
     protected final int[][] matrix;  // multi-row matrix {{counti,valueij...}}
@@ -304,7 +304,7 @@
     public
     String[] getRowTitles(String name) {
         int totalUnique = getTotalLength();
-        int totalWeight = getTotalWeight();
+        int ltotalWeight = getTotalWeight();
         String[] histTitles = new String[matrix.length];
         int cumWeight = 0;
         int cumUnique = 0;
@@ -314,7 +314,7 @@
             int weight = getRowWeight(i);
             cumWeight += weight;
             cumUnique += unique;
-            long wpct = ((long)cumWeight * 100 + totalWeight/2) / totalWeight;
+            long wpct = ((long)cumWeight * 100 + ltotalWeight/2) / ltotalWeight;
             long upct = ((long)cumUnique * 100 + totalUnique/2) / totalUnique;
             double len = getRowBitLength(i);
             assert(0.1 > Math.abs(len - getBitLength(matrix[i][1])));
@@ -346,14 +346,14 @@
     public
     void print(String name, String[] histTitles, PrintStream out) {
         int totalUnique = getTotalLength();
-        int totalWeight = getTotalWeight();
+        int ltotalWeight = getTotalWeight();
         double tlen = getBitLength();
-        double avgLen = tlen / totalWeight;
-        double avg = (double) totalWeight / totalUnique;
+        double avgLen = tlen / ltotalWeight;
+        double avg = (double) ltotalWeight / totalUnique;
         String title = (name
                         +" len="+round(tlen,10)
                         +" avgLen="+round(avgLen,10)
-                        +" weight("+totalWeight+")"
+                        +" weight("+ltotalWeight+")"
                         +" unique["+totalUnique+"]"
                         +" avgWeight("+round(avg,100)+")");
         if (histTitles == null) {
@@ -363,9 +363,9 @@
             StringBuffer buf = new StringBuffer();
             for (int i = 0; i < matrix.length; i++) {
                 buf.setLength(0);
-                buf.append("  "+histTitles[i]+" {");
+                buf.append("  ").append(histTitles[i]).append(" {");
                 for (int j = 1; j < matrix[i].length; j++) {
-                    buf.append(" "+matrix[i][j]);
+                    buf.append(" ").append(matrix[i][j]);
                 }
                 buf.append(" }");
                 out.println(buf);
@@ -603,7 +603,7 @@
     private static
     int[] maybeSort(int[] values) {
         if (!isSorted(values, 0, false)) {
-            values = (int[]) values.clone();
+            values = values.clone();
             Arrays.sort(values);
         }
         return values;
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Instruction.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Instruction.java	Wed Jan 19 21:51:10 2011 -0800
@@ -26,13 +26,15 @@
 package com.sun.java.util.jar.pack;
 
 import java.io.IOException;
+import java.util.Arrays;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * A parsed bytecode instruction.
  * Provides accessors to various relevant bits.
  * @author John Rose
  */
-class Instruction implements Constants {
+class Instruction  {
     protected byte[] bytes;  // bytecodes
     protected int pc;        // location of this instruction
     protected int bc;        // opcode of this instruction
@@ -91,8 +93,8 @@
 
     /** A fake instruction at this pc whose next() will be at nextpc. */
     public Instruction forceNextPC(int nextpc) {
-        int length = nextpc - pc;
-        return new Instruction(bytes, pc, -1, -1, length);
+        int llength = nextpc - pc;
+        return new Instruction(bytes, pc, -1, -1, llength);
     }
 
     public static Instruction at(byte[] bytes, int pc) {
@@ -315,12 +317,24 @@
         }
     }
 
-    /** Two insns are equal if they have the same bytes. */
+    /** Two instructions are equal if they have the same bytes. */
     public boolean equals(Object o) {
-        return (o instanceof Instruction) && equals((Instruction)o);
+        return (o != null) && (o.getClass() == Instruction.class)
+                && equals((Instruction) o);
+    }
+
+    public int hashCode() {
+        int hash = 3;
+        hash = 11 * hash + Arrays.hashCode(this.bytes);
+        hash = 11 * hash + this.pc;
+        hash = 11 * hash + this.bc;
+        hash = 11 * hash + this.w;
+        hash = 11 * hash + this.length;
+        return hash;
     }
 
     public boolean equals(Instruction that) {
+        if (this.pc != that.pc)            return false;
         if (this.bc != that.bc)            return false;
         if (this.w  != that.w)             return false;
         if (this.length  != that.length)   return false;
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java	Wed Jan 19 21:51:10 2011 -0800
@@ -170,8 +170,8 @@
 
     void run(InputStream inRaw, JarOutputStream jstream,
              ByteBuffer presetInput) throws IOException {
-        BufferedInputStream in = new BufferedInputStream(inRaw);
-        this.in = in;    // for readInputFn to see
+        BufferedInputStream in0 = new BufferedInputStream(inRaw);
+        this.in = in0;    // for readInputFn to see
         _verbose = _props.getInteger(Utils.DEBUG_VERBOSE);
         // Fix for BugId: 4902477, -unpack.modification.time = 1059010598000
         // TODO eliminate and fix in unpack.cpp
@@ -224,7 +224,7 @@
             if (_verbose > 0)
                 Utils.log.info("bytes consumed = "+consumed);
             if (presetInput == null &&
-                !Utils.isPackMagic(Utils.readMagic(in))) {
+                !Utils.isPackMagic(Utils.readMagic(in0))) {
                 break;
             }
             if (_verbose > 0 ) {
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java	Wed Jan 19 21:51:10 2011 -0800
@@ -52,12 +52,13 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.jar.JarFile;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Define the main data structure transmitted by pack/unpack.
  * @author John Rose
  */
-class Package implements Constants {
+class Package {
     int verbose;
     {
         PropMap pmap = Utils.currentPropMap();
@@ -109,9 +110,9 @@
     public static final Attribute.Layout attrCodeEmpty;
     public static final Attribute.Layout attrInnerClassesEmpty;
     public static final Attribute.Layout attrSourceFileSpecial;
-    public static final Map attrDefs;
+    public static final Map<Attribute.Layout, Attribute> attrDefs;
     static {
-        HashMap<Layout, Attribute> ad = new HashMap<>(3);
+        Map<Layout, Attribute> ad = new HashMap<>(3);
         attrCodeEmpty = Attribute.define(ad, ATTR_CONTEXT_METHOD,
                                          "Code", "").layout();
         attrInnerClassesEmpty = Attribute.define(ad, ATTR_CONTEXT_CLASS,
@@ -130,8 +131,7 @@
      */
     int getHighestClassVersion() {
         int res = 0;  // initial low value
-        for (Iterator i = classes.iterator(); i.hasNext(); ) {
-            Class cls = (Class) i.next();
+        for (Class cls : classes) {
             int ver = cls.getVersion();
             if (res < ver)  res = ver;
         }
@@ -187,7 +187,7 @@
         return classes;
     }
 
-    public
+    public final
     class Class extends Attribute.Holder implements Comparable {
         public Package getPackage() { return Package.this; }
 
@@ -232,8 +232,8 @@
             initFile(newStub(classFile));
         }
 
-        List getFields() { return fields == null ? noFields : fields; }
-        List getMethods() { return methods == null ? noMethods : methods; }
+        List<Field> getFields() { return fields == null ? noFields : fields; }
+        List<Method> getMethods() { return methods == null ? noMethods : methods; }
 
         public String getName() {
             return thisClass.stringValue();
@@ -264,7 +264,7 @@
             if (olda == null)
                 return;  // no SourceFile attr.
             String obvious = getObviousSourceFile();
-            ArrayList ref = new ArrayList(1);
+            List<Entry> ref = new ArrayList<>(1);
             olda.visitRefs(this, VRM_PACKAGE, ref);
             Utf8Entry sfName = (Utf8Entry) ref.get(0);
             Attribute a = olda;
@@ -322,7 +322,7 @@
         }
 
         public void setInnerClasses(Collection<InnerClass> ics) {
-            innerClasses = (ics == null) ? null : new ArrayList<InnerClass>(ics);
+            innerClasses = (ics == null) ? null : new ArrayList<>(ics);
             // Edit the attribute list, if necessary.
             Attribute a = getAttribute(attrInnerClassesEmpty);
             if (innerClasses != null && a == null)
@@ -341,7 +341,7 @@
          *  with that of Package.this.allInnerClasses.
          */
         public List<InnerClass> computeGloballyImpliedICs() {
-            HashSet<Entry> cpRefs = new HashSet<>();
+            Set<Entry> cpRefs = new HashSet<>();
             {   // This block temporarily displaces this.innerClasses.
                 ArrayList<InnerClass> innerClassesSaved = innerClasses;
                 innerClasses = null;  // ignore for the moment
@@ -350,7 +350,7 @@
             }
             ConstantPool.completeReferencesIn(cpRefs, true);
 
-            HashSet<Entry> icRefs = new HashSet<>();
+            Set<Entry> icRefs = new HashSet<>();
             for (Entry e : cpRefs) {
                 // Restrict cpRefs to InnerClasses entries only.
                 if (!(e instanceof ClassEntry))  continue;
@@ -390,7 +390,7 @@
             List<InnerClass> impliedICs = computeGloballyImpliedICs();
             List<InnerClass> actualICs  = getInnerClasses();
             if (actualICs == null)
-                actualICs = Collections.EMPTY_LIST;
+                actualICs = Collections.emptyList();
 
             // Symmetric difference is calculated from I, A like this:
             //  diff = (I+A) - (I*A)
@@ -409,7 +409,7 @@
                 // Diff is A since I is empty.
             }
             // (I*A) is non-trivial
-            HashSet<InnerClass> center = new HashSet<>(actualICs);
+            Set<InnerClass> center = new HashSet<>(actualICs);
             center.retainAll(new HashSet<>(impliedICs));
             impliedICs.addAll(actualICs);
             impliedICs.removeAll(center);
@@ -443,7 +443,7 @@
             } else if (actualICs == null) {
                 // No local IC attribute, even though some are implied.
                 // Signal with trivial attribute.
-                localICs = Collections.EMPTY_LIST;
+                localICs = Collections.emptyList();
             } else {
                 // Transmit a non-empty diff, which will create
                 // a local ICs attribute.
@@ -588,7 +588,7 @@
             }
 
             public void strip(String attrName) {
-                if (attrName == "Code")
+                if ("Code".equals(attrName))
                     code = null;
                 if (code != null)
                     code.strip(attrName);
@@ -622,7 +622,7 @@
         }
 
         public void strip(String attrName) {
-            if (attrName == "InnerClass")
+            if ("InnerClass".equals(attrName))
                 innerClasses = null;
             for (int isM = 0; isM <= 1; isM++) {
                 ArrayList members = (isM == 0) ? fields : methods;
@@ -639,9 +639,7 @@
             if (verbose > 2)  Utils.log.fine("visitRefs "+this);
             refs.add(thisClass);
             refs.add(superClass);
-            for (int i = 0; i < interfaces.length; i++) {
-                refs.add(interfaces[i]);
-            }
+            refs.addAll(Arrays.asList(interfaces));
             for (int isM = 0; isM <= 1; isM++) {
                 ArrayList members = (isM == 0) ? fields : methods;
                 if (members == null)  continue;
@@ -741,7 +739,7 @@
     }
 
     public List<File> getClassStubs() {
-        ArrayList<File> classStubs = new ArrayList<>(classes.size());
+        List<File> classStubs = new ArrayList<>(classes.size());
         for (Class cls : classes) {
             assert(cls.file.isClassStub());
             classStubs.add(cls.file);
@@ -749,8 +747,7 @@
         return classStubs;
     }
 
-    public
-    class File implements Comparable {
+    public final class File implements Comparable {
         String nameString;  // true name of this file
         Utf8Entry name;
         int modtime = NO_MODTIME;
@@ -792,8 +789,10 @@
         // The nameString is the key.  Ignore other things.
         // (Note:  The name might be "", in the case of a trivial class stub.)
         public boolean equals(Object o) {
+            if (o == null || (o.getClass() != File.class))
+                return false;
             File that = (File)o;
-            return that.nameString == this.nameString;
+            return that.nameString.equals(this.nameString);
         }
         public int hashCode() {
             return nameString.hashCode();
@@ -816,9 +815,9 @@
             return getFileName(null);
         }
         public java.io.File getFileName(java.io.File parent) {
-            String name = this.nameString;
+            String lname = this.nameString;
             //if (name.startsWith("./"))  name = name.substring(2);
-            String fname = name.replace('/', java.io.File.separatorChar);
+            String fname = lname.replace('/', java.io.File.separatorChar);
             return new java.io.File(parent, fname);
         }
 
@@ -834,7 +833,7 @@
         }
         public long getFileLength() {
             long len = 0;
-            if (prepend == null && append == null)  return 0;
+            if (prepend == null || append == null)  return 0;
             for (Iterator i = prepend.iterator(); i.hasNext(); ) {
                 byte[] block = (byte[]) i.next();
                 len += block.length;
@@ -843,7 +842,7 @@
             return len;
         }
         public void writeTo(OutputStream out) throws IOException {
-            if (prepend == null && append == null)  return;
+            if (prepend == null || append == null)  return;
             for (Iterator i = prepend.iterator(); i.hasNext(); ) {
                 byte[] block = (byte[]) i.next();
                 out.write(block);
@@ -859,8 +858,8 @@
         }
         public InputStream getInputStream() {
             InputStream in = new ByteArrayInputStream(append.toByteArray());
-            if (prepend.size() == 0)  return in;
-            ArrayList<InputStream> isa = new ArrayList<>(prepend.size()+1);
+            if (prepend.isEmpty())  return in;
+            List<InputStream> isa = new ArrayList<>(prepend.size()+1);
             for (Iterator i = prepend.iterator(); i.hasNext(); ) {
                 byte[] bytes = (byte[]) i.next();
                 isa.add(new ByteArrayInputStream(bytes));
@@ -897,11 +896,11 @@
     }
 
     // Is there a globally declared table of inner classes?
-    ArrayList<InnerClass> allInnerClasses = new ArrayList<>();
-    HashMap<ClassEntry, InnerClass>   allInnerClassesByThis;
+    List<InnerClass> allInnerClasses = new ArrayList<>();
+    Map<ClassEntry, InnerClass>   allInnerClassesByThis;
 
     public
-    List getAllInnerClasses() {
+    List<InnerClass> getAllInnerClasses() {
         return allInnerClasses;
     }
 
@@ -955,16 +954,17 @@
             if (parse == null)  return false;
             String pkgOuter = parse[0];
             //String number = parse[1];
-            String name     = parse[2];
+            String lname     = parse[2];
             String haveName  = (this.name == null)  ? null : this.name.stringValue();
             String haveOuter = (outerClass == null) ? null : outerClass.stringValue();
-            boolean predictable = (name == haveName && pkgOuter == haveOuter);
+            boolean lpredictable = (lname == haveName && pkgOuter == haveOuter);
             //System.out.println("computePredictable => "+predictable);
-            return predictable;
+            return lpredictable;
         }
 
         public boolean equals(Object o) {
-            if (o == null)  return false;
+            if (o == null || o.getClass() != InnerClass.class)
+                return false;
             InnerClass that = (InnerClass)o;
             return eq(this.thisClass, that.thisClass)
                 && eq(this.outerClass, that.outerClass)
@@ -999,7 +999,7 @@
 
     // Helper for building InnerClasses attributes.
     static private
-    void visitInnerClassRefs(Collection innerClasses, int mode, Collection<Entry> refs) {
+    void visitInnerClassRefs(Collection<InnerClass> innerClasses, int mode, Collection<Entry> refs) {
         if (innerClasses == null) {
             return;  // no attribute; nothing to do
         }
@@ -1008,8 +1008,7 @@
         }
         if (innerClasses.size() > 0) {
             // Count the entries themselves:
-            for (Iterator i = innerClasses.iterator(); i.hasNext(); ) {
-                InnerClass c = (InnerClass) i.next();
+            for (InnerClass c : innerClasses) {
                 c.visitRefs(mode, refs);
             }
         }
@@ -1117,43 +1116,43 @@
         // what is one of { Debug, Compile, Constant, Exceptions, InnerClasses }
         if (verbose > 0)
             Utils.log.info("Stripping "+what.toLowerCase()+" data and attributes...");
-        if (what == "Debug") {
-            strip("SourceFile");
-            strip("LineNumberTable");
-            strip("LocalVariableTable");
-            strip("LocalVariableTypeTable");
-        }
-        if (what == "Compile") {
-            // Keep the inner classes normally.
-            // Although they have no effect on execution,
-            // the Reflection API exposes them, and JCK checks them.
-            // NO: // strip("InnerClasses");
-            strip("Deprecated");
-            strip("Synthetic");
-        }
-        if (what == "Exceptions") {
-            // Keep the exceptions normally.
-            // Although they have no effect on execution,
-            // the Reflection API exposes them, and JCK checks them.
-            strip("Exceptions");
-        }
-        if (what == "Constant") {
-            stripConstantFields();
+        switch (what) {
+            case "Debug":
+                strip("SourceFile");
+                strip("LineNumberTable");
+                strip("LocalVariableTable");
+                strip("LocalVariableTypeTable");
+                break;
+            case "Compile":
+                // Keep the inner classes normally.
+                // Although they have no effect on execution,
+                // the Reflection API exposes them, and JCK checks them.
+                // NO: // strip("InnerClasses");
+                strip("Deprecated");
+                strip("Synthetic");
+                break;
+            case "Exceptions":
+                // Keep the exceptions normally.
+                // Although they have no effect on execution,
+                // the Reflection API exposes them, and JCK checks them.
+                strip("Exceptions");
+                break;
+            case "Constant":
+                stripConstantFields();
+                break;
         }
     }
 
     public void trimToSize() {
         classes.trimToSize();
-        for (Iterator i = classes.iterator(); i.hasNext(); ) {
-            Class c = (Class)i.next();
+        for (Class c : classes) {
             c.trimToSize();
         }
         files.trimToSize();
     }
 
     public void strip(String attrName) {
-        for (Iterator i = classes.iterator(); i.hasNext(); ) {
-            Class c = (Class)i.next();
+        for (Class c : classes) {
             c.strip(attrName);
         }
     }
@@ -1166,10 +1165,9 @@
     }
 
     public void stripConstantFields() {
-        for (Iterator i = classes.iterator(); i.hasNext(); ) {
-            Class c = (Class) i.next();
-            for (Iterator j = c.fields.iterator(); j.hasNext(); ) {
-                Class.Field f = (Class.Field) j.next();
+        for (Class c : classes) {
+            for (Iterator<Class.Field> j = c.fields.iterator(); j.hasNext(); ) {
+                Class.Field f = j.next();
                 if (Modifier.isFinal(f.flags)
                     // do not strip non-static finals:
                     && Modifier.isStatic(f.flags)
@@ -1189,8 +1187,7 @@
             c.visitRefs(mode, refs);
         }
         if (mode != VRM_CLASSIC) {
-            for (Iterator i = files.iterator(); i.hasNext(); ) {
-                File f = (File)i.next();
+            for (File f : files) {
                 f.visitRefs(mode, refs);
             }
             visitInnerClassRefs(allInnerClasses, mode, refs);
@@ -1202,6 +1199,7 @@
     // compress better.  It also moves classes to the end of the
     // file order.  It also removes JAR directory entries, which
     // are useless.
+    @SuppressWarnings("unchecked")
     void reorderFiles(boolean keepClassOrder, boolean stripDirectories) {
         // First reorder the classes, if that is allowed.
         if (!keepClassOrder) {
@@ -1214,9 +1212,9 @@
         // modtimes and options are not transmitted, and the stub files
         // for class files do not need to be transmitted at all.
         // Also
-        List stubs = getClassStubs();
-        for (Iterator i = files.iterator(); i.hasNext(); ) {
-            File file = (File) i.next();
+        List<File> stubs = getClassStubs();
+        for (Iterator<File> i = files.iterator(); i.hasNext(); ) {
+            File file = i.next();
             if (file.isClassStub() ||
                 (stripDirectories && file.isDirectory())) {
                 i.remove();
@@ -1259,8 +1257,8 @@
 
     void trimStubs() {
         // Restore enough non-trivial stubs to carry the needed class modtimes.
-        for (ListIterator i = files.listIterator(files.size()); i.hasPrevious(); ) {
-            File file = (File) i.previous();
+        for (ListIterator<File> i = files.listIterator(files.size()); i.hasPrevious(); ) {
+            File file = i.previous();
             if (!file.isTrivialClassStub()) {
                 if (verbose > 1)
                     Utils.log.fine("Keeping last non-trivial "+file);
@@ -1309,7 +1307,7 @@
 
     // Use this before writing the class files.
     void ensureAllClassFiles() {
-        HashSet<File> fileSet = new HashSet<>(files);
+        Set<File> fileSet = new HashSet<>(files);
         for (Class cls : classes) {
             // Add to the end of ths list:
             if (!fileSet.contains(cls.file))
@@ -1317,8 +1315,8 @@
         }
     }
 
-    static final List noObjects = Arrays.asList(new Object[0]);
-    static final List noFields = Arrays.asList(new Class.Field[0]);
-    static final List noMethods = Arrays.asList(new Class.Method[0]);
-    static final List noInnerClasses = Arrays.asList(new InnerClass[0]);
+    static final List<Object> noObjects = Arrays.asList(new Object[0]);
+    static final List<Class.Field> noFields = Arrays.asList(new Class.Field[0]);
+    static final List<Class.Method> noMethods = Arrays.asList(new Class.Method[0]);
+    static final List<InnerClass> noInnerClasses = Arrays.asList(new InnerClass[0]);
 }
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java	Wed Jan 19 21:51:10 2011 -0800
@@ -32,11 +32,28 @@
 import com.sun.java.util.jar.pack.ConstantPool.MemberEntry;
 import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry;
 import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry;
-import java.io.*;
-import java.util.*;
 import com.sun.java.util.jar.pack.Package.Class;
 import com.sun.java.util.jar.pack.Package.File;
 import com.sun.java.util.jar.pack.Package.InnerClass;
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.PrintStream;
+import java.io.FilterInputStream;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Set;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Reader for a package file.
@@ -418,7 +435,7 @@
                 cp_Int.readFrom(in);
                 for (int i = 0; i < cpMap.length; i++) {
                     int x = cp_Int.getInt();  // coding handles signs OK
-                    cpMap[i] = ConstantPool.getLiteralEntry(new Integer(x));
+                    cpMap[i] = ConstantPool.getLiteralEntry(x);
                 }
                 cp_Int.doneDisbursing();
                 break;
@@ -428,7 +445,7 @@
                 for (int i = 0; i < cpMap.length; i++) {
                     int x = cp_Float.getInt();
                     float fx = Float.intBitsToFloat(x);
-                    cpMap[i] = ConstantPool.getLiteralEntry(new Float(fx));
+                    cpMap[i] = ConstantPool.getLiteralEntry(fx);
                 }
                 cp_Float.doneDisbursing();
                 break;
@@ -444,7 +461,7 @@
                     long hi = cp_Long_hi.getInt();
                     long lo = cp_Long_lo.getInt();
                     long x = (hi << 32) + ((lo << 32) >>> 32);
-                    cpMap[i] = ConstantPool.getLiteralEntry(new Long(x));
+                    cpMap[i] = ConstantPool.getLiteralEntry(x);
                 }
                 cp_Long_hi.doneDisbursing();
                 cp_Long_lo.doneDisbursing();
@@ -462,7 +479,7 @@
                     long lo = cp_Double_lo.getInt();
                     long x = (hi << 32) + ((lo << 32) >>> 32);
                     double dx = Double.longBitsToDouble(x);
-                    cpMap[i] = ConstantPool.getLiteralEntry(new Double(dx));
+                    cpMap[i] = ConstantPool.getLiteralEntry(dx);
                 }
                 cp_Double_hi.doneDisbursing();
                 cp_Double_lo.doneDisbursing();
@@ -645,7 +662,7 @@
         cp_Utf8_big_suffix.doneDisbursing();
     }
 
-    HashMap utf8Signatures;  // Utf8Entry->SignatureEntry
+    Map<Utf8Entry, SignatureEntry> utf8Signatures;
 
     void readSignatureBands(Entry[] cpMap) throws IOException {
         //  cp_Signature:
@@ -663,7 +680,7 @@
         cp_Signature_classes.expectLength(getIntTotal(numSigClasses));
         cp_Signature_classes.readFrom(in);
         cp_Signature_classes.setIndex(getCPIndex(CONSTANT_Class));
-        utf8Signatures = new HashMap();
+        utf8Signatures = new HashMap<>();
         for (int i = 0; i < cpMap.length; i++) {
             Utf8Entry formRef = (Utf8Entry) cp_Signature_form.getRef();
             ClassEntry[] classRefs = new ClassEntry[numSigClasses[i]];
@@ -863,7 +880,7 @@
         ic_name.expectLength(longICCount);
         ic_name.readFrom(in);
         ic_flags.resetForSecondPass();
-        ArrayList icList = new ArrayList(numInnerClasses);
+        List<InnerClass> icList = new ArrayList<>(numInnerClasses);
         for (int i = 0; i < numInnerClasses; i++) {
             int flags = ic_flags.getInt();
             boolean longForm = (flags & ACC_IC_LONG_FORM) != 0;
@@ -876,7 +893,7 @@
                 thisName   = (Utf8Entry)  ic_name.getRef();
             } else {
                 String n = thisClass.stringValue();
-                String[] parse = pkg.parseInnerClassName(n);
+                String[] parse = Package.parseInnerClassName(n);
                 assert(parse != null);
                 String pkgOuter = parse[0];
                 //String number = parse[1];
@@ -905,7 +922,7 @@
 
     void readLocalInnerClasses(Class cls) throws IOException {
         int nc = class_InnerClasses_N.getInt();
-        ArrayList localICs = new ArrayList(nc);
+        List<InnerClass> localICs = new ArrayList<>(nc);
         for (int i = 0; i < nc; i++) {
             ClassEntry thisClass = (ClassEntry) class_InnerClasses_RC.getRef();
             int        flags     =              class_InnerClasses_F.getInt();
@@ -994,10 +1011,8 @@
         return -1;
     }
 
-    Comparator entryOutputOrder = new Comparator() {
-        public int compare(Object o0, Object o1) {
-            Entry e0 = (Entry) o0;
-            Entry e1 = (Entry) o1;
+    Comparator<Entry> entryOutputOrder = new Comparator<>() {
+        public int compare(Entry  e0, Entry e1) {
             int k0 = getOutputIndex(e0);
             int k1 = getOutputIndex(e1);
             if (k0 >= 0 && k1 >= 0)
@@ -1034,9 +1049,8 @@
     }
 
     Entry[] reconstructLocalCPMap(Class cls) {
-        HashSet ldcRefs = (HashSet) ldcRefMap.get(cls);
-        HashSet cpRefs = new HashSet();
-        HashSet sigSet = new HashSet();
+        Set<Entry> ldcRefs = ldcRefMap.get(cls);
+        Set<Entry> cpRefs = new HashSet<>();
 
         // look for constant pool entries:
         cls.visitRefs(VRM_CLASSIC, cpRefs);
@@ -1064,8 +1078,7 @@
 
         // construct a local constant pool
         int numDoubles = 0;
-        for (Iterator i = cpRefs.iterator(); i.hasNext(); ) {
-            Entry e = (Entry) i.next();
+        for (Entry e : cpRefs) {
             if (e.isDoubleWord())  numDoubles++;
             assert(e.tag != CONSTANT_Signature) : (e);
         }
@@ -1075,8 +1088,7 @@
         // Add all ldc operands first.
         if (ldcRefs != null) {
             assert(cpRefs.containsAll(ldcRefs));
-            for (Iterator i = ldcRefs.iterator(); i.hasNext(); ) {
-                Entry e = (Entry) i.next();
+            for (Entry e : ldcRefs) {
                 cpMap[fillp++] = e;
             }
             assert(fillp == 1+ldcRefs.size());
@@ -1085,11 +1097,10 @@
         }
 
         // Next add all the two-byte references.
-        HashSet wideRefs = cpRefs;
+        Set<Entry> wideRefs = cpRefs;
         cpRefs = null;  // do not use!
         int narrowLimit = fillp;
-        for (Iterator i = wideRefs.iterator(); i.hasNext(); ) {
-            Entry e = (Entry) i.next();
+        for (Entry e : wideRefs) {
             cpMap[fillp++] = e;
         }
         assert(fillp == narrowLimit+wideRefs.size());
@@ -1144,7 +1155,7 @@
         method_descr.expectLength(totalNM);
         if (verbose > 1)  Utils.log.fine("expecting #fields="+totalNF+" and #methods="+totalNM+" in #classes="+numClasses);
 
-        ArrayList fields = new ArrayList(totalNF);
+        List<Class.Field> fields = new ArrayList<>(totalNF);
         field_descr.readFrom(in);
         for (int i = 0; i < classes.length; i++) {
             Class c = classes[i];
@@ -1160,7 +1171,7 @@
         countAndReadAttrs(ATTR_CONTEXT_FIELD, fields);
         fields = null;  // release to GC
 
-        ArrayList methods = new ArrayList(totalNM);
+        List<Class.Method> methods = new ArrayList<>(totalNM);
         method_descr.readFrom(in);
         for (int i = 0; i < classes.length; i++) {
             Class c = classes[i];
@@ -1182,13 +1193,12 @@
     }
 
     Code[] allCodes;
-    List codesWithFlags;
-    HashMap ldcRefMap = new HashMap();  // HashMap<Class, HashSet<Entry>>
+    List<Code> codesWithFlags;
+    Map<Class, Set<Entry>> ldcRefMap = new HashMap<>();
 
-    Code[] buildCodeAttrs(List methods) {
-        ArrayList codes = new ArrayList(methods.size());
-        for (Iterator i = methods.iterator(); i.hasNext(); ) {
-            Class.Method m = (Class.Method) i.next();
+    Code[] buildCodeAttrs(List<Class.Method> methods) {
+        List<Code> codes = new ArrayList<>(methods.size());
+        for (Class.Method m : methods) {
             if (m.getAttribute(attrCodeEmpty) != null) {
                 m.code = new Code(m);
                 codes.add(m.code);
@@ -1211,7 +1221,7 @@
         boolean attrsOK = testBit(archiveOptions, AO_HAVE_ALL_CODE_FLAGS);
         code_headers.expectLength(allCodes.length);
         code_headers.readFrom(in);
-        ArrayList longCodes = new ArrayList(allCodes.length / 10);
+        List<Code> longCodes = new ArrayList<>(allCodes.length / 10);
         for (int i = 0; i < allCodes.length; i++) {
             Code c = allCodes[i];
             int sc = code_headers.getByte();
@@ -1238,8 +1248,7 @@
         code_max_stack.readFrom(in);
         code_max_na_locals.readFrom(in);
         code_handler_count.readFrom(in);
-        for (Iterator i = longCodes.iterator(); i.hasNext(); ) {
-            Code c = (Code) i.next();
+        for (Code c : longCodes) {
             c.setMaxStack(     code_max_stack.getInt() );
             c.setMaxNALocals(  code_max_na_locals.getInt() );
             c.setHandlerCount( code_handler_count.getInt() );
@@ -1386,8 +1395,9 @@
 
         // Fetch the attribute layout definitions which govern the bands
         // we are about to read.
-        Attribute.Layout[] defs = new Attribute.Layout[attrDefs[ctype].size()];
-        attrDefs[ctype].toArray(defs);
+        List<Attribute.Layout> defList = attrDefs.get(ctype);
+        Attribute.Layout[] defs = new Attribute.Layout[defList.size()];
+        defList.toArray(defs);
         IntBand xxx_flags_hi = getAttrBand(xxx_attr_bands, AB_FLAGS_HI);
         IntBand xxx_flags_lo = getAttrBand(xxx_attr_bands, AB_FLAGS_LO);
         IntBand xxx_attr_count = getAttrBand(xxx_attr_bands, AB_ATTR_COUNT);
@@ -1450,7 +1460,7 @@
                 bits -= (1L<<ai);
                 nfa += 1;
             }
-            ArrayList ha = new ArrayList(nfa + noa);
+            List<Attribute> ha = new ArrayList<>(nfa + noa);
             h.attributes = ha;
             bits = attrBits;  // iterate again
             for (int ai = 0; bits != 0; ai++) {
@@ -1516,7 +1526,7 @@
                 if (predef != isPredefinedAttr(ctype, ai))
                     continue;  // wrong pass
                 int totalCount = totalCounts[ai];
-                Band[] ab = (Band[]) attrBandTable.get(def);
+                Band[] ab = attrBandTable.get(def);
                 if (def == attrInnerClassesEmpty) {
                     // Special case.
                     // Size the bands as if using the following layout:
@@ -1571,15 +1581,16 @@
                                    ATTR_CONTEXT_NAME[ctype]+" attribute");
     }
 
+    @SuppressWarnings("unchecked")
     void readAttrs(int ctype, Collection holders) throws IOException {
         // Decode band values into attributes.
-        HashSet sawDefs = new HashSet();
+        Set<Attribute.Layout> sawDefs = new HashSet<>();
         ByteArrayOutputStream buf = new ByteArrayOutputStream();
         for (Iterator i = holders.iterator(); i.hasNext(); ) {
             final Attribute.Holder h = (Attribute.Holder) i.next();
             if (h.attributes == null)  continue;
-            for (ListIterator j = h.attributes.listIterator(); j.hasNext(); ) {
-                Attribute a = (Attribute) j.next();
+            for (ListIterator<Attribute> j = h.attributes.listIterator(); j.hasNext(); ) {
+                Attribute a = j.next();
                 Attribute.Layout def = a.layout();
                 if (def.bandCount == 0) {
                     if (def == attrInnerClassesEmpty) {
@@ -1595,7 +1606,7 @@
                 if (isCV)  setConstantValueIndex((Class.Field)h);
                 if (verbose > 2)
                     Utils.log.fine("read "+a+" in "+h);
-                final Band[] ab = (Band[]) attrBandTable.get(def);
+                final Band[] ab = attrBandTable.get(def);
                 // Read one attribute of type def from ab into a byte array.
                 buf.reset();
                 Object fixups = a.unparse(new Attribute.ValueStream() {
@@ -1617,10 +1628,9 @@
         }
 
         // Mark the bands we just used as done disbursing.
-        for (Iterator i = sawDefs.iterator(); i.hasNext(); ) {
-            Attribute.Layout def = (Attribute.Layout) i.next();
+        for (Attribute.Layout def : sawDefs) {
             if (def == null)  continue;  // unused index
-            Band[] ab = (Band[]) attrBandTable.get(def);
+            Band[] ab = attrBandTable.get(def);
             for (int j = 0; j < ab.length; j++) {
                 ab[j].doneDisbursing();
             }
@@ -1778,7 +1788,7 @@
         // scratch buffer for collecting code::
         byte[] buf = new byte[1<<12];
         // record of all switch opcodes (these are variable-length)
-        ArrayList allSwitchOps = new ArrayList();
+        List<Integer> allSwitchOps = new ArrayList<>();
         for (int k = 0; k < allCodes.length; k++) {
             Code c = allCodes[k];
         scanOneMethod:
@@ -1798,7 +1808,7 @@
                 case _tableswitch:
                 case _lookupswitch:
                     bc_case_count.expectMoreLength(1);
-                    allSwitchOps.add(new Integer(bc));
+                    allSwitchOps.add(bc);
                     break;
                 case _iinc:
                     bc_local.expectMoreLength(1);
@@ -1866,8 +1876,8 @@
 
         // To size instruction bands correctly, we need info on switches:
         bc_case_count.readFrom(in);
-        for (Iterator i = allSwitchOps.iterator(); i.hasNext(); ) {
-            int bc = ((Integer)i.next()).intValue();
+        for (Integer i : allSwitchOps) {
+            int bc = i.intValue();
             int caseCount = bc_case_count.getInt();
             bc_label.expectMoreLength(1+caseCount); // default label + cases
             bc_case_value.expectMoreLength(bc == _tableswitch ? 1 : caseCount);
@@ -1892,9 +1902,9 @@
 
             Class curClass = code.thisClass();
 
-            HashSet ldcRefSet = (HashSet) ldcRefMap.get(curClass);
+            Set<Entry> ldcRefSet = ldcRefMap.get(curClass);
             if (ldcRefSet == null)
-                ldcRefMap.put(curClass, ldcRefSet = new HashSet());
+                ldcRefMap.put(curClass, ldcRefSet = new HashSet<>());
 
             ClassEntry thisClass  = curClass.thisClass;
             ClassEntry superClass = curClass.superClass;
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java	Wed Jan 19 21:51:10 2011 -0800
@@ -45,10 +45,10 @@
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Map;
+import java.util.Set;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Writer for a package file.
@@ -111,12 +111,12 @@
         }
     }
 
-    HashSet     requiredEntries;  // for the CP
-    HashMap     backCountTable;   // for layout callables
+    Set<Entry>                       requiredEntries;  // for the CP
+    Map<Attribute.Layout, int[]>     backCountTable;   // for layout callables
     int[][]     attrCounts;       // count attr. occurences
 
     void setup() {
-        requiredEntries = new HashSet();
+        requiredEntries = new HashSet<>();
         setArchiveOptions();
         trimClassAttributes();
         collectAttributeLayouts();
@@ -139,9 +139,7 @@
         // Import defaults from package (deflate hint, etc.).
         archiveOptions |= pkg.default_options;
 
-        for (Iterator i = pkg.files.iterator(); i.hasNext(); ) {
-            File file = (File) i.next();
-
+        for (File file : pkg.files) {
             int modtime = file.modtime;
             int options = file.options;
 
@@ -178,16 +176,15 @@
             }
         }
         // Decide on default version number (majority rule).
-        HashMap verCounts = new HashMap();
+        Map<Integer, int[]> verCounts = new HashMap<>();
         int bestCount = 0;
         int bestVersion = -1;
-        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
-            Class cls = (Class) i.next();
+        for (Class cls : pkg.classes) {
             int version = cls.getVersion();
-            int[] var = (int[]) verCounts.get(new Integer(version));
+            int[] var = verCounts.get(version);
             if (var == null) {
                 var = new int[1];
-                verCounts.put(new Integer(version), var);
+                verCounts.put(version, var);
             }
             int count = (var[0] += 1);
             //System.out.println("version="+version+" count="+count);
@@ -210,9 +207,7 @@
                            Package.versionStringOf(pkg.getHighestClassVersion()));
 
         // Now add explicit pseudo-attrs. to classes with odd versions.
-        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
-            Class cls = (Class) i.next();
-
+        for (Class cls : pkg.classes) {
             if (cls.getVersion() != bestVersion) {
                 Attribute a = makeClassFileVersionAttr(cls.minver, cls.majver);
                 if (verbose > 1) {
@@ -228,8 +223,7 @@
         }
 
         // Decide if we are transmitting a huge resource file:
-        for (Iterator i = pkg.files.iterator(); i.hasNext(); ) {
-            File file = (File) i.next();
+        for (File file : pkg.files) {
             long len = file.getFileLength();
             if (len != (int)len) {
                 archiveOptions |= AO_HAVE_FILE_SIZE_HI;
@@ -244,10 +238,8 @@
         // we must declare unconditional presence of code flags.
         int cost0 = 0;
         int cost1 = 0;
-        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
-            Class cls = (Class) i.next();
-            for (Iterator j = cls.getMethods().iterator(); j.hasNext(); ) {
-                Class.Method m = (Class.Method) j.next();
+        for (Class cls : pkg.classes) {
+            for (Class.Method m : cls.getMethods()) {
                 if (m.code != null) {
                     if (m.code.attributeSize() == 0) {
                         // cost of a useless unconditional flags byte
@@ -352,7 +344,7 @@
             archive_header_1.putInt(pkg.default_modtime);
             archive_header_1.putInt(pkg.files.size());
         } else {
-            assert(pkg.files.size() == 0);
+            assert(pkg.files.isEmpty());
         }
 
         if (haveSpecial) {
@@ -697,8 +689,7 @@
         boolean haveModtime = testBit(options, AO_HAVE_FILE_MODTIME);
         boolean haveOptions = testBit(options, AO_HAVE_FILE_OPTIONS);
         if (!haveOptions) {
-            for (Iterator i = pkg.files.iterator(); i.hasNext(); ) {
-                File file = (File) i.next();
+            for (File file : pkg.files) {
                 if (file.isClassStub()) {
                     haveOptions = true;
                     options |= AO_HAVE_FILE_OPTIONS;
@@ -711,9 +702,7 @@
             options |= AO_HAVE_FILE_HEADERS;
             archiveOptions = options;
         }
-
-        for (Iterator i = pkg.files.iterator(); i.hasNext(); ) {
-            File file = (File) i.next();
+        for (File file : pkg.files) {
             file_name.putRef(file.name);
             long len = file.getFileLength();
             file_size_lo.putInt((int)len);
@@ -731,22 +720,20 @@
             Utils.log.info("Wrote "+numFiles+" resource files");
     }
 
+    @SuppressWarnings("unchecked")
     void collectAttributeLayouts() {
         maxFlags = new int[ATTR_CONTEXT_LIMIT];
-        allLayouts = new HashMap[ATTR_CONTEXT_LIMIT];
+        allLayouts = new FixedList<>(ATTR_CONTEXT_LIMIT);
         for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
-            allLayouts[i] = new HashMap();
+            allLayouts.set(i, new HashMap<Attribute.Layout, int[]>());
         }
         // Collect maxFlags and allLayouts.
-        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
-            Class cls = (Class) i.next();
+        for (Class cls : pkg.classes) {
             visitAttributeLayoutsIn(ATTR_CONTEXT_CLASS, cls);
-            for (Iterator j = cls.getFields().iterator(); j.hasNext(); ) {
-                Class.Field f = (Class.Field) j.next();
+            for (Class.Field f : cls.getFields()) {
                 visitAttributeLayoutsIn(ATTR_CONTEXT_FIELD, f);
             }
-            for (Iterator j = cls.getMethods().iterator(); j.hasNext(); ) {
-                Class.Method m = (Class.Method) j.next();
+            for (Class.Method m : cls.getMethods()) {
                 visitAttributeLayoutsIn(ATTR_CONTEXT_METHOD, m);
                 if (m.code != null) {
                     visitAttributeLayoutsIn(ATTR_CONTEXT_CODE, m.code);
@@ -755,7 +742,7 @@
         }
         // If there are many species of attributes, use 63-bit flags.
         for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
-            int nl = allLayouts[i].size();
+            int nl = allLayouts.get(i).size();
             boolean haveLongFlags = haveFlagsHi(i);
             final int TOO_MANY_ATTRS = 32 /*int flag size*/
                 - 12 /*typical flag bits in use*/
@@ -781,7 +768,7 @@
         }
         // Collect counts for both predefs. and custom defs.
         // Decide on custom, local attribute definitions.
-        backCountTable = new HashMap();
+        backCountTable = new HashMap<>();
         attrCounts = new int[ATTR_CONTEXT_LIMIT][];
         for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
             // Now the remaining defs in allLayouts[i] need attr. indexes.
@@ -793,11 +780,12 @@
             assert(attrIndexLimit[i] < 64);  // all bits fit into a Java long
             avHiBits &= (1L<<attrIndexLimit[i])-1;
             int nextLoBit = 0;
-            Map.Entry[] layoutsAndCounts = new Map.Entry[allLayouts[i].size()];
-            allLayouts[i].entrySet().toArray(layoutsAndCounts);
+            Map<Attribute.Layout, int[]> defMap = allLayouts.get(i);
+            Map.Entry[] layoutsAndCounts = new Map.Entry[defMap.size()];
+            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<>() {
                 public int compare(Object o0, Object o1) {
                     Map.Entry e0 = (Map.Entry) o0;
                     Map.Entry e1 = (Map.Entry) o1;
@@ -814,7 +802,7 @@
                 Attribute.Layout def = (Attribute.Layout) e.getKey();
                 int count = ((int[])e.getValue())[0];
                 int index;
-                Integer predefIndex = (Integer) attrIndexTable.get(def);
+                Integer predefIndex = attrIndexTable.get(def);
                 if (predefIndex != null) {
                     // The index is already set.
                     index = predefIndex.intValue();
@@ -872,29 +860,32 @@
 
     // Scratch variables for processing attributes and flags.
     int[] maxFlags;
-    HashMap[] allLayouts;
+    List<Map<Attribute.Layout, int[]>> allLayouts;
 
     void visitAttributeLayoutsIn(int ctype, Attribute.Holder h) {
         // Make note of which flags appear in the class file.
         // Set them in maxFlags.
         maxFlags[ctype] |= h.flags;
-        for (Iterator i = h.getAttributes().iterator(); i.hasNext(); ) {
-            Attribute a = (Attribute) i.next();
+        for (Attribute a : h.getAttributes()) {
             Attribute.Layout def = a.layout();
-            int[] count = (int[]) allLayouts[ctype].get(def);
-            if (count == null)
-                allLayouts[ctype].put(def, count = new int[1]);
-            if (count[0] < Integer.MAX_VALUE)
+            Map<Attribute.Layout, int[]> defMap = allLayouts.get(ctype);
+            int[] count = defMap.get(def);
+            if (count == null) {
+                defMap.put(def, count = new int[1]);
+            }
+            if (count[0] < Integer.MAX_VALUE) {
                 count[0] += 1;
+            }
         }
     }
 
     Attribute.Layout[] attrDefsWritten;
 
+    @SuppressWarnings("unchecked")
     void writeAttrDefs() throws IOException {
-        ArrayList defList = new ArrayList();
+        List<Object[]> defList = new ArrayList<>();
         for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
-            int limit = attrDefs[i].size();
+            int limit = attrDefs.get(i).size();
             for (int j = 0; j < limit; j++) {
                 int header = i;  // ctype
                 if (j < attrIndexLimit[i]) {
@@ -906,9 +897,9 @@
                         continue;
                     }
                 }
-                Attribute.Layout def = (Attribute.Layout) attrDefs[i].get(j);
-                defList.add(new Object[]{ new Integer(header), def });
-                assert(new Integer(j).equals(attrIndexTable.get(def)));
+                Attribute.Layout def = attrDefs.get(i).get(j);
+                defList.add(new Object[]{ Integer.valueOf(header), def });
+                assert(Integer.valueOf(j).equals(attrIndexTable.get(def)));
             }
         }
         // Sort the new attr defs into some "natural" order.
@@ -934,10 +925,7 @@
         attrDefsWritten = new Attribute.Layout[numAttrDefs];
         PrintStream dump = !optDumpBands ? null
             : new PrintStream(getDumpStream(attr_definition_headers, ".def"));
-        int[] indexForDebug = new int[ATTR_CONTEXT_LIMIT];
-        for (int i = 0; i < ATTR_CONTEXT_LIMIT; i++) {
-            indexForDebug[i] = attrIndexLimit[i];
-        }
+        int[] indexForDebug = Arrays.copyOf(attrIndexLimit, ATTR_CONTEXT_LIMIT);
         for (int i = 0; i < defs.length; i++) {
             int header = ((Integer)defs[i][0]).intValue();
             Attribute.Layout def = (Attribute.Layout) defs[i][1];
@@ -953,7 +941,7 @@
             if (debug) {
                 int hdrIndex = (header >> ADH_BIT_SHIFT) - ADH_BIT_IS_LSB;
                 if (hdrIndex < 0)  hdrIndex = indexForDebug[def.ctype()]++;
-                int realIndex = ((Integer) attrIndexTable.get(def)).intValue();
+                int realIndex = (attrIndexTable.get(def)).intValue();
                 assert(hdrIndex == realIndex);
             }
             if (dump != null) {
@@ -969,8 +957,8 @@
         for (int ctype = 0; ctype < ATTR_CONTEXT_LIMIT; ctype++) {
             MultiBand xxx_attr_bands = attrBands[ctype];
             IntBand xxx_attr_calls = getAttrBand(xxx_attr_bands, AB_ATTR_CALLS);
-            Attribute.Layout[] defs = new Attribute.Layout[attrDefs[ctype].size()];
-            attrDefs[ctype].toArray(defs);
+            Attribute.Layout[] defs = new Attribute.Layout[attrDefs.get(ctype).size()];
+            attrDefs.get(ctype).toArray(defs);
             for (boolean predef = true; ; predef = false) {
                 for (int ai = 0; ai < defs.length; ai++) {
                     Attribute.Layout def = defs[ai];
@@ -980,7 +968,7 @@
                     int totalCount = attrCounts[ctype][ai];
                     if (totalCount == 0)
                         continue;  // irrelevant
-                    int[] bc = (int[]) backCountTable.get(def);
+                    int[] bc = backCountTable.get(def);
                     for (int j = 0; j < bc.length; j++) {
                         if (bc[j] >= 0) {
                             int backCount = bc[j];
@@ -998,8 +986,7 @@
     }
 
     void trimClassAttributes() {
-        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
-            Class cls = (Class) i.next();
+        for (Class cls : pkg.classes) {
             // Replace "obvious" SourceFile attrs by null.
             cls.minimizeSourceFile();
         }
@@ -1008,14 +995,12 @@
     void collectInnerClasses() {
         // Capture inner classes, removing them from individual classes.
         // Irregular inner classes must stay local, though.
-        HashMap allICMap = new HashMap();
+        Map<ClassEntry, InnerClass> allICMap = new HashMap<>();
         // First, collect a consistent global set.
-        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
-            Class cls = (Class) i.next();
+        for (Class cls : pkg.classes) {
             if (!cls.hasInnerClasses())  continue;
-            for (Iterator j = cls.getInnerClasses().iterator(); j.hasNext(); ) {
-                InnerClass ic = (InnerClass) j.next();
-                InnerClass pic = (InnerClass) allICMap.put(ic.thisClass, ic);
+            for (InnerClass ic : cls.getInnerClasses()) {
+                InnerClass pic = allICMap.put(ic.thisClass, ic);
                 if (pic != null && !pic.equals(ic) && pic.predictable) {
                     // Different ICs.  Choose the better to make global.
                     allICMap.put(pic.thisClass, pic);
@@ -1036,15 +1021,13 @@
         // Next, empty out of every local set the consistent entries.
         // Calculate whether there is any remaining need to have a local
         // set, and whether it needs to be locked.
-        for (Iterator i = pkg.classes.iterator(); i.hasNext(); ) {
-            Class cls = (Class) i.next();
+        for (Class cls : pkg.classes) {
             cls.minimizeLocalICs();
         }
     }
 
     void writeInnerClasses() throws IOException {
-        for (Iterator i = pkg.getAllInnerClasses().iterator(); i.hasNext(); ) {
-            InnerClass ic = (InnerClass) i.next();
+        for (InnerClass ic : pkg.getAllInnerClasses()) {
             int flags = ic.flags;
             assert((flags & ACC_IC_LONG_FORM) == 0);
             if (!ic.predictable) {
@@ -1064,10 +1047,9 @@
      *  local attribute.  This is expected to be rare.
      */
     void writeLocalInnerClasses(Class cls) throws IOException {
-        List localICs = cls.getInnerClasses();
+        List<InnerClass> localICs = cls.getInnerClasses();
         class_InnerClasses_N.putInt(localICs.size());
-        for (Iterator i = localICs.iterator(); i.hasNext(); ) {
-            InnerClass ic = (InnerClass) i.next();
+        for(InnerClass ic : localICs) {
             class_InnerClasses_RC.putRef(ic.thisClass);
             // Is it redundant with the global version?
             if (ic.equals(pkg.getGlobalInnerClass(ic.thisClass))) {
@@ -1121,18 +1103,16 @@
     }
 
     void writeMembers(Class cls) throws IOException {
-        List fields = cls.getFields();
+        List<Class.Field> fields = cls.getFields();
         class_field_count.putInt(fields.size());
-        for (Iterator i = fields.iterator(); i.hasNext(); ) {
-            Class.Field f = (Class.Field) i.next();
+        for (Class.Field f : fields) {
             field_descr.putRef(f.getDescriptor());
             writeAttrs(ATTR_CONTEXT_FIELD, f, cls);
         }
 
-        List methods = cls.getMethods();
+        List<Class.Method> methods = cls.getMethods();
         class_method_count.putInt(methods.size());
-        for (Iterator i = methods.iterator(); i.hasNext(); ) {
-            Class.Method m = (Class.Method) i.next();
+        for (Class.Method m : methods) {
             method_descr.putRef(m.getDescriptor());
             writeAttrs(ATTR_CONTEXT_METHOD, m, cls);
             assert((m.code != null) == (m.getAttribute(attrCodeEmpty) != null));
@@ -1206,11 +1186,10 @@
         long flagMask = attrFlagMask[ctype];  // which flags are attr bits?
         long flagsToAdd = 0;
         int overflowCount = 0;
-        for (ListIterator j = h.attributes.listIterator(); j.hasNext(); ) {
-            Attribute a = (Attribute) j.next();
+        for (Attribute a : h.attributes) {
             Attribute.Layout def = a.layout();
-            int index = ((Integer)attrIndexTable.get(def)).intValue();
-            assert(attrDefs[ctype].get(index) == def);
+            int index = (attrIndexTable.get(def)).intValue();
+            assert(attrDefs.get(ctype).get(index) == def);
             if (verbose > 3)
                 Utils.log.fine("add attr @"+index+" "+a+" in "+h);
             if (index < attrIndexLimit[ctype] && testBit(flagMask, 1L<<index)) {
@@ -1239,10 +1218,10 @@
                 continue;
             }
             assert(a.fixups == null);
-            final Band[] ab = (Band[]) attrBandTable.get(def);
+            final Band[] ab = attrBandTable.get(def);
             assert(ab != null);
             assert(ab.length == def.bandCount);
-            final int[] bc = (int[]) backCountTable.get(def);
+            final int[] bc = backCountTable.get(def);
             assert(bc != null);
             assert(bc.length == def.getCallables().length);
             // Write one attribute of type def into ab.
@@ -1306,7 +1285,7 @@
     private int initOpVariant(Instruction i, Entry newClass) {
         if (i.getBC() != _invokespecial)  return -1;
         MemberEntry ref = (MemberEntry) i.getCPRef(curCPMap);
-        if (ref.descRef.nameRef.stringValue() != "<init>")
+        if ("<init>".equals(ref.descRef.nameRef.stringValue()) == false)
             return -1;
         ClassEntry refClass = ref.classRef;
         if (refClass == curClass.thisClass)
@@ -1618,14 +1597,16 @@
             String count = "" + codeHist[bc];
             count = "         ".substring(count.length()) + count;
             String pct = "" + (codeHist[bc] * 10000 / totalBytes);
-            while (pct.length() < 4)  pct = "0" + pct;
+            while (pct.length() < 4) {
+                pct = "0" + pct;
+            }
             pct = pct.substring(0, pct.length()-2) + "." + pct.substring(pct.length()-2);
             hist[bc] = count + "  " + pct + "%  " + iname;
         }
         Arrays.sort(hist);
         System.out.println("Bytecode histogram ["+totalBytes+"]");
         for (int i = hist.length; --i >= 0; ) {
-            if (hist[i] == "")  continue;
+            if ("".equals(hist[i]))  continue;
             System.out.println(hist[i]);
         }
         for (int tag = 0; tag < ldcHist.length; tag++) {
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java	Wed Jan 19 21:51:10 2011 -0800
@@ -69,7 +69,8 @@
      * Get the set of options for the pack and unpack engines.
      * @return A sorted association of option key strings to option values.
      */
-    public SortedMap<String, String> properties() {
+    @SuppressWarnings("unchecked")
+    public SortedMap properties() {
         return props;
     }
 
@@ -155,8 +156,8 @@
 
 
     // All the worker bees.....
-
     // The packer worker.
+    @SuppressWarnings("unchecked")
     private class DoPack {
         final int verbose = props.getInteger(Utils.DEBUG_VERBOSE);
 
@@ -179,11 +180,11 @@
             unknownAttrCommand = uaMode.intern();
         }
 
-        final HashMap attrDefs;
-        final HashMap attrCommands;
+        final Map<Attribute.Layout, Attribute> attrDefs;
+        final Map<Attribute.Layout, String> attrCommands;
         {
-            HashMap attrDefs     = new HashMap();
-            HashMap attrCommands = new HashMap();
+            Map<Attribute.Layout, Attribute> lattrDefs   = new HashMap<>();
+            Map<Attribute.Layout, String>  lattrCommands = new HashMap<>();
             String[] keys = {
                 Pack200.Packer.CLASS_ATTRIBUTE_PFX,
                 Pack200.Packer.FIELD_ATTRIBUTE_PFX,
@@ -198,8 +199,9 @@
             };
             for (int i = 0; i < ctypes.length; i++) {
                 String pfx = keys[i];
-                Map<String, String> map = props.prefixMap(pfx);
-                for (String key : map.keySet()) {
+                Map<Object, Object> map = props.prefixMap(pfx);
+                for (Object k : map.keySet()) {
+                    String key = (String)k;
                     assert(key.startsWith(pfx));
                     String name = key.substring(pfx.length());
                     String layout = props.getProperty(key);
@@ -207,24 +209,18 @@
                     if (Pack200.Packer.STRIP.equals(layout) ||
                         Pack200.Packer.PASS.equals(layout) ||
                         Pack200.Packer.ERROR.equals(layout)) {
-                        attrCommands.put(lkey, layout.intern());
+                        lattrCommands.put(lkey, layout.intern());
                     } else {
-                        Attribute.define(attrDefs, ctypes[i], name, layout);
+                        Attribute.define(lattrDefs, ctypes[i], name, layout);
                         if (verbose > 1) {
                             Utils.log.fine("Added layout for "+Constants.ATTR_CONTEXT_NAME[i]+" attribute "+name+" = "+layout);
                         }
-                        assert(attrDefs.containsKey(lkey));
+                        assert(lattrDefs.containsKey(lkey));
                     }
                 }
             }
-            if (attrDefs.size() > 0)
-                this.attrDefs = attrDefs;
-            else
-                this.attrDefs = null;
-            if (attrCommands.size() > 0)
-                this.attrCommands = attrCommands;
-            else
-                this.attrCommands = null;
+            this.attrDefs = (lattrDefs.isEmpty()) ? null : lattrDefs;
+            this.attrCommands = (lattrCommands.isEmpty()) ? null : lattrCommands;
         }
 
         final boolean keepFileOrder
@@ -275,8 +271,8 @@
         {
             // Which class files will be passed through?
             passFiles = props.getProperties(Pack200.Packer.PASS_FILE_PFX);
-            for (ListIterator i = passFiles.listIterator(); i.hasNext(); ) {
-                String file = (String) i.next();
+            for (ListIterator<String> i = passFiles.listIterator(); i.hasNext(); ) {
+                String file = i.next();
                 if (file == null) { i.remove(); continue; }
                 file = Utils.getJarEntryName(file);  // normalize '\\' to '/'
                 if (file.endsWith("/"))
@@ -333,7 +329,7 @@
             pkg.reset();
         }
 
-        class InFile {
+        final class InFile {
             final String name;
             final JarFile jf;
             final JarEntry je;
@@ -596,8 +592,8 @@
                 // Package builder must have created a stub for each class.
                 assert(pkg.files.containsAll(pkg.getClassStubs()));
                 // Order of stubs in file list must agree with classes.
-                List res = pkg.files;
-                assert((res = new ArrayList(pkg.files))
+                List<Package.File> res = pkg.files;
+                assert((res = new ArrayList<>(pkg.files))
                        .retainAll(pkg.getClassStubs()) || true);
                 assert(res.equals(pkg.getClassStubs()));
             }
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java	Wed Jan 19 21:51:10 2011 -0800
@@ -31,6 +31,8 @@
 import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.Set;
+import static com.sun.java.util.jar.pack.Constants.*;
 
 /**
  * Population-based coding.
@@ -38,7 +40,7 @@
  * @author John Rose
  */
 // This tactic alone reduces the final zipped rt.jar by about a percent.
-class PopulationCoding implements Constants, CodingMethod {
+class PopulationCoding implements CodingMethod {
     Histogram vHist;   // histogram of all values
     int[]     fValues; // list of favored values
     int       fVlen;   // inclusive max index
@@ -62,8 +64,8 @@
         }
     }
     public void setFavoredValues(int[] fValues) {
-        int fVlen = fValues.length-1;
-        setFavoredValues(fValues, fVlen);
+        int lfVlen = fValues.length-1;
+        setFavoredValues(fValues, lfVlen);
     }
     public void setHistogram(Histogram vHist) {
         this.vHist = vHist;
@@ -103,7 +105,7 @@
         if (tokenCoding instanceof Coding && fValues != null) {
             Coding tc = (Coding) tokenCoding;
             if (tc == fitTokenCoding(fVlen, tc.L()))
-                this.L = tc.L();;
+                this.L = tc.L();
             // Otherwise, it's a non-default coding.
         }
     }
@@ -217,13 +219,13 @@
     }
 
     private long[] makeSymtab() {
-        long[] symtab = new long[fVlen];
+        long[] lsymtab = new long[fVlen];
         for (int token = 1; token <= fVlen; token++) {
-            symtab[token-1] = ((long)fValues[token] << 32) | token;
+            lsymtab[token-1] = ((long)fValues[token] << 32) | token;
         }
         // Index by value:
-        Arrays.sort(symtab);
-        return symtab;
+        Arrays.sort(lsymtab);
+        return lsymtab;
     }
 
     private Coding getTailCoding(CodingMethod c) {
@@ -302,12 +304,12 @@
     }
 
     int[] readFavoredValuesFrom(InputStream in, int maxForDebug) throws IOException {
-        int[] fValues = new int[1000];  // realloc as needed
+        int[] lfValues = new int[1000];  // realloc as needed
         // The set uniqueValuesForDebug records all favored values.
         // As each new value is added, we assert that the value
         // was not already in the set.
-        HashSet uniqueValuesForDebug = null;
-        assert((uniqueValuesForDebug = new HashSet()) != null);
+        Set<Integer> uniqueValuesForDebug = null;
+        assert((uniqueValuesForDebug = new HashSet<>()) != null);
         int fillp = 1;
         maxForDebug += fillp;
         int min = Integer.MIN_VALUE;  // farthest from the center
@@ -317,13 +319,14 @@
         while (fcm instanceof AdaptiveCoding) {
             AdaptiveCoding ac = (AdaptiveCoding) fcm;
             int len = ac.headLength;
-            while (fillp + len > fValues.length)
-                fValues = BandStructure.realloc(fValues);
+            while (fillp + len > lfValues.length) {
+                lfValues = BandStructure.realloc(lfValues);
+            }
             int newFillp = fillp + len;
-            ac.headCoding.readArrayFrom(in, fValues, fillp, newFillp);
+            ac.headCoding.readArrayFrom(in, lfValues, fillp, newFillp);
             while (fillp < newFillp) {
-                int val = fValues[fillp++];
-                assert(uniqueValuesForDebug.add(new Integer(val)));
+                int val = lfValues[fillp++];
+                assert(uniqueValuesForDebug.add(val));
                 assert(fillp <= maxForDebug);
                 last = val;
                 min = moreCentral(min, val);
@@ -344,10 +347,10 @@
                 state = val;
                 if (fillp > 1 && (val == last || val == min)) //|| val == min2
                     break;
-                if (fillp == fValues.length)
-                    fValues = BandStructure.realloc(fValues);
-                fValues[fillp++] = val;
-                assert(uniqueValuesForDebug.add(new Integer(val)));
+                if (fillp == lfValues.length)
+                    lfValues = BandStructure.realloc(lfValues);
+                lfValues[fillp++] = val;
+                assert(uniqueValuesForDebug.add(val));
                 assert(fillp <= maxForDebug);
                 last = val;
                 min = moreCentral(min, val);
@@ -358,17 +361,17 @@
                 int val = fc.readFrom(in);
                 if (fillp > 1 && (val == last || val == min)) //|| val == min2
                     break;
-                if (fillp == fValues.length)
-                    fValues = BandStructure.realloc(fValues);
-                fValues[fillp++] = val;
-                assert(uniqueValuesForDebug.add(new Integer(val)));
+                if (fillp == lfValues.length)
+                    lfValues = BandStructure.realloc(lfValues);
+                lfValues[fillp++] = val;
+                assert(uniqueValuesForDebug.add(val));
                 assert(fillp <= maxForDebug);
                 last = val;
                 min = moreCentral(min, val);
                 //min2 = moreCentral2(min2, val, min);
             }
         }
-        return BandStructure.realloc(fValues, fillp);
+        return BandStructure.realloc(lfValues, fillp);
     }
 
     private static int moreCentral(int x, int y) {
@@ -478,7 +481,7 @@
         boolean verbose
             = (p200 != null &&
                p200.getBoolean(Utils.COM_PREFIX+"verbose.pop"));
-        StringBuffer res = new StringBuffer(100);
+        StringBuilder res = new StringBuilder(100);
         res.append("pop(").append("fVlen=").append(fVlen);
         if (verbose && fValues != null) {
             res.append(" fV=[");
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003,2010 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -34,8 +34,8 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -46,36 +46,36 @@
 /**
  * Control block for publishing Pack200 options to the other classes.
  */
-class PropMap extends TreeMap {
-    ArrayList _listeners = new ArrayList(1);
+
+final class PropMap implements SortedMap<Object, Object>  {
+    private final TreeMap<Object, Object> theMap = new TreeMap<>();;
+    private final List<PropertyChangeListener> listenerList = new ArrayList<>(1);
 
     void addListener(PropertyChangeListener listener) {
-        _listeners.add(listener);
+        listenerList.add(listener);
     }
 
     void removeListener(PropertyChangeListener listener) {
-        _listeners.remove(listener);
+        listenerList.remove(listener);
     }
 
-    void addListeners(ArrayList listeners) {
-        _listeners.addAll(listeners);
+    void addListeners(ArrayList<PropertyChangeListener> listeners) {
+        listenerList.addAll(listeners);
     }
 
-    void removeListeners(ArrayList listeners) {
-        _listeners.removeAll(listeners);
+    void removeListeners(ArrayList<PropertyChangeListener> listeners) {
+        listenerList.removeAll(listeners);
     }
 
     // Override:
     public Object put(Object key, Object value) {
-        Object oldValue = super.put(key, value);
-        if (value != oldValue && _listeners.size() > 0) {
+        Object oldValue = theMap.put(key, value);
+        if (value != oldValue && !listenerList.isEmpty()) {
             // Post the property change event.
             PropertyChangeEvent event =
                 new PropertyChangeEvent(this, (String) key,
                                         oldValue, value);
-            for (Iterator i = _listeners.iterator(); i.hasNext(); ) {
-                PropertyChangeListener listener =
-                    (PropertyChangeListener) i.next();
+            for (PropertyChangeListener listener : listenerList) {
                 listener.propertyChange(event);
             }
         }
@@ -85,7 +85,7 @@
     // All this other stuff is private to the current package.
     // Outide clients of Pack200 do not need to use it; they can
     // get by with generic SortedMap functionality.
-    private static Map defaultProps;
+    private static Map<Object, Object> defaultProps;
     static {
         Properties props = new Properties();
 
@@ -122,13 +122,12 @@
         // Define certain attribute layouts by default.
         // Do this after the previous props are put in place,
         // to allow override if necessary.
+        InputStream propStr = null;
         try {
             String propFile = "intrinsic.properties";
-            InputStream propStr = PackerImpl.class.getResourceAsStream(propFile);
+            propStr = PackerImpl.class.getResourceAsStream(propFile);
             props.load(new BufferedInputStream(propStr));
-            propStr.close();
-            for (Iterator i = props.entrySet().iterator(); i.hasNext(); ) {
-                Map.Entry e = (Map.Entry) i.next();
+            for (Map.Entry<Object, Object> e : props.entrySet()) {
                 String key = (String) e.getKey();
                 String val = (String) e.getValue();
                 if (key.startsWith("attribute.")) {
@@ -137,19 +136,25 @@
             }
         } catch (IOException ee) {
             throw new RuntimeException(ee);
+        } finally {
+            try {
+                if (propStr != null) {
+                    propStr.close();
+                }
+            } catch (IOException ignore) {}
         }
 
-        defaultProps = (new HashMap(props));  // shrink to fit
+        defaultProps = (new HashMap<>(props));  // shrink to fit
     }
 
     PropMap() {
-        putAll(defaultProps);
+        theMap.putAll(defaultProps);
     }
 
     // Return a view of this map which includes only properties
     // that begin with the given prefix.  This is easy because
     // the map is sorted, and has a subMap accessor.
-    SortedMap prefixMap(String prefix) {
+    SortedMap<Object, Object> prefixMap(String prefix) {
         int len = prefix.length();
         if (len == 0)
             return this;
@@ -174,8 +179,8 @@
 
     // Get sequence of props for "prefix", and "prefix.*".
     List getProperties(String prefix) {
-        Collection values = prefixMap(prefix).values();
-        ArrayList res = new ArrayList(values.size());
+        Collection<Object> values = prefixMap(prefix).values();
+        List<Object> res = new ArrayList<>(values.size());
         res.addAll(values);
         while (res.remove(null));
         return res;
@@ -240,11 +245,97 @@
     void list(PrintWriter out) {
         out.println("#"+Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT+"[");
         Set defaults = defaultProps.entrySet();
-        for (Iterator i = entrySet().iterator(); i.hasNext(); ) {
-            Map.Entry e = (Map.Entry) i.next();
+        for (Map.Entry e : theMap.entrySet()) {
             if (defaults.contains(e))  continue;
             out.println("  " + e.getKey() + " = " + e.getValue());
         }
         out.println("#]");
     }
+
+    @Override
+    public int size() {
+        return theMap.size();
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return theMap.isEmpty();
+    }
+
+    @Override
+    public boolean containsKey(Object key) {
+        return theMap.containsKey(key);
+    }
+
+    @Override
+    public boolean containsValue(Object value) {
+        return theMap.containsValue(value);
+    }
+
+    @Override
+    public Object get(Object key) {
+        return theMap.get(key);
+    }
+
+    @Override
+    public Object remove(Object key) {
+       return theMap.remove(key);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public void putAll(Map m) {
+       theMap.putAll(m);
+    }
+
+    @Override
+    public void clear() {
+        theMap.clear();
+    }
+
+    @Override
+    public Set<Object> keySet() {
+       return theMap.keySet();
+    }
+
+    @Override
+    public Collection<Object> values() {
+       return theMap.values();
+    }
+
+    @Override
+    public Set<Map.Entry<Object, Object>> entrySet() {
+        return theMap.entrySet();
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public Comparator<Object> comparator() {
+        return (Comparator<Object>) theMap.comparator();
+    }
+
+    @Override
+    public SortedMap<Object, Object> subMap(Object fromKey, Object toKey) {
+        return theMap.subMap(fromKey, toKey);
+    }
+
+    @Override
+    public SortedMap<Object, Object> headMap(Object toKey) {
+        return theMap.headMap(toKey);
+    }
+
+    @Override
+    public SortedMap<Object, Object> tailMap(Object fromKey) {
+        return theMap.tailMap(fromKey);
+    }
+
+    @Override
+    public Object firstKey() {
+        return theMap.firstKey();
+    }
+
+    @Override
+    public Object lastKey() {
+       return theMap.lastKey();
+    }
 }
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java	Wed Jan 19 21:51:10 2011 -0800
@@ -34,7 +34,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.HashSet;
-import java.util.Iterator;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.TimeZone;
 import java.util.jar.JarEntry;
@@ -81,7 +81,8 @@
      * Get the set of options for the pack and unpack engines.
      * @return A sorted association of option key strings to option values.
      */
-    public SortedMap<String, String> properties() {
+    @SuppressWarnings("unchecked")
+    public SortedMap properties() {
         return props;
     }
 
@@ -225,9 +226,8 @@
             props.setProperty(java.util.jar.Pack200.Unpacker.PROGRESS,"50");
             pkg.ensureAllClassFiles();
             // Now write out the files.
-            HashSet<Package.Class> classesToWrite = new HashSet<>(pkg.getClasses());
-            for (Iterator i = pkg.getFiles().iterator(); i.hasNext(); ) {
-                Package.File file = (Package.File) i.next();
+            Set<Package.Class> classesToWrite = new HashSet<>(pkg.getClasses());
+            for (Package.File file : pkg.getFiles()) {
                 String name = file.nameString;
                 JarEntry je = new JarEntry(Utils.getJarEntryName(name));
                 boolean deflate;
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java	Wed Jan 19 21:51:10 2011 -0800
@@ -297,7 +297,7 @@
             (int)( (1.0 - ((double)ze.getCompressedSize()/(double)ze.getSize()))*100 )
             : 0 ;
         // Follow unzip -lv output
-        return (long)ze.getSize() + "\t" + ze.getMethod()
+        return ze.getSize() + "\t" + ze.getMethod()
             + "\t" + ze.getCompressedSize() + "\t"
             + store + "%\t"
             + new Date(ze.getTime()) + "\t"
--- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1393,8 +1393,11 @@
         public void run() {
             if (Printer.trace) Printer.trace(">>> DirectClip: run() threadID="+Thread.currentThread().getId());
             while (thread != null) {
-                if (!doIO) {
-                    synchronized(lock) {
+                // doIO is volatile, but we could check it, then get
+                // pre-empted while another thread changes doIO and notifies,
+                // before we wait (so we sleep in wait forever).
+                synchronized(lock) {
+                    if (!doIO) {
                         try {
                             lock.wait();
                         } catch(InterruptedException ie) {}
--- a/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngine.java	Wed Jan 19 21:51:10 2011 -0800
@@ -61,26 +61,43 @@
     private ScriptEngineFactory factory;
     private InterfaceImplementor implementor;
 
+    private static final int languageVersion = getLanguageVersion();
+    private static final int optimizationLevel = getOptimizationLevel();
     static {
         ContextFactory.initGlobal(new ContextFactory() {
             protected Context makeContext() {
                 Context cx = super.makeContext();
+                cx.setLanguageVersion(languageVersion);
+                cx.setOptimizationLevel(optimizationLevel);
                 cx.setClassShutter(RhinoClassShutter.getInstance());
                 cx.setWrapFactory(RhinoWrapFactory.getInstance());
                 return cx;
             }
-
-            public boolean hasFeature(Context cx, int feature) {
-                // we do not support E4X (ECMAScript for XML)!
-                if (feature == Context.FEATURE_E4X) {
-                    return false;
-                } else {
-                    return super.hasFeature(cx, feature);
-                }
-            }
         });
     }
 
+    private static final String RHINO_JS_VERSION = "rhino.js.version";
+    private static int getLanguageVersion() {
+        int version;
+        String tmp = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction(RHINO_JS_VERSION));
+        if (tmp != null) {
+            version = Integer.parseInt((String)tmp);
+        } else {
+            version = Context.VERSION_1_8;
+        }
+        return version;
+    }
+
+    private static final String RHINO_OPT_LEVEL = "rhino.opt.level";
+    private static int getOptimizationLevel() {
+        int optLevel = -1;
+        // disable optimizer under security manager, for now.
+        if (System.getSecurityManager() == null) {
+            optLevel = Integer.getInteger(RHINO_OPT_LEVEL, -1);
+        }
+        return optLevel;
+    }
 
     /**
      * Creates a new instance of RhinoScriptEngine
@@ -333,6 +350,7 @@
         return result instanceof Undefined ? null : result;
     }
 
+    /*
     public static void main(String[] args) throws Exception {
         if (args.length == 0) {
             System.out.println("No file specified");
@@ -347,4 +365,5 @@
         engine.eval(r);
         System.out.println(engine.get("x"));
     }
+    */
 }
--- a/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/script/javascript/RhinoScriptEngineFactory.java	Wed Jan 19 21:51:10 2011 -0800
@@ -58,11 +58,11 @@
         } else if (key.equals(ScriptEngine.ENGINE)) {
             return "Mozilla Rhino";
         } else if (key.equals(ScriptEngine.ENGINE_VERSION)) {
-            return "1.6 release 2";
+            return "1.7 release 3 PRERELEASE";
         } else if (key.equals(ScriptEngine.LANGUAGE)) {
             return "ECMAScript";
         } else if (key.equals(ScriptEngine.LANGUAGE_VERSION)) {
-            return "1.6";
+            return "1.8";
         } else if (key.equals("THREADING")) {
             return "MULTITHREADED";
         } else {
@@ -128,10 +128,12 @@
         return ret;
     }
 
+    /*
     public static void main(String[] args) {
         RhinoScriptEngineFactory fact = new RhinoScriptEngineFactory();
         System.out.println(fact.getParameter(ScriptEngine.ENGINE_VERSION));
     }
+    */
 
     private static List<String> names;
     private static List<String> mimeTypes;
--- a/jdk/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/script/javascript/RhinoTopLevel.java	Wed Jan 19 21:51:10 2011 -0800
@@ -37,15 +37,6 @@
  * @since 1.6
  */
 public final class RhinoTopLevel extends ImporterTopLevel {
-
-    // variables defined always to help Java access from JavaScript
-    private static final String builtinVariables =
-                "var com = Packages.com;                   \n" +
-                "var edu = Packages.edu;                   \n" +
-                "var javax = Packages.javax;               \n" +
-                "var net = Packages.net;                   \n" +
-                "var org = Packages.org;                   \n";
-
     RhinoTopLevel(Context cx, RhinoScriptEngine engine) {
         super(cx);
         this.engine = engine;
@@ -67,9 +58,6 @@
         String names[] = { "bindings", "scope", "sync"  };
         defineFunctionProperties(names, RhinoTopLevel.class,
                 ScriptableObject.DONTENUM);
-
-        // define built-in variables
-        cx.evaluateString(this, builtinVariables, "<builtin>", 1, null);
     }
 
     /**
--- a/jdk/src/share/classes/com/sun/tools/script/shell/init.js	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/com/sun/tools/script/shell/init.js	Wed Jan 19 21:51:10 2011 -0800
@@ -311,9 +311,9 @@
 	try {
 		engine.eval(reader);
 	} finally {
-		engine.put(engine.FILENAME, oldFilename);	
+		engine.put(engine.FILENAME, oldFilename);
+	        streamClose(stream);
 	}
-	streamClose(stream);
 }
 
 // file system utilities
--- a/jdk/src/share/classes/java/awt/SplashScreen.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/awt/SplashScreen.java	Wed Jan 19 21:51:10 2011 -0800
@@ -33,27 +33,17 @@
 import sun.awt.image.SunWritableRaster;
 
 /**
- * The splash screen can be created at application startup, before the
+ * The splash screen can be displayed at application startup, before the
  * Java Virtual Machine (JVM) starts. The splash screen is displayed as an
- * undecorated window containing an image. You can use GIF, JPEG, and PNG files
- * for the image. Animation (for GIF) and transparency (for GIF, PNG) are
- * supported. The window is positioned at the center of the screen (the
- * position on multi-monitor systems is not specified - it is platform and
- * implementation dependent).
- * The window is closed automatically as soon as the first window is displayed by
- * Swing/AWT (may be also closed manually using the Java API, see below).
+ * undecorated window containing an image. You can use GIF, JPEG, or PNG files
+ * for the image. Animation is supported for the GIF format, while transparency
+ * is supported both for GIF and PNG.  The window is positioned at the center
+ * of the screen. The position on multi-monitor systems is not specified. It is
+ * platform and implementation dependent.  The splash screen window is closed
+ * automatically as soon as the first window is displayed by Swing/AWT (may be
+ * also closed manually using the Java API, see below).
  * <P>
- * There are two ways to show the native splash screen:
- * <P>
- * <UL>
- * <LI>If your application is run from the command line or from a shortcut,
- * use the "-splash:" Java application  launcher option to show a splash screen.
- * <BR>
- * For example:
- * <PRE>
- * java -splash:filename.gif Test
- * </PRE>
- * <LI>If your application is packaged in a jar file, you can use the
+ * If your application is packaged in a jar file, you can use the
  * "SplashScreen-Image" option in a manifest file to show a splash screen.
  * Place the image in the jar archive and specify the path in the option.
  * The path should not have a leading slash.
@@ -64,18 +54,39 @@
  * Main-Class: Test
  * SplashScreen-Image: filename.gif
  * </PRE>
+ * <P>
+ * If the Java implementation provides the command-line interface and you run
+ * your application by using the command line or a shortcut, use the Java
+ * application launcher option to show a splash screen. The Oracle reference
+ * implementation allows you to specify the splash screen image location with
+ * the {@code -splash:} option.
+ * <BR>
+ * For example:
+ * <PRE>
+ * java -splash:filename.gif Test
+ * </PRE>
  * The command line interface has higher precedence over the manifest
  * setting.
- * </UL>
+ * <p>
+ * The splash screen will be displayed as faithfully as possible to present the
+ * whole splash screen image given the limitations of the target platform and
+ * display.
+ * <p>
+ * It is implied that the specified image is presented on the screen "as is",
+ * i.e. preserving the exact color values as specified in the image file. Under
+ * certain circumstances, though, the presented image may differ, e.g. when
+ * applying color dithering to present a 32 bits per pixel (bpp) image on a 16
+ * or 8 bpp screen. The native platform display configuration may also affect
+ * the colors of the displayed image (e.g.  color profiles, etc.)
  * <p>
  * The {@code SplashScreen} class provides the API for controlling the splash
  * screen. This class may be used to close the splash screen, change the splash
- * screen image, get the image position/size and paint in the splash screen. It
- * cannot be used to create the splash screen; you should use the command line or manifest
- * file option for that.
+ * screen image, get the splash screen native window position/size, and paint
+ * in the splash screen. It cannot be used to create the splash screen. You
+ * should use the options provided by the Java implementation for that.
  * <p>
  * This class cannot be instantiated. Only a single instance of this class
- * can exist, and it may be obtained using the {@link #getSplashScreen()}
+ * can exist, and it may be obtained by using the {@link #getSplashScreen()}
  * static method. In case the splash screen has not been created at
  * application startup via the command line or manifest file option,
  * the <code>getSplashScreen</code> method returns <code>null</code>.
@@ -91,7 +102,7 @@
 
     /**
      * Returns the {@code SplashScreen} object used for
-     * Java startup splash screen control.
+     * Java startup splash screen control on systems that support display.
      *
      * @throws UnsupportedOperationException if the splash screen feature is not
      *         supported by the current toolkit
@@ -219,6 +230,9 @@
      * <p>
      * You cannot control the size or position of the splash screen.
      * The splash screen size is adjusted automatically when the image changes.
+     * <p>
+     * The image may contain transparent areas, and thus the reported bounds may
+     * be larger than the visible splash screen image on the screen.
      *
      * @return a {@code Rectangle} containing the splash screen bounds
      * @throws IllegalStateException if the splash screen has already been closed
@@ -237,6 +251,9 @@
      * <p>
      * You cannot control the size or position of the splash screen.
      * The splash screen size is adjusted automatically when the image changes.
+     * <p>
+     * The image may contain transparent areas, and thus the reported size may
+     * be larger than the visible splash screen image on the screen.
      *
      * @return a {@link Dimension} object indicating the splash screen size
      * @throws IllegalStateException if the splash screen has already been closed
@@ -254,6 +271,10 @@
      * screen window. You should call {@code update()} on the
      * <code>SplashScreen</code> when you want the splash screen to be
      * updated immediately.
+     * <p>
+     * The pixel (0, 0) in the coordinate space of the graphics context
+     * corresponds to the origin of the splash screen native window bounds (see
+     * {@link #getBounds()}).
      *
      * @return graphics context for the splash screen overlay surface
      * @throws IllegalStateException if the splash screen has already been closed
@@ -334,6 +355,11 @@
      * Determines whether the splash screen is visible. The splash screen may
      * be hidden using {@link #close()}, it is also hidden automatically when
      * the first AWT/Swing window is made visible.
+     * <p>
+     * Note that the native platform may delay presenting the splash screen
+     * native window on the screen. The return value of {@code true} for this
+     * method only guarantees that the conditions to hide the splash screen
+     * window have not occurred yet.
      *
      * @return true if the splash screen is visible (has not been closed yet),
      *         false otherwise
--- a/jdk/src/share/classes/java/awt/image/IndexColorModel.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/awt/image/IndexColorModel.java	Wed Jan 19 21:51:10 2011 -0800
@@ -625,7 +625,7 @@
             }
             nBits[0] = nBits[1] = nBits[2] = 8;
         }
-        return nBits;
+        return nBits.clone();
     }
 
     /**
--- a/jdk/src/share/classes/java/awt/image/SampleModel.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/awt/image/SampleModel.java	Wed Jan 19 21:51:10 2011 -0800
@@ -121,7 +121,7 @@
      */
     public SampleModel(int dataType, int w, int h, int numBands)
     {
-        float size = (float)w*h;
+        long size = (long)w * h;
         if (w <= 0 || h <= 0) {
             throw new IllegalArgumentException("Width ("+w+") and height ("+
                                                h+") must be > 0");
--- a/jdk/src/share/classes/java/awt/image/SinglePixelPackedSampleModel.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/awt/image/SinglePixelPackedSampleModel.java	Wed Jan 19 21:51:10 2011 -0800
@@ -92,7 +92,8 @@
      * Constructs a SinglePixelPackedSampleModel with bitMasks.length bands.
      * Each sample is stored in a data array element in the position of
      * its corresponding bit mask.  Each bit mask must be contiguous and
-     * masks must not overlap.
+     * masks must not overlap. Bit masks exceeding data type capacity are
+     * truncated.
      * @param dataType  The data type for storing samples.
      * @param w         The width (in pixels) of the region of the
      *                  image data described.
@@ -120,7 +121,8 @@
      * and a scanline stride equal to scanlineStride data array elements.
      * Each sample is stored in a data array element in the position of
      * its corresponding bit mask.  Each bit mask must be contiguous and
-     * masks must not overlap.
+     * masks must not overlap. Bit masks exceeding data type capacity are
+     * truncated.
      * @param dataType  The data type for storing samples.
      * @param w         The width (in pixels) of the region of
      *                  image data described.
@@ -153,11 +155,13 @@
         this.bitOffsets = new int[numBands];
         this.bitSizes = new int[numBands];
 
+        int maxMask = (int)((1L << DataBuffer.getDataTypeSize(dataType)) - 1);
+
         this.maxBitSize = 0;
         for (int i=0; i<numBands; i++) {
             int bitOffset = 0, bitSize = 0, mask;
-            mask = bitMasks[i];
-
+            this.bitMasks[i] &= maxMask;
+            mask = this.bitMasks[i];
             if (mask != 0) {
                 while ((mask & 1) == 0) {
                     mask = mask >>> 1;
@@ -243,30 +247,12 @@
 
     /** Returns the number of bits per sample for all bands. */
     public int[] getSampleSize() {
-        int mask;
-        int sampleSize[] = new int [numBands];
-        for (int i=0; i<numBands; i++) {
-            sampleSize[i] = 0;
-            mask = bitMasks[i] >>> bitOffsets[i];
-            while ((mask & 1) != 0) {
-                sampleSize[i] ++;
-                mask = mask >>> 1;
-            }
-        }
-
-        return sampleSize;
+        return bitSizes.clone();
     }
 
     /** Returns the number of bits per sample for the specified band. */
     public int getSampleSize(int band) {
-        int sampleSize = 0;
-        int mask = bitMasks[band] >>> bitOffsets[band];
-        while ((mask & 1) != 0) {
-            sampleSize ++;
-            mask = mask >>> 1;
-        }
-
-        return sampleSize;
+        return bitSizes[band];
     }
 
     /** Returns the offset (in data array elements) of pixel (x,y).
--- a/jdk/src/share/classes/java/io/DeleteOnExitHook.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/io/DeleteOnExitHook.java	Wed Jan 19 21:51:10 2011 -0800
@@ -34,7 +34,7 @@
  */
 
 class DeleteOnExitHook {
-    private static LinkedHashSet<String> files = new LinkedHashSet<String>();
+    private static LinkedHashSet<String> files = new LinkedHashSet<>();
     static {
         // DeleteOnExitHook must be the last shutdown hook to be invoked.
         // Application shutdown hooks may add the first file to the
@@ -71,7 +71,7 @@
             files = null;
         }
 
-        ArrayList<String> toBeDeleted = new ArrayList<String>(theFiles);
+        ArrayList<String> toBeDeleted = new ArrayList<>(theFiles);
 
         // reverse the list to maintain previous jdk deletion order.
         // Last in first deleted.
--- a/jdk/src/share/classes/java/io/File.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/io/File.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1067,7 +1067,7 @@
         if ((names == null) || (filter == null)) {
             return names;
         }
-        List<String> v = new ArrayList<String>();
+        List<String> v = new ArrayList<>();
         for (int i = 0 ; i < names.length ; i++) {
             if (filter.accept(this, names[i])) {
                 v.add(names[i]);
@@ -1158,7 +1158,7 @@
     public File[] listFiles(FilenameFilter filter) {
         String ss[] = list();
         if (ss == null) return null;
-        ArrayList<File> files = new ArrayList<File>();
+        ArrayList<File> files = new ArrayList<>();
         for (String s : ss)
             if ((filter == null) || filter.accept(this, s))
                 files.add(new File(s, this));
@@ -1195,7 +1195,7 @@
     public File[] listFiles(FileFilter filter) {
         String ss[] = list();
         if (ss == null) return null;
-        ArrayList<File> files = new ArrayList<File>();
+        ArrayList<File> files = new ArrayList<>();
         for (String s : ss) {
             File f = new File(s, this);
             if ((filter == null) || filter.accept(f))
--- a/jdk/src/share/classes/java/io/FileInputStream.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/io/FileInputStream.java	Wed Jan 19 21:51:10 2011 -0800
@@ -56,7 +56,7 @@
     private volatile boolean closed = false;
 
     private static final ThreadLocal<Boolean> runningFinalize =
-        new ThreadLocal<Boolean>();
+        new ThreadLocal<>();
 
     private static boolean isRunningFinalize() {
         Boolean val;
--- a/jdk/src/share/classes/java/io/FileOutputStream.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/io/FileOutputStream.java	Wed Jan 19 21:51:10 2011 -0800
@@ -69,7 +69,7 @@
     private final Object closeLock = new Object();
     private volatile boolean closed = false;
     private static final ThreadLocal<Boolean> runningFinalize =
-        new ThreadLocal<Boolean>();
+        new ThreadLocal<>();
 
     private static boolean isRunningFinalize() {
         Boolean val;
--- a/jdk/src/share/classes/java/io/FilePermission.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/io/FilePermission.java	Wed Jan 19 21:51:10 2011 -0800
@@ -725,7 +725,7 @@
      */
 
     public FilePermissionCollection() {
-        perms = new ArrayList<Permission>();
+        perms = new ArrayList<>();
     }
 
     /**
@@ -830,7 +830,7 @@
         // Don't call out.defaultWriteObject()
 
         // Write out Vector
-        Vector<Permission> permissions = new Vector<Permission>(perms.size());
+        Vector<Permission> permissions = new Vector<>(perms.size());
         synchronized (this) {
             permissions.addAll(perms);
         }
@@ -853,7 +853,7 @@
 
         // Get the one we want
         Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null);
-        perms = new ArrayList<Permission>(permissions.size());
+        perms = new ArrayList<>(permissions.size());
         perms.addAll(permissions);
     }
 }
--- a/jdk/src/share/classes/java/io/ObjectInputStream.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/io/ObjectInputStream.java	Wed Jan 19 21:51:10 2011 -0800
@@ -213,7 +213,7 @@
 
     /** table mapping primitive type names to corresponding class objects */
     private static final HashMap<String, Class<?>> primClasses
-        = new HashMap<String, Class<?>>(8, 1.0F);
+        = new HashMap<>(8, 1.0F);
     static {
         primClasses.put("boolean", boolean.class);
         primClasses.put("byte", byte.class);
@@ -229,11 +229,11 @@
     private static class Caches {
         /** cache of subclass security audit results */
         static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits =
-            new ConcurrentHashMap<WeakClassKey,Boolean>();
+            new ConcurrentHashMap<>();
 
         /** queue for WeakReferences to audited subclasses */
         static final ReferenceQueue<Class<?>> subclassAuditsQueue =
-            new ReferenceQueue<Class<?>>();
+            new ReferenceQueue<>();
     }
 
     /** filter stream for handling block data conversion */
--- a/jdk/src/share/classes/java/io/ObjectOutputStream.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/io/ObjectOutputStream.java	Wed Jan 19 21:51:10 2011 -0800
@@ -165,11 +165,11 @@
     private static class Caches {
         /** cache of subclass security audit results */
         static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits =
-            new ConcurrentHashMap<WeakClassKey,Boolean>();
+            new ConcurrentHashMap<>();
 
         /** queue for WeakReferences to audited subclasses */
         static final ReferenceQueue<Class<?>> subclassAuditsQueue =
-            new ReferenceQueue<Class<?>>();
+            new ReferenceQueue<>();
     }
 
     /** filter stream for handling block data conversion */
@@ -2413,7 +2413,7 @@
         private final List<String> stack;
 
         DebugTraceInfoStack() {
-            stack = new ArrayList<String>();
+            stack = new ArrayList<>();
         }
 
         /**
--- a/jdk/src/share/classes/java/io/ObjectStreamClass.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/io/ObjectStreamClass.java	Wed Jan 19 21:51:10 2011 -0800
@@ -84,18 +84,18 @@
     private static class Caches {
         /** cache mapping local classes -> descriptors */
         static final ConcurrentMap<WeakClassKey,Reference<?>> localDescs =
-            new ConcurrentHashMap<WeakClassKey,Reference<?>>();
+            new ConcurrentHashMap<>();
 
         /** cache mapping field group/local desc pairs -> field reflectors */
         static final ConcurrentMap<FieldReflectorKey,Reference<?>> reflectors =
-            new ConcurrentHashMap<FieldReflectorKey,Reference<?>>();
+            new ConcurrentHashMap<>();
 
         /** queue for WeakReferences to local classes */
         private static final ReferenceQueue<Class<?>> localDescsQueue =
-            new ReferenceQueue<Class<?>>();
+            new ReferenceQueue<>();
         /** queue for WeakReferences to field reflectors keys */
         private static final ReferenceQueue<Class<?>> reflectorsQueue =
-            new ReferenceQueue<Class<?>>();
+            new ReferenceQueue<>();
     }
 
     /** class associated with this descriptor (if any) */
@@ -290,7 +290,7 @@
         EntryFuture future = null;
         if (entry == null) {
             EntryFuture newEntry = new EntryFuture();
-            Reference<?> newRef = new SoftReference<EntryFuture>(newEntry);
+            Reference<?> newRef = new SoftReference<>(newEntry);
             do {
                 if (ref != null) {
                     Caches.localDescs.remove(key, ref);
@@ -329,7 +329,7 @@
                 entry = th;
             }
             if (future.set(entry)) {
-                Caches.localDescs.put(key, new SoftReference<Object>(entry));
+                Caches.localDescs.put(key, new SoftReference<>(entry));
             } else {
                 // nested lookup call already set future
                 entry = future.get();
@@ -1130,7 +1130,7 @@
     private ClassDataSlot[] getClassDataLayout0()
         throws InvalidClassException
     {
-        ArrayList<ClassDataSlot> slots = new ArrayList<ClassDataSlot>();
+        ArrayList<ClassDataSlot> slots = new ArrayList<>();
         Class<?> start = cl, end = cl;
 
         // locate closest non-serializable superclass
@@ -1566,7 +1566,7 @@
 
         ObjectStreamField[] boundFields =
             new ObjectStreamField[serialPersistentFields.length];
-        Set<String> fieldNames = new HashSet<String>(serialPersistentFields.length);
+        Set<String> fieldNames = new HashSet<>(serialPersistentFields.length);
 
         for (int i = 0; i < serialPersistentFields.length; i++) {
             ObjectStreamField spf = serialPersistentFields[i];
@@ -1604,7 +1604,7 @@
      */
     private static ObjectStreamField[] getDefaultSerialFields(Class<?> cl) {
         Field[] clFields = cl.getDeclaredFields();
-        ArrayList<ObjectStreamField> list = new ArrayList<ObjectStreamField>();
+        ArrayList<ObjectStreamField> list = new ArrayList<>();
         int mask = Modifier.STATIC | Modifier.TRANSIENT;
 
         for (int i = 0; i < clFields.length; i++) {
@@ -1855,8 +1855,8 @@
             writeKeys = new long[nfields];
             offsets = new int[nfields];
             typeCodes = new char[nfields];
-            ArrayList<Class<?>> typeList = new ArrayList<Class<?>>();
-            Set<Long> usedKeys = new HashSet<Long>();
+            ArrayList<Class<?>> typeList = new ArrayList<>();
+            Set<Long> usedKeys = new HashSet<>();
 
 
             for (int i = 0; i < nfields; i++) {
@@ -2092,7 +2092,7 @@
         EntryFuture future = null;
         if (entry == null) {
             EntryFuture newEntry = new EntryFuture();
-            Reference<?> newRef = new SoftReference<EntryFuture>(newEntry);
+            Reference<?> newRef = new SoftReference<>(newEntry);
             do {
                 if (ref != null) {
                     Caches.reflectors.remove(key, ref);
@@ -2118,7 +2118,7 @@
                 entry = th;
             }
             future.set(entry);
-            Caches.reflectors.put(key, new SoftReference<Object>(entry));
+            Caches.reflectors.put(key, new SoftReference<>(entry));
         }
 
         if (entry instanceof FieldReflector) {
--- a/jdk/src/share/classes/java/lang/ApplicationShutdownHooks.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/ApplicationShutdownHooks.java	Wed Jan 19 21:51:10 2011 -0800
@@ -47,7 +47,7 @@
                     }
                 }
             );
-            hooks = new IdentityHashMap<Thread, Thread>();
+            hooks = new IdentityHashMap<>();
         } catch (IllegalStateException e) {
             // application shutdown hooks cannot be added if
             // shutdown is in progress.
--- a/jdk/src/share/classes/java/lang/Character.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/Character.java	Wed Jan 19 21:51:10 2011 -0800
@@ -648,8 +648,7 @@
      */
     public static final class UnicodeBlock extends Subset {
 
-        private static Map<String, UnicodeBlock> map
-            = new HashMap<String, UnicodeBlock>(256);
+        private static Map<String, UnicodeBlock> map = new HashMap<>(256);
 
         /**
          * Creates a UnicodeBlock with the given identifier name.
@@ -4178,7 +4177,7 @@
 
         private static HashMap<String, Character.UnicodeScript> aliases;
         static {
-            aliases = new HashMap<String, UnicodeScript>(128);
+            aliases = new HashMap<>(128);
             aliases.put("ARAB", ARABIC);
             aliases.put("ARMI", IMPERIAL_ARAMAIC);
             aliases.put("ARMN", ARMENIAN);
--- a/jdk/src/share/classes/java/lang/CharacterName.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/CharacterName.java	Wed Jan 19 21:51:10 2011 -0800
@@ -81,7 +81,7 @@
             } while (cpOff < cpEnd);
             strPool = new byte[total - cpEnd];
             dis.readFully(strPool);
-            refStrPool = new SoftReference<byte[]>(strPool);
+            refStrPool = new SoftReference<>(strPool);
         } catch (Exception x) {
             throw new InternalError(x.getMessage());
         } finally {
--- a/jdk/src/share/classes/java/lang/Class.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/Class.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1306,7 +1306,7 @@
         return java.security.AccessController.doPrivileged(
             new java.security.PrivilegedAction<Class<?>[]>() {
                 public Class[] run() {
-                    List<Class<?>> list = new ArrayList<Class<?>>();
+                    List<Class<?>> list = new ArrayList<>();
                     Class<?> currentClass = Class.this;
                     while (currentClass != null) {
                         Class<?>[] members = currentClass.getDeclaredClasses();
@@ -2306,9 +2306,9 @@
         res = Reflection.filterFields(this, getDeclaredFields0(publicOnly));
         if (useCaches) {
             if (publicOnly) {
-                declaredPublicFields = new SoftReference<Field[]>(res);
+                declaredPublicFields = new SoftReference<>(res);
             } else {
-                declaredFields = new SoftReference<Field[]>(res);
+                declaredFields = new SoftReference<>(res);
             }
         }
         return res;
@@ -2330,9 +2330,9 @@
 
         // No cached value available; compute value recursively.
         // Traverse in correct order for getField().
-        List<Field> fields = new ArrayList<Field>();
+        List<Field> fields = new ArrayList<>();
         if (traversedInterfaces == null) {
-            traversedInterfaces = new HashSet<Class<?>>();
+            traversedInterfaces = new HashSet<>();
         }
 
         // Local fields
@@ -2358,7 +2358,7 @@
         res = new Field[fields.size()];
         fields.toArray(res);
         if (useCaches) {
-            publicFields = new SoftReference<Field[]>(res);
+            publicFields = new SoftReference<>(res);
         }
         return res;
     }
@@ -2403,9 +2403,9 @@
         }
         if (useCaches) {
             if (publicOnly) {
-                publicConstructors = new SoftReference<Constructor<T>[]>(res);
+                publicConstructors = new SoftReference<>(res);
             } else {
-                declaredConstructors = new SoftReference<Constructor<T>[]>(res);
+                declaredConstructors = new SoftReference<>(res);
             }
         }
         return res;
@@ -2440,9 +2440,9 @@
         res = Reflection.filterMethods(this, getDeclaredMethods0(publicOnly));
         if (useCaches) {
             if (publicOnly) {
-                declaredPublicMethods = new SoftReference<Method[]>(res);
+                declaredPublicMethods = new SoftReference<>(res);
             } else {
-                declaredMethods = new SoftReference<Method[]>(res);
+                declaredMethods = new SoftReference<>(res);
             }
         }
         return res;
@@ -2598,7 +2598,7 @@
         methods.compactAndTrim();
         res = methods.getArray();
         if (useCaches) {
-            publicMethods = new SoftReference<Method[]>(res);
+            publicMethods = new SoftReference<>(res);
         }
         return res;
     }
@@ -2977,7 +2977,7 @@
             if (universe == null)
                 throw new IllegalArgumentException(
                     getName() + " is not an enum type");
-            Map<String, T> m = new HashMap<String, T>(2 * universe.length);
+            Map<String, T> m = new HashMap<>(2 * universe.length);
             for (T constant : universe)
                 m.put(((Enum<?>)constant).name(), constant);
             enumConstantDirectory = m;
@@ -3090,7 +3090,7 @@
         if (superClass == null) {
             annotations = declaredAnnotations;
         } else {
-            annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+            annotations = new HashMap<>();
             superClass.initAnnotationsIfNecessary();
             for (Map.Entry<Class<? extends Annotation>, Annotation> e : superClass.annotations.entrySet()) {
                 Class<? extends Annotation> annotationClass = e.getKey();
--- a/jdk/src/share/classes/java/lang/ClassLoader.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java	Wed Jan 19 21:51:10 2011 -0800
@@ -247,7 +247,7 @@
 
     // The classes loaded by this class loader. The only purpose of this table
     // is to keep the classes from being GC'ed until the loader is GC'ed.
-    private final Vector<Class<?>> classes = new Vector<Class<?>>();
+    private final Vector<Class<?>> classes = new Vector<>();
 
     // The "default" domain. Set as the default ProtectionDomain on newly
     // created classes.
@@ -266,8 +266,7 @@
     // The packages defined in this class loader.  Each package name is mapped
     // to its corresponding Package object.
     // @GuardedBy("itself")
-    private final HashMap<String, Package> packages =
-        new HashMap<String, Package>();
+    private final HashMap<String, Package> packages = new HashMap<>();
 
     private static Void checkCreateClassLoader() {
         SecurityManager security = System.getSecurityManager();
@@ -280,16 +279,16 @@
     private ClassLoader(Void unused, ClassLoader parent) {
         this.parent = parent;
         if (ParallelLoaders.isRegistered(this.getClass())) {
-            parallelLockMap = new ConcurrentHashMap<String, Object>();
-            package2certs = new ConcurrentHashMap<String, Certificate[]>();
+            parallelLockMap = new ConcurrentHashMap<>();
+            package2certs = new ConcurrentHashMap<>();
             domains =
                 Collections.synchronizedSet(new HashSet<ProtectionDomain>());
             assertionLock = new Object();
         } else {
             // no finer-grained lock; lock on the classloader instance
             parallelLockMap = null;
-            package2certs = new Hashtable<String, Certificate[]>();
-            domains = new HashSet<ProtectionDomain>();
+            package2certs = new Hashtable<>();
+            domains = new HashSet<>();
             assertionLock = this;
         }
     }
@@ -1182,7 +1181,7 @@
         }
         tmp[1] = findResources(name);
 
-        return new CompoundEnumeration<URL>(tmp);
+        return new CompoundEnumeration<>(tmp);
     }
 
     /**
@@ -1657,7 +1656,7 @@
     protected Package[] getPackages() {
         Map<String, Package> map;
         synchronized (packages) {
-            map = new HashMap<String, Package>(packages);
+            map = new HashMap<>(packages);
         }
         Package[] pkgs;
         if (parent != null) {
@@ -1764,20 +1763,17 @@
     }
 
     // All native library names we've loaded.
-    private static Vector<String> loadedLibraryNames
-        = new Vector<String>();
+    private static Vector<String> loadedLibraryNames = new Vector<>();
 
     // Native libraries belonging to system classes.
     private static Vector<NativeLibrary> systemNativeLibraries
-        = new Vector<NativeLibrary>();
+        = new Vector<>();
 
     // Native libraries associated with the class loader.
-    private Vector<NativeLibrary> nativeLibraries
-        = new Vector<NativeLibrary>();
+    private Vector<NativeLibrary> nativeLibraries = new Vector<>();
 
     // native libraries being loaded/unloaded.
-    private static Stack<NativeLibrary> nativeLibraryContext
-        = new Stack<NativeLibrary>();
+    private static Stack<NativeLibrary> nativeLibraryContext = new Stack<>();
 
     // The paths searched for libraries
     private static String usr_paths[];
@@ -2101,8 +2097,8 @@
          * them to empty maps, effectively ignoring any present settings.
          */
         synchronized (assertionLock) {
-            classAssertionStatus = new HashMap<String, Boolean>();
-            packageAssertionStatus = new HashMap<String, Boolean>();
+            classAssertionStatus = new HashMap<>();
+            packageAssertionStatus = new HashMap<>();
             defaultAssertionStatus = false;
         }
     }
@@ -2164,8 +2160,8 @@
     private void initializeJavaAssertionMaps() {
         // assert Thread.holdsLock(assertionLock);
 
-        classAssertionStatus = new HashMap<String, Boolean>();
-        packageAssertionStatus = new HashMap<String, Boolean>();
+        classAssertionStatus = new HashMap<>();
+        packageAssertionStatus = new HashMap<>();
         AssertionStatusDirectives directives = retrieveDirectives();
 
         for(int i = 0; i < directives.classes.length; i++)
--- a/jdk/src/share/classes/java/lang/Package.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/Package.java	Wed Jan 19 21:51:10 2011 -0800
@@ -588,16 +588,13 @@
     }
 
     // The map of loaded system packages
-    private static Map<String, Package> pkgs
-        = new HashMap<String, Package>(31);
+    private static Map<String, Package> pkgs = new HashMap<>(31);
 
     // Maps each directory or zip file name to its corresponding url
-    private static Map<String, URL> urls
-        = new HashMap<String, URL>(10);
+    private static Map<String, URL> urls = new HashMap<>(10);
 
     // Maps each code source url for a jar file to its manifest
-    private static Map<String, Manifest> mans
-        = new HashMap<String, Manifest>(10);
+    private static Map<String, Manifest> mans = new HashMap<>(10);
 
     private static native String getSystemPackage0(String name);
     private static native String[] getSystemPackages0();
--- a/jdk/src/share/classes/java/lang/ProcessBuilder.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/ProcessBuilder.java	Wed Jan 19 21:51:10 2011 -0800
@@ -214,7 +214,7 @@
      * @param command a string array containing the program and its arguments
      */
     public ProcessBuilder(String... command) {
-        this.command = new ArrayList<String>(command.length);
+        this.command = new ArrayList<>(command.length);
         for (String arg : command)
             this.command.add(arg);
     }
@@ -251,7 +251,7 @@
      * @return this process builder
      */
     public ProcessBuilder command(String... command) {
-        this.command = new ArrayList<String>(command.length);
+        this.command = new ArrayList<>(command.length);
         for (String arg : command)
             this.command.add(arg);
         return this;
--- a/jdk/src/share/classes/java/lang/String.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/String.java	Wed Jan 19 21:51:10 2011 -0800
@@ -2330,7 +2330,7 @@
             int off = 0;
             int next = 0;
             boolean limited = limit > 0;
-            ArrayList<String> list = new ArrayList<String>();
+            ArrayList<String> list = new ArrayList<>();
             while ((next = indexOf(ch, off)) != -1) {
                 if (!limited || list.size() < limit - 1) {
                     list.add(substring(off, next));
--- a/jdk/src/share/classes/java/lang/StringCoding.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/StringCoding.java	Wed Jan 19 21:51:10 2011 -0800
@@ -53,9 +53,9 @@
 
     /** The cached coders for each thread */
     private final static ThreadLocal<SoftReference<StringDecoder>> decoder =
-        new ThreadLocal<SoftReference<StringDecoder>>();
+        new ThreadLocal<>();
     private final static ThreadLocal<SoftReference<StringEncoder>> encoder =
-        new ThreadLocal<SoftReference<StringEncoder>>();
+        new ThreadLocal<>();
 
     private static boolean warnUnsupportedCharset = true;
 
@@ -67,7 +67,7 @@
     }
 
     private static <T> void set(ThreadLocal<SoftReference<T>> tl, T ob) {
-        tl.set(new SoftReference<T>(ob));
+        tl.set(new SoftReference<>(ob));
     }
 
     // Trim the given byte array to the given length
--- a/jdk/src/share/classes/java/lang/Thread.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/Thread.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1642,8 +1642,7 @@
         // Get a snapshot of the list of all threads
         Thread[] threads = getThreads();
         StackTraceElement[][] traces = dumpThreads(threads);
-        Map<Thread, StackTraceElement[]> m
-            = new HashMap<Thread, StackTraceElement[]>(threads.length);
+        Map<Thread, StackTraceElement[]> m = new HashMap<>(threads.length);
         for (int i = 0; i < threads.length; i++) {
             StackTraceElement[] stackTrace = traces[i];
             if (stackTrace != null) {
@@ -1664,11 +1663,11 @@
     private static class Caches {
         /** cache of subclass security audit results */
         static final ConcurrentMap<WeakClassKey,Boolean> subclassAudits =
-            new ConcurrentHashMap<WeakClassKey,Boolean>();
+            new ConcurrentHashMap<>();
 
         /** queue for WeakReferences to audited subclasses */
         static final ReferenceQueue<Class<?>> subclassAuditsQueue =
-            new ReferenceQueue<Class<?>>();
+            new ReferenceQueue<>();
     }
 
     /**
--- a/jdk/src/share/classes/java/lang/Throwable.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/Throwable.java	Wed Jan 19 21:51:10 2011 -0800
@@ -828,7 +828,7 @@
                 // Use the sentinel for a zero-length list
                 suppressed = SUPPRESSED_SENTINEL;
             } else { // Copy Throwables to new list
-                suppressed = new ArrayList<Throwable>(1);
+                suppressed = new ArrayList<>(1);
                 for (Throwable t : suppressedExceptions) {
                     // Enforce constraints on suppressed exceptions in
                     // case of corrupt or malicious stream.
@@ -911,7 +911,7 @@
                 return;
 
             if (suppressedExceptions == SUPPRESSED_SENTINEL)
-                suppressedExceptions = new ArrayList<Throwable>(1);
+                suppressedExceptions = new ArrayList<>(1);
 
             assert suppressedExceptions != SUPPRESSED_SENTINEL;
 
--- a/jdk/src/share/classes/java/lang/management/ManagementFactory.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/management/ManagementFactory.java	Wed Jan 19 21:51:10 2011 -0800
@@ -794,7 +794,7 @@
      */
     public static List<Class<? extends PlatformManagedObject>> getAllPlatformMXBeanInterfaces() {
         List<Class<? extends PlatformManagedObject>> result =
-            new ArrayList<Class<? extends PlatformManagedObject>>();
+            new ArrayList<>();
         for (PlatformComponent component: PlatformComponent.values()) {
             result.add(component.getMXBeanInterface());
         }
--- a/jdk/src/share/classes/java/lang/management/PlatformComponent.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/management/PlatformComponent.java	Wed Jan 19 21:51:10 2011 -0800
@@ -267,7 +267,7 @@
             List<T> getGcMXBeanList(Class<T> gcMXBeanIntf) {
         List<GarbageCollectorMXBean> list =
             ManagementFactoryHelper.getGarbageCollectorMXBeans();
-        List<T> result = new ArrayList<T>(list.size());
+        List<T> result = new ArrayList<>(list.size());
         for (GarbageCollectorMXBean m : list) {
             if (gcMXBeanIntf.isInstance(m)) {
                 result.add(gcMXBeanIntf.cast(m));
@@ -330,7 +330,7 @@
     }
 
     private static Set<String> keyProperties(String... keyNames) {
-        Set<String> set = new HashSet<String>();
+        Set<String> set = new HashSet<>();
         set.add("type");
         for (String s : keyNames) {
             set.add(s);
@@ -364,7 +364,7 @@
         List<T> getMXBeans(MBeanServerConnection mbs, Class<T> mxbeanInterface)
         throws java.io.IOException
     {
-        List<T> result = new ArrayList<T>();
+        List<T> result = new ArrayList<>();
         for (ObjectName on : getObjectNames(mbs)) {
             result.add(ManagementFactory.
                 newPlatformMXBeanProxy(mbs,
--- a/jdk/src/share/classes/java/lang/reflect/Constructor.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/reflect/Constructor.java	Wed Jan 19 21:51:10 2011 -0800
@@ -144,7 +144,7 @@
         // which implicitly requires that new java.lang.reflect
         // objects be fabricated for each reflective call on Class
         // objects.)
-        Constructor<T> res = new Constructor<T>(clazz,
+        Constructor<T> res = new Constructor<>(clazz,
                                                 parameterTypes,
                                                 exceptionTypes, modifiers, slot,
                                                 signature,
--- a/jdk/src/share/classes/java/lang/reflect/Proxy.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/reflect/Proxy.java	Wed Jan 19 21:51:10 2011 -0800
@@ -232,7 +232,7 @@
 
     /** maps a class loader to the proxy class cache for that loader */
     private static Map<ClassLoader, Map<List<String>, Object>> loaderToCache
-        = new WeakHashMap<ClassLoader, Map<List<String>, Object>>();
+        = new WeakHashMap<>();
 
     /** marks that a particular proxy class is currently being generated */
     private static Object pendingGenerationMarker = new Object();
@@ -356,7 +356,7 @@
         String[] interfaceNames = new String[interfaces.length];
 
         // for detecting duplicates
-        Set<Class<?>> interfaceSet = new HashSet<Class<?>>();
+        Set<Class<?>> interfaceSet = new HashSet<>();
 
         for (int i = 0; i < interfaces.length; i++) {
             /*
@@ -413,7 +413,7 @@
         synchronized (loaderToCache) {
             cache = loaderToCache.get(loader);
             if (cache == null) {
-                cache = new HashMap<List<String>, Object>();
+                cache = new HashMap<>();
                 loaderToCache.put(loader, cache);
             }
             /*
--- a/jdk/src/share/classes/java/lang/reflect/ReflectAccess.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/lang/reflect/ReflectAccess.java	Wed Jan 19 21:51:10 2011 -0800
@@ -84,7 +84,7 @@
                                              byte[] annotations,
                                              byte[] parameterAnnotations)
     {
-        return new Constructor<T>(declaringClass,
+        return new Constructor<>(declaringClass,
                                   parameterTypes,
                                   checkedExceptions,
                                   modifiers,
--- a/jdk/src/share/classes/java/sql/DriverManager.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/sql/DriverManager.java	Wed Jan 19 21:51:10 2011 -0800
@@ -364,7 +364,7 @@
      * @return the list of JDBC Drivers loaded by the caller's class loader
      */
     public static java.util.Enumeration<Driver> getDrivers() {
-        java.util.Vector<Driver> result = new java.util.Vector<Driver>();
+        java.util.Vector<Driver> result = new java.util.Vector<>();
         java.util.Vector drivers = null;
 
         if (!initialized) {
--- a/jdk/src/share/classes/java/sql/Statement.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/sql/Statement.java	Wed Jan 19 21:51:10 2011 -0800
@@ -577,7 +577,7 @@
      *
      * @see #addBatch
      * @see DatabaseMetaData#supportsBatchUpdates
-     * @since 1.3
+     * @since 1.2
      */
     int[] executeBatch() throws SQLException;
 
--- a/jdk/src/share/classes/java/util/AbstractList.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/AbstractList.java	Wed Jan 19 21:51:10 2011 -0800
@@ -482,8 +482,8 @@
      */
     public List<E> subList(int fromIndex, int toIndex) {
         return (this instanceof RandomAccess ?
-                new RandomAccessSubList<E>(this, fromIndex, toIndex) :
-                new SubList<E>(this, fromIndex, toIndex));
+                new RandomAccessSubList<>(this, fromIndex, toIndex) :
+                new SubList<>(this, fromIndex, toIndex));
     }
 
     // Comparison and hashing
@@ -747,7 +747,7 @@
     }
 
     public List<E> subList(int fromIndex, int toIndex) {
-        return new SubList<E>(this, fromIndex, toIndex);
+        return new SubList<>(this, fromIndex, toIndex);
     }
 
     private void rangeCheck(int index) {
@@ -776,6 +776,6 @@
     }
 
     public List<E> subList(int fromIndex, int toIndex) {
-        return new RandomAccessSubList<E>(this, fromIndex, toIndex);
+        return new RandomAccessSubList<>(this, fromIndex, toIndex);
     }
 }
--- a/jdk/src/share/classes/java/util/Arrays.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/Arrays.java	Wed Jan 19 21:51:10 2011 -0800
@@ -2824,7 +2824,7 @@
      * @return a list view of the specified array
      */
     public static <T> List<T> asList(T... a) {
-        return new ArrayList<T>(a);
+        return new ArrayList<>(a);
     }
 
     /**
--- a/jdk/src/share/classes/java/util/Collections.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/Collections.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1035,7 +1035,7 @@
      * @return an unmodifiable view of the specified collection.
      */
     public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c) {
-        return new UnmodifiableCollection<T>(c);
+        return new UnmodifiableCollection<>(c);
     }
 
     /**
@@ -1109,7 +1109,7 @@
      * @return an unmodifiable view of the specified set.
      */
     public static <T> Set<T> unmodifiableSet(Set<? extends T> s) {
-        return new UnmodifiableSet<T>(s);
+        return new UnmodifiableSet<>(s);
     }
 
     /**
@@ -1141,7 +1141,7 @@
      * @return an unmodifiable view of the specified sorted set.
      */
     public static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> s) {
-        return new UnmodifiableSortedSet<T>(s);
+        return new UnmodifiableSortedSet<>(s);
     }
 
     /**
@@ -1158,13 +1158,13 @@
         public Comparator<? super E> comparator() {return ss.comparator();}
 
         public SortedSet<E> subSet(E fromElement, E toElement) {
-            return new UnmodifiableSortedSet<E>(ss.subSet(fromElement,toElement));
+            return new UnmodifiableSortedSet<>(ss.subSet(fromElement,toElement));
         }
         public SortedSet<E> headSet(E toElement) {
-            return new UnmodifiableSortedSet<E>(ss.headSet(toElement));
+            return new UnmodifiableSortedSet<>(ss.headSet(toElement));
         }
         public SortedSet<E> tailSet(E fromElement) {
-            return new UnmodifiableSortedSet<E>(ss.tailSet(fromElement));
+            return new UnmodifiableSortedSet<>(ss.tailSet(fromElement));
         }
 
         public E first()                   {return ss.first();}
@@ -1188,8 +1188,8 @@
      */
     public static <T> List<T> unmodifiableList(List<? extends T> list) {
         return (list instanceof RandomAccess ?
-                new UnmodifiableRandomAccessList<T>(list) :
-                new UnmodifiableList<T>(list));
+                new UnmodifiableRandomAccessList<>(list) :
+                new UnmodifiableList<>(list));
     }
 
     /**
@@ -1250,7 +1250,7 @@
         }
 
         public List<E> subList(int fromIndex, int toIndex) {
-            return new UnmodifiableList<E>(list.subList(fromIndex, toIndex));
+            return new UnmodifiableList<>(list.subList(fromIndex, toIndex));
         }
 
         /**
@@ -1267,7 +1267,7 @@
          */
         private Object readResolve() {
             return (list instanceof RandomAccess
-                    ? new UnmodifiableRandomAccessList<E>(list)
+                    ? new UnmodifiableRandomAccessList<>(list)
                     : this);
         }
     }
@@ -1283,7 +1283,7 @@
         }
 
         public List<E> subList(int fromIndex, int toIndex) {
-            return new UnmodifiableRandomAccessList<E>(
+            return new UnmodifiableRandomAccessList<>(
                 list.subList(fromIndex, toIndex));
         }
 
@@ -1296,7 +1296,7 @@
          * deserialization.
          */
         private Object writeReplace() {
-            return new UnmodifiableList<E>(list);
+            return new UnmodifiableList<>(list);
         }
     }
 
@@ -1315,7 +1315,7 @@
      * @return an unmodifiable view of the specified map.
      */
     public static <K,V> Map<K,V> unmodifiableMap(Map<? extends K, ? extends V> m) {
-        return new UnmodifiableMap<K,V>(m);
+        return new UnmodifiableMap<>(m);
     }
 
     /**
@@ -1363,7 +1363,7 @@
 
         public Set<Map.Entry<K,V>> entrySet() {
             if (entrySet==null)
-                entrySet = new UnmodifiableEntrySet<K,V>(m.entrySet());
+                entrySet = new UnmodifiableEntrySet<>(m.entrySet());
             return entrySet;
         }
 
@@ -1400,7 +1400,7 @@
                         return i.hasNext();
                     }
                     public Map.Entry<K,V> next() {
-                        return new UnmodifiableEntry<K,V>(i.next());
+                        return new UnmodifiableEntry<>(i.next());
                     }
                     public void remove() {
                         throw new UnsupportedOperationException();
@@ -1411,7 +1411,7 @@
             public Object[] toArray() {
                 Object[] a = c.toArray();
                 for (int i=0; i<a.length; i++)
-                    a[i] = new UnmodifiableEntry<K,V>((Map.Entry<K,V>)a[i]);
+                    a[i] = new UnmodifiableEntry<>((Map.Entry<K,V>)a[i]);
                 return a;
             }
 
@@ -1422,7 +1422,7 @@
                 Object[] arr = c.toArray(a.length==0 ? a : Arrays.copyOf(a, 0));
 
                 for (int i=0; i<arr.length; i++)
-                    arr[i] = new UnmodifiableEntry<K,V>((Map.Entry<K,V>)arr[i]);
+                    arr[i] = new UnmodifiableEntry<>((Map.Entry<K,V>)arr[i]);
 
                 if (arr.length > a.length)
                     return (T[])arr;
@@ -1443,7 +1443,7 @@
                 if (!(o instanceof Map.Entry))
                     return false;
                 return c.contains(
-                    new UnmodifiableEntry<Object,Object>((Map.Entry<?,?>) o));
+                    new UnmodifiableEntry<>((Map.Entry<?,?>) o));
             }
 
             /**
@@ -1517,7 +1517,7 @@
      * @return an unmodifiable view of the specified sorted map.
      */
     public static <K,V> SortedMap<K,V> unmodifiableSortedMap(SortedMap<K, ? extends V> m) {
-        return new UnmodifiableSortedMap<K,V>(m);
+        return new UnmodifiableSortedMap<>(m);
     }
 
     /**
@@ -1535,13 +1535,13 @@
         public Comparator<? super K> comparator() {return sm.comparator();}
 
         public SortedMap<K,V> subMap(K fromKey, K toKey) {
-            return new UnmodifiableSortedMap<K,V>(sm.subMap(fromKey, toKey));
+            return new UnmodifiableSortedMap<>(sm.subMap(fromKey, toKey));
         }
         public SortedMap<K,V> headMap(K toKey) {
-            return new UnmodifiableSortedMap<K,V>(sm.headMap(toKey));
+            return new UnmodifiableSortedMap<>(sm.headMap(toKey));
         }
         public SortedMap<K,V> tailMap(K fromKey) {
-            return new UnmodifiableSortedMap<K,V>(sm.tailMap(fromKey));
+            return new UnmodifiableSortedMap<>(sm.tailMap(fromKey));
         }
 
         public K firstKey()           {return sm.firstKey();}
@@ -1583,11 +1583,11 @@
      * @return a synchronized view of the specified collection.
      */
     public static <T> Collection<T> synchronizedCollection(Collection<T> c) {
-        return new SynchronizedCollection<T>(c);
+        return new SynchronizedCollection<>(c);
     }
 
     static <T> Collection<T> synchronizedCollection(Collection<T> c, Object mutex) {
-        return new SynchronizedCollection<T>(c, mutex);
+        return new SynchronizedCollection<>(c, mutex);
     }
 
     /**
@@ -1686,11 +1686,11 @@
      * @return a synchronized view of the specified set.
      */
     public static <T> Set<T> synchronizedSet(Set<T> s) {
-        return new SynchronizedSet<T>(s);
+        return new SynchronizedSet<>(s);
     }
 
     static <T> Set<T> synchronizedSet(Set<T> s, Object mutex) {
-        return new SynchronizedSet<T>(s, mutex);
+        return new SynchronizedSet<>(s, mutex);
     }
 
     /**
@@ -1754,7 +1754,7 @@
      * @return a synchronized view of the specified sorted set.
      */
     public static <T> SortedSet<T> synchronizedSortedSet(SortedSet<T> s) {
-        return new SynchronizedSortedSet<T>(s);
+        return new SynchronizedSortedSet<>(s);
     }
 
     /**
@@ -1783,18 +1783,18 @@
 
         public SortedSet<E> subSet(E fromElement, E toElement) {
             synchronized (mutex) {
-                return new SynchronizedSortedSet<E>(
+                return new SynchronizedSortedSet<>(
                     ss.subSet(fromElement, toElement), mutex);
             }
         }
         public SortedSet<E> headSet(E toElement) {
             synchronized (mutex) {
-                return new SynchronizedSortedSet<E>(ss.headSet(toElement), mutex);
+                return new SynchronizedSortedSet<>(ss.headSet(toElement), mutex);
             }
         }
         public SortedSet<E> tailSet(E fromElement) {
             synchronized (mutex) {
-               return new SynchronizedSortedSet<E>(ss.tailSet(fromElement),mutex);
+               return new SynchronizedSortedSet<>(ss.tailSet(fromElement),mutex);
             }
         }
 
@@ -1833,14 +1833,14 @@
      */
     public static <T> List<T> synchronizedList(List<T> list) {
         return (list instanceof RandomAccess ?
-                new SynchronizedRandomAccessList<T>(list) :
-                new SynchronizedList<T>(list));
+                new SynchronizedRandomAccessList<>(list) :
+                new SynchronizedList<>(list));
     }
 
     static <T> List<T> synchronizedList(List<T> list, Object mutex) {
         return (list instanceof RandomAccess ?
-                new SynchronizedRandomAccessList<T>(list, mutex) :
-                new SynchronizedList<T>(list, mutex));
+                new SynchronizedRandomAccessList<>(list, mutex) :
+                new SynchronizedList<>(list, mutex));
     }
 
     /**
@@ -1903,7 +1903,7 @@
 
         public List<E> subList(int fromIndex, int toIndex) {
             synchronized (mutex) {
-                return new SynchronizedList<E>(list.subList(fromIndex, toIndex),
+                return new SynchronizedList<>(list.subList(fromIndex, toIndex),
                                             mutex);
             }
         }
@@ -1922,7 +1922,7 @@
          */
         private Object readResolve() {
             return (list instanceof RandomAccess
-                    ? new SynchronizedRandomAccessList<E>(list)
+                    ? new SynchronizedRandomAccessList<>(list)
                     : this);
         }
     }
@@ -1944,7 +1944,7 @@
 
         public List<E> subList(int fromIndex, int toIndex) {
             synchronized (mutex) {
-                return new SynchronizedRandomAccessList<E>(
+                return new SynchronizedRandomAccessList<>(
                     list.subList(fromIndex, toIndex), mutex);
             }
         }
@@ -1958,7 +1958,7 @@
          * deserialization.
          */
         private Object writeReplace() {
-            return new SynchronizedList<E>(list);
+            return new SynchronizedList<>(list);
         }
     }
 
@@ -1990,7 +1990,7 @@
      * @return a synchronized view of the specified map.
      */
     public static <K,V> Map<K,V> synchronizedMap(Map<K,V> m) {
-        return new SynchronizedMap<K,V>(m);
+        return new SynchronizedMap<>(m);
     }
 
     /**
@@ -2051,7 +2051,7 @@
         public Set<K> keySet() {
             synchronized (mutex) {
                 if (keySet==null)
-                    keySet = new SynchronizedSet<K>(m.keySet(), mutex);
+                    keySet = new SynchronizedSet<>(m.keySet(), mutex);
                 return keySet;
             }
         }
@@ -2059,7 +2059,7 @@
         public Set<Map.Entry<K,V>> entrySet() {
             synchronized (mutex) {
                 if (entrySet==null)
-                    entrySet = new SynchronizedSet<Map.Entry<K,V>>(m.entrySet(), mutex);
+                    entrySet = new SynchronizedSet<>(m.entrySet(), mutex);
                 return entrySet;
             }
         }
@@ -2067,7 +2067,7 @@
         public Collection<V> values() {
             synchronized (mutex) {
                 if (values==null)
-                    values = new SynchronizedCollection<V>(m.values(), mutex);
+                    values = new SynchronizedCollection<>(m.values(), mutex);
                 return values;
             }
         }
@@ -2129,7 +2129,7 @@
      * @return a synchronized view of the specified sorted map.
      */
     public static <K,V> SortedMap<K,V> synchronizedSortedMap(SortedMap<K,V> m) {
-        return new SynchronizedSortedMap<K,V>(m);
+        return new SynchronizedSortedMap<>(m);
     }
 
 
@@ -2159,18 +2159,18 @@
 
         public SortedMap<K,V> subMap(K fromKey, K toKey) {
             synchronized (mutex) {
-                return new SynchronizedSortedMap<K,V>(
+                return new SynchronizedSortedMap<>(
                     sm.subMap(fromKey, toKey), mutex);
             }
         }
         public SortedMap<K,V> headMap(K toKey) {
             synchronized (mutex) {
-                return new SynchronizedSortedMap<K,V>(sm.headMap(toKey), mutex);
+                return new SynchronizedSortedMap<>(sm.headMap(toKey), mutex);
             }
         }
         public SortedMap<K,V> tailMap(K fromKey) {
             synchronized (mutex) {
-               return new SynchronizedSortedMap<K,V>(sm.tailMap(fromKey),mutex);
+               return new SynchronizedSortedMap<>(sm.tailMap(fromKey),mutex);
             }
         }
 
@@ -2246,7 +2246,7 @@
      */
     public static <E> Collection<E> checkedCollection(Collection<E> c,
                                                       Class<E> type) {
-        return new CheckedCollection<E>(c, type);
+        return new CheckedCollection<>(c, type);
     }
 
     @SuppressWarnings("unchecked")
@@ -2378,7 +2378,7 @@
      * @since 1.5
      */
     public static <E> Set<E> checkedSet(Set<E> s, Class<E> type) {
-        return new CheckedSet<E>(s, type);
+        return new CheckedSet<>(s, type);
     }
 
     /**
@@ -2424,7 +2424,7 @@
      */
     public static <E> SortedSet<E> checkedSortedSet(SortedSet<E> s,
                                                     Class<E> type) {
-        return new CheckedSortedSet<E>(s, type);
+        return new CheckedSortedSet<>(s, type);
     }
 
     /**
@@ -2484,8 +2484,8 @@
      */
     public static <E> List<E> checkedList(List<E> list, Class<E> type) {
         return (list instanceof RandomAccess ?
-                new CheckedRandomAccessList<E>(list, type) :
-                new CheckedList<E>(list, type));
+                new CheckedRandomAccessList<>(list, type) :
+                new CheckedList<>(list, type));
     }
 
     /**
@@ -2550,7 +2550,7 @@
         }
 
         public List<E> subList(int fromIndex, int toIndex) {
-            return new CheckedList<E>(list.subList(fromIndex, toIndex), type);
+            return new CheckedList<>(list.subList(fromIndex, toIndex), type);
         }
     }
 
@@ -2567,7 +2567,7 @@
         }
 
         public List<E> subList(int fromIndex, int toIndex) {
-            return new CheckedRandomAccessList<E>(
+            return new CheckedRandomAccessList<>(
                 list.subList(fromIndex, toIndex), type);
         }
     }
@@ -2609,7 +2609,7 @@
     public static <K, V> Map<K, V> checkedMap(Map<K, V> m,
                                               Class<K> keyType,
                                               Class<V> valueType) {
-        return new CheckedMap<K,V>(m, keyType, valueType);
+        return new CheckedMap<>(m, keyType, valueType);
     }
 
 
@@ -2677,15 +2677,14 @@
             // - protection from malicious t
             // - correct behavior if t is a concurrent map
             Object[] entries = t.entrySet().toArray();
-            List<Map.Entry<K,V>> checked =
-                new ArrayList<Map.Entry<K,V>>(entries.length);
+            List<Map.Entry<K,V>> checked = new ArrayList<>(entries.length);
             for (Object o : entries) {
                 Map.Entry<?,?> e = (Map.Entry<?,?>) o;
                 Object k = e.getKey();
                 Object v = e.getValue();
                 typeCheck(k, v);
                 checked.add(
-                    new AbstractMap.SimpleImmutableEntry<K,V>((K) k, (V) v));
+                    new AbstractMap.SimpleImmutableEntry<>((K) k, (V) v));
             }
             for (Map.Entry<K,V> e : checked)
                 m.put(e.getKey(), e.getValue());
@@ -2695,7 +2694,7 @@
 
         public Set<Map.Entry<K,V>> entrySet() {
             if (entrySet==null)
-                entrySet = new CheckedEntrySet<K,V>(m.entrySet(), valueType);
+                entrySet = new CheckedEntrySet<>(m.entrySet(), valueType);
             return entrySet;
         }
 
@@ -2810,7 +2809,7 @@
                 if (!(o instanceof Map.Entry))
                     return false;
                 return s.remove(new AbstractMap.SimpleImmutableEntry
-                                <Object, Object>((Map.Entry<?,?>)o));
+                                <>((Map.Entry<?,?>)o));
             }
 
             public boolean removeAll(Collection<?> c) {
@@ -2843,7 +2842,7 @@
 
             static <K,V,T> CheckedEntry<K,V,T> checkedEntry(Map.Entry<K,V> e,
                                                             Class<T> valueType) {
-                return new CheckedEntry<K,V,T>(e, valueType);
+                return new CheckedEntry<>(e, valueType);
             }
 
             /**
@@ -2884,7 +2883,7 @@
                     if (!(o instanceof Map.Entry))
                         return false;
                     return e.equals(new AbstractMap.SimpleImmutableEntry
-                                    <Object, Object>((Map.Entry<?,?>)o));
+                                    <>((Map.Entry<?,?>)o));
                 }
             }
         }
@@ -2927,7 +2926,7 @@
     public static <K,V> SortedMap<K,V> checkedSortedMap(SortedMap<K, V> m,
                                                         Class<K> keyType,
                                                         Class<V> valueType) {
-        return new CheckedSortedMap<K,V>(m, keyType, valueType);
+        return new CheckedSortedMap<>(m, keyType, valueType);
     }
 
     /**
@@ -2993,7 +2992,7 @@
 
     private static class EmptyIterator<E> implements Iterator<E> {
         static final EmptyIterator<Object> EMPTY_ITERATOR
-            = new EmptyIterator<Object>();
+            = new EmptyIterator<>();
 
         public boolean hasNext() { return false; }
         public E next() { throw new NoSuchElementException(); }
@@ -3042,7 +3041,7 @@
         implements ListIterator<E>
     {
         static final EmptyListIterator<Object> EMPTY_ITERATOR
-            = new EmptyListIterator<Object>();
+            = new EmptyListIterator<>();
 
         public boolean hasPrevious() { return false; }
         public E previous() { throw new NoSuchElementException(); }
@@ -3078,7 +3077,7 @@
 
     private static class EmptyEnumeration<E> implements Enumeration<E> {
         static final EmptyEnumeration<Object> EMPTY_ENUMERATION
-            = new EmptyEnumeration<Object>();
+            = new EmptyEnumeration<>();
 
         public boolean hasMoreElements() { return false; }
         public E nextElement() { throw new NoSuchElementException(); }
@@ -3090,7 +3089,7 @@
      * @see #emptySet()
      */
     @SuppressWarnings("unchecked")
-    public static final Set EMPTY_SET = new EmptySet<Object>();
+    public static final Set EMPTY_SET = new EmptySet<>();
 
     /**
      * Returns the empty set (immutable).  This set is serializable.
@@ -3150,7 +3149,7 @@
      * @see #emptyList()
      */
     @SuppressWarnings("unchecked")
-    public static final List EMPTY_LIST = new EmptyList<Object>();
+    public static final List EMPTY_LIST = new EmptyList<>();
 
     /**
      * Returns the empty list (immutable).  This list is serializable.
@@ -3224,7 +3223,7 @@
      * @since 1.3
      */
     @SuppressWarnings("unchecked")
-    public static final Map EMPTY_MAP = new EmptyMap<Object,Object>();
+    public static final Map EMPTY_MAP = new EmptyMap<>();
 
     /**
      * Returns the empty map (immutable).  This map is serializable.
@@ -3286,7 +3285,7 @@
      * @return an immutable set containing only the specified object.
      */
     public static <T> Set<T> singleton(T o) {
-        return new SingletonSet<T>(o);
+        return new SingletonSet<>(o);
     }
 
     static <E> Iterator<E> singletonIterator(final E e) {
@@ -3339,7 +3338,7 @@
      * @since 1.3
      */
     public static <T> List<T> singletonList(T o) {
-        return new SingletonList<T>(o);
+        return new SingletonList<>(o);
     }
 
     /**
@@ -3381,7 +3380,7 @@
      * @since 1.3
      */
     public static <K,V> Map<K,V> singletonMap(K key, V value) {
-        return new SingletonMap<K,V>(key, value);
+        return new SingletonMap<>(key, value);
     }
 
     /**
@@ -3423,7 +3422,7 @@
         public Set<Map.Entry<K,V>> entrySet() {
             if (entrySet==null)
                 entrySet = Collections.<Map.Entry<K,V>>singleton(
-                    new SimpleImmutableEntry<K,V>(k, v));
+                    new SimpleImmutableEntry<>(k, v));
             return entrySet;
         }
 
@@ -3455,7 +3454,7 @@
     public static <T> List<T> nCopies(int n, T o) {
         if (n < 0)
             throw new IllegalArgumentException("List length = " + n);
-        return new CopiesList<T>(n, o);
+        return new CopiesList<>(n, o);
     }
 
     /**
@@ -3529,7 +3528,7 @@
             if (fromIndex > toIndex)
                 throw new IllegalArgumentException("fromIndex(" + fromIndex +
                                                    ") > toIndex(" + toIndex + ")");
-            return new CopiesList<E>(toIndex - fromIndex, element);
+            return new CopiesList<>(toIndex - fromIndex, element);
         }
     }
 
@@ -3595,7 +3594,7 @@
         if (cmp instanceof ReverseComparator2)
             return ((ReverseComparator2<T>)cmp).cmp;
 
-        return new ReverseComparator2<T>(cmp);
+        return new ReverseComparator2<>(cmp);
     }
 
     /**
@@ -3674,7 +3673,7 @@
      * @see ArrayList
      */
     public static <T> ArrayList<T> list(Enumeration<T> e) {
-        ArrayList<T> l = new ArrayList<T>();
+        ArrayList<T> l = new ArrayList<>();
         while (e.hasMoreElements())
             l.add(e.nextElement());
         return l;
@@ -3819,7 +3818,7 @@
      * @since 1.6
      */
     public static <E> Set<E> newSetFromMap(Map<E, Boolean> map) {
-        return new SetFromMap<E>(map);
+        return new SetFromMap<>(map);
     }
 
     /**
@@ -3883,7 +3882,7 @@
      * @since  1.6
      */
     public static <T> Queue<T> asLifoQueue(Deque<T> deque) {
-        return new AsLIFOQueue<T>(deque);
+        return new AsLIFOQueue<>(deque);
     }
 
     /**
--- a/jdk/src/share/classes/java/util/EnumMap.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/EnumMap.java	Wed Jan 19 21:51:10 2011 -0800
@@ -499,7 +499,7 @@
             int j = 0;
             for (int i = 0; i < vals.length; i++)
                 if (vals[i] != null)
-                    a[j++] = new AbstractMap.SimpleEntry<K,V>(
+                    a[j++] = new AbstractMap.SimpleEntry<>(
                         keyUniverse[i], unmaskNull(vals[i]));
             return a;
         }
--- a/jdk/src/share/classes/java/util/EnumSet.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/EnumSet.java	Wed Jan 19 21:51:10 2011 -0800
@@ -110,9 +110,9 @@
             throw new ClassCastException(elementType + " not an enum");
 
         if (universe.length <= 64)
-            return new RegularEnumSet<E>(elementType, universe);
+            return new RegularEnumSet<>(elementType, universe);
         else
-            return new JumboEnumSet<E>(elementType, universe);
+            return new JumboEnumSet<>(elementType, universe);
     }
 
     /**
@@ -430,7 +430,7 @@
     }
 
     Object writeReplace() {
-        return new SerializationProxy<E>(this);
+        return new SerializationProxy<>(this);
     }
 
     // readObject method for the serialization proxy pattern
--- a/jdk/src/share/classes/java/util/Formatter.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/Formatter.java	Wed Jan 19 21:51:10 2011 -0800
@@ -2490,7 +2490,7 @@
      * Finds format specifiers in the format string.
      */
     private FormatString[] parse(String s) {
-        ArrayList<FormatString> al = new ArrayList<FormatString>();
+        ArrayList<FormatString> al = new ArrayList<>();
         Matcher m = fsPattern.matcher(s);
         for (int i = 0, len = s.length(); i < len; ) {
             if (m.find(i)) {
--- a/jdk/src/share/classes/java/util/HashMap.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/HashMap.java	Wed Jan 19 21:51:10 2011 -0800
@@ -763,7 +763,7 @@
      */
     void addEntry(int hash, K key, V value, int bucketIndex) {
         Entry<K,V> e = table[bucketIndex];
-        table[bucketIndex] = new Entry<K,V>(hash, key, value, e);
+        table[bucketIndex] = new Entry<>(hash, key, value, e);
         if (size++ >= threshold)
             resize(2 * table.length);
     }
@@ -778,7 +778,7 @@
      */
     void createEntry(int hash, K key, V value, int bucketIndex) {
         Entry<K,V> e = table[bucketIndex];
-        table[bucketIndex] = new Entry<K,V>(hash, key, value, e);
+        table[bucketIndex] = new Entry<>(hash, key, value, e);
         size++;
     }
 
--- a/jdk/src/share/classes/java/util/HashSet.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/HashSet.java	Wed Jan 19 21:51:10 2011 -0800
@@ -100,7 +100,7 @@
      * default initial capacity (16) and load factor (0.75).
      */
     public HashSet() {
-        map = new HashMap<E,Object>();
+        map = new HashMap<>();
     }
 
     /**
@@ -113,7 +113,7 @@
      * @throws NullPointerException if the specified collection is null
      */
     public HashSet(Collection<? extends E> c) {
-        map = new HashMap<E,Object>(Math.max((int) (c.size()/.75f) + 1, 16));
+        map = new HashMap<>(Math.max((int) (c.size()/.75f) + 1, 16));
         addAll(c);
     }
 
@@ -127,7 +127,7 @@
      *             than zero, or if the load factor is nonpositive
      */
     public HashSet(int initialCapacity, float loadFactor) {
-        map = new HashMap<E,Object>(initialCapacity, loadFactor);
+        map = new HashMap<>(initialCapacity, loadFactor);
     }
 
     /**
@@ -139,7 +139,7 @@
      *             than zero
      */
     public HashSet(int initialCapacity) {
-        map = new HashMap<E,Object>(initialCapacity);
+        map = new HashMap<>(initialCapacity);
     }
 
     /**
@@ -156,7 +156,7 @@
      *             than zero, or if the load factor is nonpositive
      */
     HashSet(int initialCapacity, float loadFactor, boolean dummy) {
-        map = new LinkedHashMap<E,Object>(initialCapacity, loadFactor);
+        map = new LinkedHashMap<>(initialCapacity, loadFactor);
     }
 
     /**
--- a/jdk/src/share/classes/java/util/Hashtable.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/Hashtable.java	Wed Jan 19 21:51:10 2011 -0800
@@ -455,7 +455,7 @@
 
         // Creates the new entry.
         Entry<K,V> e = tab[index];
-        tab[index] = new Entry<K,V>(hash, key, value, e);
+        tab[index] = new Entry<>(hash, key, value, e);
         count++;
         return null;
     }
@@ -579,7 +579,7 @@
         if (count == 0) {
             return Collections.emptyEnumeration();
         } else {
-            return new Enumerator<T>(type, false);
+            return new Enumerator<>(type, false);
         }
     }
 
@@ -587,7 +587,7 @@
         if (count == 0) {
             return Collections.emptyIterator();
         } else {
-            return new Enumerator<T>(type, true);
+            return new Enumerator<>(type, true);
         }
     }
 
@@ -929,7 +929,7 @@
         }
         // Creates the new entry.
         Entry<K,V> e = tab[index];
-        tab[index] = new Entry<K,V>(hash, key, value, e);
+        tab[index] = new Entry<>(hash, key, value, e);
         count++;
     }
 
@@ -950,7 +950,7 @@
         }
 
         protected Object clone() {
-            return new Entry<K,V>(hash, key, value,
+            return new Entry<>(hash, key, value,
                                   (next==null ? null : (Entry<K,V>) next.clone()));
         }
 
--- a/jdk/src/share/classes/java/util/IdentityHashMap.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/IdentityHashMap.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1134,7 +1134,7 @@
             Object[] result = new Object[size];
             Iterator<Map.Entry<K,V>> it = iterator();
             for (int i = 0; i < size; i++)
-                result[i] = new AbstractMap.SimpleEntry<K,V>(it.next());
+                result[i] = new AbstractMap.SimpleEntry<>(it.next());
             return result;
         }
 
@@ -1146,7 +1146,7 @@
                     .newInstance(a.getClass().getComponentType(), size);
             Iterator<Map.Entry<K,V>> it = iterator();
             for (int i = 0; i < size; i++)
-                a[i] = (T) new AbstractMap.SimpleEntry<K,V>(it.next());
+                a[i] = (T) new AbstractMap.SimpleEntry<>(it.next());
             if (a.length > size)
                 a[size] = null;
             return a;
--- a/jdk/src/share/classes/java/util/JumboEnumSet.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/JumboEnumSet.java	Wed Jan 19 21:51:10 2011 -0800
@@ -89,7 +89,7 @@
      * @return an iterator over the elements contained in this set
      */
     public Iterator<E> iterator() {
-        return new EnumSetIterator<E>();
+        return new EnumSetIterator<>();
     }
 
     private class EnumSetIterator<E extends Enum<E>> implements Iterator<E> {
--- a/jdk/src/share/classes/java/util/LinkedHashMap.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/LinkedHashMap.java	Wed Jan 19 21:51:10 2011 -0800
@@ -237,7 +237,7 @@
      * the chain.
      */
     void init() {
-        header = new Entry<K,V>(-1, null, null, null);
+        header = new Entry<>(-1, null, null, null);
         header.before = header.after = header;
     }
 
@@ -438,7 +438,7 @@
      */
     void createEntry(int hash, K key, V value, int bucketIndex) {
         HashMap.Entry<K,V> old = table[bucketIndex];
-        Entry<K,V> e = new Entry<K,V>(hash, key, value, old);
+        Entry<K,V> e = new Entry<>(hash, key, value, old);
         table[bucketIndex] = e;
         e.addBefore(header);
         size++;
--- a/jdk/src/share/classes/java/util/LinkedList.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/LinkedList.java	Wed Jan 19 21:51:10 2011 -0800
@@ -122,7 +122,7 @@
      */
     private void linkFirst(E e) {
         final Node<E> f = first;
-        final Node<E> newNode = new Node<E>(null, e, f);
+        final Node<E> newNode = new Node<>(null, e, f);
         first = newNode;
         if (f == null)
             last = newNode;
@@ -137,7 +137,7 @@
      */
     void linkLast(E e) {
         final Node<E> l = last;
-        final Node<E> newNode = new Node<E>(l, e, null);
+        final Node<E> newNode = new Node<>(l, e, null);
         last = newNode;
         if (l == null)
             first = newNode;
@@ -153,7 +153,7 @@
     void linkBefore(E e, Node<E> succ) {
         // assert succ != null;
         final Node<E> pred = succ.prev;
-        final Node<E> newNode = new Node<E>(pred, e, succ);
+        final Node<E> newNode = new Node<>(pred, e, succ);
         succ.prev = newNode;
         if (pred == null)
             first = newNode;
@@ -419,7 +419,7 @@
 
         for (Object o : a) {
             @SuppressWarnings("unchecked") E e = (E) o;
-            Node<E> newNode = new Node<E>(pred, e, null);
+            Node<E> newNode = new Node<>(pred, e, null);
             if (pred == null)
                 first = newNode;
             else
--- a/jdk/src/share/classes/java/util/ListResourceBundle.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/ListResourceBundle.java	Wed Jan 19 21:51:10 2011 -0800
@@ -187,7 +187,7 @@
             return;
 
         Object[][] contents = getContents();
-        HashMap<String,Object> temp = new HashMap<String,Object>(contents.length);
+        HashMap<String,Object> temp = new HashMap<>(contents.length);
         for (int i = 0; i < contents.length; ++i) {
             // key must be non-null String, value must be non-null
             String key = (String) contents[i][0];
--- a/jdk/src/share/classes/java/util/PriorityQueue.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/PriorityQueue.java	Wed Jan 19 21:51:10 2011 -0800
@@ -538,7 +538,7 @@
                     cursor--;
                 else {
                     if (forgetMeNot == null)
-                        forgetMeNot = new ArrayDeque<E>();
+                        forgetMeNot = new ArrayDeque<>();
                     forgetMeNot.add(moved);
                 }
             } else if (lastRetElt != null) {
--- a/jdk/src/share/classes/java/util/Properties.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/Properties.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1011,7 +1011,7 @@
      * @since   1.6
      */
     public Set<String> stringPropertyNames() {
-        Hashtable<String, String> h = new Hashtable<String, String>();
+        Hashtable<String, String> h = new Hashtable<>();
         enumerateStringProperties(h);
         return h.keySet();
     }
--- a/jdk/src/share/classes/java/util/RegularEnumSet.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/RegularEnumSet.java	Wed Jan 19 21:51:10 2011 -0800
@@ -71,7 +71,7 @@
      * @return an iterator over the elements contained in this set
      */
     public Iterator<E> iterator() {
-        return new EnumSetIterator<E>();
+        return new EnumSetIterator<>();
     }
 
     private class EnumSetIterator<E extends Enum<E>> implements Iterator<E> {
--- a/jdk/src/share/classes/java/util/ServiceLoader.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/ServiceLoader.java	Wed Jan 19 21:51:10 2011 -0800
@@ -191,7 +191,7 @@
     private ClassLoader loader;
 
     // Cached providers, in instantiation order
-    private LinkedHashMap<String,S> providers = new LinkedHashMap<String,S>();
+    private LinkedHashMap<String,S> providers = new LinkedHashMap<>();
 
     // The current lazy-lookup iterator
     private LazyIterator lookupIterator;
@@ -291,7 +291,7 @@
     {
         InputStream in = null;
         BufferedReader r = null;
-        ArrayList<String> names = new ArrayList<String>();
+        ArrayList<String> names = new ArrayList<>();
         try {
             in = u.openStream();
             r = new BufferedReader(new InputStreamReader(in, "utf-8"));
@@ -463,7 +463,7 @@
     public static <S> ServiceLoader<S> load(Class<S> service,
                                             ClassLoader loader)
     {
-        return new ServiceLoader<S>(service, loader);
+        return new ServiceLoader<>(service, loader);
     }
 
     /**
--- a/jdk/src/share/classes/java/util/TimSort.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/TimSort.java	Wed Jan 19 21:51:10 2011 -0800
@@ -196,7 +196,7 @@
          * extending short natural runs to minRun elements, and merging runs
          * to maintain stack invariant.
          */
-        TimSort<T> ts = new TimSort<T>(a, c);
+        TimSort<T> ts = new TimSort<>(a, c);
         int minRun = minRunLength(nRemaining);
         do {
             // Identify next run
--- a/jdk/src/share/classes/java/util/TreeMap.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/TreeMap.java	Wed Jan 19 21:51:10 2011 -0800
@@ -533,7 +533,7 @@
             // throw NullPointerException
             //
             // compare(key, key); // type check
-            root = new Entry<K,V>(key, value, null);
+            root = new Entry<>(key, value, null);
             size = 1;
             modCount++;
             return null;
@@ -569,7 +569,7 @@
                     return t.setValue(value);
             } while (t != null);
         }
-        Entry<K,V> e = new Entry<K,V>(key, value, parent);
+        Entry<K,V> e = new Entry<>(key, value, parent);
         if (cmp < 0)
             parent.left = e;
         else
@@ -1069,14 +1069,14 @@
         }
         public NavigableSet<E> subSet(E fromElement, boolean fromInclusive,
                                       E toElement,   boolean toInclusive) {
-            return new KeySet<E>(m.subMap(fromElement, fromInclusive,
+            return new KeySet<>(m.subMap(fromElement, fromInclusive,
                                           toElement,   toInclusive));
         }
         public NavigableSet<E> headSet(E toElement, boolean inclusive) {
-            return new KeySet<E>(m.headMap(toElement, inclusive));
+            return new KeySet<>(m.headMap(toElement, inclusive));
         }
         public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
-            return new KeySet<E>(m.tailMap(fromElement, inclusive));
+            return new KeySet<>(m.tailMap(fromElement, inclusive));
         }
         public SortedSet<E> subSet(E fromElement, E toElement) {
             return subSet(fromElement, true, toElement, false);
@@ -1205,7 +1205,7 @@
      */
     static <K,V> Map.Entry<K,V> exportEntry(TreeMap.Entry<K,V> e) {
         return (e == null) ? null :
-            new AbstractMap.SimpleImmutableEntry<K,V>(e);
+            new AbstractMap.SimpleImmutableEntry<>(e);
     }
 
     /**
@@ -2406,7 +2406,7 @@
             value = (defaultVal != null ? defaultVal : (V) str.readObject());
         }
 
-        Entry<K,V> middle =  new Entry<K,V>(key, value, null);
+        Entry<K,V> middle =  new Entry<>(key, value, null);
 
         // color nodes in non-full bottommost level red
         if (level == redLevel)
--- a/jdk/src/share/classes/java/util/TreeSet.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/TreeSet.java	Wed Jan 19 21:51:10 2011 -0800
@@ -138,7 +138,7 @@
      *        ordering} of the elements will be used.
      */
     public TreeSet(Comparator<? super E> comparator) {
-        this(new TreeMap<E,Object>(comparator));
+        this(new TreeMap<>(comparator));
     }
 
     /**
@@ -195,7 +195,7 @@
      * @since 1.6
      */
     public NavigableSet<E> descendingSet() {
-        return new TreeSet<E>(m.descendingMap());
+        return new TreeSet<>(m.descendingMap());
     }
 
     /**
@@ -322,7 +322,7 @@
      */
     public NavigableSet<E> subSet(E fromElement, boolean fromInclusive,
                                   E toElement,   boolean toInclusive) {
-        return new TreeSet<E>(m.subMap(fromElement, fromInclusive,
+        return new TreeSet<>(m.subMap(fromElement, fromInclusive,
                                        toElement,   toInclusive));
     }
 
@@ -335,7 +335,7 @@
      * @since 1.6
      */
     public NavigableSet<E> headSet(E toElement, boolean inclusive) {
-        return new TreeSet<E>(m.headMap(toElement, inclusive));
+        return new TreeSet<>(m.headMap(toElement, inclusive));
     }
 
     /**
@@ -347,7 +347,7 @@
      * @since 1.6
      */
     public NavigableSet<E> tailSet(E fromElement, boolean inclusive) {
-        return new TreeSet<E>(m.tailMap(fromElement, inclusive));
+        return new TreeSet<>(m.tailMap(fromElement, inclusive));
     }
 
     /**
@@ -477,7 +477,7 @@
             throw new InternalError();
         }
 
-        clone.m = new TreeMap<E,Object>(m);
+        clone.m = new TreeMap<>(m);
         return clone;
     }
 
@@ -524,9 +524,9 @@
         // Create backing TreeMap
         TreeMap<E,Object> tm;
         if (c==null)
-            tm = new TreeMap<E,Object>();
+            tm = new TreeMap<>();
         else
-            tm = new TreeMap<E,Object>(c);
+            tm = new TreeMap<>(c);
         m = tm;
 
         // Read in size
--- a/jdk/src/share/classes/java/util/WeakHashMap.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/WeakHashMap.java	Wed Jan 19 21:51:10 2011 -0800
@@ -171,7 +171,7 @@
     /**
      * Reference queue for cleared WeakEntries
      */
-    private final ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
+    private final ReferenceQueue<Object> queue = new ReferenceQueue<>();
 
     /**
      * The number of times this WeakHashMap has been structurally modified.
@@ -439,7 +439,7 @@
 
         modCount++;
         Entry<K,V> e = tab[i];
-        tab[i] = new Entry<K,V>(k, value, queue, h, e);
+        tab[i] = new Entry<>(k, value, queue, h, e);
         if (++size >= threshold)
             resize(tab.length * 2);
         return null;
@@ -955,10 +955,9 @@
         }
 
         private List<Map.Entry<K,V>> deepCopy() {
-            List<Map.Entry<K,V>> list =
-                new ArrayList<Map.Entry<K,V>>(size());
+            List<Map.Entry<K,V>> list = new ArrayList<>(size());
             for (Map.Entry<K,V> e : this)
-                list.add(new AbstractMap.SimpleEntry<K,V>(e));
+                list.add(new AbstractMap.SimpleEntry<>(e));
             return list;
         }
 
--- a/jdk/src/share/classes/java/util/jar/Pack200.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/jar/Pack200.java	Wed Jan 19 21:51:10 2011 -0800
@@ -732,14 +732,14 @@
     private synchronized static Object newInstance(String prop) {
         String implName = "(unknown)";
         try {
-            Class impl = (prop == PACK_PROVIDER)? packerImpl: unpackerImpl;
+            Class impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
             if (impl == null) {
                 // The first time, we must decide which class to use.
                 implName = java.security.AccessController.doPrivileged(
                     new sun.security.action.GetPropertyAction(prop,""));
                 if (implName != null && !implName.equals(""))
                     impl = Class.forName(implName);
-                else if (prop == PACK_PROVIDER)
+                else if (PACK_PROVIDER.equals(prop))
                     impl = com.sun.java.util.jar.pack.PackerImpl.class;
                 else
                     impl = com.sun.java.util.jar.pack.UnpackerImpl.class;
--- a/jdk/src/share/classes/java/util/logging/FileHandler.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/logging/FileHandler.java	Wed Jan 19 21:51:10 2011 -0800
@@ -127,7 +127,7 @@
     private FileOutputStream lockStream;
     private File files[];
     private static final int MAX_LOCKS = 100;
-    private static java.util.HashMap<String, String> locks = new java.util.HashMap<String, String>();
+    private static java.util.HashMap<String, String> locks = new java.util.HashMap<>();
 
     // A metered stream is a subclass of OutputStream that
     //   (a) forwards all its output to a target stream
--- a/jdk/src/share/classes/java/util/logging/Level.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/logging/Level.java	Wed Jan 19 21:51:10 2011 -0800
@@ -59,7 +59,7 @@
  */
 
 public class Level implements java.io.Serializable {
-    private static java.util.ArrayList<Level> known = new java.util.ArrayList<Level>();
+    private static java.util.ArrayList<Level> known = new java.util.ArrayList<>();
     private static String defaultBundle = "sun.util.logging.resources.logging";
 
     /**
--- a/jdk/src/share/classes/java/util/logging/LogManager.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/logging/LogManager.java	Wed Jan 19 21:51:10 2011 -0800
@@ -156,8 +156,7 @@
     private final static Level defaultLevel = Level.INFO;
 
     // Table of named Loggers that maps names to Loggers.
-    private Hashtable<String,LoggerWeakRef> namedLoggers =
-        new Hashtable<String,LoggerWeakRef>();
+    private Hashtable<String,LoggerWeakRef> namedLoggers = new Hashtable<>();
     // Tree of named Loggers
     private LogNode root = new LogNode(null);
     private Logger rootLogger;
@@ -422,7 +421,7 @@
     // loggerRefQueue holds LoggerWeakRef objects for Logger objects
     // that have been GC'ed.
     private final ReferenceQueue<Logger> loggerRefQueue
-        = new ReferenceQueue<Logger>();
+        = new ReferenceQueue<>();
 
     // Package-level inner class.
     // Helper class for managing WeakReferences to Logger objects.
@@ -672,7 +671,7 @@
                 name = "";
             }
             if (node.children == null) {
-                node.children = new HashMap<String,LogNode>();
+                node.children = new HashMap<>();
             }
             LogNode child = node.children.get(head);
             if (child == null) {
@@ -856,7 +855,7 @@
         }
         hands = hands.trim();
         int ix = 0;
-        Vector<String> result = new Vector<String>();
+        Vector<String> result = new Vector<>();
         while (ix < hands.length()) {
             int end = ix;
             while (end < hands.length()) {
--- a/jdk/src/share/classes/java/util/logging/LogRecord.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/logging/LogRecord.java	Wed Jan 19 21:51:10 2011 -0800
@@ -85,8 +85,7 @@
     private static final AtomicInteger nextThreadId
         = new AtomicInteger(MIN_SEQUENTIAL_THREAD_ID);
 
-    private static final ThreadLocal<Integer> threadIds
-        = new ThreadLocal<Integer>();
+    private static final ThreadLocal<Integer> threadIds = new ThreadLocal<>();
 
     /**
      * @serial Logging message level
--- a/jdk/src/share/classes/java/util/logging/Logger.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/logging/Logger.java	Wed Jan 19 21:51:10 2011 -0800
@@ -170,7 +170,7 @@
     private LogManager manager;
     private String name;
     private final CopyOnWriteArrayList<Handler> handlers =
-        new CopyOnWriteArrayList<Handler>();
+        new CopyOnWriteArrayList<>();
     private String resourceBundleName;
     private volatile boolean useParentHandlers = true;
     private volatile Filter filter;
@@ -1420,13 +1420,13 @@
             // Set our new parent.
             parent = newParent;
             if (parent.kids == null) {
-                parent.kids = new ArrayList<LogManager.LoggerWeakRef>(2);
+                parent.kids = new ArrayList<>(2);
             }
             if (ref == null) {
                 // we didn't have a previous parent
                 ref = manager.new LoggerWeakRef(this);
             }
-            ref.setParentRef(new WeakReference<Logger>(parent));
+            ref.setParentRef(new WeakReference<>(parent));
             parent.kids.add(ref);
 
             // As a result of the reparenting, the effective level
--- a/jdk/src/share/classes/java/util/logging/Logging.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/logging/Logging.java	Wed Jan 19 21:51:10 2011 -0800
@@ -56,7 +56,7 @@
 
     public List<String> getLoggerNames() {
         Enumeration loggers = logManager.getLoggerNames();
-        ArrayList<String> array = new ArrayList<String>();
+        ArrayList<String> array = new ArrayList<>();
 
         for (; loggers.hasMoreElements();) {
             array.add((String) loggers.nextElement());
--- a/jdk/src/share/classes/java/util/prefs/AbstractPreferences.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/prefs/AbstractPreferences.java	Wed Jan 19 21:51:10 2011 -0800
@@ -155,8 +155,7 @@
      * All known unremoved children of this node.  (This "cache" is consulted
      * prior to calling childSpi() or getChild().
      */
-    private Map<String, AbstractPreferences> kidCache
-        = new HashMap<String, AbstractPreferences>();
+    private Map<String, AbstractPreferences> kidCache = new HashMap<>();
 
     /**
      * This field is used to keep track of whether or not this node has
@@ -713,7 +712,7 @@
             if (removed)
                 throw new IllegalStateException("Node has been removed.");
 
-            Set<String> s = new TreeSet<String>(kidCache.keySet());
+            Set<String> s = new TreeSet<>(kidCache.keySet());
             for (String kid : childrenNamesSpi())
                 s.add(kid);
             return s.toArray(EMPTY_STRING_ARRAY);
@@ -1442,8 +1441,7 @@
      * event delivery from preference activity, greatly simplifying
      * locking and reducing opportunity for deadlock.
      */
-    private static final List<EventObject> eventQueue
-        = new LinkedList<EventObject>();
+    private static final List<EventObject> eventQueue = new LinkedList<>();
 
     /**
      * These two classes are used to distinguish NodeChangeEvents on
--- a/jdk/src/share/classes/java/util/regex/Pattern.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/regex/Pattern.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1068,7 +1068,7 @@
     public String[] split(CharSequence input, int limit) {
         int index = 0;
         boolean matchLimited = limit > 0;
-        ArrayList<String> matchList = new ArrayList<String>();
+        ArrayList<String> matchList = new ArrayList<>();
         Matcher m = matcher(input);
 
         // Add segments before each match found
@@ -1566,7 +1566,7 @@
 
     Map<String, Integer> namedGroups() {
         if (namedGroups == null)
-            namedGroups = new HashMap<String, Integer>(2);
+            namedGroups = new HashMap<>(2);
         return namedGroups;
     }
 
@@ -5309,7 +5309,7 @@
         }
 
         private static final HashMap<String, CharPropertyFactory> map
-            = new HashMap<String, CharPropertyFactory>();
+            = new HashMap<>();
 
         static {
             // Unicode character property aliases, defined in
--- a/jdk/src/share/classes/java/util/zip/Inflater.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/zip/Inflater.java	Wed Jan 19 21:51:10 2011 -0800
@@ -382,6 +382,12 @@
             throw new NullPointerException("Inflater has been closed");
     }
 
+    boolean ended() {
+        synchronized (zsRef) {
+            return zsRef.address() == 0;
+        }
+    }
+
     private native static void initIDs();
     private native static long init(boolean nowrap);
     private native static void setDictionary(long addr, byte[] b, int off,
--- a/jdk/src/share/classes/java/util/zip/ZipFile.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/zip/ZipFile.java	Wed Jan 19 21:51:10 2011 -0800
@@ -424,6 +424,8 @@
      */
     private void releaseInflater(Inflater inf) {
         synchronized (inflaters) {
+            if (inf.ended())
+                return;
             inf.reset();
             inflaters.add(inf);
         }
@@ -543,7 +545,7 @@
 
             if (streams.size() !=0) {
                 Set<InputStream> copy = streams;
-                streams = new HashSet<InputStream>();
+                streams = new HashSet<>();
                 for (InputStream is: copy)
                     is.close();
             }
--- a/jdk/src/share/classes/java/util/zip/ZipOutputStream.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/java/util/zip/ZipOutputStream.java	Wed Jan 19 21:51:10 2011 -0800
@@ -52,8 +52,8 @@
     }
 
     private XEntry current;
-    private Vector<XEntry> xentries = new Vector<XEntry>();
-    private HashSet<String> names = new HashSet<String>();
+    private Vector<XEntry> xentries = new Vector<>();
+    private HashSet<String> names = new HashSet<>();
     private CRC32 crc = new CRC32();
     private long written = 0;
     private long locoff = 0;
--- a/jdk/src/share/classes/javax/net/ssl/X509ExtendedTrustManager.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/javax/net/ssl/X509ExtendedTrustManager.java	Wed Jan 19 21:51:10 2011 -0800
@@ -63,7 +63,7 @@
      * should be "RSA". Checking is case-sensitive.
      * <p>
      * If the <code>socket</code> parameter is an instance of
-     * {@link javax.net.SSLSocket}, and the endpoint identification
+     * {@link javax.net.ssl.SSLSocket}, and the endpoint identification
      * algorithm of the <code>SSLParameters</code> is non-empty, to prevent
      * man-in-the-middle attacks, the address that the <code>socket</code>
      * connected to should be checked against the peer's identity presented
@@ -71,7 +71,7 @@
      * identification algorithm.
      * <p>
      * If the <code>socket</code> parameter is an instance of
-     * {@link javax.net.SSLSocket}, and the algorithm constraints of the
+     * {@link javax.net.ssl.SSLSocket}, and the algorithm constraints of the
      * <code>SSLParameters</code> is non-null, for every certificate in the
      * certification path, fields such as subject public key, the signature
      * algorithm, key usage, extended key usage, etc. need to conform to the
@@ -88,8 +88,8 @@
      * @throws CertificateException if the certificate chain is not trusted
      *        by this TrustManager
      *
-     * @see SSLParameters#getEndpointIdentificationProtocol
-     * @see SSLParameters#setEndpointIdentificationProtocol(String)
+     * @see SSLParameters#getEndpointIdentificationAlgorithm
+     * @see SSLParameters#setEndpointIdentificationAlgorithm(String)
      * @see SSLParameters#getAlgorithmConstraints
      * @see SSLParameters#setAlgorithmConstraints(AlgorithmConstraints)
      */
@@ -111,7 +111,7 @@
      * certificate is used. Checking is case-sensitive.
      * <p>
      * If the <code>socket</code> parameter is an instance of
-     * {@link javax.net.SSLSocket}, and the endpoint identification
+     * {@link javax.net.ssl.SSLSocket}, and the endpoint identification
      * algorithm of the <code>SSLParameters</code> is non-empty, to prevent
      * man-in-the-middle attacks, the address that the <code>socket</code>
      * connected to should be checked against the peer's identity presented
@@ -119,7 +119,7 @@
      * identification algorithm.
      * <p>
      * If the <code>socket</code> parameter is an instance of
-     * {@link javax.net.SSLSocket}, and the algorithm constraints of the
+     * {@link javax.net.ssl.SSLSocket}, and the algorithm constraints of the
      *  <code>SSLParameters</code> is non-null, for every certificate in the
      * certification path, fields such as subject public key, the signature
      * algorithm, key usage, extended key usage, etc. need to conform to the
@@ -136,8 +136,8 @@
      * @throws CertificateException if the certificate chain is not trusted
      *        by this TrustManager
      *
-     * @see SSLParameters#getEndpointIdentificationProtocol
-     * @see SSLParameters#setEndpointIdentificationProtocol(String)
+     * @see SSLParameters#getEndpointIdentificationAlgorithm
+     * @see SSLParameters#setEndpointIdentificationAlgorithm(String)
      * @see SSLParameters#getAlgorithmConstraints
      * @see SSLParameters#setAlgorithmConstraints(AlgorithmConstraints)
      */
@@ -177,8 +177,8 @@
      * @throws CertificateException if the certificate chain is not trusted
      *        by this TrustManager
      *
-     * @see SSLParameters#getEndpointIdentificationProtocol
-     * @see SSLParameters#setEndpointIdentificationProtocol(String)
+     * @see SSLParameters#getEndpointIdentificationAlgorithm
+     * @see SSLParameters#setEndpointIdentificationAlgorithm(String)
      * @see SSLParameters#getAlgorithmConstraints
      * @see SSLParameters#setAlgorithmConstraints(AlgorithmConstraints)
      */
@@ -223,8 +223,8 @@
      * @throws CertificateException if the certificate chain is not trusted
      *        by this TrustManager
      *
-     * @see SSLParameters#getEndpointIdentificationProtocol
-     * @see SSLParameters#setEndpointIdentificationProtocol(String)
+     * @see SSLParameters#getEndpointIdentificationAlgorithm
+     * @see SSLParameters#setEndpointIdentificationAlgorithm(String)
      * @see SSLParameters#getAlgorithmConstraints
      * @see SSLParameters#setAlgorithmConstraints(AlgorithmConstraints)
      */
--- a/jdk/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/javax/print/attribute/standard/DialogTypeSelection.java	Wed Jan 19 21:51:10 2011 -0800
@@ -52,6 +52,8 @@
 public final class DialogTypeSelection extends EnumSyntax
         implements PrintRequestAttribute {
 
+    private static final long serialVersionUID = 7518682952133256029L;
+
     /**
      *
      */
--- a/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/javax/swing/DefaultDesktopManager.java	Wed Jan 19 21:51:10 2011 -0800
@@ -359,7 +359,22 @@
                         f.getWidth()-1, f.getHeight()-1);
               }
               g.drawRect( newX, newY, f.getWidth()-1, f.getHeight()-1);
-              currentLoc = new Point (newX, newY);
+              /* Work around for 6635462: XOR mode may cause a SurfaceLost on first use.
+              * Swing doesn't expect that its XOR drawRect did
+              * not complete, so believes that on re-entering at
+              * the next update location, that there is an XOR rect
+              * to draw out at "currentLoc". But in fact
+              * its now got a new clean surface without that rect,
+              * so drawing it "out" in fact draws it on, leaving garbage.
+              * So only update/set currentLoc if the draw completed.
+              */
+              sun.java2d.SurfaceData sData =
+                  ((sun.java2d.SunGraphics2D)g).getSurfaceData();
+
+              if (!sData.isSurfaceLost()) {
+                  currentLoc = new Point (newX, newY);
+              }
+;
               g.dispose();
             }
         } else if (dragMode == FASTER_DRAG_MODE) {
@@ -412,7 +427,14 @@
                 g.drawRect( currentBounds.x, currentBounds.y, currentBounds.width-1, currentBounds.height-1);
               }
               g.drawRect( newX, newY, newWidth-1, newHeight-1);
-              currentBounds = new Rectangle (newX, newY, newWidth, newHeight);
+
+              // Work around for 6635462, see comment in dragFrame()
+              sun.java2d.SurfaceData sData =
+                  ((sun.java2d.SunGraphics2D)g).getSurfaceData();
+              if (!sData.isSurfaceLost()) {
+                  currentBounds = new Rectangle (newX, newY, newWidth, newHeight);
+              }
+
               g.setPaintMode();
               g.dispose();
             }
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Wed Jan 19 21:51:10 2011 -0800
@@ -102,26 +102,6 @@
     public final static int MAX_BUTTONS_SUPPORTED = 20;
 
     public SunToolkit() {
-        /* If awt.threadgroup is set to class name the instance of
-         * this class is created (should be subclass of ThreadGroup)
-         * and EventDispatchThread is created inside of it
-         *
-         * If loaded class overrides uncaughtException instance
-         * handles all uncaught exception on EventDispatchThread
-         */
-        ThreadGroup threadGroup = null;
-        String tgName = System.getProperty("awt.threadgroup", "");
-
-        if (tgName.length() != 0) {
-            try {
-                Constructor ctor = Class.forName(tgName).
-                    getConstructor(new Class[] {String.class});
-                threadGroup = (ThreadGroup)ctor.newInstance(new Object[] {"AWT-ThreadGroup"});
-            } catch (Exception e) {
-                System.err.println("Failed loading " + tgName + ": " + e);
-            }
-        }
-
         Runnable initEQ = new Runnable() {
             public void run () {
                 EventQueue eventQueue;
@@ -144,17 +124,7 @@
             }
         };
 
-        if (threadGroup != null) {
-            Thread eqInitThread = new Thread(threadGroup, initEQ, "EventQueue-Init");
-            eqInitThread.start();
-            try {
-                eqInitThread.join();
-            } catch (InterruptedException e) {
-                e.printStackTrace();
-            }
-        } else {
-            initEQ.run();
-        }
+        initEQ.run();
     }
 
     public boolean useBufferPerWindow() {
--- a/jdk/src/share/classes/sun/dc/DuctusRenderingEngine.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/dc/DuctusRenderingEngine.java	Wed Jan 19 21:51:10 2011 -0800
@@ -635,6 +635,88 @@
         return r;
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public AATileGenerator getAATileGenerator(double x, double y,
+                                              double dx1, double dy1,
+                                              double dx2, double dy2,
+                                              double lw1, double lw2,
+                                              Region clip,
+                                              int bbox[])
+    {
+        // REMIND: Deal with large coordinates!
+        double ldx1, ldy1, ldx2, ldy2;
+        boolean innerpgram = (lw1 > 0 && lw2 > 0);
+
+        if (innerpgram) {
+            ldx1 = dx1 * lw1;
+            ldy1 = dy1 * lw1;
+            ldx2 = dx2 * lw2;
+            ldy2 = dy2 * lw2;
+            x -= (ldx1 + ldx2) / 2.0;
+            y -= (ldy1 + ldy2) / 2.0;
+            dx1 += ldx1;
+            dy1 += ldy1;
+            dx2 += ldx2;
+            dy2 += ldy2;
+            if (lw1 > 1 && lw2 > 1) {
+                // Inner parallelogram was entirely consumed by stroke...
+                innerpgram = false;
+            }
+        } else {
+            ldx1 = ldy1 = ldx2 = ldy2 = 0;
+        }
+
+        Rasterizer r = getRasterizer();
+
+        r.setUsage(Rasterizer.EOFILL);
+
+        r.beginPath();
+        r.beginSubpath((float) x, (float) y);
+        r.appendLine((float) (x+dx1), (float) (y+dy1));
+        r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
+        r.appendLine((float) (x+dx2), (float) (y+dy2));
+        r.closedSubpath();
+        if (innerpgram) {
+            x += ldx1 + ldx2;
+            y += ldy1 + ldy2;
+            dx1 -= 2.0 * ldx1;
+            dy1 -= 2.0 * ldy1;
+            dx2 -= 2.0 * ldx2;
+            dy2 -= 2.0 * ldy2;
+            r.beginSubpath((float) x, (float) y);
+            r.appendLine((float) (x+dx1), (float) (y+dy1));
+            r.appendLine((float) (x+dx1+dx2), (float) (y+dy1+dy2));
+            r.appendLine((float) (x+dx2), (float) (y+dy2));
+            r.closedSubpath();
+        }
+
+        try {
+            r.endPath();
+            r.getAlphaBox(bbox);
+            clip.clipBoxToBounds(bbox);
+            if (bbox[0] >= bbox[2] || bbox[1] >= bbox[3]) {
+                dropRasterizer(r);
+                return null;
+            }
+            r.setOutputArea(bbox[0], bbox[1],
+                            bbox[2] - bbox[0],
+                            bbox[3] - bbox[1]);
+        } catch (PRException e) {
+            /*
+             * This exeption is thrown from the native part of the Ductus
+             * (only in case of a debug build) to indicate that some
+             * segments of the path have very large coordinates.
+             * See 4485298 for more info.
+             */
+            System.err.println("DuctusRenderingEngine.getAATileGenerator: "+e);
+        }
+
+        return r;
+    }
+
     private void feedConsumer(PathConsumer consumer, PathIterator pi) {
         try {
             consumer.beginPath();
--- a/jdk/src/share/classes/sun/font/FileFontStrike.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/font/FileFontStrike.java	Wed Jan 19 21:51:10 2011 -0800
@@ -58,10 +58,10 @@
     private static final int SEGINTARRAY   = 3;
     private static final int SEGLONGARRAY  = 4;
 
-    private int glyphCacheFormat = UNINITIALISED;
+    private volatile int glyphCacheFormat = UNINITIALISED;
 
-    /* segmented arrays are blocks of 256 */
-    private static final int SEGSHIFT = 8;
+    /* segmented arrays are blocks of 32 */
+    private static final int SEGSHIFT = 5;
     private static final int SEGSIZE  = 1 << SEGSHIFT;
 
     private boolean segmentedCache;
@@ -171,7 +171,7 @@
         mapper = fileFont.getMapper();
         int numGlyphs = mapper.getNumGlyphs();
 
-        /* Always segment for fonts with > 2K glyphs, but also for smaller
+        /* Always segment for fonts with > 256 glyphs, but also for smaller
          * fonts with non-typical sizes and transforms.
          * Segmenting for all non-typical pt sizes helps to minimise memory
          * usage when very many distinct strikes are created.
@@ -522,32 +522,33 @@
     }
 
     /* Called only from synchronized code or constructor */
-    private void initGlyphCache() {
+    private synchronized void initGlyphCache() {
 
         int numGlyphs = mapper.getNumGlyphs();
-
+        int tmpFormat = UNINITIALISED;
         if (segmentedCache) {
             int numSegments = (numGlyphs + SEGSIZE-1)/SEGSIZE;
             if (longAddresses) {
-                glyphCacheFormat = SEGLONGARRAY;
+                tmpFormat = SEGLONGARRAY;
                 segLongGlyphImages = new long[numSegments][];
                 this.disposer.segLongGlyphImages = segLongGlyphImages;
              } else {
-                 glyphCacheFormat = SEGINTARRAY;
+                 tmpFormat = SEGINTARRAY;
                  segIntGlyphImages = new int[numSegments][];
                  this.disposer.segIntGlyphImages = segIntGlyphImages;
              }
         } else {
             if (longAddresses) {
-                glyphCacheFormat = LONGARRAY;
+                tmpFormat = LONGARRAY;
                 longGlyphImages = new long[numGlyphs];
                 this.disposer.longGlyphImages = longGlyphImages;
             } else {
-                glyphCacheFormat = INTARRAY;
+                tmpFormat = INTARRAY;
                 intGlyphImages = new int[numGlyphs];
                 this.disposer.intGlyphImages = intGlyphImages;
             }
         }
+        glyphCacheFormat = tmpFormat;
     }
 
     float getGlyphAdvance(int glyphCode) {
--- a/jdk/src/share/classes/sun/font/Font2D.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/font/Font2D.java	Wed Jan 19 21:51:10 2011 -0800
@@ -343,7 +343,21 @@
             }
             strike = createStrike(desc);
             //StrikeCache.addStrike();
-            strikeRef = StrikeCache.getStrikeRef(strike);
+            /* If we are creating many strikes on this font which
+             * involve non-quadrant rotations, or more general
+             * transforms which include shears, then force the use
+             * of weak references rather than soft references.
+             * This means that it won't live much beyond the next GC,
+             * which is what we want for what is likely a transient strike.
+             */
+            int txType = desc.glyphTx.getType();
+            if (txType == AffineTransform.TYPE_GENERAL_TRANSFORM ||
+                (txType & AffineTransform.TYPE_GENERAL_ROTATION) != 0 &&
+                strikeCache.size() > 10) {
+                strikeRef = StrikeCache.getStrikeRef(strike, true);
+            } else {
+                strikeRef = StrikeCache.getStrikeRef(strike);
+            }
             strikeCache.put(desc, strikeRef);
             //strike.lastlookupTime = System.currentTimeMillis();
             lastFontStrike = new SoftReference(strike);
--- a/jdk/src/share/classes/sun/io/Converters.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/io/Converters.java	Wed Jan 19 21:51:10 2011 -0800
@@ -120,7 +120,7 @@
 
     private static Class<?> cache(int type, Object encoding, Class<?> c) {
         SoftReference<Object[]>[] srs = classCache[type];
-        srs[CACHE_SIZE - 1] = new SoftReference<Object[]>(new Object[] { c, encoding });
+        srs[CACHE_SIZE - 1] = new SoftReference<>(new Object[] { c, encoding });
         moveToFront(srs, CACHE_SIZE - 1);
         return c;
     }
--- a/jdk/src/share/classes/sun/java2d/SurfaceData.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/java2d/SurfaceData.java	Wed Jan 19 21:51:10 2011 -0800
@@ -367,16 +367,17 @@
     public static final TextPipe aaTextRenderer;
     public static final TextPipe lcdTextRenderer;
 
-    protected static final CompositePipe colorPipe;
+    protected static final AlphaColorPipe colorPipe;
     protected static final PixelToShapeConverter colorViaShape;
     protected static final PixelToParallelogramConverter colorViaPgram;
     protected static final TextPipe colorText;
     protected static final CompositePipe clipColorPipe;
     protected static final TextPipe clipColorText;
     protected static final AAShapePipe AAColorShape;
-    protected static final PixelToShapeConverter AAColorViaShape;
+    protected static final PixelToParallelogramConverter AAColorViaShape;
+    protected static final PixelToParallelogramConverter AAColorViaPgram;
     protected static final AAShapePipe AAClipColorShape;
-    protected static final PixelToShapeConverter AAClipColorViaShape;
+    protected static final PixelToParallelogramConverter AAClipColorViaShape;
 
     protected static final CompositePipe paintPipe;
     protected static final SpanShapeRenderer paintShape;
@@ -385,9 +386,9 @@
     protected static final CompositePipe clipPaintPipe;
     protected static final TextPipe clipPaintText;
     protected static final AAShapePipe AAPaintShape;
-    protected static final PixelToShapeConverter AAPaintViaShape;
+    protected static final PixelToParallelogramConverter AAPaintViaShape;
     protected static final AAShapePipe AAClipPaintShape;
-    protected static final PixelToShapeConverter AAClipPaintViaShape;
+    protected static final PixelToParallelogramConverter AAClipPaintViaShape;
 
     protected static final CompositePipe compPipe;
     protected static final SpanShapeRenderer compShape;
@@ -396,9 +397,9 @@
     protected static final CompositePipe clipCompPipe;
     protected static final TextPipe clipCompText;
     protected static final AAShapePipe AACompShape;
-    protected static final PixelToShapeConverter AACompViaShape;
+    protected static final PixelToParallelogramConverter AACompViaShape;
     protected static final AAShapePipe AAClipCompShape;
-    protected static final PixelToShapeConverter AAClipCompViaShape;
+    protected static final PixelToParallelogramConverter AAClipCompViaShape;
 
     protected static final DrawImagePipe imagepipe;
 
@@ -427,6 +428,22 @@
         }
     }
 
+    private static PixelToParallelogramConverter
+        makeConverter(AAShapePipe renderer,
+                      ParallelogramPipe pgrampipe)
+    {
+        return new PixelToParallelogramConverter(renderer,
+                                                 pgrampipe,
+                                                 1.0/8.0, 0.499,
+                                                 false);
+    }
+
+    private static PixelToParallelogramConverter
+        makeConverter(AAShapePipe renderer)
+    {
+        return makeConverter(renderer, renderer);
+    }
+
     static {
         colorPrimitives = new LoopPipe();
 
@@ -445,9 +462,10 @@
         clipColorPipe = new SpanClipRenderer(colorPipe);
         clipColorText = new TextRenderer(clipColorPipe);
         AAColorShape = new AAShapePipe(colorPipe);
-        AAColorViaShape = new PixelToShapeConverter(AAColorShape);
+        AAColorViaShape = makeConverter(AAColorShape);
+        AAColorViaPgram = makeConverter(AAColorShape, colorPipe);
         AAClipColorShape = new AAShapePipe(clipColorPipe);
-        AAClipColorViaShape = new PixelToShapeConverter(AAClipColorShape);
+        AAClipColorViaShape = makeConverter(AAClipColorShape);
 
         paintPipe = new AlphaPaintPipe();
         paintShape = new SpanShapeRenderer.Composite(paintPipe);
@@ -456,9 +474,9 @@
         clipPaintPipe = new SpanClipRenderer(paintPipe);
         clipPaintText = new TextRenderer(clipPaintPipe);
         AAPaintShape = new AAShapePipe(paintPipe);
-        AAPaintViaShape = new PixelToShapeConverter(AAPaintShape);
+        AAPaintViaShape = makeConverter(AAPaintShape);
         AAClipPaintShape = new AAShapePipe(clipPaintPipe);
-        AAClipPaintViaShape = new PixelToShapeConverter(AAClipPaintShape);
+        AAClipPaintViaShape = makeConverter(AAClipPaintShape);
 
         compPipe = new GeneralCompositePipe();
         compShape = new SpanShapeRenderer.Composite(compPipe);
@@ -467,9 +485,9 @@
         clipCompPipe = new SpanClipRenderer(compPipe);
         clipCompText = new TextRenderer(clipCompPipe);
         AACompShape = new AAShapePipe(compPipe);
-        AACompViaShape = new PixelToShapeConverter(AACompShape);
+        AACompViaShape = makeConverter(AACompShape);
         AAClipCompShape = new AAShapePipe(clipCompPipe);
-        AAClipCompViaShape = new PixelToShapeConverter(AAClipCompShape);
+        AAClipCompViaShape = makeConverter(AAClipCompShape);
 
         imagepipe = new DrawImage();
     }
@@ -591,12 +609,12 @@
                 if (sg2d.clipState == sg2d.CLIP_SHAPE) {
                     sg2d.drawpipe = AAClipCompViaShape;
                     sg2d.fillpipe = AAClipCompViaShape;
-                    sg2d.shapepipe = AAClipCompShape;
+                    sg2d.shapepipe = AAClipCompViaShape;
                     sg2d.textpipe = clipCompText;
                 } else {
                     sg2d.drawpipe = AACompViaShape;
                     sg2d.fillpipe = AACompViaShape;
-                    sg2d.shapepipe = AACompShape;
+                    sg2d.shapepipe = AACompViaShape;
                     sg2d.textpipe = compText;
                 }
             } else {
@@ -616,13 +634,17 @@
                 if (sg2d.clipState == sg2d.CLIP_SHAPE) {
                     sg2d.drawpipe = AAClipColorViaShape;
                     sg2d.fillpipe = AAClipColorViaShape;
-                    sg2d.shapepipe = AAClipColorShape;
+                    sg2d.shapepipe = AAClipColorViaShape;
                     sg2d.textpipe = clipColorText;
                 } else {
-                    sg2d.drawpipe = AAColorViaShape;
-                    sg2d.fillpipe = AAColorViaShape;
-                    sg2d.shapepipe = AAColorShape;
-                    if (sg2d.paintState > sg2d.PAINT_OPAQUECOLOR ||
+                    PixelToParallelogramConverter converter =
+                        (sg2d.alphafill.canDoParallelograms()
+                         ? AAColorViaPgram
+                         : AAColorViaShape);
+                    sg2d.drawpipe = converter;
+                    sg2d.fillpipe = converter;
+                    sg2d.shapepipe = converter;
+                    if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR ||
                         sg2d.compositeState > sg2d.COMP_ISCOPY)
                     {
                         sg2d.textpipe = colorText;
@@ -634,12 +656,12 @@
                 if (sg2d.clipState == sg2d.CLIP_SHAPE) {
                     sg2d.drawpipe = AAClipPaintViaShape;
                     sg2d.fillpipe = AAClipPaintViaShape;
-                    sg2d.shapepipe = AAClipPaintShape;
+                    sg2d.shapepipe = AAClipPaintViaShape;
                     sg2d.textpipe = clipPaintText;
                 } else {
                     sg2d.drawpipe = AAPaintViaShape;
                     sg2d.fillpipe = AAPaintViaShape;
-                    sg2d.shapepipe = AAPaintShape;
+                    sg2d.shapepipe = AAPaintViaShape;
                     sg2d.textpipe = paintText;
                 }
             }
@@ -793,6 +815,18 @@
         }
     }
 
+    private static CompositeType getFillCompositeType(SunGraphics2D sg2d) {
+        CompositeType compType = sg2d.imageComp;
+        if (sg2d.compositeState == sg2d.COMP_ISCOPY) {
+            if (compType == CompositeType.SrcOverNoEa) {
+                compType = CompositeType.OpaqueSrcOverNoEa;
+            } else {
+                compType = CompositeType.SrcNoEa;
+            }
+        }
+        return compType;
+    }
+
     /**
      * Returns a MaskFill object that can be used on this destination
      * with the source (paint) and composite types determined by the given
@@ -802,9 +836,10 @@
      * surface) before returning a specific MaskFill object.
      */
     protected MaskFill getMaskFill(SunGraphics2D sg2d) {
-        return MaskFill.getFromCache(getPaintSurfaceType(sg2d),
-                                     sg2d.imageComp,
-                                     getSurfaceType());
+        SurfaceType src = getPaintSurfaceType(sg2d);
+        CompositeType comp = getFillCompositeType(sg2d);
+        SurfaceType dst = getSurfaceType();
+        return MaskFill.getFromCache(src, comp, dst);
     }
 
     private static RenderCache loopcache = new RenderCache(30);
@@ -816,9 +851,7 @@
      */
     public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
         SurfaceType src = getPaintSurfaceType(sg2d);
-        CompositeType comp = (sg2d.compositeState == sg2d.COMP_ISCOPY
-                              ? CompositeType.SrcNoEa
-                              : sg2d.imageComp);
+        CompositeType comp = getFillCompositeType(sg2d);
         SurfaceType dst = sg2d.getSurfaceData().getSurfaceType();
 
         Object o = loopcache.get(src, comp, dst);
--- a/jdk/src/share/classes/sun/java2d/loops/CompositeType.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/java2d/loops/CompositeType.java	Wed Jan 19 21:51:10 2011 -0800
@@ -27,6 +27,7 @@
 
 import java.awt.image.BufferedImage;
 import java.awt.AlphaComposite;
+import java.util.HashMap;
 
 /**
  * A CompositeType object provides a chained description of a type of
@@ -51,6 +52,11 @@
  * the indicated algorithm if all of the more specific searches fail.
  */
 public final class CompositeType {
+
+    private static int unusedUID = 1;
+    private static final HashMap<String,Integer> compositeUIDMap =
+        new HashMap<String,Integer>(100);
+
     /*
      * CONSTANTS USED BY ALL PRIMITIVES TO DESCRIBE THE COMPOSITING
      * ALGORITHMS THEY CAN PERFORM
@@ -153,6 +159,22 @@
         SrcOverNoEa   = SrcOver.deriveSubType(DESC_SRC_OVER_NO_EA);
 
     /*
+     * A special CompositeType for the case where we are filling in
+     * SrcOverNoEa mode with an opaque color.  In that case then the
+     * best loop for us to use would be a SrcNoEa loop, but what if
+     * there is no such loop?  In that case then we would end up
+     * backing off to a Src loop (which should still be fine) or an
+     * AnyAlpha loop which would be slower than a SrcOver loop in
+     * most cases.
+     * The fix is to use the following chain which looks for loops
+     * in the following order:
+     *    SrcNoEa, Src, SrcOverNoEa, SrcOver, AnyAlpha
+     */
+    public static final CompositeType
+        OpaqueSrcOverNoEa = SrcOverNoEa.deriveSubType(DESC_SRC)
+                                       .deriveSubType(DESC_SRC_NO_EA);
+
+    /*
      * END OF CompositeType OBJECTS FOR THE VARIOUS CONSTANTS
      */
 
@@ -210,7 +232,6 @@
         }
     }
 
-    private static int unusedUID = 1;
     private int uniqueID;
     private String desc;
     private CompositeType next;
@@ -218,14 +239,20 @@
     private CompositeType(CompositeType parent, String desc) {
         next = parent;
         this.desc = desc;
-        this.uniqueID = makeUniqueID();
+        this.uniqueID = makeUniqueID(desc);
     }
 
-    private synchronized static final int makeUniqueID() {
-        if (unusedUID > 255) {
-            throw new InternalError("composite type id overflow");
+    public synchronized static final int makeUniqueID(String desc) {
+        Integer i = compositeUIDMap.get(desc);
+
+        if (i == null) {
+            if (unusedUID > 255) {
+                throw new InternalError("composite type id overflow");
+            }
+            i = unusedUID++;
+            compositeUIDMap.put(desc, i);
         }
-        return unusedUID++;
+        return i;
     }
 
     public int getUniqueID() {
--- a/jdk/src/share/classes/sun/java2d/loops/MaskFill.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/java2d/loops/MaskFill.java	Wed Jan 19 21:51:10 2011 -0800
@@ -50,6 +50,10 @@
 public class MaskFill extends GraphicsPrimitive
 {
     public static final String methodSignature = "MaskFill(...)".toString();
+    public static final String fillPgramSignature =
+        "FillAAPgram(...)".toString();
+    public static final String drawPgramSignature =
+        "DrawAAPgram(...)".toString();
 
     public static final int primTypeID = makePrimTypeID();
 
@@ -92,6 +96,14 @@
         return fill;
     }
 
+    protected MaskFill(String alternateSignature,
+                       SurfaceType srctype,
+                       CompositeType comptype,
+                       SurfaceType dsttype)
+    {
+        super(alternateSignature, primTypeID, srctype, comptype, dsttype);
+    }
+
     protected MaskFill(SurfaceType srctype,
                        CompositeType comptype,
                        SurfaceType dsttype)
@@ -115,6 +127,23 @@
                                 int x, int y, int w, int h,
                                 byte[] mask, int maskoff, int maskscan);
 
+    public native void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData,
+                                   Composite comp,
+                                   double x, double y,
+                                   double dx1, double dy1,
+                                   double dx2, double dy2);
+
+    public native void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData,
+                                   Composite comp,
+                                   double x, double y,
+                                   double dx1, double dy1,
+                                   double dx2, double dy2,
+                                   double lw1, double lw2);
+
+    public boolean canDoParallelograms() {
+        return (getNativePrim() != 0);
+    }
+
     static {
         GraphicsPrimitiveMgr.registerGeneral(new MaskFill(null, null, null));
     }
@@ -182,12 +211,22 @@
 
     private static class TraceMaskFill extends MaskFill {
         MaskFill target;
+        MaskFill fillPgramTarget;
+        MaskFill drawPgramTarget;
 
         public TraceMaskFill(MaskFill target) {
             super(target.getSourceType(),
                   target.getCompositeType(),
                   target.getDestType());
             this.target = target;
+            this.fillPgramTarget = new MaskFill(fillPgramSignature,
+                                                target.getSourceType(),
+                                                target.getCompositeType(),
+                                                target.getDestType());
+            this.drawPgramTarget = new MaskFill(drawPgramSignature,
+                                                target.getSourceType(),
+                                                target.getCompositeType(),
+                                                target.getDestType());
         }
 
         public GraphicsPrimitive traceWrap() {
@@ -203,5 +242,32 @@
             target.MaskFill(sg2d, sData, comp, x, y, w, h,
                             mask, maskoff, maskscan);
         }
+
+        public void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData,
+                                Composite comp,
+                                double x, double y,
+                                double dx1, double dy1,
+                                double dx2, double dy2)
+        {
+            tracePrimitive(fillPgramTarget);
+            target.FillAAPgram(sg2d, sData, comp,
+                               x, y, dx1, dy1, dx2, dy2);
+        }
+
+        public void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData,
+                                Composite comp,
+                                double x, double y,
+                                double dx1, double dy1,
+                                double dx2, double dy2,
+                                double lw1, double lw2)
+        {
+            tracePrimitive(drawPgramTarget);
+            target.DrawAAPgram(sg2d, sData, comp,
+                               x, y, dx1, dy1, dx2, dy2, lw1, lw2);
+        }
+
+        public boolean canDoParallelograms() {
+            return target.canDoParallelograms();
+        }
     }
 }
--- a/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java	Wed Jan 19 21:51:10 2011 -0800
@@ -28,6 +28,7 @@
 import java.awt.BasicStroke;
 import java.awt.Rectangle;
 import java.awt.Shape;
+import java.awt.geom.Rectangle2D;
 import java.awt.geom.PathIterator;
 import sun.awt.SunHints;
 import sun.java2d.SunGraphics2D;
@@ -39,7 +40,9 @@
  * This class sets up the Generator and computes the alpha tiles
  * and then passes them on to a CompositePipe object for painting.
  */
-public class AAShapePipe implements ShapeDrawPipe {
+public class AAShapePipe
+    implements ShapeDrawPipe, ParallelogramPipe
+{
     static RenderingEngine renderengine = RenderingEngine.getInstance();
 
     CompositePipe outpipe;
@@ -65,6 +68,59 @@
         renderPath(sg, s, null);
     }
 
+    private static Rectangle2D computeBBox(double x, double y,
+                                           double dx1, double dy1,
+                                           double dx2, double dy2)
+    {
+        double lox, loy, hix, hiy;
+        lox = hix = x;
+        loy = hiy = y;
+        if (dx1 < 0) { lox += dx1; } else { hix += dx1; }
+        if (dy1 < 0) { loy += dy1; } else { hiy += dy1; }
+        if (dx2 < 0) { lox += dx2; } else { hix += dx2; }
+        if (dy2 < 0) { loy += dy2; } else { hiy += dy2; }
+        return new Rectangle2D.Double(lox, loy, hix-lox, hiy-loy);
+    }
+
+    public void fillParallelogram(SunGraphics2D sg,
+                                  double x, double y,
+                                  double dx1, double dy1,
+                                  double dx2, double dy2)
+    {
+        Region clip = sg.getCompClip();
+        int abox[] = new int[4];
+        AATileGenerator aatg =
+            renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0,
+                                            clip, abox);
+        if (aatg == null) {
+            // Nothing to render
+            return;
+        }
+
+        renderTiles(sg, computeBBox(x, y, dx1, dy1, dx2, dy2), aatg, abox);
+    }
+
+    public void drawParallelogram(SunGraphics2D sg,
+                                  double x, double y,
+                                  double dx1, double dy1,
+                                  double dx2, double dy2,
+                                  double lw1, double lw2)
+    {
+        Region clip = sg.getCompClip();
+        int abox[] = new int[4];
+        AATileGenerator aatg =
+            renderengine.getAATileGenerator(x, y, dx1, dy1, dx2, dy2, 0, 0,
+                                            clip, abox);
+        if (aatg == null) {
+            // Nothing to render
+            return;
+        }
+
+        // Note that bbox is of the original shape, not the wide path.
+        // This is appropriate for handing to Paint methods...
+        renderTiles(sg, computeBBox(x, y, dx1, dy1, dx2, dy2), aatg, abox);
+    }
+
     private static byte[] theTile;
 
     public synchronized static byte[] getAlphaTile(int len) {
@@ -85,8 +141,6 @@
         boolean adjust = (bs != null &&
                           sg.strokeHint != SunHints.INTVAL_STROKE_PURE);
         boolean thin = (sg.strokeState <= sg.STROKE_THINDASHED);
-        Object context = null;
-        byte alpha[] = null;
 
         Region clip = sg.getCompClip();
         int abox[] = new int[4];
@@ -98,6 +152,14 @@
             return;
         }
 
+        renderTiles(sg, s, aatg, abox);
+    }
+
+    public void renderTiles(SunGraphics2D sg, Shape s,
+                            AATileGenerator aatg, int abox[])
+    {
+        Object context = null;
+        byte alpha[] = null;
         try {
             context = outpipe.startSequence(sg, s,
                                             new Rectangle(abox[0], abox[1],
--- a/jdk/src/share/classes/sun/java2d/pipe/AlphaColorPipe.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/java2d/pipe/AlphaColorPipe.java	Wed Jan 19 21:51:10 2011 -0800
@@ -34,7 +34,7 @@
  * into a destination that supports direct alpha compositing of a solid
  * color, according to one of the rules in the AlphaComposite class.
  */
-public class AlphaColorPipe implements CompositePipe {
+public class AlphaColorPipe implements CompositePipe, ParallelogramPipe {
     public AlphaColorPipe() {
     }
 
@@ -64,4 +64,23 @@
     public void endSequence(Object context) {
         return;
     }
+
+    public void fillParallelogram(SunGraphics2D sg,
+                                  double x, double y,
+                                  double dx1, double dy1,
+                                  double dx2, double dy2)
+    {
+        sg.alphafill.FillAAPgram(sg, sg.getSurfaceData(), sg.composite,
+                                 x, y, dx1, dy1, dx2, dy2);
+    }
+
+    public void drawParallelogram(SunGraphics2D sg,
+                                  double x, double y,
+                                  double dx1, double dy1,
+                                  double dx2, double dy2,
+                                  double lw1, double lw2)
+    {
+        sg.alphafill.DrawAAPgram(sg, sg.getSurfaceData(), sg.composite,
+                                 x, y, dx1, dy1, dx2, dy2, lw1, lw2);
+    }
 }
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java	Wed Jan 19 21:51:10 2011 -0800
@@ -281,6 +281,72 @@
                                                        int bbox[]);
 
     /**
+     * Construct an antialiased tile generator for the given parallelogram
+     * store the bounds of the tile iteration in the bbox parameter.
+     * The parallelogram is specified as a starting point and 2 delta
+     * vectors that indicate the slopes of the 2 pairs of sides of the
+     * parallelogram.
+     * The 4 corners of the parallelogram are defined by the 4 points:
+     * <ul>
+     * <li> {@code x}, {@code y}
+     * <li> {@code x+dx1}, {@code y+dy1}
+     * <li> {@code x+dx1+dx2}, {@code y+dy1+dy2}
+     * <li> {@code x+dx2}, {@code y+dy2}
+     * </ul>
+     * The {@code lw1} and {@code lw2} parameters provide a specification
+     * for an optionally stroked parallelogram if they are positive numbers.
+     * The {@code lw1} parameter is the ratio of the length of the {@code dx1},
+     * {@code dx2} delta vector to half of the line width in that same
+     * direction.
+     * The {@code lw2} parameter provides the same ratio for the other delta
+     * vector.
+     * If {@code lw1} and {@code lw2} are both greater than zero, then
+     * the parallelogram figure is doubled by both expanding and contracting
+     * each delta vector by its corresponding {@code lw} value.
+     * If either (@code lw1) or {@code lw2} are also greater than 1, then
+     * the inner (contracted) parallelogram disappears and the figure is
+     * simply a single expanded parallelogram.
+     * The {@code clip} parameter specifies the current clip in effect
+     * in device coordinates and can be used to prune the data for the
+     * operation, but the renderer is not required to perform any
+     * clipping.
+     * <p>
+     * Upon returning, this method will fill the {@code bbox} parameter
+     * with 4 values indicating the bounds of the iteration of the
+     * tile generator.
+     * The iteration order of the tiles will be as specified by the
+     * pseudo-code:
+     * <pre>
+     *     for (y = bbox[1]; y < bbox[3]; y += tileheight) {
+     *         for (x = bbox[0]; x < bbox[2]; x += tilewidth) {
+     *         }
+     *     }
+     * </pre>
+     * If there is no output to be rendered, this method may return
+     * null.
+     *
+     * @param x the X coordinate of the first corner of the parallelogram
+     * @param y the Y coordinate of the first corner of the parallelogram
+     * @param dx1 the X coordinate delta of the first leg of the parallelogram
+     * @param dy1 the Y coordinate delta of the first leg of the parallelogram
+     * @param dx2 the X coordinate delta of the second leg of the parallelogram
+     * @param dy2 the Y coordinate delta of the second leg of the parallelogram
+     * @param lw1 the line width ratio for the first leg of the parallelogram
+     * @param lw2 the line width ratio for the second leg of the parallelogram
+     * @param clip the current clip in effect in device coordinates
+     * @param bbox returns the bounds of the iteration
+     * @return the {@code AATileGenerator} instance to be consulted
+     *         for tile coverages, or null if there is no output to render
+     * @since 1.7
+     */
+    public abstract AATileGenerator getAATileGenerator(double x, double y,
+                                                       double dx1, double dy1,
+                                                       double dx2, double dy2,
+                                                       double lw1, double lw2,
+                                                       Region clip,
+                                                       int bbox[]);
+
+    /**
      * Returns the minimum pen width that the antialiasing rasterizer
      * can represent without dropouts occuring.
      * @since 1.7
@@ -393,5 +459,24 @@
                                              bs, thin, normalize,
                                              bbox);
         }
+        public AATileGenerator getAATileGenerator(double x, double y,
+                                                  double dx1, double dy1,
+                                                  double dx2, double dy2,
+                                                  double lw1, double lw2,
+                                                  Region clip,
+                                                  int bbox[])
+        {
+            System.out.println(name+".getAATileGenerator("+
+                               x+", "+y+", "+
+                               dx1+", "+dy1+", "+
+                               dx2+", "+dy2+", "+
+                               lw1+", "+lw2+", "+
+                               clip+")");
+            return target.getAATileGenerator(x, y,
+                                             dx1, dy1,
+                                             dx2, dy2,
+                                             lw1, lw2,
+                                             clip, bbox);
+        }
     }
 }
--- a/jdk/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/java2d/pisces/PiscesRenderingEngine.java	Wed Jan 19 21:51:10 2011 -0800
@@ -557,6 +557,69 @@
         return ptg;
     }
 
+    public AATileGenerator getAATileGenerator(double x, double y,
+                                              double dx1, double dy1,
+                                              double dx2, double dy2,
+                                              double lw1, double lw2,
+                                              Region clip,
+                                              int bbox[])
+    {
+        // REMIND: Deal with large coordinates!
+        double ldx1, ldy1, ldx2, ldy2;
+        boolean innerpgram = (lw1 > 0 && lw2 > 0);
+
+        if (innerpgram) {
+            ldx1 = dx1 * lw1;
+            ldy1 = dy1 * lw1;
+            ldx2 = dx2 * lw2;
+            ldy2 = dy2 * lw2;
+            x -= (ldx1 + ldx2) / 2.0;
+            y -= (ldy1 + ldy2) / 2.0;
+            dx1 += ldx1;
+            dy1 += ldy1;
+            dx2 += ldx2;
+            dy2 += ldy2;
+            if (lw1 > 1 && lw2 > 1) {
+                // Inner parallelogram was entirely consumed by stroke...
+                innerpgram = false;
+            }
+        } else {
+            ldx1 = ldy1 = ldx2 = ldy2 = 0;
+        }
+
+        Renderer r = new Renderer(3, 3,
+                                  clip.getLoX(), clip.getLoY(),
+                                  clip.getWidth(), clip.getHeight(),
+                                  PathIterator.WIND_EVEN_ODD);
+
+        r.moveTo((float) x, (float) y);
+        r.lineTo((float) (x+dx1), (float) (y+dy1));
+        r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
+        r.lineTo((float) (x+dx2), (float) (y+dy2));
+        r.closePath();
+
+        if (innerpgram) {
+            x += ldx1 + ldx2;
+            y += ldy1 + ldy2;
+            dx1 -= 2.0 * ldx1;
+            dy1 -= 2.0 * ldy1;
+            dx2 -= 2.0 * ldx2;
+            dy2 -= 2.0 * ldy2;
+            r.moveTo((float) x, (float) y);
+            r.lineTo((float) (x+dx1), (float) (y+dy1));
+            r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2));
+            r.lineTo((float) (x+dx2), (float) (y+dy2));
+            r.closePath();
+        }
+
+        r.pathDone();
+
+        r.endRendering();
+        PiscesTileGenerator ptg = new PiscesTileGenerator(r, r.MAX_AA_ALPHA);
+        ptg.getBbox(bbox);
+        return ptg;
+    }
+
     /**
      * Returns the minimum pen width that the antialiasing rasterizer
      * can represent without dropouts occuring.
--- a/jdk/src/share/classes/sun/launcher/LauncherHelper.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/launcher/LauncherHelper.java	Wed Jan 19 21:51:10 2011 -0800
@@ -45,15 +45,18 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.math.BigDecimal;
-import java.math.MathContext;
 import java.math.RoundingMode;
 import java.util.ResourceBundle;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import java.util.Locale.Category;
 import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 import java.util.jar.Manifest;
@@ -73,11 +76,6 @@
     private static final String PROP_SETTINGS   = "Property settings:";
     private static final String LOCALE_SETTINGS = "Locale settings:";
 
-    private static final long K = 1024;
-    private static final long M = K * K;
-    private static final long G = M * K;
-    private static final long T = G * K;
-
     private static synchronized ResourceBundle getLauncherResourceBundle() {
         if (javarb == null) {
             javarb = ResourceBundle.getBundle(defaultBundleName);
@@ -96,14 +94,20 @@
      * optionFlag: specifies which options to print default is all other
      *    possible values are vm, properties, locale.
      *
+     * initialHeapSize: in bytes, as set by the launcher, a zero-value indicates
+     *    this code should determine this value, using a suitable method or
+     *    the line could be omitted.
+     *
      * maxHeapSize: in bytes, as set by the launcher, a zero-value indicates
      *    this code should determine this value, using a suitable method.
      *
      * stackSize: in bytes, as set by the launcher, a zero-value indicates
-     * this code determine this value, using a suitable method.
+     *    this code determine this value, using a suitable method or omit the
+     *    line entirely.
      */
     static void showSettings(boolean printToStderr, String optionFlag,
-            long maxHeapSize, long stackSize, boolean isServer) {
+            long initialHeapSize, long maxHeapSize, long stackSize,
+            boolean isServer) {
 
         PrintStream ostream = (printToStderr) ? System.err : System.out;
         String opts[] = optionFlag.split(":");
@@ -112,7 +116,8 @@
                 : "all";
         switch (optStr) {
             case "vm":
-                printVmSettings(ostream, maxHeapSize, stackSize, isServer);
+                printVmSettings(ostream, initialHeapSize, maxHeapSize,
+                        stackSize, isServer);
                 break;
             case "properties":
                 printProperties(ostream);
@@ -121,7 +126,8 @@
                 printLocale(ostream);
                 break;
             default:
-                printVmSettings(ostream, maxHeapSize, stackSize, isServer);
+                printVmSettings(ostream, initialHeapSize, maxHeapSize,
+                        stackSize, isServer);
                 printProperties(ostream);
                 printLocale(ostream);
                 break;
@@ -131,18 +137,25 @@
     /*
      * prints the main vm settings subopt/section
      */
-    private static void printVmSettings(PrintStream ostream, long maxHeapSize,
+    private static void printVmSettings(PrintStream ostream,
+            long initialHeapSize, long maxHeapSize,
             long stackSize, boolean isServer) {
 
         ostream.println(VM_SETTINGS);
         if (stackSize != 0L) {
-            ostream.println(INDENT + "Stack Size: " + scaleValue(stackSize));
+            ostream.println(INDENT + "Stack Size: " +
+                    SizePrefix.scaleValue(stackSize));
+        }
+        if (initialHeapSize != 0L) {
+             ostream.println(INDENT + "Min. Heap Size: " +
+                    SizePrefix.scaleValue(initialHeapSize));
         }
         if (maxHeapSize != 0L) {
-            ostream.println(INDENT + "Max. Heap Size: " + scaleValue(maxHeapSize));
+            ostream.println(INDENT + "Max. Heap Size: " +
+                    SizePrefix.scaleValue(maxHeapSize));
         } else {
             ostream.println(INDENT + "Max. Heap Size (Estimated): "
-                    + scaleValue(Runtime.getRuntime().maxMemory()));
+                    + SizePrefix.scaleValue(Runtime.getRuntime().maxMemory()));
         }
         ostream.println(INDENT + "Ergonomics Machine Class: "
                 + ((isServer) ? "server" : "client"));
@@ -152,28 +165,6 @@
     }
 
     /*
-     * scale the incoming values to a human readable form, represented as
-     * K, M, G and T, see java.c parse_size for the scaled values and
-     * suffixes.
-     */
-
-    private static String scaleValue(double v) {
-        MathContext mc2 = new MathContext(3, RoundingMode.HALF_EVEN);
-
-        if (v >= K && v < M) {
-            return (new BigDecimal(v / K, mc2)).toPlainString() + "K";
-        } else if (v >= M && v < G) {
-            return (new BigDecimal(v / M, mc2)).toPlainString() + "M";
-        } else if (v >= G && v < T) {
-            return (new BigDecimal(v / G, mc2)).toPlainString() + "G";
-        } else if (v >= T) {
-            return (new BigDecimal(v / T, mc2)).toPlainString() + "T";
-        } else {
-            return String.format("%.0f", v);
-        }
-    }
-
-    /*
      * prints the properties subopt/section
      */
     private static void printProperties(PrintStream ostream) {
@@ -196,16 +187,17 @@
             String key, String value) {
         ostream.print(INDENT + key + " = ");
         if (key.equals("line.separator")) {
-            byte[] bytes = value.getBytes();
-            for (byte b : bytes) {
+            for (byte b : value.getBytes()) {
                 switch (b) {
                     case 0xd:
-                        ostream.print("CR ");
+                        ostream.print("\\r ");
                         break;
                     case 0xa:
-                        ostream.print("LF ");
+                        ostream.print("\\n ");
                         break;
                     default:
+                        // print any bizzare line separators in hex, but really
+                        // shouldn't happen.
                         ostream.printf("0x%02X", b & 0xff);
                         break;
                 }
@@ -217,15 +209,14 @@
             ostream.println(value);
             return;
         }
-        // pretty print the path values as a list
         String[] values = value.split(System.getProperty("path.separator"));
-        int len = values.length;
-        for (int i = 0 ; i < len ; i++) {
-            if (i == 0) { // first line treated specially
-                ostream.println(values[i]);
+        boolean first = true;
+        for (String s : values) {
+            if (first) { // first line treated specially
+                ostream.println(s);
+                first = false;
             } else { // following lines prefix with indents
-                ostream.print(INDENT + INDENT);
-                ostream.println(values[i]);
+                ostream.println(INDENT + INDENT + s);
             }
         }
     }
@@ -236,21 +227,35 @@
     private static void printLocale(PrintStream ostream) {
         Locale locale = Locale.getDefault();
         ostream.println(LOCALE_SETTINGS);
-        ostream.println(INDENT + "default locale = " + locale.getDisplayLanguage());
+        ostream.println(INDENT + "default locale = " +
+                locale.getDisplayLanguage());
+        ostream.println(INDENT + "default display locale = " +
+                Locale.getDefault(Category.DISPLAY).getDisplayName());
+        ostream.println(INDENT + "default format locale = " +
+                Locale.getDefault(Category.FORMAT).getDisplayName());
         printLocales(ostream);
         ostream.println();
     }
 
     private static void printLocales(PrintStream ostream) {
-        Locale[] locales = Locale.getAvailableLocales();
-        final int len = locales == null ? 0 : locales.length;
+        Locale[] tlocales = Locale.getAvailableLocales();
+        final int len = tlocales == null ? 0 : tlocales.length;
         if (len < 1 ) {
             return;
         }
+        // Locale does not implement Comparable so we convert it to String
+        // and sort it for pretty printing.
+        Set<String> sortedSet = new TreeSet<>();
+        for (Locale l : tlocales) {
+            sortedSet.add(l.toString());
+        }
+
         ostream.print(INDENT + "available locales = ");
-        final int last = len - 1 ;
-        for (int i = 0; i < last ; i++) {
-            ostream.print(locales[i]);
+        Iterator<String> iter = sortedSet.iterator();
+        final int last = len - 1;
+        for (int i = 0 ; iter.hasNext() ; i++) {
+            String s = iter.next();
+            ostream.print(s);
             if (i != last) {
                 ostream.print(", ");
             }
@@ -260,7 +265,42 @@
                 ostream.print(INDENT + INDENT);
             }
         }
-        ostream.println(locales[last]);
+    }
+
+    private enum SizePrefix {
+
+        KILO(1024, "K"),
+        MEGA(1024 * 1024, "M"),
+        GIGA(1024 * 1024 * 1024, "G"),
+        TERA(1024L * 1024L * 1024L * 1024L, "T");
+        long size;
+        String abbrev;
+
+        SizePrefix(long size, String abbrev) {
+            this.size = size;
+            this.abbrev = abbrev;
+        }
+
+        private static String scale(long v, SizePrefix prefix) {
+            return BigDecimal.valueOf(v).divide(BigDecimal.valueOf(prefix.size),
+                    2, RoundingMode.HALF_EVEN).toPlainString() + prefix.abbrev;
+        }
+        /*
+         * scale the incoming values to a human readable form, represented as
+         * K, M, G and T, see java.c parse_size for the scaled values and
+         * suffixes. The lowest possible scaled value is Kilo.
+         */
+        static String scaleValue(long v) {
+            if (v < MEGA.size) {
+                return scale(v, KILO);
+            } else if (v < GIGA.size) {
+                return scale(v, MEGA);
+            } else if (v < TERA.size) {
+                return scale(v, GIGA);
+            } else {
+                return scale(v, TERA);
+            }
+        }
     }
 
     /**
--- a/jdk/src/share/classes/sun/security/jgss/krb5/CipherHelper.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/CipherHelper.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -710,29 +710,21 @@
      * where HMAC is on {16-byte confounder | plaintext | 16-byte token_header}
      * HMAC is not encrypted; it is appended at the end.
      */
-    void encryptData(WrapToken_v2 token, byte[] confounder, byte[] tokenHeader,
-        byte[] plaintext, int start, int len, int key_usage, OutputStream os)
-        throws GSSException, IOException {
+    byte[] encryptData(WrapToken_v2 token, byte[] confounder, byte[] tokenHeader,
+            byte[] plaintext, int start, int len, int key_usage)
+            throws GSSException {
 
-        byte[] ctext = null;
         switch (etype) {
-                case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
-                    ctext = aes128Encrypt(confounder, tokenHeader,
-                                plaintext, start, len, key_usage);
-                    break;
-                case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
-                    ctext = aes256Encrypt(confounder, tokenHeader,
-                                plaintext, start, len, key_usage);
-                    break;
-                default:
-                    throw new GSSException(GSSException.FAILURE, -1,
-                        "Unsupported etype: " + etype);
+            case EncryptedData.ETYPE_AES128_CTS_HMAC_SHA1_96:
+                return aes128Encrypt(confounder, tokenHeader,
+                            plaintext, start, len, key_usage);
+            case EncryptedData.ETYPE_AES256_CTS_HMAC_SHA1_96:
+                return aes256Encrypt(confounder, tokenHeader,
+                            plaintext, start, len, key_usage);
+            default:
+                throw new GSSException(GSSException.FAILURE, -1,
+                    "Unsupported etype: " + etype);
         }
-
-        // Krb5Token.debug("EncryptedData = " +
-        //              Krb5Token.getHexBytes(ctext) + "\n");
-        // Write to stream
-        os.write(ctext);
     }
 
     void encryptData(WrapToken token, byte[] confounder, byte[] plaintext,
--- a/jdk/src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/MessageToken_v2.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -26,42 +26,40 @@
 package sun.security.jgss.krb5;
 
 import org.ietf.jgss.*;
-import sun.security.jgss.*;
-import sun.security.krb5.*;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.IOException;
 import java.io.ByteArrayInputStream;
-import java.security.GeneralSecurityException;
+import java.io.ByteArrayOutputStream;
 import java.security.MessageDigest;
+import java.util.Arrays;
 
 /**
  * This class is a base class for new GSS token definitions, as defined
- * in draft-ietf-krb-wg-gssapi-cfx-07.txt, that pertain to per-message
- * GSS-API calls. Conceptually GSS-API has two types of per-message tokens:
- * WrapToken and MicToken. They differ in the respect that a WrapToken
- * carries additional plaintext or ciphertext application data besides
- * just the sequence number and checksum. This class encapsulates the
- * commonality in the structure of the WrapToken and the MicToken.
- * This structure can be represented as:
+ * in RFC 4121, that pertain to per-message GSS-API calls. Conceptually
+ * GSS-API has two types of per-message tokens: WrapToken and MicToken.
+ * They differ in the respect that a WrapToken carries additional plaintext
+ * or ciphertext application data besides just the sequence number and
+ * checksum. This class encapsulates the commonality in the structure of
+ * the WrapToken and the MicToken. This structure can be represented as:
  * <p>
  * <pre>
- *  Wrap Tokens
+ * Wrap Tokens
  *
  *     Octet no   Name        Description
  *    ---------------------------------------------------------------
  *      0..1     TOK_ID     Identification field.  Tokens emitted by
- *                          GSS_Wrap() contain the the hex value 05 04
- *                          expressed in big endian order in this field.
+ *                          GSS_Wrap() contain the hex value 05 04
+ *                          expressed in big-endian order in this field.
  *      2        Flags      Attributes field, as described in section
  *                          4.2.2.
  *      3        Filler     Contains the hex value FF.
- *      4..5     EC         Contains the "extra count" field, in big
+ *      4..5     EC         Contains the "extra count" field, in big-
  *                          endian order as described in section 4.2.3.
  *      6..7     RRC        Contains the "right rotation count" in big
  *                          endian order, as described in section 4.2.5.
  *      8..15    SND_SEQ    Sequence number field in clear text,
- *                          expressed in big endian order.
+ *                          expressed in big-endian order.
  *      16..last Data       Encrypted data for Wrap tokens with
  *                          confidentiality, or plaintext data followed
  *                          by the checksum for Wrap tokens without
@@ -73,67 +71,82 @@
  *     -----------------------------------------------------------------
  *      0..1     TOK_ID     Identification field.  Tokens emitted by
  *                          GSS_GetMIC() contain the hex value 04 04
- *                          expressed in big endian order in this field.
+ *                          expressed in big-endian order in this field.
  *      2        Flags      Attributes field, as described in section
  *                          4.2.2.
  *      3..7     Filler     Contains five octets of hex value FF.
  *      8..15    SND_SEQ    Sequence number field in clear text,
- *                          expressed in big endian order.
+ *                          expressed in big-endian order.
  *      16..last SGN_CKSUM  Checksum of the "to-be-signed" data and
  *                          octet 0..15, as described in section 4.2.4.
  *
  * </pre>
  * <p>
+ * This class is the super class of WrapToken_v2 and MicToken_v2. The token's
+ * header (bytes[0..15]) and data (byte[16..]) are saved in tokenHeader and
+ * tokenData fields. Since there is no easy way to find out the exact length
+ * of a WrapToken_v2 token from any header info, in the case of reading from
+ * stream, we read all available() bytes into the token.
+ * <p>
+ * All read actions are performed in this super class. On the write part, the
+ * super class only write the tokenHeader, and the content writing is inside
+ * child classes.
  *
  * @author Seema Malkani
  */
 
 abstract class MessageToken_v2 extends Krb5Token {
 
+    protected static final int TOKEN_HEADER_SIZE = 16;
     private static final int TOKEN_ID_POS = 0;
     private static final int TOKEN_FLAG_POS = 2;
     private static final int TOKEN_EC_POS = 4;
     private static final int TOKEN_RRC_POS = 6;
 
-    // token header size
-    static final int TOKEN_HEADER_SIZE = 16;
-
-    private int tokenId = 0;
-    private int seqNumber;
-
-    // EC and RRC fields
-    private int ec = 0;
-    private int rrc = 0;
-
-    private boolean confState = true;
-    private boolean initiator = true;
+    /**
+     * The size of the random confounder used in a WrapToken.
+     */
+    protected static final int CONFOUNDER_SIZE = 16;
 
-    byte[] confounder = null;
-    byte[] checksum = null;
-
-    private int key_usage = 0;
-    private byte[] seqNumberData = null;
-
-    private MessageTokenHeader tokenHeader = null;
-
-    /* cipher instance used by the corresponding GSSContext */
-    CipherHelper cipherHelper = null;
-
-    // draft-ietf-krb-wg-gssapi-cfx-07
+    // RFC 4121, key usage values
     static final int KG_USAGE_ACCEPTOR_SEAL = 22;
     static final int KG_USAGE_ACCEPTOR_SIGN = 23;
     static final int KG_USAGE_INITIATOR_SEAL = 24;
     static final int KG_USAGE_INITIATOR_SIGN = 25;
 
-    // draft-ietf-krb-wg-gssapi-cfx-07
+    // RFC 4121, Flags Field
     private static final int FLAG_SENDER_IS_ACCEPTOR = 1;
     private static final int FLAG_WRAP_CONFIDENTIAL  = 2;
     private static final int FLAG_ACCEPTOR_SUBKEY    = 4;
     private static final int FILLER = 0xff;
 
+    private MessageTokenHeader tokenHeader = null;
+
+    // Common field
+    private int tokenId = 0;
+    private int seqNumber;
+    protected byte[] tokenData; // content of token, without the header
+    protected int tokenDataLen;
+
+    // Key usage number for crypto action
+    private int key_usage = 0;
+
+    // EC and RRC fields, WrapToken only
+    private int ec = 0;
+    private int rrc = 0;
+
+    // Checksum. Always in MicToken, might be in WrapToken
+    byte[] checksum = null;
+
+    // Context properties
+    private boolean confState = true;
+    private boolean initiator = true;
+
+    /* cipher instance used by the corresponding GSSContext */
+    CipherHelper cipherHelper = null;
+
     /**
-     * Constructs a MessageToken from a byte array. If there are more bytes
-     * in the array than needed, the extra bytes are simply ignroed.
+     * Constructs a MessageToken from a byte array.
      *
      * @param tokenId the token id that should be contained in this token as
      * it is read.
@@ -156,7 +169,9 @@
     /**
      * Constructs a MessageToken from an InputStream. Bytes will be read on
      * demand and the thread might block if there are not enough bytes to
-     * complete the token.
+     * complete the token. Please note there is no accurate way to find out
+     * the size of a token, but we try our best to make sure there is
+     * enough bytes to construct one.
      *
      * @param tokenId the token id that should be contained in this token as
      * it is read.
@@ -186,25 +201,58 @@
                                 : KG_USAGE_ACCEPTOR_SIGN);
             }
 
-            // Read checksum
-            int tokenLen = is.available();
-            byte[] data = new byte[tokenLen];
-            readFully(is, data);
-            checksum = new byte[cipherHelper.getChecksumLength()];
-            System.arraycopy(data, tokenLen-cipherHelper.getChecksumLength(),
-                        checksum, 0, cipherHelper.getChecksumLength());
-            // debug("\nLeaving MessageToken.Cons\n");
+            int minSize = 0;    // minimal size for token data
+            if (tokenId == Krb5Token.WRAP_ID_v2 && prop.getPrivacy()) {
+                minSize = CONFOUNDER_SIZE +
+                        TOKEN_HEADER_SIZE + cipherHelper.getChecksumLength();
+            } else {
+                minSize = cipherHelper.getChecksumLength();
+            }
 
-            // validate EC for Wrap tokens without confidentiality
-            if (!prop.getPrivacy() &&
-                (tokenId == Krb5Token.WRAP_ID_v2)) {
-                if (checksum.length != ec) {
-                    throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
-                        getTokenName(tokenId) + ":" + "EC incorrect!");
+            // Read token data
+            if (tokenId == Krb5Token.MIC_ID_v2) {
+                // The only case we can precisely predict the token data length
+                tokenDataLen = minSize;
+                tokenData = new byte[minSize];
+                readFully(is, tokenData);
+            } else {
+                tokenDataLen = is.available();
+                if (tokenDataLen >= minSize) {  // read in one shot
+                    tokenData = new byte[tokenDataLen];
+                    readFully(is, tokenData);
+                } else {
+                    byte[] tmp = new byte[minSize];
+                    readFully(is, tmp);
+                    // Hope while blocked in the read above, more data would
+                    // come and is.available() below contains the whole token.
+                    int more = is.available();
+                    tokenDataLen = minSize + more;
+                    tokenData = Arrays.copyOf(tmp, tokenDataLen);
+                    readFully(is, tokenData, minSize, more);
                 }
             }
 
+            if (tokenId == Krb5Token.WRAP_ID_v2) {
+                // Does non-confidential data needs a rotate?
+                rotate();
+            }
 
+            if (tokenId == Krb5Token.MIC_ID_v2 ||
+                    (tokenId == Krb5Token.WRAP_ID_v2 && !prop.getPrivacy())) {
+                // Read checksum
+                int chkLen = cipherHelper.getChecksumLength();
+                checksum = new byte[chkLen];
+                System.arraycopy(tokenData, tokenDataLen-chkLen,
+                        checksum, 0, chkLen);
+
+                // validate EC for Wrap tokens without confidentiality
+                if (tokenId == Krb5Token.WRAP_ID_v2 && !prop.getPrivacy()) {
+                    if (chkLen != ec) {
+                        throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
+                            getTokenName(tokenId) + ":" + "EC incorrect!");
+                    }
+                }
+            }
         } catch (IOException e) {
             throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
                 getTokenName(tokenId) + ":" + e.getMessage());
@@ -263,8 +311,7 @@
             prop.setPrivacy(false);
         }
 
-        // Create a new gss token header as defined in
-        // draft-ietf-krb-wg-gssapi-cfx-07
+        // Create a new gss token header as defined in RFC 4121
         tokenHeader = new MessageTokenHeader(tokenId,
                                 prop.getPrivacy(), true);
         // debug("\n\t Message Header = " +
@@ -326,50 +373,21 @@
      * Rotate bytes as per the "RRC" (Right Rotation Count) received.
      * Our implementation does not do any rotates when sending, only
      * when receiving, we rotate left as per the RRC count, to revert it.
-     *
-     * @return true if bytes are rotated
      */
-    public boolean rotate_left(byte[] in_bytes, int tokenOffset,
-        byte[] out_bytes, int bufsize) {
-
-        int offset = 0;
-        // debug("\nRotate left: (before rotation) in_bytes = [ " +
-        //              getHexBytes(in_bytes, tokenOffset, bufsize) + "]");
-        if (rrc > 0) {
-           if (bufsize == 0) {
-                return false;
-           }
-           rrc = rrc % (bufsize - TOKEN_HEADER_SIZE);
-           if (rrc == 0) {
-                return false;
-           }
+    private void rotate() {
+        if (rrc % tokenDataLen != 0) {
+           rrc = rrc % tokenDataLen;
+           byte[] newBytes = new byte[tokenDataLen];
 
-           // if offset is not zero
-           if (tokenOffset > 0) {
-                offset += tokenOffset;
-           }
-
-           // copy the header
-           System.arraycopy(in_bytes, offset, out_bytes, 0, TOKEN_HEADER_SIZE);
-           offset += TOKEN_HEADER_SIZE;
+           System.arraycopy(tokenData, rrc, newBytes, 0, tokenDataLen-rrc);
+           System.arraycopy(tokenData, 0, newBytes, tokenDataLen-rrc, rrc);
 
-           // copy rest of the bytes
-           System.arraycopy(in_bytes, offset+rrc, out_bytes,
-                        TOKEN_HEADER_SIZE, bufsize-TOKEN_HEADER_SIZE-rrc);
-
-           // copy the bytes specified by rrc count
-           System.arraycopy(in_bytes, offset, out_bytes,
-                        bufsize-TOKEN_HEADER_SIZE-rrc, rrc);
-
-           // debug("\nRotate left: (after rotation) out_bytes = [ " +
-           //           getHexBytes(out_bytes, 0, bufsize) + "]");
-           return true;
+           tokenData = newBytes;
         }
-        return false;
     }
 
     public final int getSequenceNumber() {
-        return (readBigEndian(seqNumberData, 0, 4));
+        return seqNumber;
     }
 
     /**
@@ -444,44 +462,25 @@
 
         this.cipherHelper = context.getCipherHelper(null);
         //    debug("In MessageToken.Cons");
-
-        // draft-ietf-krb-wg-gssapi-cfx-07
-        this.tokenId = tokenId;
     }
 
     /**
-     * Encodes a GSSHeader and this token onto an OutputStream.
+     * Encodes a MessageTokenHeader onto an OutputStream.
      *
      * @param os the OutputStream to which this should be written
-     * @throws GSSException if an error occurs while writing to the OutputStream
+     * @throws IOException is an error occurs while writing to the OutputStream
      */
-    public void encode(OutputStream os) throws IOException, GSSException {
-        // debug("Writing tokenHeader " + getHexBytes(tokenHeader.getBytes());
-        // (16 bytes of token header that includes sequence Number)
+    protected void encodeHeader(OutputStream os) throws IOException {
         tokenHeader.encode(os);
-        // debug("Writing checksum: " + getHexBytes(checksum));
-        if (tokenId == MIC_ID_v2) {
-           os.write(checksum);
-        }
     }
 
     /**
-     * Obtains the size of this token. Note that this excludes the size of
-     * the GSSHeader.
-     * @return token size
+     * Encodes a MessageToken_v2 onto an OutputStream.
+     *
+     * @param os the OutputStream to which this should be written
+     * @throws IOException is an error occurs while encoding the token
      */
-    protected int getKrb5TokenSize() throws GSSException {
-        return getTokenSize();
-    }
-
-    protected final int getTokenSize() throws GSSException {
-        return (TOKEN_HEADER_SIZE + cipherHelper.getChecksumLength());
-    }
-
-    protected static final int getTokenSize(CipherHelper ch)
-        throws GSSException {
-        return (TOKEN_HEADER_SIZE + ch.getChecksumLength());
-    }
+    public abstract void encode(OutputStream os) throws IOException;
 
     protected final byte[] getTokenHeader() {
         return (tokenHeader.getBytes());
@@ -493,45 +492,14 @@
 
     /**
      * This inner class represents the initial portion of the message token.
-     * It constitutes the first 16 bytes of the message token:
-     * <pre>
-     *  Wrap Tokens
-     *
-     *     Octet no   Name        Description
-     *    ---------------------------------------------------------------
-     *      0..1     TOK_ID     Identification field.  Tokens emitted by
-     *                          GSS_Wrap() contain the the hex value 05 04
-     *                          expressed in big endian order in this field.
-     *      2        Flags      Attributes field, as described in section
-     *                          4.2.2.
-     *      3        Filler     Contains the hex value FF.
-     *      4..5     EC         Contains the "extra count" field, in big
-     *                          endian order as described in section 4.2.3.
-     *      6..7     RRC        Contains the "right rotation count" in big
-     *                          endian order, as described in section 4.2.5.
-     *      8..15    SND_SEQ    Sequence number field in clear text,
-     *                          expressed in big endian order.
-     *
-     * MIC Tokens
-     *
-     *     Octet no   Name        Description
-     *     -----------------------------------------------------------------
-     *      0..1     TOK_ID     Identification field.  Tokens emitted by
-     *                          GSS_GetMIC() contain the hex value 04 04
-     *                          expressed in big endian order in this field.
-     *      2        Flags      Attributes field, as described in section
-     *                          4.2.2.
-     *      3..7     Filler     Contains five octets of hex value FF.
-     *      8..15    SND_SEQ    Sequence number field in clear text,
-     *                          expressed in big endian order.
-     * </pre>
+     * It constitutes the first 16 bytes of the message token.
      */
     class MessageTokenHeader {
 
          private int tokenId;
          private byte[] bytes = new byte[TOKEN_HEADER_SIZE];
 
-         // new token header draft-ietf-krb-wg-gssapi-cfx-07
+         // Writes a new token header
          public MessageTokenHeader(int tokenId, boolean conf,
                 boolean have_acceptor_subkey) throws GSSException {
 
@@ -542,16 +510,15 @@
 
             // Flags (Note: MIT impl requires subkey)
             int flags = 0;
-            flags = ((initiator ? 0 : FLAG_SENDER_IS_ACCEPTOR) |
+            flags = (initiator ? 0 : FLAG_SENDER_IS_ACCEPTOR) |
                      ((conf && tokenId != MIC_ID_v2) ?
                                 FLAG_WRAP_CONFIDENTIAL : 0) |
-                     (have_acceptor_subkey ? FLAG_ACCEPTOR_SUBKEY : 0));
+                     (have_acceptor_subkey ? FLAG_ACCEPTOR_SUBKEY : 0);
             bytes[2] = (byte) flags;
 
             // filler
             bytes[3] = (byte) FILLER;
 
-            // EC and RRC fields
             if (tokenId == WRAP_ID_v2) {
                 // EC field
                 bytes[4] = (byte) 0;
@@ -560,21 +527,19 @@
                 bytes[6] = (byte) 0;
                 bytes[7] = (byte) 0;
             } else if (tokenId == MIC_ID_v2) {
-                // octets of filler FF
+                // more filler for MicToken
                 for (int i = 4; i < 8; i++) {
                     bytes[i] = (byte) FILLER;
                 }
             }
 
-            // Calculate SND_SEQ
-            seqNumberData = new byte[8];
-            writeBigEndian(seqNumber, seqNumberData, 4);
-            System.arraycopy(seqNumberData, 0, bytes, 8, 8);
+            // Calculate SND_SEQ, only write 4 bytes from the 12th position
+            writeBigEndian(seqNumber, bytes, 12);
         }
 
         /**
-         * Constructs a MessageTokenHeader by reading it from an InputStream
-         * and sets the appropriate confidentiality and quality of protection
+         * Reads a MessageTokenHeader from an InputStream and sets the
+         * appropriate confidentiality and quality of protection
          * values in a MessageProp structure.
          *
          * @param is the InputStream to read from
@@ -588,15 +553,23 @@
             readFully(is, bytes, 0, TOKEN_HEADER_SIZE);
             tokenId = readInt(bytes, TOKEN_ID_POS);
 
+            // validate Token ID
+            if (tokenId != tokId) {
+                throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
+                    getTokenName(tokenId) + ":" + "Defective Token ID!");
+            }
+
             /*
              * Validate new GSS TokenHeader
              */
-            // valid acceptor_flag is set
+
+            // valid acceptor_flag
+            // If I am initiator, the received token should have ACCEPTOR on
             int acceptor_flag = (initiator ? FLAG_SENDER_IS_ACCEPTOR : 0);
             int flag = bytes[TOKEN_FLAG_POS] & FLAG_SENDER_IS_ACCEPTOR;
-            if (!(flag == acceptor_flag)) {
+            if (flag != acceptor_flag) {
                 throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
-                        getTokenName(tokenId) + ":" + "Acceptor Flag Missing!");
+                        getTokenName(tokenId) + ":" + "Acceptor Flag Error!");
             }
 
             // check for confidentiality
@@ -608,21 +581,20 @@
                 prop.setPrivacy(false);
             }
 
-            // validate Token ID
-            if (tokenId != tokId) {
-                throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
-                    getTokenName(tokenId) + ":" + "Defective Token ID!");
-            }
+            if (tokenId == WRAP_ID_v2) {
+                // validate filler
+                if ((bytes[3] & 0xff) != FILLER) {
+                    throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
+                        getTokenName(tokenId) + ":" + "Defective Token Filler!");
+                }
 
-            // validate filler
-            if ((bytes[3] & 0xff) != FILLER) {
-                throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
-                    getTokenName(tokenId) + ":" + "Defective Token Filler!");
-            }
+                // read EC field
+                ec = readBigEndian(bytes, TOKEN_EC_POS, 2);
 
-            // validate next 4 bytes of filler for MIC tokens
-            if (tokenId == MIC_ID_v2) {
-                for (int i = 4; i < 8; i++) {
+                // read RRC field
+                rrc = readBigEndian(bytes, TOKEN_RRC_POS, 2);
+            } else if (tokenId == MIC_ID_v2) {
+                for (int i = 3; i < 8; i++) {
                     if ((bytes[i] & 0xff) != FILLER) {
                         throw new GSSException(GSSException.DEFECTIVE_TOKEN,
                                 -1, getTokenName(tokenId) + ":" +
@@ -631,18 +603,11 @@
                 }
             }
 
-            // read EC field
-            ec = readBigEndian(bytes, TOKEN_EC_POS, 2);
-
-            // read RRC field
-            rrc = readBigEndian(bytes, TOKEN_RRC_POS, 2);
-
             // set default QOP
             prop.setQOP(0);
 
             // sequence number
-            seqNumberData = new byte[8];
-            System.arraycopy(bytes, 8, seqNumberData, 0, 8);
+            seqNumber = readBigEndian(bytes, 0, 8);
         }
 
         /**
--- a/jdk/src/share/classes/sun/security/jgss/krb5/MicToken_v2.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/MicToken_v2.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -29,12 +29,11 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.IOException;
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 
 /**
  * This class represents the new format of GSS MIC tokens, as specified
- * in draft-ietf-krb-wg-gssapi-cfx-07.txt
+ * in RFC 4121
  *
  * MIC tokens = { 16-byte token-header |  HMAC }
  * where HMAC is on { plaintext | 16-byte token-header }
@@ -48,12 +47,11 @@
                   byte[] tokenBytes, int tokenOffset, int tokenLen,
                   MessageProp prop)  throws GSSException {
         super(Krb5Token.MIC_ID_v2, context,
-          tokenBytes, tokenOffset, tokenLen, prop);
+                tokenBytes, tokenOffset, tokenLen, prop);
     }
 
-    public MicToken_v2(Krb5Context context,
-                   InputStream is, MessageProp prop)
-    throws GSSException {
+    public MicToken_v2(Krb5Context context, InputStream is, MessageProp prop)
+            throws GSSException {
         super(Krb5Token.MIC_ID_v2, context, is, prop);
     }
 
@@ -64,7 +62,6 @@
     }
 
     public void verify(InputStream data) throws GSSException {
-
         byte[] dataBytes = null;
         try {
             dataBytes = new byte[data.available()];
@@ -79,7 +76,7 @@
 
     public MicToken_v2(Krb5Context context, MessageProp prop,
                   byte[] data, int pos, int len)
-        throws GSSException {
+            throws GSSException {
         super(Krb5Token.MIC_ID_v2, context);
 
         //      debug("Application data to MicToken verify is [" +
@@ -89,7 +86,7 @@
     }
 
     public MicToken_v2(Krb5Context context, MessageProp prop, InputStream data)
-        throws GSSException, IOException {
+            throws GSSException, IOException {
 
         super(Krb5Token.MIC_ID_v2, context);
         byte[] dataBytes = new byte[data.available()];
@@ -101,22 +98,21 @@
         genSignAndSeqNumber(prop, dataBytes, 0, dataBytes.length);
     }
 
-    public int encode(byte[] outToken, int offset)
-        throws IOException, GSSException {
-
-        // Token  is small
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        super.encode(bos);
-        byte[] token = bos.toByteArray();
-        System.arraycopy(token, 0, outToken, offset, token.length);
-        return token.length;
-    }
-
-    public byte[] encode() throws IOException, GSSException {
-
+    public byte[] encode() throws IOException {
         // XXX Fine tune this initial size
         ByteArrayOutputStream bos = new ByteArrayOutputStream(50);
         encode(bos);
         return bos.toByteArray();
     }
+
+    public int encode(byte[] outToken, int offset) throws IOException {
+        byte[] token = encode();
+        System.arraycopy(token, 0, outToken, offset, token.length);
+        return token.length;
+    }
+
+    public void encode(OutputStream os) throws IOException {
+        encodeHeader(os);
+        os.write(checksum);
+    }
 }
--- a/jdk/src/share/classes/sun/security/jgss/krb5/WrapToken.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/WrapToken.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -27,14 +27,11 @@
 
 import org.ietf.jgss.*;
 import sun.security.jgss.*;
-import java.security.GeneralSecurityException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.IOException;
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import sun.security.krb5.Confounder;
-import sun.security.krb5.KrbException;
 
 /**
  * This class represents a token emitted by the GSSContext.wrap()
@@ -336,24 +333,29 @@
                 // debug("\t\tNo encryption was performed by peer.\n");
                 readFully(is, confounder);
 
-                // Data is always a multiple of 8 with this GSS Mech
-                // Copy all but last block as they are
-                int numBlocks = (dataSize - CONFOUNDER_SIZE)/8 - 1;
-                int offset = dataBufOffset;
-                for (int i = 0; i < numBlocks; i++) {
-                    readFully(is, dataBuf, offset, 8);
-                    offset += 8;
-                }
+                if (cipherHelper.isArcFour()) {
+                    padding = pads[1];
+                    readFully(is, dataBuf, dataBufOffset, dataSize-CONFOUNDER_SIZE-1);
+                } else {
+                    // Data is always a multiple of 8 with this GSS Mech
+                    // Copy all but last block as they are
+                    int numBlocks = (dataSize - CONFOUNDER_SIZE)/8 - 1;
+                    int offset = dataBufOffset;
+                    for (int i = 0; i < numBlocks; i++) {
+                        readFully(is, dataBuf, offset, 8);
+                        offset += 8;
+                    }
 
-                byte[] finalBlock = new byte[8];
-                readFully(is, finalBlock);
+                    byte[] finalBlock = new byte[8];
+                    readFully(is, finalBlock);
 
-                int padSize = finalBlock[7];
-                padding = pads[padSize];
+                    int padSize = finalBlock[7];
+                    padding = pads[padSize];
 
-                // debug("\t\tPadding applied was: " + padSize + "\n");
-                System.arraycopy(finalBlock, 0, dataBuf, offset,
-                                 finalBlock.length - padSize);
+                    // debug("\t\tPadding applied was: " + padSize + "\n");
+                    System.arraycopy(finalBlock, 0, dataBuf, offset,
+                                     finalBlock.length - padSize);
+                }
             }
         } catch (IOException e) {
             throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
--- a/jdk/src/share/classes/sun/security/jgss/krb5/WrapToken_v2.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/jgss/krb5/WrapToken_v2.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -27,66 +27,30 @@
 
 import org.ietf.jgss.*;
 import sun.security.jgss.*;
-import java.security.GeneralSecurityException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.IOException;
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
 import sun.security.krb5.Confounder;
-import sun.security.krb5.KrbException;
 
 /**
- * This class represents the new format of GSS tokens, as specified in
- * draft-ietf-krb-wg-gssapi-cfx-07.txt, emitted by the GSSContext.wrap()
- * call. It is a MessageToken except that it also contains plaintext or
- * encrypted data at the end. A WrapToken has certain other rules that are
- * peculiar to it and different from a  MICToken, which is another type of
- * MessageToken. All data in a WrapToken is prepended by a random counfounder
- * of 16 bytes. Thus, all application data is replaced by
- * (confounder || data || tokenHeader || checksum).
+ * This class represents the new format of GSS tokens, as specified in RFC
+ * 4121, emitted by the GSSContext.wrap() call. It is a MessageToken except
+ * that it also contains plaintext or encrypted data at the end. A WrapToken
+ * has certain other rules that are peculiar to it and different from a
+ * MICToken, which is another type of MessageToken. All data in a WrapToken is
+ * prepended by a random confounder of 16 bytes. Thus, all application data
+ * is replaced by (confounder || data || tokenHeader || checksum).
  *
  * @author Seema Malkani
  */
 class WrapToken_v2 extends MessageToken_v2 {
-    /**
-     * The size of the random confounder used in a WrapToken.
-     */
-    static final int CONFOUNDER_SIZE = 16;
-
-    /*
-     * A token may come in either in an InputStream or as a
-     * byte[]. Store a reference to it in either case and process
-     * it's data only later when getData() is called and
-     * decryption/copying is needed to be done. Note that JCE can
-     * decrypt both from a byte[] and from an InputStream.
-     */
-    private boolean readTokenFromInputStream = true;
-    private InputStream is = null;
-    private byte[] tokenBytes = null;
-    private int tokenOffset = 0;
-    private int tokenLen = 0;
-
-    /*
-     * Application data may come from an InputStream or from a
-     * byte[]. However, it will always be stored and processed as a
-     * byte[] since
-     * (a) the MessageDigest class only accepts a byte[] as input and
-     * (b) It allows writing to an OuputStream via a CipherOutputStream.
-     */
-    private byte[] dataBytes = null;
-    private int dataOffset = 0;
-    private int dataLen = 0;
-
-    // the len of the token data:
-    //          (confounder || data || tokenHeader || checksum)
-    private int dataSize = 0;
 
     // Accessed by CipherHelper
     byte[] confounder = null;
 
-    private boolean privacy = false;
-    private boolean initiator = true;
+    private final boolean privacy;
 
     /**
      * Constructs a WrapToken from token bytes obtained from the
@@ -104,30 +68,9 @@
                      byte[] tokenBytes, int tokenOffset, int tokenLen,
                      MessageProp prop)  throws GSSException {
 
-        // Just parse the MessageToken part first
         super(Krb5Token.WRAP_ID_v2, context,
               tokenBytes, tokenOffset, tokenLen, prop);
-        this.readTokenFromInputStream = false;
-
-        // rotate token bytes as per RRC
-        byte[] new_tokenBytes = new byte[tokenLen];
-        if (rotate_left(tokenBytes, tokenOffset, new_tokenBytes, tokenLen)) {
-            this.tokenBytes = new_tokenBytes;
-            this.tokenOffset = 0;
-        } else {
-            this.tokenBytes = tokenBytes;
-            this.tokenOffset = tokenOffset;
-        }
-
-        // Will need the token bytes again when extracting data
-        this.tokenLen = tokenLen;
         this.privacy = prop.getPrivacy();
-
-        dataSize = tokenLen - TOKEN_HEADER_SIZE;
-
-        // save initiator
-        this.initiator = context.isInitiator();
-
     }
 
     /**
@@ -145,27 +88,8 @@
                      InputStream is, MessageProp prop)
         throws GSSException {
 
-        // Just parse the MessageToken part first
         super(Krb5Token.WRAP_ID_v2, context, is, prop);
-
-        // Will need the token bytes again when extracting data
-        this.is = is;
         this.privacy = prop.getPrivacy();
-
-        // get the token length
-        try {
-            this.tokenLen = is.available();
-        } catch (IOException e) {
-            throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
-                                   getTokenName(getTokenId())
-                                   + ": " + e.getMessage());
-        }
-
-        // data size
-        dataSize = tokenLen - TOKEN_HEADER_SIZE;
-
-        // save initiator
-        this.initiator = context.isInitiator();
     }
 
     /**
@@ -177,13 +101,9 @@
      */
     public byte[] getData() throws GSSException {
 
-        byte[] temp = new byte[dataSize];
+        byte[] temp = new byte[tokenDataLen];
         int len = getData(temp, 0);
-        // len obtained is after removing confounder, tokenHeader and HMAC
-
-        byte[] retVal = new byte[len];
-        System.arraycopy(temp, 0, retVal, 0, retVal.length);
-        return retVal;
+        return Arrays.copyOf(temp, len);
     }
 
     /**
@@ -200,69 +120,26 @@
     public int getData(byte[] dataBuf, int dataBufOffset)
         throws GSSException {
 
-        if (readTokenFromInputStream)
-            getDataFromStream(dataBuf, dataBufOffset);
-        else
-            getDataFromBuffer(dataBuf, dataBufOffset);
-
-        int retVal = 0;
-        if (privacy) {
-            retVal = dataSize - confounder.length -
-                TOKEN_HEADER_SIZE - cipherHelper.getChecksumLength();
-        } else {
-            retVal = dataSize - cipherHelper.getChecksumLength();
-        }
-        return retVal;
-    }
-
-    /**
-     * Helper routine to obtain the application data transmitted in
-     * this WrapToken. It is called if the WrapToken was constructed
-     * with a byte array as input.
-     * @param dataBuf the output buffer into which the data must be
-     * written
-     * @param dataBufOffset the offset at which to write the data
-     * @throws GSSException if an error occurs while decrypting any
-     * cipher text and checking for validity
-     */
-    private void getDataFromBuffer(byte[] dataBuf, int dataBufOffset)
-        throws GSSException {
-
-        int dataPos = tokenOffset + TOKEN_HEADER_SIZE;
-        int data_length = 0;
-
-        if (dataPos + dataSize > tokenOffset + tokenLen)
-            throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
-                                   "Insufficient data in "
-                                   + getTokenName(getTokenId()));
         // debug("WrapToken cons: data is token is [" +
         //      getHexBytes(tokenBytes, tokenOffset, tokenLen) + "]\n");
-        confounder = new byte[CONFOUNDER_SIZE];
 
         // Do decryption if this token was privacy protected.
         if (privacy) {
 
             // decrypt data
-            cipherHelper.decryptData(this, tokenBytes, dataPos, dataSize,
+            cipherHelper.decryptData(this, tokenData, 0, tokenDataLen,
                                 dataBuf, dataBufOffset, getKeyUsage());
-            /*
-            debug("\t\tDecrypted data is [" +
-                getHexBytes(confounder) + " " +
-                getHexBytes(dataBuf, dataBufOffset,
-                dataSize - CONFOUNDER_SIZE) +
-                "]\n");
-            */
 
-            data_length = dataSize - CONFOUNDER_SIZE -
-                        TOKEN_HEADER_SIZE - cipherHelper.getChecksumLength();
+            return tokenDataLen - CONFOUNDER_SIZE -
+                TOKEN_HEADER_SIZE - cipherHelper.getChecksumLength();
         } else {
 
             // Token data is in cleartext
-            debug("\t\tNo encryption was performed by peer.\n");
+            // debug("\t\tNo encryption was performed by peer.\n");
 
             // data
-            data_length = dataSize - cipherHelper.getChecksumLength();
-            System.arraycopy(tokenBytes, dataPos,
+            int data_length = tokenDataLen - cipherHelper.getChecksumLength();
+            System.arraycopy(tokenData, 0,
                              dataBuf, dataBufOffset,
                              data_length);
             // debug("\t\tData is: " + getHexBytes(dataBuf, data_length));
@@ -274,95 +151,26 @@
                 throw new GSSException(GSSException.BAD_MIC, -1,
                          "Corrupt checksum in Wrap token");
             }
+            return data_length;
         }
     }
 
     /**
-     * Helper routine to obtain the application data transmitted in
-     * this WrapToken. It is called if the WrapToken was constructed
-     * with an Inputstream.
-     * @param dataBuf the output buffer into which the data must be
-     * written
-     * @param dataBufOffset the offset at which to write the data
-     * @throws GSSException if an error occurs while decrypting any
-     * cipher text and checking for validity
+     * Writes a WrapToken_v2 object
      */
-    private void getDataFromStream(byte[] dataBuf, int dataBufOffset)
-        throws GSSException {
-
-        int data_length = 0;
-        // Don't check the token length. Data will be read on demand from
-        // the InputStream.
-        // debug("WrapToken cons: data will be read from InputStream.\n");
-
-        confounder = new byte[CONFOUNDER_SIZE];
-
-        try {
-            // Do decryption if this token was privacy protected.
-            if (privacy) {
-
-                cipherHelper.decryptData(this, is, dataSize,
-                    dataBuf, dataBufOffset, getKeyUsage());
-
-                /*
-                debug("\t\tDecrypted data is [" +
-                     getHexBytes(confounder) + " " +
-                     getHexBytes(dataBuf, dataBufOffset,
-                  dataSize - CONFOUNDER_SIZE) +
-                     "]\n");
-                */
-                data_length = dataSize - CONFOUNDER_SIZE -
-                        TOKEN_HEADER_SIZE - cipherHelper.getChecksumLength();
-            } else {
-
-                // Token data is in cleartext
-                debug("\t\tNo encryption was performed by peer.\n");
-                readFully(is, confounder);
-
-                // read the data
-                data_length = dataSize - cipherHelper.getChecksumLength();
-                readFully(is, dataBuf, dataBufOffset, data_length);
-
-                /*
-                 * Make sure checksum is not corrupt
-                 */
-                if (!verifySign(dataBuf, dataBufOffset, data_length)) {
-                    throw new GSSException(GSSException.BAD_MIC, -1,
-                         "Corrupt checksum in Wrap token");
-                }
-            }
-        } catch (IOException e) {
-            throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1,
-                                   getTokenName(getTokenId())
-                                   + ": " + e.getMessage());
-        }
-
-    }
-
-
     public WrapToken_v2(Krb5Context context, MessageProp prop,
                      byte[] dataBytes, int dataOffset, int dataLen)
-        throws GSSException {
+            throws GSSException {
 
         super(Krb5Token.WRAP_ID_v2, context);
 
         confounder = Confounder.bytes(CONFOUNDER_SIZE);
 
-        dataSize = confounder.length + dataLen + TOKEN_HEADER_SIZE +
-                        cipherHelper.getChecksumLength();
-        this.dataBytes = dataBytes;
-        this.dataOffset = dataOffset;
-        this.dataLen = dataLen;
-
-        // save initiator
-        this.initiator = context.isInitiator();
-
         // debug("\nWrapToken cons: data to wrap is [" +
         // getHexBytes(confounder) + " " +
         // getHexBytes(dataBytes, dataOffset, dataLen) + "]\n");
 
-        genSignAndSeqNumber(prop,
-                            dataBytes, dataOffset, dataLen);
+        genSignAndSeqNumber(prop, dataBytes, dataOffset, dataLen);
 
         /*
          * If the application decides to ask for privacy when the context
@@ -374,110 +182,42 @@
             prop.setPrivacy(false);
 
         privacy = prop.getPrivacy();
-    }
 
-    public void encode(OutputStream os) throws IOException, GSSException {
-
-        super.encode(os);
-
-        // debug("\n\nWriting data: [");
         if (!privacy) {
-
             // Wrap Tokens (without confidentiality) =
             // { 16 byte token_header | plaintext | 12-byte HMAC }
             // where HMAC is on { plaintext | token_header }
 
-            // calculate checksum
-            byte[] checksum = getChecksum(dataBytes, dataOffset, dataLen);
-
-            // data
-            // debug(" " + getHexBytes(dataBytes, dataOffset, dataLen));
-            os.write(dataBytes, dataOffset, dataLen);
-
-            // write HMAC
-            // debug(" " + getHexBytes(checksum,
-            //                  cipherHelper.getChecksumLength()));
-            os.write(checksum);
-
+            tokenData = new byte[dataLen + checksum.length];
+            System.arraycopy(dataBytes, dataOffset, tokenData, 0, dataLen);
+            System.arraycopy(checksum, 0, tokenData, dataLen, checksum.length);
         } else {
-
             // Wrap Tokens (with confidentiality) =
             // { 16 byte token_header |
             // Encrypt(16-byte confounder | plaintext | token_header) |
             // 12-byte HMAC }
 
-            cipherHelper.encryptData(this, confounder, getTokenHeader(),
-                dataBytes, dataOffset, dataLen, getKeyUsage(), os);
-
+            tokenData = cipherHelper.encryptData(this, confounder, getTokenHeader(),
+                dataBytes, dataOffset, dataLen, getKeyUsage());
         }
-        // debug("]\n");
     }
 
-    public byte[] encode() throws IOException, GSSException {
-        // XXX Fine tune this initial size
-        ByteArrayOutputStream bos = new ByteArrayOutputStream(dataSize + 50);
+    public void encode(OutputStream os) throws IOException {
+        encodeHeader(os);
+        os.write(tokenData);
+    }
+
+    public byte[] encode() throws IOException {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream(
+                MessageToken_v2.TOKEN_HEADER_SIZE + tokenData.length);
         encode(bos);
         return bos.toByteArray();
     }
 
-    public int encode(byte[] outToken, int offset)
-        throws IOException, GSSException  {
-
-        int retVal = 0;
-
-        // Token header is small
-        ByteArrayOutputStream bos = new ByteArrayOutputStream();
-        super.encode(bos);
-        byte[] header = bos.toByteArray();
-        System.arraycopy(header, 0, outToken, offset, header.length);
-        offset += header.length;
-
-        // debug("WrapToken.encode: Writing data: [");
-        if (!privacy) {
-
-            // Wrap Tokens (without confidentiality) =
-            // { 16 byte token_header | plaintext | 12-byte HMAC }
-            // where HMAC is on { plaintext | token_header }
-
-            // calculate checksum
-            byte[] checksum = getChecksum(dataBytes, dataOffset, dataLen);
-
-            // data
-            // debug(" " + getHexBytes(dataBytes, dataOffset, dataLen));
-            System.arraycopy(dataBytes, dataOffset, outToken, offset,
-                             dataLen);
-            offset += dataLen;
-
-            // write HMAC
-            // debug(" " + getHexBytes(checksum,
-            //                  cipherHelper.getChecksumLength()));
-            System.arraycopy(checksum, 0, outToken, offset,
-                                cipherHelper.getChecksumLength());
-
-            retVal = header.length + dataLen + cipherHelper.getChecksumLength();
-        } else {
-
-            // Wrap Tokens (with confidentiality) =
-            // { 16 byte token_header |
-            // Encrypt(16-byte confounder | plaintext | token_header) |
-            // 12-byte HMAC }
-            int cLen = cipherHelper.encryptData(this, confounder,
-                        getTokenHeader(), dataBytes, dataOffset, dataLen,
-                        outToken, offset, getKeyUsage());
-
-            retVal = header.length + cLen;
-            // debug(getHexBytes(outToken, offset, dataSize));
-        }
-
-        // debug("]\n");
-
-        // %%% assume that plaintext length == ciphertext len
-        return retVal;
-
-    }
-
-    protected int getKrb5TokenSize() throws GSSException {
-        return (getTokenSize() + dataSize);
+    public int encode(byte[] outToken, int offset) throws IOException {
+        byte[] token = encode();
+        System.arraycopy(token, 0, outToken, offset, token.length);
+        return token.length;
     }
 
     // This implementation is way to conservative. And it certainly
@@ -485,6 +225,7 @@
     static int getSizeLimit(int qop, boolean confReq, int maxTokenSize,
         CipherHelper ch) throws GSSException {
         return (GSSHeader.getMaxMechTokenSize(OID, maxTokenSize) -
-                (getTokenSize(ch) + CONFOUNDER_SIZE) - 8 /* safety */);
+                (TOKEN_HEADER_SIZE + ch.getChecksumLength() + CONFOUNDER_SIZE)
+                - 8 /* safety */);
     }
 }
--- a/jdk/src/share/classes/sun/security/pkcs11/Config.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/pkcs11/Config.java	Wed Jan 19 21:51:10 2011 -0800
@@ -343,6 +343,7 @@
         st.wordChars('{', '{'); // need {} for property subst
         st.wordChars('}', '}');
         st.wordChars('*', '*');
+        st.wordChars('~', '~');
         // XXX check ASCII table and add all other characters except special
 
         // special: #="(),
--- a/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11Cipher.java	Wed Jan 19 21:51:10 2011 -0800
@@ -395,6 +395,8 @@
             }
         } catch (PKCS11Exception e) {
             throw new ProviderException("Cancel failed", e);
+        } finally {
+            reset();
         }
     }
 
@@ -408,12 +410,18 @@
         if (session == null) {
             session = token.getOpSession();
         }
-        if (encrypt) {
-            token.p11.C_EncryptInit(session.id(),
-                    new CK_MECHANISM(mechanism, iv), p11Key.keyID);
-        } else {
-            token.p11.C_DecryptInit(session.id(),
-                    new CK_MECHANISM(mechanism, iv), p11Key.keyID);
+        try {
+            if (encrypt) {
+                token.p11.C_EncryptInit(session.id(),
+                        new CK_MECHANISM(mechanism, iv), p11Key.keyID);
+            } else {
+                token.p11.C_DecryptInit(session.id(),
+                        new CK_MECHANISM(mechanism, iv), p11Key.keyID);
+            }
+        } catch (PKCS11Exception ex) {
+            // release session when initialization failed
+            session = token.releaseSession(session);
+            throw ex;
         }
         bytesBuffered = 0;
         padBufferLen = 0;
@@ -448,6 +456,16 @@
         return result;
     }
 
+    // reset the states to the pre-initialized values
+    private void reset() {
+        initialized = false;
+        bytesBuffered = 0;
+        padBufferLen = 0;
+        if (session != null) {
+            session = token.releaseSession(session);
+        }
+    }
+
     // see JCE spec
     protected byte[] engineUpdate(byte[] in, int inOfs, int inLen) {
         try {
@@ -566,6 +584,7 @@
                 throw (ShortBufferException)
                         (new ShortBufferException().initCause(e));
             }
+            reset();
             throw new ProviderException("update() failed", e);
         }
     }
@@ -683,6 +702,7 @@
                 throw (ShortBufferException)
                         (new ShortBufferException().initCause(e));
             }
+            reset();
             throw new ProviderException("update() failed", e);
         }
     }
@@ -729,10 +749,7 @@
             handleException(e);
             throw new ProviderException("doFinal() failed", e);
         } finally {
-            initialized = false;
-            bytesBuffered = 0;
-            padBufferLen = 0;
-            session = token.releaseSession(session);
+            reset();
         }
     }
 
@@ -806,9 +823,7 @@
             handleException(e);
             throw new ProviderException("doFinal() failed", e);
         } finally {
-            initialized = false;
-            bytesBuffered = 0;
-            session = token.releaseSession(session);
+            reset();
         }
     }
 
--- a/jdk/src/share/classes/sun/security/ssl/CipherSuite.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/ssl/CipherSuite.java	Wed Jan 19 21:51:10 2011 -0800
@@ -577,14 +577,16 @@
     final static MacAlg M_SHA256  = new MacAlg("SHA256", 32);
     final static MacAlg M_SHA384  = new MacAlg("SHA384", 48);
 
-    // PRFs (PseudoRandom Function) from TLS specifications.
-    //
-    // TLS 1.1- uses a single MD5/SHA1-based PRF algorithm for generating
-    // the necessary material.
-    //
-    // In TLS 1.2+, all existing/known CipherSuites use SHA256, however
-    // new Ciphersuites (e.g. RFC 5288) can define specific PRF hash
-    // algorithms.
+    /**
+     * PRFs (PseudoRandom Function) from TLS specifications.
+     *
+     * TLS 1.1- uses a single MD5/SHA1-based PRF algorithm for generating
+     * the necessary material.
+     *
+     * In TLS 1.2+, all existing/known CipherSuites use SHA256, however
+     * new Ciphersuites (e.g. RFC 5288) can define specific PRF hash
+     * algorithms.
+     */
     static enum PRF {
 
         // PRF algorithms
@@ -862,8 +864,18 @@
         add("SSL_NULL_WITH_NULL_NULL",
                               0x0000,   1, K_NULL,       B_NULL,    F);
 
-        // Definition of the CipherSuites that are enabled by default.
-        // They are listed in preference order, most preferred first.
+        /*
+         * Definition of the CipherSuites that are enabled by default.
+         * They are listed in preference order, most preferred first, using
+         * the following criteria:
+         * 1. Prefer the stronger buld cipher, in the order of AES_256,
+         *    AES_128, RC-4, 3DES-EDE.
+         * 2. Prefer the stronger MAC algorithm, in the order of SHA384,
+         *    SHA256, SHA, MD5.
+         * 3. Prefer the better performance of key exchange and digital
+         *    signature algorithm, in the order of ECDHE-ECDSA, ECDHE-RSA,
+         *    RSA, ECDH-ECDSA, ECDH-RSA, DHE-RSA, DHE-DSS.
+         */
         int p = DEFAULT_SUITES_PRIORITY * 2;
 
         // shorten names to fit the following table cleanly.
@@ -873,170 +885,185 @@
 
         //  ID           Key Exchange   Cipher     A  obs  suprt  PRF
         //  ======       ============   =========  =  ===  =====  ========
-        add("TLS_RSA_WITH_AES_128_CBC_SHA256",
-            0x003c, --p, K_RSA,         B_AES_128, T, max, tls12, P_SHA256);
+        add("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
+            0xc024, --p, K_ECDHE_ECDSA, B_AES_256, T, max, tls12, P_SHA384);
+        add("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
+            0xc028, --p, K_ECDHE_RSA,   B_AES_256, T, max, tls12, P_SHA384);
         add("TLS_RSA_WITH_AES_256_CBC_SHA256",
             0x003d, --p, K_RSA,         B_AES_256, T, max, tls12, P_SHA256);
-        add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
-            0x0040, --p, K_DHE_DSS,     B_AES_128, T, max, tls12, P_SHA256);
-        add("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
-            0x0067, --p, K_DHE_RSA,     B_AES_128, T, max, tls12, P_SHA256);
+        add("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384",
+            0xc026, --p, K_ECDH_ECDSA,  B_AES_256, T, max, tls12, P_SHA384);
+        add("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384",
+            0xc02a, --p, K_ECDH_RSA,    B_AES_256, T, max, tls12, P_SHA384);
+        add("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
+            0x006b, --p, K_DHE_RSA,     B_AES_256, T, max, tls12, P_SHA256);
         add("TLS_DHE_DSS_WITH_AES_256_CBC_SHA256",
             0x006a, --p, K_DHE_DSS,     B_AES_256, T, max, tls12, P_SHA256);
-        add("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256",
-            0x006b, --p, K_DHE_RSA,     B_AES_256, T, max, tls12, P_SHA256);
+
+        add("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
+            0xC00A, --p, K_ECDHE_ECDSA, B_AES_256, T);
+        add("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
+            0xC014, --p, K_ECDHE_RSA,   B_AES_256, T);
+        add("TLS_RSA_WITH_AES_256_CBC_SHA",
+            0x0035, --p, K_RSA,         B_AES_256, T);
+        add("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
+            0xC005, --p, K_ECDH_ECDSA,  B_AES_256, T);
+        add("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
+            0xC00F, --p, K_ECDH_RSA,    B_AES_256, T);
+        add("TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
+            0x0039, --p, K_DHE_RSA,     B_AES_256, T);
+        add("TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
+            0x0038, --p, K_DHE_DSS,     B_AES_256, T);
 
         add("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
             0xc023, --p, K_ECDHE_ECDSA, B_AES_128, T, max, tls12, P_SHA256);
-        add("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384",
-            0xc024, --p, K_ECDHE_ECDSA, B_AES_256, T, max, tls12, P_SHA384);
+        add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
+            0xc027, --p, K_ECDHE_RSA,   B_AES_128, T, max, tls12, P_SHA256);
+        add("TLS_RSA_WITH_AES_128_CBC_SHA256",
+            0x003c, --p, K_RSA,         B_AES_128, T, max, tls12, P_SHA256);
         add("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256",
             0xc025, --p, K_ECDH_ECDSA,  B_AES_128, T, max, tls12, P_SHA256);
-        add("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384",
-            0xc026, --p, K_ECDH_ECDSA,  B_AES_256, T, max, tls12, P_SHA384);
-        add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
-            0xc027, --p, K_ECDHE_RSA,   B_AES_128, T, max, tls12, P_SHA256);
-        add("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384",
-            0xc028, --p, K_ECDHE_RSA,   B_AES_256, T, max, tls12, P_SHA384);
         add("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256",
             0xc029, --p, K_ECDH_RSA,    B_AES_128, T, max, tls12, P_SHA256);
-        add("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384",
-            0xc02a, --p, K_ECDH_RSA,    B_AES_256, T, max, tls12, P_SHA384);
+        add("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256",
+            0x0067, --p, K_DHE_RSA,     B_AES_128, T, max, tls12, P_SHA256);
+        add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256",
+            0x0040, --p, K_DHE_DSS,     B_AES_128, T, max, tls12, P_SHA256);
 
-        add("SSL_RSA_WITH_RC4_128_MD5",
-            0x0004, --p, K_RSA,         B_RC4_128, N);
-        add("SSL_RSA_WITH_RC4_128_SHA",
-            0x0005, --p, K_RSA,         B_RC4_128, N);
+        add("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
+            0xC009, --p, K_ECDHE_ECDSA, B_AES_128, T);
+        add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
+            0xC013, --p, K_ECDHE_RSA,   B_AES_128, T);
         add("TLS_RSA_WITH_AES_128_CBC_SHA",
             0x002f, --p, K_RSA,         B_AES_128, T);
-        add("TLS_RSA_WITH_AES_256_CBC_SHA",
-            0x0035, --p, K_RSA,         B_AES_256, T);
-
-        add("TLS_ECDH_ECDSA_WITH_RC4_128_SHA",
-            0xC002, --p, K_ECDH_ECDSA,  B_RC4_128, N);
         add("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA",
             0xC004, --p, K_ECDH_ECDSA,  B_AES_128, T);
-        add("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA",
-            0xC005, --p, K_ECDH_ECDSA,  B_AES_256, T);
-        add("TLS_ECDH_RSA_WITH_RC4_128_SHA",
-            0xC00C, --p, K_ECDH_RSA,    B_RC4_128, N);
         add("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA",
             0xC00E, --p, K_ECDH_RSA,    B_AES_128, T);
-        add("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA",
-            0xC00F, --p, K_ECDH_RSA,    B_AES_256, T);
+        add("TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+            0x0033, --p, K_DHE_RSA,     B_AES_128, T);
+        add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+            0x0032, --p, K_DHE_DSS,     B_AES_128, T);
 
         add("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
             0xC007, --p, K_ECDHE_ECDSA, B_RC4_128, N);
-        add("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
-            0xC009, --p, K_ECDHE_ECDSA, B_AES_128, T);
-        add("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
-            0xC00A, --p, K_ECDHE_ECDSA, B_AES_256, T);
         add("TLS_ECDHE_RSA_WITH_RC4_128_SHA",
             0xC011, --p, K_ECDHE_RSA,   B_RC4_128, N);
-        add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
-            0xC013, --p, K_ECDHE_RSA,   B_AES_128, T);
-        add("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
-            0xC014, --p, K_ECDHE_RSA,   B_AES_256, T);
+        add("SSL_RSA_WITH_RC4_128_SHA",
+            0x0005, --p, K_RSA,         B_RC4_128, N);
+        add("TLS_ECDH_ECDSA_WITH_RC4_128_SHA",
+            0xC002, --p, K_ECDH_ECDSA,  B_RC4_128, N);
+        add("TLS_ECDH_RSA_WITH_RC4_128_SHA",
+            0xC00C, --p, K_ECDH_RSA,    B_RC4_128, N);
 
-        add("TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
-            0x0033, --p, K_DHE_RSA,     B_AES_128, T);
-        add("TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
-            0x0039, --p, K_DHE_RSA,     B_AES_256, T);
-        add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
-            0x0032, --p, K_DHE_DSS,     B_AES_128, T);
-        add("TLS_DHE_DSS_WITH_AES_256_CBC_SHA",
-            0x0038, --p, K_DHE_DSS,     B_AES_256, T);
-
+        add("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
+            0xC008, --p, K_ECDHE_ECDSA, B_3DES,    T);
+        add("TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
+            0xC012, --p, K_ECDHE_RSA,   B_3DES,    T);
         add("SSL_RSA_WITH_3DES_EDE_CBC_SHA",
             0x000a, --p, K_RSA,         B_3DES,    T);
         add("TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA",
             0xC003, --p, K_ECDH_ECDSA,  B_3DES,    T);
         add("TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA",
             0xC00D, --p, K_ECDH_RSA,    B_3DES,    T);
-        add("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA",
-            0xC008, --p, K_ECDHE_ECDSA, B_3DES,    T);
-        add("TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
-            0xC012, --p, K_ECDHE_RSA,   B_3DES,    T);
         add("SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
             0x0016, --p, K_DHE_RSA,     B_3DES,    T);
         add("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA",
             0x0013, --p, K_DHE_DSS,     B_3DES,    N);
 
+        add("SSL_RSA_WITH_RC4_128_MD5",
+            0x0004, --p, K_RSA,         B_RC4_128, N);
+
         // Renegotiation protection request Signalling Cipher Suite Value (SCSV)
         add("TLS_EMPTY_RENEGOTIATION_INFO_SCSV",
             0x00ff, --p, K_SCSV,        B_NULL,    T);
 
-        // Definition of the CipherSuites that are supported but not enabled
-        // by default.
-        // They are listed in preference order, preferred first.
+        /*
+         * Definition of the CipherSuites that are supported but not enabled
+         * by default.
+         * They are listed in preference order, preferred first, using the
+         * following criteria:
+         * 1. CipherSuites for KRB5 need additional KRB5 service
+         *    configuration, and these suites are not common in practice,
+         *    so we put KRB5 based cipher suites at the end of the supported
+         *    list.
+         * 2. If a cipher suite has been obsoleted, we put it at the end of
+         *    the list.
+         * 3. Prefer the stronger bulk cipher, in the order of AES_256,
+         *    AES_128, RC-4, 3DES-EDE, DES, RC4_40, DES40, NULL.
+         * 4. Prefer the stronger MAC algorithm, in the order of SHA384,
+         *    SHA256, SHA, MD5.
+         * 5. Prefer the better performance of key exchange and digital
+         *    signature algorithm, in the order of ECDHE-ECDSA, ECDHE-RSA,
+         *    RSA, ECDH-ECDSA, ECDH-RSA, DHE-RSA, DHE-DSS, anonymous.
+         */
         p = DEFAULT_SUITES_PRIORITY;
 
-        // weak single-DES cipher suites
+        add("TLS_DH_anon_WITH_AES_256_CBC_SHA256",
+            0x006d, --p, K_DH_ANON,     B_AES_256, N, max, tls12, P_SHA256);
+        add("TLS_ECDH_anon_WITH_AES_256_CBC_SHA",
+            0xC019, --p, K_ECDH_ANON,   B_AES_256, T);
+        add("TLS_DH_anon_WITH_AES_256_CBC_SHA",
+            0x003a, --p, K_DH_ANON,     B_AES_256, N);
+
+        add("TLS_DH_anon_WITH_AES_128_CBC_SHA256",
+            0x006c, --p, K_DH_ANON,     B_AES_128, N, max, tls12, P_SHA256);
+        add("TLS_ECDH_anon_WITH_AES_128_CBC_SHA",
+            0xC018, --p, K_ECDH_ANON,   B_AES_128, T);
+        add("TLS_DH_anon_WITH_AES_128_CBC_SHA",
+            0x0034, --p, K_DH_ANON,     B_AES_128, N);
+
+        add("TLS_ECDH_anon_WITH_RC4_128_SHA",
+            0xC016, --p, K_ECDH_ANON,   B_RC4_128, N);
+        add("SSL_DH_anon_WITH_RC4_128_MD5",
+            0x0018, --p, K_DH_ANON,     B_RC4_128, N);
+
+        add("TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA",
+            0xC017, --p, K_ECDH_ANON,   B_3DES,    T);
+        add("SSL_DH_anon_WITH_3DES_EDE_CBC_SHA",
+            0x001b, --p, K_DH_ANON,     B_3DES,    N);
+
+        add("TLS_RSA_WITH_NULL_SHA256",
+            0x003b, --p, K_RSA,         B_NULL,    N, max, tls12, P_SHA256);
+        add("TLS_ECDHE_ECDSA_WITH_NULL_SHA",
+            0xC006, --p, K_ECDHE_ECDSA, B_NULL,    N);
+        add("TLS_ECDHE_RSA_WITH_NULL_SHA",
+            0xC010, --p, K_ECDHE_RSA,   B_NULL,    N);
+        add("SSL_RSA_WITH_NULL_SHA",
+            0x0002, --p, K_RSA,         B_NULL,    N);
+        add("TLS_ECDH_ECDSA_WITH_NULL_SHA",
+            0xC001, --p, K_ECDH_ECDSA,  B_NULL,    N);
+        add("TLS_ECDH_RSA_WITH_NULL_SHA",
+            0xC00B, --p, K_ECDH_RSA,    B_NULL,    N);
+        add("TLS_ECDH_anon_WITH_NULL_SHA",
+            0xC015, --p, K_ECDH_ANON,   B_NULL,    N);
+        add("SSL_RSA_WITH_NULL_MD5",
+            0x0001, --p, K_RSA,         B_NULL,    N);
+
+        // weak cipher suites obsoleted in TLS 1.2
         add("SSL_RSA_WITH_DES_CBC_SHA",
             0x0009, --p, K_RSA,         B_DES,     N, tls12);
         add("SSL_DHE_RSA_WITH_DES_CBC_SHA",
             0x0015, --p, K_DHE_RSA,     B_DES,     N, tls12);
         add("SSL_DHE_DSS_WITH_DES_CBC_SHA",
             0x0012, --p, K_DHE_DSS,     B_DES,     N, tls12);
-
-        // Anonymous key exchange and the NULL ciphers
-        add("SSL_RSA_WITH_NULL_MD5",
-            0x0001, --p, K_RSA,         B_NULL,    N);
-        add("SSL_RSA_WITH_NULL_SHA",
-            0x0002, --p, K_RSA,         B_NULL,    N);
-        add("TLS_RSA_WITH_NULL_SHA256",
-            0x003b, --p, K_RSA,         B_NULL,    N, max, tls12, P_SHA256);
-
-        add("TLS_ECDH_ECDSA_WITH_NULL_SHA",
-            0xC001, --p, K_ECDH_ECDSA,  B_NULL,    N);
-        add("TLS_ECDH_RSA_WITH_NULL_SHA",
-            0xC00B, --p, K_ECDH_RSA,    B_NULL,    N);
-        add("TLS_ECDHE_ECDSA_WITH_NULL_SHA",
-            0xC006, --p, K_ECDHE_ECDSA, B_NULL,    N);
-        add("TLS_ECDHE_RSA_WITH_NULL_SHA",
-            0xC010, --p, K_ECDHE_RSA,   B_NULL,    N);
-
-        add("SSL_DH_anon_WITH_RC4_128_MD5",
-            0x0018, --p, K_DH_ANON,     B_RC4_128, N);
-        add("TLS_DH_anon_WITH_AES_128_CBC_SHA",
-            0x0034, --p, K_DH_ANON,     B_AES_128, N);
-        add("TLS_DH_anon_WITH_AES_256_CBC_SHA",
-            0x003a, --p, K_DH_ANON,     B_AES_256, N);
-        add("SSL_DH_anon_WITH_3DES_EDE_CBC_SHA",
-            0x001b, --p, K_DH_ANON,     B_3DES,    N);
         add("SSL_DH_anon_WITH_DES_CBC_SHA",
             0x001a, --p, K_DH_ANON,     B_DES,     N, tls12);
 
-        add("TLS_DH_anon_WITH_AES_128_CBC_SHA256",
-            0x006c, --p, K_DH_ANON,     B_AES_128, N, max, tls12, P_SHA256);
-        add("TLS_DH_anon_WITH_AES_256_CBC_SHA256",
-            0x006d, --p, K_DH_ANON,     B_AES_256, N, max, tls12, P_SHA256);
-
-        add("TLS_ECDH_anon_WITH_RC4_128_SHA",
-            0xC016, --p, K_ECDH_ANON,   B_RC4_128, N);
-        add("TLS_ECDH_anon_WITH_AES_128_CBC_SHA",
-            0xC018, --p, K_ECDH_ANON,   B_AES_128, T);
-        add("TLS_ECDH_anon_WITH_AES_256_CBC_SHA",
-            0xC019, --p, K_ECDH_ANON,   B_AES_256, T);
-        add("TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA",
-            0xC017, --p, K_ECDH_ANON,   B_3DES,    T);
-
+        // weak cipher suites obsoleted in TLS 1.1
+        add("SSL_RSA_EXPORT_WITH_RC4_40_MD5",
+            0x0003, --p, K_RSA_EXPORT,  B_RC4_40,  N, tls11);
         add("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",
             0x0017, --p, K_DH_ANON,     B_RC4_40,  N, tls11);
-        add("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
-            0x0019, --p, K_DH_ANON,     B_DES_40,  N, tls11);
 
-        add("TLS_ECDH_anon_WITH_NULL_SHA",
-            0xC015, --p, K_ECDH_ANON,   B_NULL,    N);
-
-        add("SSL_RSA_EXPORT_WITH_RC4_40_MD5",
-            0x0003, --p, K_RSA_EXPORT,  B_RC4_40,  N, tls11);
         add("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
             0x0008, --p, K_RSA_EXPORT,  B_DES_40,  N, tls11);
         add("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
             0x0014, --p, K_DHE_RSA,     B_DES_40,  N, tls11);
         add("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA",
             0x0011, --p, K_DHE_DSS,     B_DES_40,  N, tls11);
+        add("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
+            0x0019, --p, K_DH_ANON,     B_DES_40,  N, tls11);
 
         // Supported Kerberos ciphersuites from RFC2712
         add("TLS_KRB5_WITH_RC4_128_SHA",
--- a/jdk/src/share/classes/sun/security/ssl/ClientHandshaker.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/ssl/ClientHandshaker.java	Wed Jan 19 21:51:10 2011 -0800
@@ -381,8 +381,7 @@
                     mesgVersion);
         }
 
-        handshakeHash.protocolDetermined(
-            mesgVersion.v >= ProtocolVersion.TLS12.v);
+        handshakeHash.protocolDetermined(mesgVersion);
 
         // Set protocolVersion and propagate to SSLSocket and the
         // Handshake streams
@@ -1223,7 +1222,7 @@
         // not follow the spec that HandshakeHash.reset() can be only be
         // called before protocolDetermined.
         // if (maxProtocolVersion.v < ProtocolVersion.TLS12.v) {
-        //     handshakeHash.protocolDetermined(false);
+        //     handshakeHash.protocolDetermined(maxProtocolVersion);
         // }
 
         // create the ClientHello message
--- a/jdk/src/share/classes/sun/security/ssl/HandshakeHash.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/ssl/HandshakeHash.java	Wed Jan 19 21:51:10 2011 -0800
@@ -49,27 +49,27 @@
  *
  * You need to obey these conventions when using this class:
  *
- * 1. protocolDetermined(boolean isTLS12) should be called when the negotiated
+ * 1. protocolDetermined(version) should be called when the negotiated
  * protocol version is determined.
  *
  * 2. Before protocolDetermined() is called, only update(), reset(),
  * restrictCertificateVerifyAlgs(), setFinishedAlg(), and
  * setCertificateVerifyAlg() can be called.
  *
- * 3. After protocolDetermined(*) is called. reset() cannot be called.
+ * 3. After protocolDetermined() is called, reset() cannot be called.
  *
- * 4. After protocolDetermined(false) is called, getFinishedHash() and
- * getCertificateVerifyHash() cannot be called. After protocolDetermined(true)
- * is called, getMD5Clone() and getSHAClone() cannot be called.
+ * 4. After protocolDetermined() is called, if the version is pre-TLS 1.2,
+ * getFinishedHash() and getCertificateVerifyHash() cannot be called. Otherwise,
+ * getMD5Clone() and getSHAClone() cannot be called.
  *
  * 5. getMD5Clone() and getSHAClone() can only be called after
- * protocolDetermined(false) is called.
+ * protocolDetermined() is called and version is pre-TLS 1.2.
  *
  * 6. getFinishedHash() and getCertificateVerifyHash() can only be called after
- * all protocolDetermined(true), setCertificateVerifyAlg() and setFinishedAlg()
- * have been called. If a CertificateVerify message is to be used, call
- * setCertificateVerifyAlg() with the hash algorithm as the argument.
- * Otherwise, you still must call setCertificateVerifyAlg(null) before
+ * all protocolDetermined(), setCertificateVerifyAlg() and setFinishedAlg()
+ * have been called and the version is TLS 1.2. If a CertificateVerify message
+ * is to be used, call setCertificateVerifyAlg() with the hash algorithm as the
+ * argument. Otherwise, you still must call setCertificateVerifyAlg(null) before
  * calculating any hash value.
  *
  * Suggestions: Call protocolDetermined(), restrictCertificateVerifyAlgs(),
@@ -78,6 +78,7 @@
  * Example:
  * <pre>
  * HandshakeHash hh = new HandshakeHash(...)
+ * hh.protocolDetermined(ProtocolVersion.TLS12);
  * hh.update(clientHelloBytes);
  * hh.setFinishedAlg("SHA-256");
  * hh.update(serverHelloBytes);
@@ -161,12 +162,12 @@
     }
 
 
-    void protocolDetermined(boolean isTLS12) {
+    void protocolDetermined(ProtocolVersion pv) {
 
         // Do not set again, will ignore
         if (version != -1) return;
 
-        version = isTLS12 ? 2 : 1;
+        version = pv.compareTo(ProtocolVersion.TLS12) >= 0 ? 2 : 1;
         switch (version) {
             case 1:
                 // initiate md5, sha and call update on saved array
@@ -310,91 +311,6 @@
             throw new Error("BAD");
         }
     }
-
-    ////////////////////////////////////////////////////////////////
-    // TEST
-    ////////////////////////////////////////////////////////////////
-
-    public static void main(String[] args) throws Exception {
-        Test t = new Test();
-        t.test(null, "SHA-256");
-        t.test("", "SHA-256");
-        t.test("SHA-1", "SHA-256");
-        t.test("SHA-256", "SHA-256");
-        t.test("SHA-384", "SHA-256");
-        t.test("SHA-512", "SHA-256");
-        t.testSame("sha", "SHA-1");
-        t.testSame("SHA", "SHA-1");
-        t.testSame("SHA1", "SHA-1");
-        t.testSame("SHA-1", "SHA-1");
-        t.testSame("SHA256", "SHA-256");
-        t.testSame("SHA-256", "SHA-256");
-    }
-
-    static class Test {
-        void update(HandshakeHash hh, String s) {
-            hh.update(s.getBytes(), 0, s.length());
-        }
-        static byte[] digest(String alg, String data) throws Exception {
-            return MessageDigest.getInstance(alg).digest(data.getBytes());
-        }
-        static void equals(byte[] b1, byte[] b2) {
-            if (!Arrays.equals(b1, b2)) {
-                throw new RuntimeException("Bad");
-            }
-        }
-        void testSame(String a, String a2) {
-            System.out.println("testSame: " + a + " " + a2);
-            if (!HandshakeHash.normalizeAlgName(a).equals(a2)) {
-                throw new RuntimeException("Bad");
-            }
-        }
-        /**
-         * Special convention: when it's certain that CV will not be used at the
-         * very beginning, use null as cvAlg. If known at a late stage, use "".
-         */
-        void test(String cvAlg, String finAlg) throws Exception {
-            System.out.println("test: " + cvAlg + " " + finAlg);
-            byte[] cv = null, f1, f2;
-            HandshakeHash hh = new HandshakeHash(true, true, null);
-            if (cvAlg == null) {
-                hh.setCertificateVerifyAlg(cvAlg);
-            }
-
-            update(hh, "ClientHello,");
-            hh.reset();
-            update(hh, "ClientHellov2,");
-            hh.setFinishedAlg(finAlg);
-
-            // Useless calls
-            hh.setFinishedAlg("SHA-1");
-            hh.setFinishedAlg("SHA-512");
-
-            update(hh, "More,");
-            if (cvAlg != null) {
-                if (cvAlg.isEmpty()) cvAlg = null;
-                hh.setCertificateVerifyAlg(cvAlg);
-            }
-
-            // Useless calls
-            hh.setCertificateVerifyAlg("SHA-1");
-            hh.setCertificateVerifyAlg(null);
-
-            hh.protocolDetermined(true);
-
-            if (cvAlg != null) {
-                cv = hh.getAllHandshakeMessages();
-                equals(cv, "ClientHellov2,More,".getBytes());
-            }
-
-            update(hh, "FIN1,");
-            f1 = hh.getFinishedHash();
-            equals(f1, digest(finAlg, "ClientHellov2,More,FIN1,"));
-            update(hh, "FIN2,");
-            f2 = hh.getFinishedHash();
-            equals(f2, digest(finAlg, "ClientHellov2,More,FIN1,FIN2,"));
-        }
-    }
 }
 
 /**
--- a/jdk/src/share/classes/sun/security/ssl/ServerHandshaker.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/security/ssl/ServerHandshaker.java	Wed Jan 19 21:51:10 2011 -0800
@@ -424,8 +424,7 @@
                 " not enabled or not supported");
         }
 
-        handshakeHash.protocolDetermined(
-            selectedVersion.v >= ProtocolVersion.TLS12.v);
+        handshakeHash.protocolDetermined(selectedVersion);
         setVersion(selectedVersion);
 
         m1.protocolVersion = protocolVersion;
--- a/jdk/src/share/classes/sun/tools/jstat/resources/jstat_options	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/tools/jstat/resources/jstat_options	Wed Jan 19 21:51:10 2011 -0800
@@ -589,7 +589,7 @@
   }
   column {
     header "^S0CMX^"	/* Survivor 0 Space Capacity - Maximum */
-    data sun.gc.generation.0.space.1.capacity
+    data sun.gc.generation.0.space.1.maxCapacity
     scale K
     align right
     width 8
@@ -597,7 +597,7 @@
   }
   column {
     header "^S0C^"	/* Survivor 0 Space Capacity - Current */
-    data sun.gc.generation.0.space.1.maxCapacity
+    data sun.gc.generation.0.space.1.capacity
     scale K
     align right
     width 8
--- a/jdk/src/share/classes/sun/util/logging/PlatformLogger.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/classes/sun/util/logging/PlatformLogger.java	Wed Jan 19 21:51:10 2011 -0800
@@ -113,7 +113,7 @@
 
     // Table of known loggers.  Maps names to PlatformLoggers.
     private static Map<String,WeakReference<PlatformLogger>> loggers =
-        new HashMap<String,WeakReference<PlatformLogger>>();
+        new HashMap<>();
 
     /**
      * Returns a PlatformLogger of a given name.
@@ -126,7 +126,7 @@
         }
         if (log == null) {
             log = new PlatformLogger(name);
-            loggers.put(name, new WeakReference<PlatformLogger>(log));
+            loggers.put(name, new WeakReference<>(log));
         }
         return log;
     }
@@ -488,7 +488,7 @@
      */
     static class JavaLogger extends LoggerProxy {
         private static final Map<Integer, Object> levelObjects =
-            new HashMap<Integer, Object>();
+            new HashMap<>();
 
         static {
             if (LoggingSupport.isAvailable()) {
--- a/jdk/src/share/demo/jvmti/heapTracker/heapTracker.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/demo/jvmti/heapTracker/heapTracker.c	Wed Jan 19 21:51:10 2011 -0800
@@ -340,7 +340,7 @@
 }
 
 /* Java Native Method for Object.<init> */
-static void
+static void JNICALL
 HEAP_TRACKER_native_newobj(JNIEnv *env, jclass klass, jthread thread, jobject o)
 {
     TraceInfo *tinfo;
@@ -353,7 +353,7 @@
 }
 
 /* Java Native Method for newarray */
-static void
+static void JNICALL
 HEAP_TRACKER_native_newarr(JNIEnv *env, jclass klass, jthread thread, jobject a)
 {
     TraceInfo *tinfo;
--- a/jdk/src/share/native/sun/awt/image/awt_parseImage.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/native/sun/awt/image/awt_parseImage.c	Wed Jan 19 21:51:10 2011 -0800
@@ -178,7 +178,7 @@
         jnbits = (*env)->GetObjectField(env, rasterP->jsampleModel,
                                         g_SPPSMnBitsID);
         if (jmask == NULL || joffs == NULL || jnbits == NULL ||
-            rasterP->sppsm.maxBitSize < 0 || rasterP->sppsm.maxBitSize > 8)
+            rasterP->sppsm.maxBitSize < 0)
         {
             JNU_ThrowInternalError(env, "Can't grab SPPSM fields");
             return -1;
@@ -280,6 +280,17 @@
                                   rasterP->chanOffsets);
     }
 
+    /* additioanl check for sppsm fields validity: make sure that
+     * size of raster samples doesn't exceed the data type cpacity.
+     */
+    if (rasterP->dataType > UNKNOWN_DATA_TYPE && /* data type has been recognized */
+        rasterP->sppsm.maxBitSize > 0 && /* raster has SPP sample model */
+        rasterP->sppsm.maxBitSize > (rasterP->dataSize * 8))
+    {
+        JNU_ThrowInternalError(env, "Raster samples are too big");
+        return -1;
+    }
+
 #if 0
     fprintf(stderr,"---------------------\n");
     fprintf(stderr,"Width  : %d\n",rasterP->width);
--- a/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/native/sun/awt/splashscreen/splashscreen_gfx_impl.h	Wed Jan 19 21:51:10 2011 -0800
@@ -88,27 +88,18 @@
 /*      blend (lerp between) two rgb quads
         src and dst alpha is ignored
         the algorithm: src*alpha+dst*(1-alpha)=(src-dst)*alpha+dst, rb and g are done separately
-        it's possible to verify that it's almost accurate indeed */
-
+*/
 INLINE rgbquad_t
 blendRGB(rgbquad_t dst, rgbquad_t src, rgbquad_t alpha)
 {
-    const rgbquad_t dstrb = dst & 0xFF00FF;
-    const rgbquad_t dstg = dst & 0xFF00;
-    const rgbquad_t srcrb = src & 0xFF00FF;
-    const rgbquad_t srcg = src & 0xFF00;
-
-    rgbquad_t drb = srcrb - dstrb;
-    rgbquad_t dg = srcg - dstg;
+    const rgbquad_t a = alpha;
+    const rgbquad_t a1 = 0xFF - alpha;
 
-    alpha += 1;
-
-    drb *= alpha;
-    dg *= alpha;
-    drb >>= 8;
-    dg >>= 8;
-
-    return ((drb + dstrb) & 0xFF00FF) | ((dg + dstg) & 0xFF00);
+    return MAKE_QUAD(
+        (rgbquad_t)((QUAD_RED(src) * a + QUAD_RED(dst) * a1) / 0xFF),
+        (rgbquad_t)((QUAD_GREEN(src) * a + QUAD_GREEN(dst) * a1) / 0xFF),
+        (rgbquad_t)((QUAD_BLUE(src) * a + QUAD_BLUE(dst) * a1) / 0xFF),
+        0);
 }
 
 /*      scales rgb quad by alpha. basically similar to what's above. src alpha is retained.
--- a/jdk/src/share/native/sun/java2d/loops/DrawParallelogram.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/native/sun/java2d/loops/DrawParallelogram.c	Wed Jan 19 21:51:10 2011 -0800
@@ -26,14 +26,11 @@
 #include "math.h"
 #include "GraphicsPrimitiveMgr.h"
 #include "LineUtils.h"
-#include "LoopMacros.h"
 #include "Trace.h"
+#include "ParallelogramUtils.h"
 
-#include "sun_java2d_loops_FillParallelogram.h"
 #include "sun_java2d_loops_DrawParallelogram.h"
 
-DECLARE_SOLID_DRAWLINE(AnyInt);
-
 #define HANDLE_PGRAM_EDGE(X1, Y1, X2, Y2, \
                           pRasInfo, pixel, pPrim, pFunc, pCompInfo) \
     do { \
@@ -46,28 +43,6 @@
                                ix1, iy1, ix2, iy2, JNI_TRUE); \
     } while (0)
 
-#define PGRAM_MIN_MAX(bmin, bmax, v0, dv1, dv2) \
-    do { \
-        double vmin, vmax; \
-        if (dv1 < 0) { \
-            vmin = v0+dv1; \
-            vmax = v0; \
-        } else { \
-            vmin = v0; \
-            vmax = v0+dv1; \
-        } \
-        if (dv2 < 0) { \
-            vmin -= dv2; \
-        } else { \
-            vmax += dv2; \
-        } \
-        bmin = (jint) floor(vmin + 0.5); \
-        bmax = (jint) floor(vmax + 0.5); \
-    } while(0)
-
-#define PGRAM_INIT_X(starty, x, y, slope) \
-    (DblToLong((x) + (slope) * ((starty)+0.5 - (y))) + LongOneHalf - 1)
-
 typedef struct {
     jdouble x0;
     jdouble y0;
@@ -136,20 +111,8 @@
      * Sort parallelogram by y values, ensure that each delta vector
      * has a non-negative y delta.
      */
-    if (dy1 < 0) {
-        x0 += dx1;  y0 += dy1;
-        dx1 = -dx1; dy1 = -dy1;
-    }
-    if (dy2 < 0) {
-        x0 += dx2;  y0 += dy2;
-        dx2 = -dx2; dy2 = -dy2;
-    }
-    /* Sort delta vectors so dxy1 is left of dxy2. */
-    if (dx1 * dy2 > dx2 * dy1) {
-        double v = dx1; dx1 = dx2; dx2 = v;
-               v = dy1; dy1 = dy2; dy2 = v;
-               v = lw1; lw1 = lw2; lw2 = v;
-    }
+    SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2,
+               v = lw1; lw1 = lw2; lw2 = v;);
 
     // dx,dy for line width in the "1" and "2" directions.
     ldx1 = dx1 * lw1;
@@ -161,7 +124,7 @@
     ox0 = x0 - (ldx1 + ldx2) / 2.0;
     oy0 = y0 - (ldy1 + ldy2) / 2.0;
 
-    PGRAM_MIN_MAX(ix1, ix2, ox0, dx1+ldx1, dx2+ldx2);
+    PGRAM_MIN_MAX(ix1, ix2, ox0, dx1+ldx1, dx2+ldx2, JNI_FALSE);
     iy1 = (jint) floor(oy0 + 0.5);
     iy2 = (jint) floor(oy0 + dy1 + ldy1 + dy2 + ldy2 + 0.5);
 
@@ -212,7 +175,7 @@
             // Only need to generate 4 quads if the interior still
             // has a hole in it (i.e. if the line width ratios were
             // both less than 1.0)
-            if (lw1 < 1.0f && lw2 < 1.0f) {
+            if (lw1 < 1.0 && lw2 < 1.0) {
                 // If the line widths are both less than a pixel wide
                 // then we can use a drawline function instead for even
                 // more performance.
--- a/jdk/src/share/native/sun/java2d/loops/FillParallelogram.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/native/sun/java2d/loops/FillParallelogram.c	Wed Jan 19 21:51:10 2011 -0800
@@ -25,31 +25,10 @@
 
 #include "math.h"
 #include "GraphicsPrimitiveMgr.h"
+#include "ParallelogramUtils.h"
 
 #include "sun_java2d_loops_FillParallelogram.h"
 
-#define PGRAM_MIN_MAX(bmin, bmax, v0, dv1, dv2) \
-    do { \
-        double vmin, vmax; \
-        if (dv1 < 0) { \
-            vmin = v0+dv1; \
-            vmax = v0; \
-        } else { \
-            vmin = v0; \
-            vmax = v0+dv1; \
-        } \
-        if (dv2 < 0) { \
-            vmin -= dv2; \
-        } else { \
-            vmax += dv2; \
-        } \
-        bmin = (jint) floor(vmin + 0.5); \
-        bmax = (jint) floor(vmax + 0.5); \
-    } while(0)
-
-#define PGRAM_INIT_X(starty, x, y, slope) \
-    (DblToLong((x) + (slope) * ((starty)+0.5 - (y))) + LongOneHalf - 1)
-
 /*
  * Class:     sun_java2d_loops_FillParallelogram
  * Method:    FillParallelogram
@@ -76,22 +55,11 @@
 
     /*
      * Sort parallelogram by y values, ensure that each delta vector
-     * has a non-negative y delta, and eliminate degenerate parallelograms.
+     * has a non-negative y delta.
      */
-    if (dy1 < 0) {
-        x0 += dx1;  y0 += dy1;
-        dx1 = -dx1; dy1 = -dy1;
-    }
-    if (dy2 < 0) {
-        x0 += dx2;  y0 += dy2;
-        dx2 = -dx2; dy2 = -dy2;
-    }
-    /* Sort delta vectors so dxy1 is left of dxy2. */
-    if (dx1 * dy2 > dx2 * dy1) {
-        double v = dx1; dx1 = dx2; dx2 = v;
-               v = dy1; dy1 = dy2; dy2 = v;
-    }
-    PGRAM_MIN_MAX(ix1, ix2, x0, dx1, dx2);
+    SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2, );
+
+    PGRAM_MIN_MAX(ix1, ix2, x0, dx1, dx2, JNI_FALSE);
     iy1 = (jint) floor(y0 + 0.5);
     iy2 = (jint) floor(y0 + dy1 + dy2 + 0.5);
 
--- a/jdk/src/share/native/sun/java2d/loops/MaskFill.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/native/sun/java2d/loops/MaskFill.c	Wed Jan 19 21:51:10 2011 -0800
@@ -23,7 +23,11 @@
  * questions.
  */
 
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
 #include "GraphicsPrimitiveMgr.h"
+#include "ParallelogramUtils.h"
 
 #include "sun_java2d_loops_MaskFill.h"
 
@@ -93,6 +97,967 @@
             }
         }
         SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
+   }
+   SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
+}
+
+#define MASK_BUF_LEN 1024
+
+#define DblToMask(v) ((unsigned char) ((v)*255.9999))
+
+/* Fills an aligned rectangle with potentially translucent edges. */
+static void
+fillAARect(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
+           CompositeInfo *pCompInfo, jint color, unsigned char *pMask,
+           void *pDst,
+           jdouble x1, jdouble y1, jdouble x2, jdouble y2)
+{
+    jint cx1 = pRasInfo->bounds.x1;
+    jint cy1 = pRasInfo->bounds.y1;
+    jint cx2 = pRasInfo->bounds.x2;
+    jint cy2 = pRasInfo->bounds.y2;
+    jint rx1 = (jint) ceil(x1);
+    jint ry1 = (jint) ceil(y1);
+    jint rx2 = (jint) floor(x2);
+    jint ry2 = (jint) floor(y2);
+    jint width = cx2 - cx1;
+    jint scan = pRasInfo->scanStride;
+    /* Convert xy12 into the edge coverage fractions for those edges. */
+    x1 = rx1-x1;
+    y1 = ry1-y1;
+    x2 = x2-rx2;
+    y2 = y2-ry2;
+    if (ry2 < ry1) {
+        /* Accumulate bottom coverage into top coverage. */
+        y1 = y1 + y2 - 1.0;
+        /* prevent processing of "bottom fractional row" */
+        ry2 = cy2;
+    }
+    if (rx2 < rx1) {
+        /* Accumulate right coverage into left coverage. */
+        x1 = x1 + x2 - 1.0;
+        /* prevent processing of "right fractional column" */
+        rx2 = cx2;
+    }
+    /* Check for a visible "top fractional row" and process it */
+    if (cy1 < ry1) {
+        unsigned char midcov = DblToMask(y1);
+        jint x;
+        for (x = 0; x < width; x++) {
+            pMask[x] = midcov;
+        }
+        if (cx1 < rx1) {
+            pMask[0] = DblToMask(y1 * x1);
+        }
+        if (cx2 > rx2) {
+            pMask[width-1] = DblToMask(y1 * x2);
+        }
+        (*pPrim->funcs.maskfill)(pDst,
+                                 pMask, 0, 0,
+                                 width, 1,
+                                 color, pRasInfo,
+                                 pPrim, pCompInfo);
+        pDst = PtrAddBytes(pDst, scan);
+        cy1++;
+    }
+    /* Check for a visible "left fract, solid middle, right fract" section. */
+    if (cy1 < ry2 && cy1 < cy2) {
+        jint midh = ((ry2 < cy2) ? ry2 : cy2) - cy1;
+        jint midx = cx1;
+        void *pMid = pDst;
+        /* First process the left "fractional column" if it is visible. */
+        if (midx < rx1) {
+            pMask[0] = DblToMask(x1);
+            /* Note: maskscan == 0 means we reuse this value for every row. */
+            (*pPrim->funcs.maskfill)(pMid,
+                                     pMask, 0, 0,
+                                     1, midh,
+                                     color, pRasInfo,
+                                     pPrim, pCompInfo);
+            pMid = PtrAddBytes(pMid, pRasInfo->pixelStride);
+            midx++;
+        }
+        /* Process the central solid section if it is visible. */
+        if (midx < rx2 && midx < cx2) {
+            jint midw = ((rx2 < cx2) ? rx2 : cx2) - midx;
+            /* A NULL mask buffer means "all coverages are 0xff" */
+            (*pPrim->funcs.maskfill)(pMid,
+                                     NULL, 0, 0,
+                                     midw, midh,
+                                     color, pRasInfo,
+                                     pPrim, pCompInfo);
+            pMid = PtrCoord(pMid, midw, pRasInfo->pixelStride, 0, 0);
+            midx += midw;
+        }
+        /* Finally process the right "fractional column" if it is visible. */
+        if (midx < cx2) {
+            pMask[0] = DblToMask(x2);
+            /* Note: maskscan == 0 means we reuse this value for every row. */
+            (*pPrim->funcs.maskfill)(pMid,
+                                     pMask, 0, 0,
+                                     1, midh,
+                                     color, pRasInfo,
+                                     pPrim, pCompInfo);
+        }
+        cy1 += midh;
+        pDst = PtrCoord(pDst, 0, 0, midh, scan);
+    }
+    /* Check for a visible "bottom fractional row" and process it */
+    if (cy1 < cy2) {
+        unsigned char midcov = DblToMask(y2);
+        jint x;
+        for (x = 0; x < width; x++) {
+            pMask[x] = midcov;
+        }
+        if (cx1 < rx1) {
+            pMask[0] = DblToMask(y2 * x1);
+        }
+        if (cx2 > rx2) {
+            pMask[width-1] = DblToMask(y2 * x2);
+        }
+        (*pPrim->funcs.maskfill)(pDst,
+                                 pMask, 0, 0,
+                                 width, 1,
+                                 color, pRasInfo,
+                                 pPrim, pCompInfo);
+    }
+}
+
+/*
+ * Support code for arbitrary tracing and MaskFill filling of
+ * non-rectilinear (diagonal) parallelograms.
+ *
+ * This code is based upon the following model of AA coverage.
+ *
+ * Each edge of a parallelogram (for fillPgram) or a double
+ * parallelogram (inner and outer parallelograms for drawPgram)
+ * can be rasterized independently because the geometry is well
+ * defined in such a way that none of the sides will ever cross
+ * each other and they have a fixed ordering that is fairly
+ * well predetermined.
+ *
+ * So, for each edge we will look at the diagonal line that
+ * the edge makes as it passes through a row of pixels.  Some
+ * such diagonal lines may pass entirely through the row of
+ * pixels in a single pixel column.  Some may cut across the
+ * row and pass through several pixel columns before they pass
+ * on to the next row.
+ *
+ * As the edge passes through the row of pixels it will affect
+ * the coverage of the pixels it passes through as well as all
+ * of the pixels to the right of the edge.  The coverage will
+ * either be increased (by a left edge of a parallelogram) or
+ * decreased (by a right edge) for all pixels to the right, until
+ * another edge passing the opposite direction is encountered.
+ *
+ * The coverage added or subtracted by an edge as it crosses a
+ * given pixel is calculated using a trapezoid formula in the
+ * following manner:
+ *
+ *                /
+ *     +-----+---/-+-----+
+ *     |     |  /  |     |
+ *     |     | /   |     |
+ *     +-----+/----+-----+
+ *           /
+ *
+ * The area to the right of that edge for the pixel where it
+ * crosses is given as:
+ *
+ *     trapheight * (topedge + bottomedge)/2
+ *
+ * Another thing to note is that the above formula gives the
+ * contribution of that edge to the given pixel where it crossed,
+ * but in so crossing the pixel row, it also created 100% coverage
+ * for all of the pixels to the right.
+ *
+ * This example was simplified in that the edge depicted crossed
+ * the complete pixel row and it did so entirely within the bounds
+ * of a single pixel column.  In practice, many edges may start or
+ * end in a given row and thus provide only partial row coverage
+ * (i.e. the total "trapheight" in the formula never reaches 1.0).
+ * And in other cases, edges may travel sideways through several
+ * pixel columns on a given pixel row from where they enter it to
+ * where the leave it (which also mans that the trapheight for a
+ * given pixel will be less than 1.0, but by the time the edge
+ * completes its journey through the pixel row the "coverage shadow"
+ * that it casts on all pixels to the right eventually reaches 100%).
+ *
+ * In order to simplify the calculations so that we don't have to
+ * keep propagating coverages we calculate for one edge "until we
+ * reach another edge" we will process one edge at a time and
+ * simply record in a buffer the amount that an edge added to
+ * or subtracted from the coverage for a given pixel and its
+ * following right-side neighbors.  Thus, the true total coverage
+ * of a given pixel is only determined by summing the deltas for
+ * that pixel and all of the pixels to its left.  Since we already
+ * have to scan the buffer to change floating point coverages into
+ * mask values for a MaskFill loop, it is simple enough to sum the
+ * values as we perform that scan from left to right.
+ *
+ * In the above example, note that 2 deltas need to be recorded even
+ * though the edge only intersected a single pixel.  The delta recorded
+ * for the pixel where the edge crossed will be approximately 55%
+ * (guesstimating by examining the poor ascii art) which is fine for
+ * determining how to render that pixel, but the rest of the pixels
+ * to its right should have their coverage modified by a full 100%
+ * and the 55% delta value we recorded for the pixel that the edge
+ * crossed will not get them there.  We adjust for this by adding
+ * the "remainder" of the coverage implied by the shadow to the
+ * pixel immediately to the right of where we record a trapezoidal
+ * contribution.  In this case a delta of 45% will be recorded in
+ * the pixel immediately to the right to raise the total to 100%.
+ *
+ * As we sum these delta values as we process the line from left
+ * to right, these delta values will typically drive the sum from
+ * 0% up to 100% and back down to 0% over the course of a single
+ * pixel row.  In the case of a drawn (double) parallelogram the
+ * sum will go to 100% and back to 0% twice on most scanlines.
+ *
+ * The fillAAPgram and drawAAPgram functions drive the main flow
+ * of the algorithm with help from the following structures,
+ * macros, and functions.  It is probably best to start with
+ * those 2 functions to gain an understanding of the algorithm.
+ */
+typedef struct {
+    jdouble x;
+    jdouble y;
+    jdouble xbot;
+    jdouble ybot;
+    jdouble xnexty;
+    jdouble ynextx;
+    jdouble xnextx;
+    jdouble linedx;
+    jdouble celldx;
+    jdouble celldy;
+    jboolean isTrailing;
+} EdgeInfo;
+
+#define MIN_DELTA  (1.0/256.0)
+
+/*
+ * Calculates slopes and deltas for an edge and stores results in an EdgeInfo.
+ * Returns true if the edge was valid (i.e. not ignored for some reason).
+ */
+static jboolean
+storeEdge(EdgeInfo *pEdge,
+          jdouble x, jdouble y, jdouble dx, jdouble dy,
+          jint cx1, jint cy1, jint cx2, jint cy2,
+          jboolean isTrailing)
+{
+    jdouble xbot = x + dx;
+    jdouble ybot = y + dy;
+    jboolean ret;
+
+    pEdge->x = x;
+    pEdge->y = y;
+    pEdge->xbot = xbot;
+    pEdge->ybot = ybot;
+
+    /* Note that parallelograms are sorted so dy is always non-negative */
+    if (dy > MIN_DELTA &&        /* NaN and horizontal protection */
+        ybot > cy1 &&            /* NaN and "OUT_ABOVE" protection */
+        y < cy2 &&               /* NaN and "OUT_BELOW" protection */
+        xbot == xbot &&          /* NaN protection */
+        (x < cx2 || xbot < cx2)) /* "OUT_RIGHT" protection */
+        /* Note: "OUT_LEFT" segments may still contribute coverage... */
+    {
+        /* no NaNs, dy is not horizontal, and segment contributes to clip */
+        if (dx < -MIN_DELTA || dx > MIN_DELTA) {
+            /* dx is not vertical */
+            jdouble linedx;
+            jdouble celldy;
+            jdouble nextx;
+
+            linedx = dx / dy;
+            celldy = dy / dx;
+            if (y < cy1) {
+                pEdge->x = x = x + (cy1 - y) * linedx;
+                pEdge->y = y = cy1;
+            }
+            pEdge->linedx = linedx;
+            if (dx < 0) {
+                pEdge->celldx = -1.0;
+                pEdge->celldy = -celldy;
+                pEdge->xnextx = nextx = ceil(x) - 1.0;
+            } else {
+                pEdge->celldx = +1.0;
+                pEdge->celldy = celldy;
+                pEdge->xnextx = nextx = floor(x) + 1.0;
+            }
+            pEdge->ynextx = y + (nextx - x) * celldy;
+            pEdge->xnexty = x + ((floor(y) + 1) - y) * linedx;
+        } else {
+            /* dx is essentially vertical */
+            if (y < cy1) {
+                pEdge->y = y = cy1;
+            }
+            pEdge->xbot = x;
+            pEdge->linedx = 0.0;
+            pEdge->celldx = 0.0;
+            pEdge->celldy = 1.0;
+            pEdge->xnextx = x;
+            pEdge->xnexty = x;
+            pEdge->ynextx = ybot;
+        }
+        ret = JNI_TRUE;
+    } else {
+        /* There is some reason to ignore this segment, "celldy=0" omits it */
+        pEdge->ybot = y;
+        pEdge->linedx = dx;
+        pEdge->celldx = dx;
+        pEdge->celldy = 0.0;
+        pEdge->xnextx = xbot;
+        pEdge->xnexty = xbot;
+        pEdge->ynextx = y;
+        ret = JNI_FALSE;
+    }
+    pEdge->isTrailing = isTrailing;
+    return ret;
+}
+
+/*
+ * Calculates and stores slopes and deltas for all edges of a parallelogram.
+ * Returns true if at least 1 edge was valid (i.e. not ignored for some reason).
+ *
+ * The inverted flag is true for an outer parallelogram (left and right
+ * edges are leading and trailing) and false for an inner parallelogram
+ * (where the left edge is trailing and the right edge is leading).
+ */
+static jboolean
+storePgram(EdgeInfo *pLeftEdge, EdgeInfo *pRightEdge,
+           jdouble x, jdouble y,
+           jdouble dx1, jdouble dy1,
+           jdouble dx2, jdouble dy2,
+           jint cx1, jint cy1, jint cx2, jint cy2,
+           jboolean inverted)
+{
+    jboolean ret = JNI_FALSE;
+    ret = (storeEdge(pLeftEdge  + 0,
+                     x    , y    , dx1, dy1,
+                     cx1, cy1, cx2, cy2, inverted) || ret);
+    ret = (storeEdge(pLeftEdge  + 1,
+                     x+dx1, y+dy1, dx2, dy2,
+                     cx1, cy1, cx2, cy2, inverted) || ret);
+    ret = (storeEdge(pRightEdge + 0,
+                     x    , y    , dx2, dy2,
+                     cx1, cy1, cx2, cy2, !inverted) || ret);
+    ret = (storeEdge(pRightEdge + 1,
+                     x+dx2, y+dy2, dx1, dy1,
+                     cx1, cy1, cx2, cy2, !inverted) || ret);
+    return ret;
+}
+
+/*
+ * The X0,Y0,X1,Y1 values represent a trapezoidal fragment whose
+ * coverage must be accounted for in the accum buffer.
+ *
+ * All four values are assumed to fall within (or on the edge of)
+ * a single pixel.
+ *
+ * The trapezoid area is accumulated into the proper element of
+ * the accum buffer and the remainder of the "slice height" is
+ * accumulated into the element to its right.
+ */
+#define INSERT_ACCUM(pACCUM, IMIN, IMAX, X0, Y0, X1, Y1, CX1, CX2, MULT) \
+    do { \
+        jdouble xmid = ((X0) + (X1)) * 0.5; \
+        if (xmid <= (CX2)) { \
+            jdouble sliceh = ((Y1) - (Y0)); \
+            jdouble slicearea; \
+            jint i; \
+            if (xmid < (CX1)) { \
+                /* Accumulate the entire slice height into accum[0]. */ \
+                i = 0; \
+                slicearea = sliceh; \
+            } else { \
+                jdouble xpos = floor(xmid); \
+                i = ((jint) xpos) - (CX1); \
+                slicearea = (xpos+1-xmid) * sliceh; \
+            } \
+            if (IMIN > i) { \
+                IMIN = i; \
+            } \
+            (pACCUM)[i++] += (jfloat) ((MULT) * slicearea); \
+            (pACCUM)[i++] += (jfloat) ((MULT) * (sliceh - slicearea)); \
+            if (IMAX < i) { \
+                IMAX = i; \
+            } \
+        } \
+    } while (0)
+
+/*
+ * Accumulate the contributions for a given edge crossing a given
+ * scan line into the corresponding entries of the accum buffer.
+ * CY1 is the Y coordinate of the top edge of the scanline and CY2
+ * is equal to (CY1 + 1) and is the Y coordinate of the bottom edge
+ * of the scanline.  CX1 and CX2 are the left and right edges of the
+ * clip (or area of interest) being rendered.
+ *
+ * The edge is processed from the top edge to the bottom edge and
+ * a single pixel column at a time.
+ */
+#define ACCUM_EDGE(pEDGE, pACCUM, IMIN, IMAX, CX1, CY1, CX2, CY2) \
+    do { \
+        jdouble x, y, xnext, ynext, xlast, ylast, dx, dy, mult; \
+        y = (pEDGE)->y; \
+        dy = (pEDGE)->celldy; \
+        ylast = (pEDGE)->ybot; \
+        if (ylast <= (CY1) || y >= (CY2) || dy == 0.0) { \
+            break; \
+        } \
+        x = (pEDGE)->x; \
+        dx = (pEDGE)->celldx; \
+        if (ylast > (CY2)) { \
+            ylast = (CY2); \
+            xlast = (pEDGE)->xnexty; \
+        } else { \
+            xlast = (pEDGE)->xbot; \
+        } \
+        xnext = (pEDGE)->xnextx; \
+        ynext = (pEDGE)->ynextx; \
+        mult = ((pEDGE)->isTrailing) ? -1.0 : 1.0; \
+        while (ynext <= ylast) { \
+            INSERT_ACCUM(pACCUM, IMIN, IMAX, \
+                         x, y, xnext, ynext, \
+                         CX1, CX2, mult); \
+            x = xnext; \
+            y = ynext; \
+            xnext += dx; \
+            ynext += dy; \
+        } \
+        (pEDGE)->ynextx = ynext; \
+        (pEDGE)->xnextx = xnext; \
+        INSERT_ACCUM(pACCUM, IMIN, IMAX, \
+                     x, y, xlast, ylast, \
+                     CX1, CX2, mult); \
+        (pEDGE)->x = xlast; \
+        (pEDGE)->y = ylast; \
+        (pEDGE)->xnexty = xlast + (pEDGE)->linedx; \
+    } while(0)
+
+/* Main function to fill a single Parallelogram */
+static void
+fillAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
+            CompositeInfo *pCompInfo, jint color, unsigned char *pMask,
+            void *pDst,
+            jdouble x1, jdouble y1,
+            jdouble dx1, jdouble dy1,
+            jdouble dx2, jdouble dy2)
+{
+    jint cx1 = pRasInfo->bounds.x1;
+    jint cy1 = pRasInfo->bounds.y1;
+    jint cx2 = pRasInfo->bounds.x2;
+    jint cy2 = pRasInfo->bounds.y2;
+    jint width = cx2 - cx1;
+    EdgeInfo edges[4];
+    jfloat localaccum[MASK_BUF_LEN + 1];
+    jfloat *pAccum;
+
+    if (!storePgram(edges + 0, edges + 2,
+                    x1, y1, dx1, dy1, dx2, dy2,
+                    cx1, cy1, cx2, cy2,
+                    JNI_FALSE))
+    {
+        return;
+    }
+
+    pAccum = ((width > MASK_BUF_LEN)
+              ? malloc((width + 1) * sizeof(jfloat))
+              : localaccum);
+    if (pAccum == NULL) {
+        return;
+    }
+    memset(pAccum, 0, (width+1) * sizeof(jfloat));
+
+    while (cy1 < cy2) {
+        jint lmin, lmax, rmin, rmax;
+        jint moff, x;
+        jdouble accum;
+        unsigned char lastcov;
+
+        lmin = rmin = width + 2;
+        lmax = rmax = 0;
+        ACCUM_EDGE(&edges[0], pAccum, lmin, lmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[1], pAccum, lmin, lmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[2], pAccum, rmin, rmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[3], pAccum, rmin, rmax,
+                   cx1, cy1, cx2, cy1+1);
+        if (lmax > width) {
+            lmax = width; /* Extra col has data we do not need. */
+        }
+        if (rmax > width) {
+            rmax = width; /* Extra col has data we do not need. */
+        }
+        /* If ranges overlap, handle both in the first pass. */
+        if (rmin <= lmax) {
+            lmax = rmax;
+        }
+
+        x = lmin;
+        accum = 0.0;
+        moff = 0;
+        lastcov = 0;
+        while (x < lmax) {
+            accum += pAccum[x];
+            pAccum[x] = 0.0f;
+            pMask[moff++] = lastcov = DblToMask(accum);
+            x++;
+        }
+        /* Check for a solid center section. */
+        if (lastcov == 0xFF) {
+            jint endx;
+            void *pRow;
+
+            /* First process the existing partial coverage data. */
+            if (moff > 0) {
+                pRow = PtrCoord(pDst, x-moff, pRasInfo->pixelStride, 0, 0);
+                (*pPrim->funcs.maskfill)(pRow,
+                                         pMask, 0, 0,
+                                         moff, 1,
+                                         color, pRasInfo,
+                                         pPrim, pCompInfo);
+                moff = 0;
+            }
+
+            /* Where does the center section end? */
+            /* If there is no right AA edge in the accum buffer, then */
+            /* the right edge was beyond the clip, so fill out to width */
+            endx = (rmin < rmax) ? rmin : width;
+            if (x < endx) {
+                pRow = PtrCoord(pDst, x, pRasInfo->pixelStride, 0, 0);
+                (*pPrim->funcs.maskfill)(pRow,
+                                         NULL, 0, 0,
+                                         endx - x, 1,
+                                         color, pRasInfo,
+                                         pPrim, pCompInfo);
+                x = endx;
+            }
+        } else if (lastcov > 0 && rmin >= rmax) {
+            /* We are not at 0 coverage, but there is no right edge, */
+            /* force a right edge so we process pixels out to width. */
+            rmax = width;
+        }
+        /* The following loop will process the right AA edge and/or any */
+        /* partial coverage center section not processed above. */
+        while (x < rmax) {
+            accum += pAccum[x];
+            pAccum[x] = 0.0f;
+            pMask[moff++] = DblToMask(accum);
+            x++;
+        }
+        if (moff > 0) {
+            void *pRow = PtrCoord(pDst, x-moff, pRasInfo->pixelStride, 0, 0);
+            (*pPrim->funcs.maskfill)(pRow,
+                                     pMask, 0, 0,
+                                     moff, 1,
+                                     color, pRasInfo,
+                                     pPrim, pCompInfo);
+        }
+        pDst = PtrAddBytes(pDst, pRasInfo->scanStride);
+        cy1++;
+    }
+    if (pAccum != localaccum) {
+        free(pAccum);
+    }
+}
+
+/*
+ * Class:     sun_java2d_loops_MaskFill
+ * Method:    FillAAPgram
+ * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;Ljava/awt/Composite;DDDDDD)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_java2d_loops_MaskFill_FillAAPgram
+    (JNIEnv *env, jobject self,
+     jobject sg2d, jobject sData, jobject comp,
+     jdouble x0, jdouble y0,
+     jdouble dx1, jdouble dy1,
+     jdouble dx2, jdouble dy2)
+{
+    SurfaceDataOps *sdOps;
+    SurfaceDataRasInfo rasInfo;
+    NativePrimitive *pPrim;
+    CompositeInfo compInfo;
+    jint ix1, iy1, ix2, iy2;
+
+    if ((dy1 == 0 && dx1 == 0) || (dy2 == 0 && dx2 == 0)) {
+        return;
+    }
+
+    /*
+     * Sort parallelogram by y values, ensure that each delta vector
+     * has a non-negative y delta.
+     */
+    SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2, );
+
+    PGRAM_MIN_MAX(ix1, ix2, x0, dx1, dx2, JNI_TRUE);
+    iy1 = (jint) floor(y0);
+    iy2 = (jint) ceil(y0 + dy1 + dy2);
+
+    pPrim = GetNativePrim(env, self);
+    if (pPrim == NULL) {
+        return;
+    }
+    if (pPrim->pCompType->getCompInfo != NULL) {
+        (*pPrim->pCompType->getCompInfo)(env, &compInfo, comp);
+    }
+
+    sdOps = SurfaceData_GetOps(env, sData);
+    if (sdOps == 0) {
+        return;
+    }
+
+    GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);
+    SurfaceData_IntersectBoundsXYXY(&rasInfo.bounds, ix1, iy1, ix2, iy2);
+    if (rasInfo.bounds.y2 <= rasInfo.bounds.y1 ||
+        rasInfo.bounds.x2 <= rasInfo.bounds.x1)
+    {
+        return;
+    }
+
+    if (sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags) != SD_SUCCESS) {
+        return;
+    }
+
+    ix1 = rasInfo.bounds.x1;
+    iy1 = rasInfo.bounds.y1;
+    ix2 = rasInfo.bounds.x2;
+    iy2 = rasInfo.bounds.y2;
+    if (ix2 > ix1 && iy2 > iy1) {
+        jint width = ix2 - ix1;
+        jint color = GrPrim_Sg2dGetEaRGB(env, sg2d);
+        unsigned char localmask[MASK_BUF_LEN];
+        unsigned char *pMask = ((width > MASK_BUF_LEN)
+                                ? malloc(width)
+                                : localmask);
+
+        sdOps->GetRasInfo(env, sdOps, &rasInfo);
+        if (rasInfo.rasBase != NULL && pMask != NULL) {
+            void *pDst = PtrCoord(rasInfo.rasBase,
+                                  ix1, rasInfo.pixelStride,
+                                  iy1, rasInfo.scanStride);
+            if (dy1 == 0 && dx2 == 0) {
+                if (dx1 < 0) {
+                    // We sorted by Y above, but not by X
+                    x0 += dx1;
+                    dx1 = -dx1;
+                }
+                fillAARect(pPrim, &rasInfo, &compInfo,
+                           color, pMask, pDst,
+                           x0, y0, x0+dx1, y0+dy2);
+            } else if (dx1 == 0 && dy2 == 0) {
+                if (dx2 < 0) {
+                    // We sorted by Y above, but not by X
+                    x0 += dx2;
+                    dx2 = -dx2;
+                }
+                fillAARect(pPrim, &rasInfo, &compInfo,
+                           color, pMask, pDst,
+                           x0, y0, x0+dx2, y0+dy1);
+            } else {
+                fillAAPgram(pPrim, &rasInfo, &compInfo,
+                            color, pMask, pDst,
+                            x0, y0, dx1, dy1, dx2, dy2);
+            }
+        }
+        SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
+        if (pMask != NULL && pMask != localmask) {
+            free(pMask);
+        }
     }
     SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
 }
+
+/* Main function to fill a double pair of (inner and outer) parallelograms */
+static void
+drawAAPgram(NativePrimitive *pPrim, SurfaceDataRasInfo *pRasInfo,
+            CompositeInfo *pCompInfo, jint color, unsigned char *pMask,
+            void *pDst,
+            jdouble ox0, jdouble oy0,
+            jdouble dx1, jdouble dy1,
+            jdouble dx2, jdouble dy2,
+            jdouble ldx1, jdouble ldy1,
+            jdouble ldx2, jdouble ldy2)
+{
+    jint cx1 = pRasInfo->bounds.x1;
+    jint cy1 = pRasInfo->bounds.y1;
+    jint cx2 = pRasInfo->bounds.x2;
+    jint cy2 = pRasInfo->bounds.y2;
+    jint width = cx2 - cx1;
+    EdgeInfo edges[8];
+    jfloat localaccum[MASK_BUF_LEN + 1];
+    jfloat *pAccum;
+
+    if (!storePgram(edges + 0, edges + 6,
+                    ox0, oy0,
+                    dx1 + ldx1, dy1 + ldy1,
+                    dx2 + ldx2, dy2 + ldy2,
+                    cx1, cy1, cx2, cy2,
+                    JNI_FALSE))
+    {
+        /* If outer pgram does not contribute, then inner cannot either. */
+        return;
+    }
+    storePgram(edges + 2, edges + 4,
+               ox0 + ldx1 + ldx2, oy0 + ldy1 + ldy2,
+               dx1 - ldx1, dy1 - ldy1,
+               dx2 - ldx2, dy2 - ldy2,
+               cx1, cy1, cx2, cy2,
+               JNI_TRUE);
+
+    pAccum = ((width > MASK_BUF_LEN)
+              ? malloc((width + 1) * sizeof(jfloat))
+              : localaccum);
+    if (pAccum == NULL) {
+        return;
+    }
+    memset(pAccum, 0, (width+1) * sizeof(jfloat));
+
+    while (cy1 < cy2) {
+        jint lmin, lmax, rmin, rmax;
+        jint moff, x;
+        jdouble accum;
+        unsigned char lastcov;
+
+        lmin = rmin = width + 2;
+        lmax = rmax = 0;
+        ACCUM_EDGE(&edges[0], pAccum, lmin, lmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[1], pAccum, lmin, lmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[2], pAccum, lmin, lmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[3], pAccum, lmin, lmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[4], pAccum, rmin, rmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[5], pAccum, rmin, rmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[6], pAccum, rmin, rmax,
+                   cx1, cy1, cx2, cy1+1);
+        ACCUM_EDGE(&edges[7], pAccum, rmin, rmax,
+                   cx1, cy1, cx2, cy1+1);
+        if (lmax > width) {
+            lmax = width; /* Extra col has data we do not need. */
+        }
+        if (rmax > width) {
+            rmax = width; /* Extra col has data we do not need. */
+        }
+        /* If ranges overlap, handle both in the first pass. */
+        if (rmin <= lmax) {
+            lmax = rmax;
+        }
+
+        x = lmin;
+        accum = 0.0;
+        moff = 0;
+        lastcov = 0;
+        while (x < lmax) {
+            accum += pAccum[x];
+            pAccum[x] = 0.0f;
+            pMask[moff++] = lastcov = DblToMask(accum);
+            x++;
+        }
+        /* Check for an empty or solidcenter section. */
+        if (lastcov == 0 || lastcov == 0xFF) {
+            jint endx;
+            void *pRow;
+
+            /* First process the existing partial coverage data. */
+            if (moff > 0) {
+                pRow = PtrCoord(pDst, x-moff, pRasInfo->pixelStride, 0, 0);
+                (*pPrim->funcs.maskfill)(pRow,
+                                         pMask, 0, 0,
+                                         moff, 1,
+                                         color, pRasInfo,
+                                         pPrim, pCompInfo);
+                moff = 0;
+            }
+
+            /* Where does the center section end? */
+            /* If there is no right AA edge in the accum buffer, then */
+            /* the right edge was beyond the clip, so fill out to width */
+            endx = (rmin < rmax) ? rmin : width;
+            if (x < endx) {
+                if (lastcov == 0xFF) {
+                    pRow = PtrCoord(pDst, x, pRasInfo->pixelStride, 0, 0);
+                    (*pPrim->funcs.maskfill)(pRow,
+                                             NULL, 0, 0,
+                                             endx - x, 1,
+                                             color, pRasInfo,
+                                             pPrim, pCompInfo);
+                }
+                x = endx;
+            }
+        } else if (rmin >= rmax) {
+            /* We are not at 0 coverage, but there is no right edge, */
+            /* force a right edge so we process pixels out to width. */
+            rmax = width;
+        }
+        /* The following loop will process the right AA edge and/or any */
+        /* partial coverage center section not processed above. */
+        while (x < rmax) {
+            accum += pAccum[x];
+            pAccum[x] = 0.0f;
+            pMask[moff++] = lastcov = DblToMask(accum);
+            x++;
+        }
+        if (moff > 0) {
+            void *pRow = PtrCoord(pDst, x-moff, pRasInfo->pixelStride, 0, 0);
+            (*pPrim->funcs.maskfill)(pRow,
+                                     pMask, 0, 0,
+                                     moff, 1,
+                                     color, pRasInfo,
+                                     pPrim, pCompInfo);
+        }
+        if (lastcov == 0xFF && x < width) {
+            void *pRow = PtrCoord(pDst, x, pRasInfo->pixelStride, 0, 0);
+            (*pPrim->funcs.maskfill)(pRow,
+                                     NULL, 0, 0,
+                                     width - x, 1,
+                                     color, pRasInfo,
+                                     pPrim, pCompInfo);
+        }
+        pDst = PtrAddBytes(pDst, pRasInfo->scanStride);
+        cy1++;
+    }
+    if (pAccum != localaccum) {
+        free(pAccum);
+    }
+}
+
+/*
+ * Class:     sun_java2d_loops_MaskFill
+ * Method:    DrawAAPgram
+ * Signature: (Lsun/java2d/SunGraphics2D;Lsun/java2d/SurfaceData;Ljava/awt/Composite;DDDDDDDD)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_java2d_loops_MaskFill_DrawAAPgram
+    (JNIEnv *env, jobject self,
+     jobject sg2d, jobject sData, jobject comp,
+     jdouble x0, jdouble y0,
+     jdouble dx1, jdouble dy1,
+     jdouble dx2, jdouble dy2,
+     jdouble lw1, jdouble lw2)
+{
+    SurfaceDataOps *sdOps;
+    SurfaceDataRasInfo rasInfo;
+    NativePrimitive *pPrim;
+    CompositeInfo compInfo;
+    jint ix1, iy1, ix2, iy2;
+    jdouble ldx1, ldy1, ldx2, ldy2;
+    jdouble ox0, oy0;
+
+    if ((dy1 == 0 && dx1 == 0) || (dy2 == 0 && dx2 == 0)) {
+        return;
+    }
+
+    /*
+     * Sort parallelogram by y values, ensure that each delta vector
+     * has a non-negative y delta.
+     */
+    SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2,
+               v = lw1; lw1 = lw2; lw2 = v;);
+
+    // dx,dy for line width in the "1" and "2" directions.
+    ldx1 = dx1 * lw1;
+    ldy1 = dy1 * lw1;
+    ldx2 = dx2 * lw2;
+    ldy2 = dy2 * lw2;
+
+    // calculate origin of the outer parallelogram
+    ox0 = x0 - (ldx1 + ldx2) / 2.0;
+    oy0 = y0 - (ldy1 + ldy2) / 2.0;
+
+    if (lw1 >= 1.0 || lw2 >= 1.0) {
+        /* Only need to fill an outer pgram if the interior no longer
+         * has a hole in it (i.e. if either of the line width ratios
+         * were greater than or equal to 1.0).
+         */
+        Java_sun_java2d_loops_MaskFill_FillAAPgram(env, self,
+                                                   sg2d, sData, comp,
+                                                   ox0, oy0,
+                                                   dx1 + ldx1, dy1 + ldy1,
+                                                   dx2 + ldx2, dy2 + ldy2);
+        return;
+    }
+
+    PGRAM_MIN_MAX(ix1, ix2, ox0, dx1+ldx1, dx2+ldx2, JNI_TRUE);
+    iy1 = (jint) floor(oy0);
+    iy2 = (jint) ceil(oy0 + dy1 + ldy1 + dy2 + ldy2);
+
+    pPrim = GetNativePrim(env, self);
+    if (pPrim == NULL) {
+        return;
+    }
+    if (pPrim->pCompType->getCompInfo != NULL) {
+        (*pPrim->pCompType->getCompInfo)(env, &compInfo, comp);
+    }
+
+    sdOps = SurfaceData_GetOps(env, sData);
+    if (sdOps == 0) {
+        return;
+    }
+
+    GrPrim_Sg2dGetClip(env, sg2d, &rasInfo.bounds);
+    SurfaceData_IntersectBoundsXYXY(&rasInfo.bounds, ix1, iy1, ix2, iy2);
+    if (rasInfo.bounds.y2 <= rasInfo.bounds.y1 ||
+        rasInfo.bounds.x2 <= rasInfo.bounds.x1)
+    {
+        return;
+    }
+
+    if (sdOps->Lock(env, sdOps, &rasInfo, pPrim->dstflags) != SD_SUCCESS) {
+        return;
+    }
+
+    ix1 = rasInfo.bounds.x1;
+    iy1 = rasInfo.bounds.y1;
+    ix2 = rasInfo.bounds.x2;
+    iy2 = rasInfo.bounds.y2;
+    if (ix2 > ix1 && iy2 > iy1) {
+        jint width = ix2 - ix1;
+        jint color = GrPrim_Sg2dGetEaRGB(env, sg2d);
+        unsigned char localmask[MASK_BUF_LEN];
+        unsigned char *pMask = ((width > MASK_BUF_LEN)
+                                ? malloc(width)
+                                : localmask);
+
+        sdOps->GetRasInfo(env, sdOps, &rasInfo);
+        if (rasInfo.rasBase != NULL && pMask != NULL) {
+            void *pDst = PtrCoord(rasInfo.rasBase,
+                                  ix1, rasInfo.pixelStride,
+                                  iy1, rasInfo.scanStride);
+            /*
+             * NOTE: aligned rects could probably be drawn
+             * even faster with a little work here.
+             * if (dy1 == 0 && dx2 == 0) {
+             *     drawAARect(pPrim, &rasInfo, &compInfo,
+             *                color, pMask, pDst,
+             *                ox0, oy0, ox0+dx1+ldx1, oy0+dy2+ldy2, ldx1, ldy2);
+             * } else if (dx1 == 0 && dy2 == 0) {
+             *     drawAARect(pPrim, &rasInfo, &compInfo,
+             *                color, pMask, pDst,
+             *                ox0, oy0, ox0+dx2+ldx2, oy0+dy1+ldy1, ldx2, ldy1);
+             * } else {
+             */
+            drawAAPgram(pPrim, &rasInfo, &compInfo,
+                        color, pMask, pDst,
+                        ox0, oy0,
+                        dx1, dy1, dx2, dy2,
+                        ldx1, ldy1, ldx2, ldy2);
+            /*
+             * }
+             */
+        }
+        SurfaceData_InvokeRelease(env, sdOps, &rasInfo);
+        if (pMask != NULL && pMask != localmask) {
+            free(pMask);
+        }
+    }
+    SurfaceData_InvokeUnlock(env, sdOps, &rasInfo);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/sun/java2d/loops/ParallelogramUtils.h	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2008, 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.
+ */
+
+#ifndef ParallelogramUtils_h_Included
+#define ParallelogramUtils_h_Included
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PGRAM_MIN_MAX(bmin, bmax, v0, dv1, dv2, AA) \
+    do { \
+        double vmin, vmax; \
+        if (dv1 < 0) { \
+            vmin = v0+dv1; \
+            vmax = v0; \
+        } else { \
+            vmin = v0; \
+            vmax = v0+dv1; \
+        } \
+        if (dv2 < 0) { \
+            vmin += dv2; \
+        } else { \
+            vmax += dv2; \
+        } \
+        if (AA) { \
+            bmin = (jint) floor(vmin); \
+            bmax = (jint) ceil(vmax); \
+        } else { \
+            bmin = (jint) floor(vmin + 0.5); \
+            bmax = (jint) floor(vmax + 0.5); \
+        } \
+    } while(0)
+
+#define PGRAM_INIT_X(starty, x, y, slope) \
+    (DblToLong((x) + (slope) * ((starty)+0.5 - (y))) + LongOneHalf - 1)
+
+/*
+ * Sort parallelogram by y values, ensure that each delta vector
+ * has a non-negative y delta.
+ */
+#define SORT_PGRAM(x0, y0, dx1, dy1, dx2, dy2, OTHER_SWAP_CODE) \
+    do { \
+        if (dy1 < 0) { \
+            x0 += dx1;  y0 += dy1; \
+            dx1 = -dx1; dy1 = -dy1; \
+        } \
+        if (dy2 < 0) { \
+            x0 += dx2;  y0 += dy2; \
+            dx2 = -dx2; dy2 = -dy2; \
+        } \
+        /* Sort delta vectors so dxy1 is left of dxy2. */ \
+        if (dx1 * dy2 > dx2 * dy1) { \
+            double v; \
+            v = dx1; dx1 = dx2; dx2 = v; \
+            v = dy1; dy1 = dy2; dy2 = v; \
+            OTHER_SWAP_CODE \
+        } \
+    } while(0)
+
+#endif /* ParallelogramUtils_h_Included */
--- a/jdk/src/share/native/sun/java2d/pipe/BufferedMaskBlit.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/share/native/sun/java2d/pipe/BufferedMaskBlit.c	Wed Jan 19 21:51:10 2011 -0800
@@ -119,7 +119,8 @@
                 PtrCoord(srcInfo.rasBase,
                          srcInfo.bounds.x1, srcInfo.pixelStride,
                          srcInfo.bounds.y1, srcInfo.scanStride);
-            unsigned char *pMask =
+            unsigned char *pMask, *pMaskAlloc;
+            pMask = pMaskAlloc =
                 (*env)->GetPrimitiveArrayCritical(env, maskArray, 0);
             if (pMask == NULL) {
                 J2dRlsTraceLn(J2D_TRACE_ERROR,
@@ -274,7 +275,7 @@
             bpos += width * height * sizeof(jint);
 
             (*env)->ReleasePrimitiveArrayCritical(env, maskArray,
-                                                  pMask, JNI_ABORT);
+                                                  pMaskAlloc, JNI_ABORT);
         }
         SurfaceData_InvokeRelease(env, srcOps, &srcInfo);
     }
--- a/jdk/src/solaris/classes/java/lang/ProcessEnvironment.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/solaris/classes/java/lang/ProcessEnvironment.java	Wed Jan 19 21:51:10 2011 -0800
@@ -68,7 +68,7 @@
         // We cache the C environment.  This means that subsequent calls
         // to putenv/setenv from C will not be visible from Java code.
         byte[][] environ = environ();
-        theEnvironment = new HashMap<Variable,Value>(environ.length/2 + 3);
+        theEnvironment = new HashMap<>(environ.length/2 + 3);
         // Read environment variables back to front,
         // so that earlier variables override later ones.
         for (int i = environ.length-1; i > 0; i-=2)
--- a/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Wed Jan 19 21:51:10 2011 -0800
@@ -354,7 +354,7 @@
      * log against that map.  The resulting map is then written back
      * to the disk.
      */
-    final List<Change> changeLog = new ArrayList<Change>();
+    final List<Change> changeLog = new ArrayList<>();
 
     /**
      * Represents a change to a preference.
@@ -507,7 +507,7 @@
         });
         if (newNode) {
             // These 2 things guarantee node will get wrtten at next flush/sync
-            prefsCache = new TreeMap<String, String>();
+            prefsCache = new TreeMap<>();
             nodeCreate = new NodeCreate();
             changeLog.add(nodeCreate);
         }
@@ -550,7 +550,7 @@
             loadCache();
         } catch(Exception e) {
             // assert lastSyncTime == 0;
-            prefsCache = new TreeMap<String, String>();
+            prefsCache = new TreeMap<>();
         }
     }
 
@@ -567,7 +567,7 @@
             AccessController.doPrivileged(
                 new PrivilegedExceptionAction<Void>() {
                 public Void run() throws BackingStoreException {
-                    Map<String, String> m = new TreeMap<String, String>();
+                    Map<String, String> m = new TreeMap<>();
                     long newLastSyncTime = 0;
                     try {
                         newLastSyncTime = prefsFile.lastModified();
@@ -581,7 +581,7 @@
                             prefsFile.renameTo( new File(
                                                     prefsFile.getParentFile(),
                                                   "IncorrectFormatPrefs.xml"));
-                            m = new TreeMap<String, String>();
+                            m = new TreeMap<>();
                         } else if (e instanceof FileNotFoundException) {
                         getLogger().warning("Prefs file removed in background "
                                            + prefsFile.getPath());
@@ -646,7 +646,7 @@
         return AccessController.doPrivileged(
             new PrivilegedAction<String[]>() {
                 public String[] run() {
-                    List<String> result = new ArrayList<String>();
+                    List<String> result = new ArrayList<>();
                     File[] dirContents = dir.listFiles();
                     if (dirContents != null) {
                         for (int i = 0; i < dirContents.length; i++)
@@ -794,7 +794,7 @@
         } else if (lastSyncTime != 0 && !dir.exists()) {
             // This node was removed in the background.  Playback any changes
             // against a virgin (empty) Map.
-            prefsCache = new TreeMap<String, String>();
+            prefsCache = new TreeMap<>();
             replayChanges();
         }
         if (!changeLog.isEmpty()) {
--- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Wed Jan 19 21:51:10 2011 -0800
@@ -191,7 +191,7 @@
 
     fp_gdk_threads_enter();
 
-    const char *title = (*env)->GetStringUTFChars(env, jtitle, 0);
+    const char *title = jtitle == NULL? "": (*env)->GetStringUTFChars(env, jtitle, 0);
 
     if (mode == 1) {
         /* Save action */
@@ -212,7 +212,9 @@
         }
     }
 
-    (*env)->ReleaseStringUTFChars(env, jtitle, title);
+    if (jtitle != NULL) {
+      (*env)->ReleaseStringUTFChars(env, jtitle, title);
+    }
 
     /* Set the directory */
     if (jdir != NULL) {
--- a/jdk/src/solaris/native/sun/java2d/loops/vis_IntArgbPre_Mask.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/solaris/native/sun/java2d/loops/vis_IntArgbPre_Mask.c	Wed Jan 19 21:51:10 2011 -0800
@@ -517,13 +517,15 @@
         ADD_SUFF(AnyIntSetRect)(pRasInfo, 0, 0, width, height,
                                 fgColor, pPrim, pCompInfo);
 #else
+        void *pBase = pRasInfo->rasBase;
+        pRasInfo->rasBase = rasBase;
         if (cnstA != 0xff) {
             fgColor = (cnstA << 24) | (cnstR << 16) | (cnstG << 8) | cnstB;
         }
         ADD_SUFF(AnyIntSetRect)(pRasInfo,
-                                pRasInfo->bounds.x1, pRasInfo->bounds.y1,
-                                pRasInfo->bounds.x2, pRasInfo->bounds.y2,
+                                0, 0, width, height,
                                 fgColor, pPrim, pCompInfo);
+        pRasInfo->rasBase = pBase;
 #endif
         return;
     }
@@ -582,11 +584,13 @@
     }
 
     if (pMask == NULL) {
+        void *pBase = pRasInfo->rasBase;
+        pRasInfo->rasBase = rasBase;
         fgColor = (cnstR << 24) | (cnstG << 16) | (cnstB << 8) | cnstA;
         ADD_SUFF(Any4ByteSetRect)(pRasInfo,
-                                  pRasInfo->bounds.x1, pRasInfo->bounds.y1,
-                                  pRasInfo->bounds.x2, pRasInfo->bounds.y2,
+                                  0, 0, width, height,
                                   fgColor, pPrim, pCompInfo);
+        pRasInfo->rasBase = pBase;
         return;
     }
 
--- a/jdk/src/solaris/native/sun/java2d/loops/vis_SrcMaskFill.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/solaris/native/sun/java2d/loops/vis_SrcMaskFill.c	Wed Jan 19 21:51:10 2011 -0800
@@ -150,10 +150,12 @@
     }
 
     if (pMask == NULL) {
+        void *pBase = pRasInfo->rasBase;
+        pRasInfo->rasBase = rasBase;
         ADD_SUFF(AnyIntSetRect)(pRasInfo,
-                                pRasInfo->bounds.x1, pRasInfo->bounds.y1,
-                                pRasInfo->bounds.x2, pRasInfo->bounds.y2,
+                                0, 0, width, height,
                                 fgColor, pPrim, pCompInfo);
+        pRasInfo->rasBase = pBase;
         return;
     }
 
@@ -214,15 +216,17 @@
     cnstB = (fgColor      ) & 0xff;
 
     if (pMask == NULL) {
+        void *pBase = pRasInfo->rasBase;
+        pRasInfo->rasBase = rasBase;
         if (cnstA == 0) {
             fgColor = 0;
         } else {
             fgColor = (fgColor << 8) | cnstA;
         }
         ADD_SUFF(Any4ByteSetRect)(pRasInfo,
-                                  pRasInfo->bounds.x1, pRasInfo->bounds.y1,
-                                  pRasInfo->bounds.x2, pRasInfo->bounds.y2,
+                                  0, 0, width, height,
                                   fgColor, pPrim, pCompInfo);
+        pRasInfo->rasBase = pBase;
         return;
     }
 
@@ -390,10 +394,12 @@
     if (cnstA == 0) fgColor = 0;
 
     if (pMask == NULL) {
+        void *pBase = pRasInfo->rasBase;
+        pRasInfo->rasBase = rasBase;
         ADD_SUFF(AnyIntSetRect)(pRasInfo,
-                                pRasInfo->bounds.x1, pRasInfo->bounds.y1,
-                                pRasInfo->bounds.x2, pRasInfo->bounds.y2,
+                                0, 0, width, height,
                                 fgColor, pPrim, pCompInfo);
+        pRasInfo->rasBase = pBase;
         return;
     }
 
@@ -458,10 +464,12 @@
     }
 
     if (pMask == NULL) {
+        void *pBase = pRasInfo->rasBase;
+        pRasInfo->rasBase = rasBase;
         ADD_SUFF(AnyIntSetRect)(pRasInfo,
-                                pRasInfo->bounds.x1, pRasInfo->bounds.y1,
-                                pRasInfo->bounds.x2, pRasInfo->bounds.y2,
+                                0, 0, width, height,
                                 fgColor, pPrim, pCompInfo);
+        pRasInfo->rasBase = pBase;
         return;
     }
 
@@ -526,10 +534,12 @@
     }
 
     if (pMask == NULL) {
+        void *pBase = pRasInfo->rasBase;
+        pRasInfo->rasBase = rasBase;
         ADD_SUFF(Any3ByteSetRect)(pRasInfo,
-                                  pRasInfo->bounds.x1, pRasInfo->bounds.y1,
-                                  pRasInfo->bounds.x2, pRasInfo->bounds.y2,
+                                  0, 0, width, height,
                                   fgColor, pPrim, pCompInfo);
+        pRasInfo->rasBase = pBase;
         return;
     }
 
--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c	Wed Jan 19 21:51:10 2011 -0800
@@ -187,7 +187,9 @@
                          "()Ljava/awt/Point;");
 
     keyclass = (*env)->FindClass(env, "java/awt/event/KeyEvent");
-    DASSERT (keyclass != NULL);
+    if (JNU_IsNull(env, keyclass)) {
+        return;
+    }
 
     componentIDs.isProxyActive =
         (*env)->GetFieldID(env, keyclass, "isProxyActive",
@@ -715,8 +717,10 @@
   if (xawt_root_shell == None){
       if (classXRootWindow == NULL){
           jclass cls_tmp = (*env)->FindClass(env, "sun/awt/X11/XRootWindow");
-          classXRootWindow = (jclass)(*env)->NewGlobalRef(env, cls_tmp);
-          (*env)->DeleteLocalRef(env, cls_tmp);
+          if (!JNU_IsNull(env, cls_tmp)) {
+              classXRootWindow = (jclass)(*env)->NewGlobalRef(env, cls_tmp);
+              (*env)->DeleteLocalRef(env, cls_tmp);
+          }
       }
       if( classXRootWindow != NULL) {
           methodGetXRootWindow = (*env)->GetStaticMethodID(env, classXRootWindow, "getXRootWindow", "()J");
--- a/jdk/src/windows/classes/java/lang/ProcessEnvironment.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/classes/java/lang/ProcessEnvironment.java	Wed Jan 19 21:51:10 2011 -0800
@@ -250,8 +250,7 @@
                                    envblock.substring(eql+1,end));
         }
 
-        theCaseInsensitiveEnvironment
-            = new TreeMap<String,String>(nameComparator);
+        theCaseInsensitiveEnvironment = new TreeMap<>(nameComparator);
         theCaseInsensitiveEnvironment.putAll(theEnvironment);
     }
 
@@ -296,8 +295,7 @@
     // Only for use by ProcessImpl.start()
     String toEnvironmentBlock() {
         // Sort Unicode-case-insensitively by name
-        List<Map.Entry<String,String>> list
-            = new ArrayList<Map.Entry<String,String>>(entrySet());
+        List<Map.Entry<String,String>> list = new ArrayList<>(entrySet());
         Collections.sort(list, entryComparator);
 
         StringBuilder sb = new StringBuilder(size()*30);
--- a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Wed Jan 19 21:51:10 2011 -0800
@@ -999,6 +999,8 @@
     public void setBoundsOperation(int operation) {
     }
 
+    private volatile boolean isAccelCapable = true;
+
     /**
      * Returns whether this component is capable of being hw accelerated.
      * More specifically, whether rendering to this component or a
@@ -1009,11 +1011,22 @@
      * {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
      * PERPIXEL_TRANSLUCENT}.
      *
+     * Another condition is if Xor paint mode was detected when rendering
+     * to an on-screen accelerated surface associated with this peer.
+     * in this case both on- and off-screen acceleration for this peer is
+     * disabled.
+     *
      * @return {@code true} if this component is capable of being hw
      * accelerated, {@code false} otherwise
      * @see GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
      */
     public boolean isAccelCapable() {
+        if (!isAccelCapable ||
+            !isContainingTopLevelAccelCapable((Component)target))
+        {
+            return false;
+        }
+
         boolean isTranslucent =
             SunToolkit.isContainingTopLevelTranslucent((Component)target);
         // D3D/OGL and translucent windows interacted poorly in Windows XP;
@@ -1021,6 +1034,14 @@
         return !isTranslucent || Win32GraphicsEnvironment.isVistaOS();
     }
 
+    /**
+     * Disables acceleration for this peer.
+     */
+    public void disableAcceleration() {
+        isAccelCapable = false;
+    }
+
+
     native void setRectangularShape(int lox, int loy, int hix, int hiy,
                      Region region);
 
--- a/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/classes/sun/java2d/d3d/D3DSurfaceData.java	Wed Jan 19 21:51:10 2011 -0800
@@ -437,6 +437,10 @@
         protected int getElem(final int x, final int y,
                               final SurfaceData sData)
         {
+            if (sData.isSurfaceLost()) {
+                return 0;
+            }
+
             int retPixel;
             D3DRenderQueue rq = D3DRenderQueue.getInstance();
             rq.lock();
@@ -456,6 +460,10 @@
         protected void setElem(final int x, final int y, final int pixel,
                                final SurfaceData sData)
         {
+            if (sData.isSurfaceLost()) {
+                  return;
+            }
+
             D3DRenderQueue rq = D3DRenderQueue.getInstance();
             rq.lock();
             try {
@@ -512,15 +520,32 @@
             sg2d.surfaceData.getTransparency() == Transparency.OPAQUE;
     }
 
+    /**
+     * If acceleration should no longer be used for this surface.
+     * This implementation flags to the manager that it should no
+     * longer attempt to re-create a D3DSurface.
+     */
+    void disableAccelerationForSurface() {
+        if (offscreenImage != null) {
+            SurfaceManager sm = SurfaceManager.getManager(offscreenImage);
+            if (sm instanceof D3DVolatileSurfaceManager) {
+                setSurfaceLost(true);
+                ((D3DVolatileSurfaceManager)sm).setAccelerationEnabled(false);
+            }
+        }
+    }
+
     public void validatePipe(SunGraphics2D sg2d) {
         TextPipe textpipe;
         boolean validated = false;
 
         // REMIND: the D3D pipeline doesn't support XOR!, more
-        // fixes will be needed below
+        // fixes will be needed below. For now we disable D3D rendering
+        // for the surface which had any XOR rendering done to.
         if (sg2d.compositeState >= sg2d.COMP_XOR) {
             super.validatePipe(sg2d);
             sg2d.imagepipe = d3dImagePipe;
+            disableAccelerationForSurface();
             return;
         }
 
@@ -895,7 +920,25 @@
         }
 
         @Override
+        void disableAccelerationForSurface() {
+            // for on-screen surfaces we need to make sure a backup GDI surface is
+            // is used until a new one is set (which may happen during a resize). We
+            // don't want the screen update maanger to replace the surface right way
+            // because it causes repainting issues in Swing, so we invalidate it,
+            // this will prevent SUM from issuing a replaceSurfaceData call.
+            setSurfaceLost(true);
+            invalidate();
+            flush();
+            peer.disableAcceleration();
+            ScreenUpdateManager.getInstance().dropScreenSurface(this);
+        }
+
+        @Override
         void restoreSurface() {
+            if (!peer.isAccelCapable()) {
+                throw new InvalidPipeException("Onscreen acceleration " +
+                                               "disabled for this surface");
+            }
             Window fsw = graphicsDevice.getFullScreenWindow();
             if (fsw != null && fsw != peer.getTarget()) {
                 throw new InvalidPipeException("Can't restore onscreen surface"+
--- a/jdk/src/windows/classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/classes/sun/java2d/opengl/WGLVolatileSurfaceManager.java	Wed Jan 19 21:51:10 2011 -0800
@@ -133,7 +133,9 @@
 
     @Override
     protected boolean isConfigValid(GraphicsConfiguration gc) {
-        return ((gc == null) || (gc == vImg.getGraphicsConfig()));
+        return ((gc == null) ||
+                ((gc instanceof WGLGraphicsConfig) &&
+                 (gc == vImg.getGraphicsConfig())));
     }
 
     @Override
--- a/jdk/src/windows/native/java/net/Inet4AddressImpl.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/java/net/Inet4AddressImpl.c	Wed Jan 19 21:51:10 2011 -0800
@@ -559,8 +559,8 @@
 
         if (timeout >= 0) {
           optlen = sizeof(connect_rv);
-          if (JVM_GetSockOpt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                             &optlen) <0) {
+          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+                         &optlen) <0) {
             connect_rv = WSAGetLastError();
           }
 
--- a/jdk/src/windows/native/java/net/Inet6AddressImpl.c	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/java/net/Inet6AddressImpl.c	Wed Jan 19 21:51:10 2011 -0800
@@ -671,8 +671,8 @@
         if (timeout >= 0) {
           /* has connection been established? */
           optlen = sizeof(connect_rv);
-          if (JVM_GetSockOpt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                             &optlen) <0) {
+          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+                         &optlen) <0) {
             connect_rv = WSAGetLastError();
           }
 
--- a/jdk/src/windows/native/sun/windows/Devices.h	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/sun/windows/Devices.h	Wed Jan 19 21:51:10 2011 -0800
@@ -54,7 +54,7 @@
            InstanceAccess& operator=(const InstanceAccess&);
            InstanceAccess* operator&();
        };
-friend                          InstanceAccess;
+friend class InstanceAccess;
 
 private:
                                 Devices(int numElements);
--- a/jdk/src/windows/native/sun/windows/awt.h	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/sun/windows/awt.h	Wed Jan 19 21:51:10 2011 -0800
@@ -173,7 +173,7 @@
 
 // Platform encoding is Unicode (UTF-16), re-define JNU_ functions
 // to proper JNI functions.
-#define JNU_NewStringPlatform(env, x) env->NewString(reinterpret_cast<jchar*>(x), static_cast<jsize>(_tcslen(x)))
+#define JNU_NewStringPlatform(env, x) env->NewString(reinterpret_cast<const jchar*>(x), static_cast<jsize>(_tcslen(x)))
 #define JNU_GetStringPlatformChars(env, x, y) reinterpret_cast<LPCWSTR>(env->GetStringChars(x, y))
 #define JNU_ReleaseStringPlatformChars(env, x, y) env->ReleaseStringChars(x, reinterpret_cast<const jchar*>(y))
 
--- a/jdk/src/windows/native/sun/windows/awt_Debug.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_Debug.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -47,12 +47,21 @@
     return ptr;
 }
 
+void * operator new[](size_t size, const char * filename, int linenumber) {
+    void * ptr = DMem_AllocateBlock(size, filename, linenumber);
+    if (ptr == NULL) {
+        throw std::bad_alloc();
+    }
+
+    return ptr;
+}
+
 #if _MSC_VER >= 1200
 void operator delete(void *ptr, const char*, int) {
     DASSERTMSG(FALSE, "This version of 'delete' should never get called!!!");
 }
 #endif
-void operator delete(void *ptr) {
+void operator delete(void *ptr) throw() {
     DMem_FreeBlock(ptr);
 }
 
--- a/jdk/src/windows/native/sun/windows/awt_Debug.h	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_Debug.h	Wed Jan 19 21:51:10 2011 -0800
@@ -48,11 +48,14 @@
     };
 
     extern void * operator new(size_t size, const char * filename, int linenumber);
+    extern void * operator new[](size_t size, const char * filename, int linenumber);
+
 #if _MSC_VER >= 1200
     /* VC 6.0 is more strict about enforcing matching placement new & delete */
     extern void operator delete(void *ptr, const char*, int);
 #endif
-    extern void operator delete(void *ptr);
+
+    extern void operator delete(void *ptr) throw();
     extern void DumpClipRectangle(const char * file, int line, int argc, const char * fmt, va_list arglist);
     extern void DumpUpdateRectangle(const char * file, int line, int argc, const char * fmt, va_list arglist);
 
--- a/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_DesktopProperties.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -650,7 +650,7 @@
 }
 
 void AwtDesktopProperties::SetStringProperty(LPCTSTR propName, LPTSTR value) {
-    jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
+    jstring key = JNU_NewStringPlatform(GetEnv(), propName);
     GetEnv()->CallVoidMethod(self,
                              AwtDesktopProperties::setStringPropertyID,
                              key, JNU_NewStringPlatform(GetEnv(), value));
@@ -658,7 +658,7 @@
 }
 
 void AwtDesktopProperties::SetIntegerProperty(LPCTSTR propName, int value) {
-    jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
+    jstring key = JNU_NewStringPlatform(GetEnv(), propName);
     GetEnv()->CallVoidMethod(self,
                              AwtDesktopProperties::setIntegerPropertyID,
                              key, (jint)value);
@@ -666,7 +666,7 @@
 }
 
 void AwtDesktopProperties::SetBooleanProperty(LPCTSTR propName, BOOL value) {
-    jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
+    jstring key = JNU_NewStringPlatform(GetEnv(), propName);
     GetEnv()->CallVoidMethod(self,
                              AwtDesktopProperties::setBooleanPropertyID,
                              key, value ? JNI_TRUE : JNI_FALSE);
@@ -674,7 +674,7 @@
 }
 
 void AwtDesktopProperties::SetColorProperty(LPCTSTR propName, DWORD value) {
-    jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
+    jstring key = JNU_NewStringPlatform(GetEnv(), propName);
     GetEnv()->CallVoidMethod(self,
                              AwtDesktopProperties::setColorPropertyID,
                              key, GetRValue(value), GetGValue(value),
@@ -726,7 +726,7 @@
                         style |= java_awt_Font_ITALIC;
                     }
 
-                    jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
+                    jstring key = JNU_NewStringPlatform(GetEnv(), propName);
                     GetEnv()->CallVoidMethod(self,
                               AwtDesktopProperties::setFontPropertyID,
                               key, fontName, style, pointSize);
@@ -744,7 +744,7 @@
     jint pointSize;
     jint style;
 
-    fontName = JNU_NewStringPlatform(GetEnv(), const_cast<LPWSTR>(font.lfFaceName));
+    fontName = JNU_NewStringPlatform(GetEnv(), font.lfFaceName);
 
 #if 0
     HDC         hdc;
@@ -767,7 +767,7 @@
         style |= java_awt_Font_ITALIC;
     }
 
-    jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
+    jstring key = JNU_NewStringPlatform(GetEnv(), propName);
     GetEnv()->CallVoidMethod(self, AwtDesktopProperties::setFontPropertyID,
                              key, fontName, style, pointSize);
 
@@ -776,8 +776,8 @@
 }
 
 void AwtDesktopProperties::SetSoundProperty(LPCTSTR propName, LPCTSTR winEventName) {
-    jstring key = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(propName));
-    jstring event = JNU_NewStringPlatform(GetEnv(), const_cast<LPTSTR>(winEventName));
+    jstring key = JNU_NewStringPlatform(GetEnv(), propName);
+    jstring event = JNU_NewStringPlatform(GetEnv(), winEventName);
     GetEnv()->CallVoidMethod(self,
                              AwtDesktopProperties::setSoundPropertyID,
                              key, event);
--- a/jdk/src/windows/native/sun/windows/awt_Dialog.cpp	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_Dialog.cpp	Wed Jan 19 21:51:10 2011 -0800
@@ -230,7 +230,7 @@
         if (::IsIconic(hWnd)) {
             ::ShowWindow(hWnd, SW_RESTORE);
         }
-        PopupAllDialogs(blocker, TRUE, ::GetForegroundWindow(), FALSE);
+        PopupBlockers(blocker, TRUE, ::GetForegroundWindow(), FALSE);
         // return 1 to prevent the system from allowing the operation
         return 1;
     }
@@ -256,7 +256,7 @@
             HWND blocker = AwtWindow::GetModalBlocker(AwtComponent::GetTopLevelParentForWindow(hWnd));
             if (::IsWindow(blocker)) {
                 BOOL onTaskbar = !(::WindowFromPoint(mhs->pt) == hWnd);
-                PopupAllDialogs(hWnd, FALSE, ::GetForegroundWindow(), onTaskbar);
+                PopupBlockers(blocker, FALSE, ::GetForegroundWindow(), onTaskbar);
                 // return a nonzero value to prevent the system from passing
                 // the message to the target window procedure
                 return 1;
@@ -268,60 +268,60 @@
 }
 
 /*
- * The function goes through the heirarchy of the blocker dialogs and
- * popups all the dialogs. Note that the function starts from the top
- * blocker dialog and goes down to the dialog which is the bottom dialog.
- * Using another traversal may cause to the flickering issue as a bottom
- * dialog will cover a top dialog for some period of time.
+ * The function goes through the hierarchy of the blockers and
+ * popups all the blockers. Note that the function starts from the top
+ * blocker and goes down to the blocker which is the bottom one.
+ * Using another traversal algorithm (bottom->top) may cause to flickering
+ * as the bottom blocker will cover the top blocker for a while.
  */
-void AwtDialog::PopupAllDialogs(HWND dialog, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar)
+void AwtDialog::PopupBlockers(HWND blocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar)
 {
-    HWND blocker = AwtWindow::GetModalBlocker(dialog);
-    BOOL isBlocked = ::IsWindow(blocker);
-    if (isBlocked) {
-        PopupAllDialogs(blocker, isModalHook, prevFGWindow, onTaskbar);
+    HWND nextBlocker = AwtWindow::GetModalBlocker(blocker);
+    BOOL nextBlockerExists = ::IsWindow(nextBlocker);
+    if (nextBlockerExists) {
+        PopupBlockers(nextBlocker, isModalHook, prevFGWindow, onTaskbar);
     }
-    PopupOneDialog(dialog, blocker, isModalHook, prevFGWindow, onTaskbar);
+    PopupBlocker(blocker, nextBlocker, isModalHook, prevFGWindow, onTaskbar);
 }
 
 /*
- * The function popups the dialog, it distinguishes non-blocked dialogs
- * and activates the dialogs (sets as foreground window). If the dialog is
- * blocked, then it changes the Z-order of the dialog.
+ * The function popups the blocker, for a non-blocked blocker we need
+ * to activate the blocker but if a blocker is blocked, then we need
+ * to change z-order of the blocker placing the blocker under the next blocker.
  */
-void AwtDialog::PopupOneDialog(HWND dialog, HWND blocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar)
+void AwtDialog::PopupBlocker(HWND blocker, HWND nextBlocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar)
 {
-    if (dialog == AwtToolkit::GetInstance().GetHWnd()) {
+    if (blocker == AwtToolkit::GetInstance().GetHWnd()) {
         return;
     }
 
     // fix for 6494032
-    if (isModalHook && !::IsWindowVisible(dialog)) {
-        ::ShowWindow(dialog, SW_SHOWNA);
+    if (isModalHook && !::IsWindowVisible(blocker)) {
+        ::ShowWindow(blocker, SW_SHOWNA);
     }
 
-    BOOL isBlocked = ::IsWindow(blocker);
+    BOOL nextBlockerExists = ::IsWindow(nextBlocker);
     UINT flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE;
 
-    if (isBlocked) {
+    if (nextBlockerExists) {
         // Fix for 6829546: if blocker is a top-most window, but window isn't, then
         // calling ::SetWindowPos(dialog, blocker, ...) makes window top-most as well
-        BOOL isBlockerTopmost = (::GetWindowLong(blocker, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
-        BOOL isDialogTopmost = (::GetWindowLong(dialog, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
-        if (!isBlockerTopmost || isDialogTopmost) {
-            ::SetWindowPos(dialog, blocker, 0, 0, 0, 0, flags);
+        BOOL topmostNextBlocker = (::GetWindowLong(nextBlocker, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
+        BOOL topmostBlocker = (::GetWindowLong(blocker, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
+        if (!topmostNextBlocker || topmostBlocker) {
+            ::SetWindowPos(blocker, nextBlocker, 0, 0, 0, 0, flags);
         } else {
-            ::SetWindowPos(dialog, HWND_TOP, 0, 0, 0, 0, flags);
+            ::SetWindowPos(blocker, HWND_TOP, 0, 0, 0, 0, flags);
         }
     } else {
-        ::SetWindowPos(dialog, HWND_TOP, 0, 0, 0, 0, flags);
+        ::SetWindowPos(blocker, HWND_TOP, 0, 0, 0, 0, flags);
         // no beep/flash if the mouse was clicked in the taskbar menu
         // or the dialog is currently inactive
-        if (!isModalHook && !onTaskbar && (dialog == prevFGWindow)) {
-            AnimateModalBlocker(dialog);
+        if (!isModalHook && !onTaskbar && (blocker == prevFGWindow)) {
+            AnimateModalBlocker(blocker);
         }
-        ::BringWindowToTop(dialog);
-        ::SetForegroundWindow(dialog);
+        ::BringWindowToTop(blocker);
+        ::SetForegroundWindow(blocker);
     }
 }
 
--- a/jdk/src/windows/native/sun/windows/awt_Dialog.h	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_Dialog.h	Wed Jan 19 21:51:10 2011 -0800
@@ -113,8 +113,8 @@
      */
     static void ModalPerformActivation(HWND hWnd);
 
-    static void PopupAllDialogs(HWND dialog, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar);
-    static void PopupOneDialog(HWND dialog, HWND blocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar);
+    static void PopupBlockers(HWND blocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar);
+    static void PopupBlocker(HWND blocker, HWND nextBlocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar);
 
 public:
 
--- a/jdk/src/windows/native/sun/windows/awt_TextArea.h	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_TextArea.h	Wed Jan 19 21:51:10 2011 -0800
@@ -41,9 +41,6 @@
 
 class AwtTextArea : public AwtTextComponent {
 
-    // inner classes
-    class OleCallback;
-
 public:
 
     /* java.awt.TextArea fields ids */
@@ -89,6 +86,37 @@
     static void _ReplaceText(void *param);
 
 protected:
+
+    /*****************************************************************
+     * Inner class OleCallback declaration.
+     */
+    class OleCallback : public IRichEditOleCallback {
+    public:
+        OleCallback();
+
+        STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
+        STDMETHODIMP_(ULONG) AddRef();
+        STDMETHODIMP_(ULONG) Release();
+        STDMETHODIMP GetNewStorage(LPSTORAGE FAR * ppstg);
+        STDMETHODIMP GetInPlaceContext(LPOLEINPLACEFRAME FAR * ppipframe,
+                                       LPOLEINPLACEUIWINDOW FAR* ppipuiDoc,
+                                       LPOLEINPLACEFRAMEINFO pipfinfo);
+        STDMETHODIMP ShowContainerUI(BOOL fShow);
+        STDMETHODIMP QueryInsertObject(LPCLSID pclsid, LPSTORAGE pstg, LONG cp);
+        STDMETHODIMP DeleteObject(LPOLEOBJECT poleobj);
+        STDMETHODIMP QueryAcceptData(LPDATAOBJECT pdataobj, CLIPFORMAT *pcfFormat,
+                                     DWORD reco, BOOL fReally, HGLOBAL hMetaPict);
+        STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
+        STDMETHODIMP GetClipboardData(CHARRANGE *pchrg, DWORD reco,
+                                      LPDATAOBJECT *ppdataobj);
+        STDMETHODIMP GetDragDropEffect(BOOL fDrag, DWORD grfKeyState,
+                                       LPDWORD pdwEffect);
+        STDMETHODIMP GetContextMenu(WORD seltype, LPOLEOBJECT poleobj,
+                                    CHARRANGE FAR * pchrg, HMENU FAR * phmenu);
+    private:
+        ULONG             m_refs; // Reference count
+    };//OleCallback class
+
     INLINE static OleCallback& GetOleCallback() { return sm_oleCallback; }
     void EditSetSel(CHARRANGE &cr);
     void EditGetSel(CHARRANGE &cr);
@@ -114,37 +142,6 @@
 
     static OleCallback sm_oleCallback;
 
-    /*****************************************************************
-     * Inner class OleCallback declaration.
-     */
-
-    class AwtTextArea::OleCallback : public IRichEditOleCallback {
-    public:
-        OleCallback();
-
-        STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
-        STDMETHODIMP_(ULONG) AddRef();
-        STDMETHODIMP_(ULONG) Release();
-        STDMETHODIMP GetNewStorage(LPSTORAGE FAR * ppstg);
-        STDMETHODIMP GetInPlaceContext(LPOLEINPLACEFRAME FAR * ppipframe,
-                                       LPOLEINPLACEUIWINDOW FAR* ppipuiDoc,
-                                       LPOLEINPLACEFRAMEINFO pipfinfo);
-        STDMETHODIMP ShowContainerUI(BOOL fShow);
-        STDMETHODIMP QueryInsertObject(LPCLSID pclsid, LPSTORAGE pstg, LONG cp);
-        STDMETHODIMP DeleteObject(LPOLEOBJECT poleobj);
-        STDMETHODIMP QueryAcceptData(LPDATAOBJECT pdataobj, CLIPFORMAT *pcfFormat,
-                                     DWORD reco, BOOL fReally, HGLOBAL hMetaPict);
-        STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode);
-        STDMETHODIMP GetClipboardData(CHARRANGE *pchrg, DWORD reco,
-                                      LPDATAOBJECT *ppdataobj);
-        STDMETHODIMP GetDragDropEffect(BOOL fDrag, DWORD grfKeyState,
-                                       LPDWORD pdwEffect);
-        STDMETHODIMP GetContextMenu(WORD seltype, LPOLEOBJECT poleobj,
-                                    CHARRANGE FAR * pchrg, HMENU FAR * phmenu);
-    private:
-        ULONG             m_refs; // Reference count
-    };
-
 };
 
 #endif /* AWT_TEXTAREA_H */
--- a/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_Toolkit.h	Wed Jan 19 21:51:10 2011 -0800
@@ -110,7 +110,7 @@
       private:
         const CriticalSection& critSec;
     };
-    friend Lock;
+    friend class Lock;
 
   private:
     CRITICAL_SECTION rep;
--- a/jdk/test/com/sun/awt/Translucency/WindowOpacity.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/com/sun/awt/Translucency/WindowOpacity.java	Wed Jan 19 21:51:10 2011 -0800
@@ -64,6 +64,7 @@
         boolean passed;
 
         Frame f = new Frame("Opacity test");
+        f.setUndecorated(true);
 
         passed = false;
         try {
--- a/jdk/test/java/awt/FontClass/FontPrivilege.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/java/awt/FontClass/FontPrivilege.java	Wed Jan 19 21:51:10 2011 -0800
@@ -25,7 +25,7 @@
  * @test
  * @bug 5010310 6319835 6904882 6968373
  * @summary test fonts can be created in the presence of a security manager
- * @run main/othervm/secure=java.lang.SecurityManager FontPrivilege
+ * @run main FontPrivilege
  */
 
 import java.awt.Font;
@@ -33,6 +33,8 @@
 public class FontPrivilege {
 
     public static void main(String[] args) throws Exception {
+        System.setSecurityManager(new SecurityManager());
+
         new Font("Helvetica", Font.PLAIN, 12).getFamily();
         new Font("foo bar", Font.PLAIN, 12).getFamily();
    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Graphics2D/DrawString/LCDTextSrcEa.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6996867
+ * @summary Render as LCD Text in SrcEa composite mode.
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.*;
+
+public class LCDTextSrcEa extends Component {
+
+    static int SZ=150;
+    BufferedImage target =
+        new BufferedImage(SZ, SZ, BufferedImage.TYPE_INT_RGB);
+
+    public static void main(String args[]) {
+        Frame f = new Frame("LCD Text SrcEa Test");
+        f.addWindowListener(new WindowAdapter() {
+            @Override
+            public void windowClosing(WindowEvent e) {
+                System.exit(0);
+            }
+        });
+        LCDTextSrcEa td = new LCDTextSrcEa();
+        f.add("Center", td);
+        f.pack();
+        f.setVisible(true);
+    }
+
+    public Dimension getPreferredSize() {
+        return new Dimension(SZ,SZ);
+    }
+
+    public void paint(Graphics gx) {
+
+        Graphics2D g2d = (Graphics2D) target.getGraphics();
+        g2d.setColor(Color.white);
+        g2d.fillRect(0, 0, getWidth(), getHeight());
+
+        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.01f));
+        g2d.setRenderingHint(
+                RenderingHints.KEY_TEXT_ANTIALIASING,
+                RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_VBGR);
+        g2d.setRenderingHint(
+               RenderingHints.KEY_ANTIALIASING,
+               RenderingHints.VALUE_ANTIALIAS_ON);
+
+        g2d.setColor(Color.black);
+        g2d.drawString("Some sample text.", 10, 20);
+        gx.drawImage(target, 0, 0, null);
+        boolean nongrey = false;
+        //Test BI: should be some non-greyscale color
+        for (int px=0;px<SZ;px++) {
+            for (int py=0;py<SZ;py++) {
+                int rgb = target.getRGB(px, py);
+                int r = (rgb & 0xff0000) >> 16;
+                int g = (rgb & 0x00ff00) >> 8;
+                int b = (rgb & 0x0000ff);
+                if (r != g || r !=b || g != b) {
+                     nongrey=true;
+                     break;
+                }
+            }
+        }
+        if (!nongrey) {
+            throw new RuntimeException("No LCD text found");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Graphics2D/RenderClipTest/6766342.tests	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,3 @@
+Filled AA Pure Rect(5, 29.4, 10, 10)
+Stroked AA Pure Rect(5, 4.4, 10, 10)
+Stroked AA Line(20, 20, -10, 20)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Graphics2D/RenderClipTest/RenderClipTest.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,1634 @@
+/*
+ * Copyright (c) 2008, 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 6766342
+ * @summary Tests clipping invariance for AA rectangle and line primitives
+ * @run main RenderClipTest -strict -readfile 6766342.tests
+ * @run main RenderClipTest -rectsuite -count 10
+ */
+
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.image.*;
+import java.awt.event.*;
+import java.util.Vector;
+import java.io.*;
+
+public class RenderClipTest {
+    public static double randDblCoord() {
+        return Math.random()*60 - 10;
+    }
+
+    public static float randFltCoord() {
+        return (float) randDblCoord();
+    }
+
+    public static int randIntCoord() {
+        return (int) Math.round(randDblCoord());
+    }
+
+    public static int randInt(int n) {
+        return ((int) (Math.random() * (n*4))) >> 2;
+    }
+
+    static int numtests;
+    static int numerrors;
+    static int numfillfailures;
+    static int numstrokefailures;
+    static int maxerr;
+
+    static boolean useAA;
+    static boolean strokePure;
+    static boolean testFill;
+    static boolean testDraw;
+    static boolean silent;
+    static boolean verbose;
+    static boolean strict;
+    static boolean showErrors;
+    static float lw;
+    static double rot;
+
+    static BufferedImage imgref;
+    static BufferedImage imgtst;
+
+    static Graphics2D grefclear;
+    static Graphics2D gtstclear;
+    static Graphics2D grefrender;
+    static Graphics2D gtstrender;
+
+    public static abstract class AnnotatedRenderOp {
+        public static AnnotatedRenderOp parse(String str) {
+            AnnotatedRenderOp ar;
+            if (((ar = Cubic.tryparse(str)) != null) ||
+                ((ar = Quad.tryparse(str)) != null) ||
+                ((ar = Poly.tryparse(str)) != null) ||
+                ((ar = Path.tryparse(str)) != null) ||
+                ((ar = Rect.tryparse(str)) != null) ||
+                ((ar = Line.tryparse(str)) != null) ||
+                ((ar = RectMethod.tryparse(str)) != null) ||
+                ((ar = LineMethod.tryparse(str)) != null))
+            {
+                return ar;
+            }
+            System.err.println("Unable to parse shape: "+str);
+            return null;
+        }
+
+        public abstract void randomize();
+
+        public abstract void fill(Graphics2D g2d);
+
+        public abstract void draw(Graphics2D g2d);
+    }
+
+    public static abstract class AnnotatedShapeOp extends AnnotatedRenderOp {
+        public abstract Shape getShape();
+
+        public void fill(Graphics2D g2d) {
+            g2d.fill(getShape());
+        }
+
+        public void draw(Graphics2D g2d) {
+            g2d.draw(getShape());
+        }
+    }
+
+    public static void usage(String err) {
+        if (err != null) {
+            System.err.println(err);
+        }
+        System.err.println("usage: java RenderClipTest "+
+                           "[-read[file F]] [-rectsuite] [-fill] [-draw]");
+        System.err.println("                           "+
+                           "[-aa] [-pure] [-lw N] [-rot N]");
+        System.err.println("                           "+
+                           "[-rectmethod] [-linemethod] [-rect] [-line]");
+        System.err.println("                           "+
+                           "[-cubic] [-quad] [-poly] [-path]");
+        System.err.println("                           "+
+                           "[-silent] [-verbose] [-showerr] [-count N]");
+        System.err.println("                           "+
+                           "[-strict] [-usage]");
+        System.err.println("    -read         Read test data from stdin");
+        System.err.println("    -readfile F   Read test data from file F");
+        System.err.println("    -rectsuite    Run a suite of rect/line tests");
+        System.err.println("    -fill         Test g.fill*(...)");
+        System.err.println("    -draw         Test g.draw*(...)");
+        System.err.println("    -aa           Use antialiased rendering");
+        System.err.println("    -pure         Use STROKE_PURE hint");
+        System.err.println("    -lw N         Test line widths of N "+
+                           "(default 1.0)");
+        System.err.println("    -rot N        Test rotation by N degrees "+
+                           "(default 0.0)");
+        System.err.println("    -rectmethod   Test fillRect/drawRect methods");
+        System.err.println("    -linemethod   Test drawLine method");
+        System.err.println("    -rect         Test Rectangle2D shapes");
+        System.err.println("    -line         Test Line2D shapes");
+        System.err.println("    -cubic        Test CubicCurve2D shapes");
+        System.err.println("    -quad         Test QuadCurve2D shapes");
+        System.err.println("    -poly         Test Polygon shapes");
+        System.err.println("    -path         Test GeneralPath shapes");
+        System.err.println("    -silent       Do not print out error curves");
+        System.err.println("    -verbose      Print out progress info");
+        System.err.println("    -showerr      Display errors on screen");
+        System.err.println("    -count N      N tests per shape, then exit "+
+                           "(default 1000)");
+        System.err.println("    -strict       All failures are important");
+        System.err.println("    -usage        Print this help, then exit");
+        System.exit((err != null) ? -1 : 0);
+    }
+
+    public static void main(String argv[]) {
+        boolean readTests = false;
+        String readFile = null;
+        boolean rectsuite = false;
+        int count = 1000;
+        lw = 1.0f;
+        rot = 0.0;
+        Vector<AnnotatedRenderOp> testOps = new Vector<AnnotatedRenderOp>();
+        for (int i = 0; i < argv.length; i++) {
+            String arg = argv[i].toLowerCase();
+            if (arg.equals("-aa")) {
+                useAA = true;
+            } else if (arg.equals("-pure")) {
+                strokePure = true;
+            } else if (arg.equals("-fill")) {
+                testFill = true;
+            } else if (arg.equals("-draw")) {
+                testDraw = true;
+            } else if (arg.equals("-lw")) {
+                if (i+1 >= argv.length) {
+                    usage("Missing argument: "+argv[i]);
+                }
+                lw = Float.parseFloat(argv[++i]);
+            } else if (arg.equals("-rot")) {
+                if (i+1 >= argv.length) {
+                    usage("Missing argument: "+argv[i]);
+                }
+                rot = Double.parseDouble(argv[++i]);
+            } else if (arg.equals("-cubic")) {
+                testOps.add(new Cubic());
+            } else if (arg.equals("-quad")) {
+                testOps.add(new Quad());
+            } else if (arg.equals("-poly")) {
+                testOps.add(new Poly());
+            } else if (arg.equals("-path")) {
+                testOps.add(new Path());
+            } else if (arg.equals("-rect")) {
+                testOps.add(new Rect());
+            } else if (arg.equals("-line")) {
+                testOps.add(new Line());
+            } else if (arg.equals("-rectmethod")) {
+                testOps.add(new RectMethod());
+            } else if (arg.equals("-linemethod")) {
+                testOps.add(new LineMethod());
+            } else if (arg.equals("-verbose")) {
+                verbose = true;
+            } else if (arg.equals("-strict")) {
+                strict = true;
+            } else if (arg.equals("-silent")) {
+                silent = true;
+            } else if (arg.equals("-showerr")) {
+                showErrors = true;
+            } else if (arg.equals("-readfile")) {
+                if (i+1 >= argv.length) {
+                    usage("Missing argument: "+argv[i]);
+                }
+                readTests = true;
+                readFile = argv[++i];
+            } else if (arg.equals("-read")) {
+                readTests = true;
+                readFile = null;
+            } else if (arg.equals("-rectsuite")) {
+                rectsuite = true;
+            } else if (arg.equals("-count")) {
+                if (i+1 >= argv.length) {
+                    usage("Missing argument: "+argv[i]);
+                }
+                count = Integer.parseInt(argv[++i]);
+            } else if (arg.equals("-usage")) {
+                usage(null);
+            } else {
+                usage("Unknown argument: "+argv[i]);
+            }
+        }
+        if (readTests) {
+            if (rectsuite || testDraw || testFill ||
+                useAA || strokePure ||
+                lw != 1.0f || rot != 0.0 ||
+                testOps.size() > 0)
+            {
+                usage("Should not specify test types with -read options");
+            }
+        } else if (rectsuite) {
+            if (testDraw || testFill ||
+                useAA || strokePure ||
+                lw != 1.0f || rot != 0.0 ||
+                testOps.size() > 0)
+            {
+                usage("Should not specify test types with -rectsuite option");
+            }
+        } else {
+            if (!testDraw && !testFill) {
+                usage("No work: Must specify one or both of "+
+                      "-fill or -draw");
+            }
+            if (testOps.size() == 0) {
+                usage("No work: Must specify one or more of "+
+                      "-rect[method], -line[method], "+
+                      "-cubic, -quad, -poly, or -path");
+            }
+        }
+        initImages();
+        if (readTests) {
+            try {
+                InputStream is;
+                if (readFile == null) {
+                    is = System.in;
+                } else {
+                    File f =
+                        new File(System.getProperty("test.src", "."),
+                                 readFile);
+                    is = new FileInputStream(f);
+                }
+                parseAndRun(is);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        } else if (rectsuite) {
+            runRectSuite(count);
+        } else {
+            initGCs();
+            for (int k = 0; k < testOps.size(); k++) {
+                AnnotatedRenderOp ar = testOps.get(k);
+                runRandomTests(ar, count);
+            }
+            disposeGCs();
+        }
+        grefclear.dispose();
+        gtstclear.dispose();
+        grefclear = gtstclear = null;
+        reportStatistics();
+    }
+
+    public static int reportStatistics() {
+        String connector = "";
+        if (numfillfailures > 0) {
+            System.out.print(numfillfailures+" fills ");
+            connector = "and ";
+        }
+        if (numstrokefailures > 0) {
+            System.out.print(connector+numstrokefailures+" strokes ");
+        }
+        int totalfailures = numfillfailures + numstrokefailures;
+        if (totalfailures == 0) {
+            System.out.print("0 ");
+        }
+        System.out.println("out of "+numtests+" tests failed...");
+        int critical = numerrors;
+        if (strict) {
+            critical += totalfailures;
+        }
+        if (critical > 0) {
+            throw new RuntimeException(critical+" tests had critical errors");
+        }
+        System.out.println("No tests had critical errors");
+        return (numerrors+totalfailures);
+    }
+
+    public static void runRectSuite(int count) {
+        AnnotatedRenderOp ops[] = {
+            new Rect(),
+            new RectMethod(),
+            new Line(),
+            new LineMethod(),
+        };
+        // Sometimes different fill algorithms are chosen for
+        // thin and wide line modes, make sure we test both...
+        float filllinewidths[] = { 0.0f, 2.0f };
+        float drawlinewidths[] = { 0.0f, 0.5f, 1.0f,
+                                   2.0f, 2.5f,
+                                   5.0f, 5.3f };
+        double rotations[] = { 0.0, 15.0, 90.0,
+                               135.0, 180.0,
+                               200.0, 270.0,
+                               300.0};
+        for (AnnotatedRenderOp ar: ops) {
+            for (double r: rotations) {
+                rot = r;
+                for (int i = 0; i < 8; i++) {
+                    float linewidths[];
+                    if ((i & 1) == 0) {
+                        if ((ar instanceof Line) ||
+                            (ar instanceof LineMethod))
+                        {
+                            continue;
+                        }
+                        testFill = true;
+                        testDraw = false;
+                        linewidths = filllinewidths;
+                    } else {
+                        testFill = false;
+                        testDraw = true;
+                        linewidths = drawlinewidths;
+                    }
+                    useAA = ((i & 2) != 0);
+                    strokePure = ((i & 4) != 0);
+                    for (float w : linewidths) {
+                        lw = w;
+                        runSuiteTests(ar, count);
+                    }
+                }
+            }
+        }
+    }
+
+    public static void runSuiteTests(AnnotatedRenderOp ar, int count) {
+        if (verbose) {
+            System.out.print("Running ");
+            System.out.print(testFill ? "Fill " : "Draw ");
+            System.out.print(BaseName(ar));
+            if (useAA) {
+                System.out.print(" AA");
+            }
+            if (strokePure) {
+                System.out.print(" Pure");
+            }
+            if (lw != 1.0f) {
+                System.out.print(" lw="+lw);
+            }
+            if (rot != 0.0f) {
+                System.out.print(" rot="+rot);
+            }
+            System.out.println();
+        }
+        initGCs();
+        runRandomTests(ar, count);
+        disposeGCs();
+    }
+
+    public static String BaseName(AnnotatedRenderOp ar) {
+        String s = ar.toString();
+        int leftparen = s.indexOf('(');
+        if (leftparen >= 0) {
+            s = s.substring(0, leftparen);
+        }
+        return s;
+    }
+
+    public static void runRandomTests(AnnotatedRenderOp ar, int count) {
+        for (int i = 0; i < count; i++) {
+            ar.randomize();
+            if (testDraw) {
+                test(ar, false);
+            }
+            if (testFill) {
+                test(ar, true);
+            }
+        }
+    }
+
+    public static void initImages() {
+        imgref = new BufferedImage(40, 40, BufferedImage.TYPE_INT_RGB);
+        imgtst = new BufferedImage(40, 40, BufferedImage.TYPE_INT_RGB);
+        grefclear = imgref.createGraphics();
+        gtstclear = imgtst.createGraphics();
+        grefclear.setColor(Color.white);
+        gtstclear.setColor(Color.white);
+    }
+
+    public static void initGCs() {
+        grefrender = imgref.createGraphics();
+        gtstrender = imgtst.createGraphics();
+        gtstrender.clipRect(10, 10, 20, 20);
+        grefrender.setColor(Color.blue);
+        gtstrender.setColor(Color.blue);
+        if (lw != 1.0f) {
+            BasicStroke bs = new BasicStroke(lw);
+            grefrender.setStroke(bs);
+            gtstrender.setStroke(bs);
+        }
+        if (rot != 0.0) {
+            double rotrad = Math.toRadians(rot);
+            grefrender.rotate(rotrad, 20, 20);
+            gtstrender.rotate(rotrad, 20, 20);
+        }
+        if (strokePure) {
+            grefrender.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
+                                        RenderingHints.VALUE_STROKE_PURE);
+            gtstrender.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
+                                        RenderingHints.VALUE_STROKE_PURE);
+        }
+        if (useAA) {
+            grefrender.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                                        RenderingHints.VALUE_ANTIALIAS_ON);
+            gtstrender.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                                        RenderingHints.VALUE_ANTIALIAS_ON);
+            maxerr = 1;
+        }
+    }
+
+    public static void disposeGCs() {
+        grefrender.dispose();
+        gtstrender.dispose();
+        grefrender = gtstrender = null;
+    }
+
+    public static void parseAndRun(InputStream in) throws IOException {
+        BufferedReader br = new BufferedReader(new InputStreamReader(in));
+        String str;
+        while ((str = br.readLine()) != null) {
+            if (str.startsWith("Stroked ") || str.startsWith("Filled ")) {
+                parseTest(str);
+                continue;
+            }
+            if (str.startsWith("Running ")) {
+                continue;
+            }
+            if (str.startsWith("Failed: ")) {
+                continue;
+            }
+            if (str.indexOf(" out of ") > 0 &&
+                str.indexOf(" tests failed...") > 0)
+            {
+                continue;
+            }
+            if (str.indexOf(" tests had critical errors") > 0) {
+                continue;
+            }
+            System.err.println("Unparseable line: "+str);
+        }
+    }
+
+    public static void parseTest(String origstr) {
+        String str = origstr;
+        boolean isfill = false;
+        useAA = strokePure = false;
+        lw = 1.0f;
+        rot = 0.0;
+        if (str.startsWith("Stroked ")) {
+            str = str.substring(8);
+            isfill = false;
+        } else if (str.startsWith("Filled ")) {
+            str = str.substring(7);
+            isfill = true;
+        } else {
+            System.err.println("Unparseable test line: "+origstr);
+        }
+        if (str.startsWith("AA ")) {
+            str = str.substring(3);
+            useAA = true;
+        }
+        if (str.startsWith("Pure ")) {
+            str = str.substring(5);
+            strokePure = true;
+        }
+        if (str.startsWith("Lw=")) {
+            int index = str.indexOf(' ', 3);
+            if (index > 0) {
+                lw = Float.parseFloat(str.substring(3, index));
+                str = str.substring(index+1);
+            }
+        }
+        if (str.startsWith("Rot=")) {
+            int index = str.indexOf(' ', 4);
+            if (index > 0) {
+                rot = Double.parseDouble(str.substring(4, index));
+                str = str.substring(index+1);
+            }
+        }
+        AnnotatedRenderOp ar = AnnotatedRenderOp.parse(str);
+        if (ar != null) {
+            initGCs();
+            test(ar, isfill);
+            disposeGCs();
+        } else {
+            System.err.println("Unparseable test line: "+origstr);
+        }
+    }
+
+    public static void test(AnnotatedRenderOp ar, boolean isfill) {
+        grefclear.fillRect(0, 0, 40, 40);
+        gtstclear.fillRect(0, 0, 40, 40);
+        if (isfill) {
+            ar.fill(grefrender);
+            ar.fill(gtstrender);
+        } else {
+            ar.draw(grefrender);
+            ar.draw(gtstrender);
+        }
+        check(imgref, imgtst, ar, isfill);
+    }
+
+    public static int[] getData(BufferedImage img) {
+        Raster r = img.getRaster();
+        DataBufferInt dbi = (DataBufferInt) r.getDataBuffer();
+        return dbi.getData();
+    }
+
+    public static int getScan(BufferedImage img) {
+        Raster r = img.getRaster();
+        SinglePixelPackedSampleModel sppsm =
+            (SinglePixelPackedSampleModel) r.getSampleModel();
+        return sppsm.getScanlineStride();
+    }
+
+    public static int getOffset(BufferedImage img) {
+        Raster r = img.getRaster();
+        SinglePixelPackedSampleModel sppsm =
+            (SinglePixelPackedSampleModel) r.getSampleModel();
+        return sppsm.getOffset(-r.getSampleModelTranslateX(),
+                               -r.getSampleModelTranslateY());
+    }
+
+    final static int opaque = 0xff000000;
+    final static int whitergb = Color.white.getRGB();
+
+    public static final int maxdiff(int rgb1, int rgb2) {
+        int maxd = 0;
+        for (int i = 0; i < 32; i += 8) {
+            int c1 = (rgb1 >> i) & 0xff;
+            int c2 = (rgb2 >> i) & 0xff;
+            int d = Math.abs(c1-c2);
+            if (maxd < d) {
+                maxd = d;
+            }
+        }
+        return maxd;
+    }
+
+    public static void check(BufferedImage imgref, BufferedImage imgtst,
+                             AnnotatedRenderOp ar, boolean wasfill)
+    {
+        numtests++;
+        int dataref[] = getData(imgref);
+        int datatst[] = getData(imgtst);
+        int scanref = getScan(imgref);
+        int scantst = getScan(imgtst);
+        int offref = getOffset(imgref);
+        int offtst = getOffset(imgtst);
+
+        // We want to check for errors outside the clip at a higher
+        // priority than errors involving different pixels touched
+        // inside the clip.
+
+        // Check above clip
+        if (check(ar, wasfill,
+                  null, 0, 0,
+                  datatst, scantst, offtst,
+                  0, 0, 40, 10))
+        {
+            return;
+        }
+        // Check below clip
+        if (check(ar, wasfill,
+                  null, 0, 0,
+                  datatst, scantst, offtst,
+                  0, 30, 40, 40))
+        {
+            return;
+        }
+        // Check left of clip
+        if (check(ar, wasfill,
+                  null, 0, 0,
+                  datatst, scantst, offtst,
+                  0, 10, 10, 30))
+        {
+            return;
+        }
+        // Check right of clip
+        if (check(ar, wasfill,
+                  null, 0, 0,
+                  datatst, scantst, offtst,
+                  30, 10, 40, 30))
+        {
+            return;
+        }
+        // Check inside clip
+        check(ar, wasfill,
+              dataref, scanref, offref,
+              datatst, scantst, offtst,
+              10, 10, 30, 30);
+    }
+
+    public static boolean check(AnnotatedRenderOp ar, boolean wasfill,
+                                int dataref[], int scanref, int offref,
+                                int datatst[], int scantst, int offtst,
+                                int x0, int y0, int x1, int y1)
+    {
+        offref += scanref * y0;
+        offtst += scantst * y0;
+        for (int y = y0; y < y1; y++) {
+            for (int x = x0; x < x1; x++) {
+                boolean failed;
+                String reason;
+                int rgbref;
+                int rgbtst;
+
+                rgbtst = datatst[offtst+x] | opaque;
+                if (dataref == null) {
+                    /* Outside of clip, must be white, no error tolerance */
+                    rgbref = whitergb;
+                    failed = (rgbtst != rgbref);
+                    reason = "stray pixel rendered outside of clip";
+                } else {
+                    /* Inside of clip, check for maxerr delta in components */
+                    rgbref = dataref[offref+x] | opaque;
+                    failed = (rgbref != rgbtst &&
+                              maxdiff(rgbref, rgbtst) > maxerr);
+                    reason = "different pixel rendered inside clip";
+                }
+                if (failed) {
+                    if (dataref == null) {
+                        numerrors++;
+                    }
+                    if (wasfill) {
+                        numfillfailures++;
+                    } else {
+                        numstrokefailures++;
+                    }
+                    if (!silent) {
+                        System.out.println("Failed: "+reason+" at "+x+", "+y+
+                                           " ["+Integer.toHexString(rgbref)+
+                                           " != "+Integer.toHexString(rgbtst)+
+                                           "]");
+                        System.out.print(wasfill ? "Filled " : "Stroked ");
+                        if (useAA) System.out.print("AA ");
+                        if (strokePure) System.out.print("Pure ");
+                        if (lw != 1) System.out.print("Lw="+lw+" ");
+                        if (rot != 0) System.out.print("Rot="+rot+" ");
+                        System.out.println(ar);
+                    }
+                    if (showErrors) {
+                        show(imgref, imgtst);
+                    }
+                    return true;
+                }
+            }
+            offref += scanref;
+            offtst += scantst;
+        }
+        return false;
+    }
+
+    static ErrorWindow errw;
+
+    public static void show(BufferedImage imgref, BufferedImage imgtst) {
+        ErrorWindow errw = new ErrorWindow();
+        errw.setImages(imgref, imgtst);
+        errw.setVisible(true);
+        errw.waitForHide();
+        errw.dispose();
+    }
+
+    public static class Cubic extends AnnotatedShapeOp {
+        public static Cubic tryparse(String str) {
+            str = str.trim();
+            if (!str.startsWith("Cubic(")) {
+                return null;
+            }
+            str = str.substring(6);
+            double coords[] = new double[8];
+            boolean foundparen = false;
+            for (int i = 0; i < coords.length; i++) {
+                int index = str.indexOf(",");
+                if (index < 0) {
+                    if (i < coords.length-1) {
+                        return null;
+                    }
+                    index = str.indexOf(")");
+                    if (index < 0) {
+                        return null;
+                    }
+                    foundparen = true;
+                }
+                String num = str.substring(0, index);
+                try {
+                    coords[i] = Double.parseDouble(num);
+                } catch (NumberFormatException nfe) {
+                    return null;
+                }
+                str = str.substring(index+1);
+            }
+            if (!foundparen || str.length() > 0) {
+                return null;
+            }
+            Cubic c = new Cubic();
+            c.cubic.setCurve(coords[0], coords[1],
+                             coords[2], coords[3],
+                             coords[4], coords[5],
+                             coords[6], coords[7]);
+            return c;
+        }
+
+        private CubicCurve2D cubic = new CubicCurve2D.Double();
+
+        public void randomize() {
+            cubic.setCurve(randDblCoord(), randDblCoord(),
+                           randDblCoord(), randDblCoord(),
+                           randDblCoord(), randDblCoord(),
+                           randDblCoord(), randDblCoord());
+        }
+
+        public Shape getShape() {
+            return cubic;
+        }
+
+        public String toString() {
+            return ("Cubic("+
+                    cubic.getX1()+", "+
+                    cubic.getY1()+", "+
+                    cubic.getCtrlX1()+", "+
+                    cubic.getCtrlY1()+", "+
+                    cubic.getCtrlX2()+", "+
+                    cubic.getCtrlY2()+", "+
+                    cubic.getX2()+", "+
+                    cubic.getY2()
+                    +")");
+        }
+    }
+
+    public static class Quad extends AnnotatedShapeOp {
+        public static Quad tryparse(String str) {
+            str = str.trim();
+            if (!str.startsWith("Quad(")) {
+                return null;
+            }
+            str = str.substring(5);
+            double coords[] = new double[6];
+            boolean foundparen = false;
+            for (int i = 0; i < coords.length; i++) {
+                int index = str.indexOf(",");
+                if (index < 0) {
+                    if (i < coords.length-1) {
+                        return null;
+                    }
+                    index = str.indexOf(")");
+                    if (index < 0) {
+                        return null;
+                    }
+                    foundparen = true;
+                }
+                String num = str.substring(0, index);
+                try {
+                    coords[i] = Double.parseDouble(num);
+                } catch (NumberFormatException nfe) {
+                    return null;
+                }
+                str = str.substring(index+1);
+            }
+            if (!foundparen || str.length() > 0) {
+                return null;
+            }
+            Quad c = new Quad();
+            c.quad.setCurve(coords[0], coords[1],
+                            coords[2], coords[3],
+                            coords[4], coords[5]);
+            return c;
+        }
+
+        private QuadCurve2D quad = new QuadCurve2D.Double();
+
+        public void randomize() {
+            quad.setCurve(randDblCoord(), randDblCoord(),
+                          randDblCoord(), randDblCoord(),
+                          randDblCoord(), randDblCoord());
+        }
+
+        public Shape getShape() {
+            return quad;
+        }
+
+        public String toString() {
+            return ("Quad("+
+                    quad.getX1()+", "+
+                    quad.getY1()+", "+
+                    quad.getCtrlX()+", "+
+                    quad.getCtrlY()+", "+
+                    quad.getX2()+", "+
+                    quad.getY2()
+                    +")");
+        }
+    }
+
+    public static class Poly extends AnnotatedShapeOp {
+        public static Poly tryparse(String str) {
+            str = str.trim();
+            if (!str.startsWith("Poly(")) {
+                return null;
+            }
+            str = str.substring(5);
+            Polygon p = new Polygon();
+            while (true) {
+                int x, y;
+                str = str.trim();
+                if (str.startsWith(")")) {
+                    str = str.substring(1);
+                    break;
+                }
+                if (p.npoints > 0) {
+                    if (str.startsWith(",")) {
+                        str = str.substring(2).trim();
+                    } else {
+                        return null;
+                    }
+                }
+                if (str.startsWith("[")) {
+                    str = str.substring(1);
+                } else {
+                    return null;
+                }
+                int index = str.indexOf(",");
+                if (index < 0) {
+                    return null;
+                }
+                String num = str.substring(0, index);
+                try {
+                    x = Integer.parseInt(num);
+                } catch (NumberFormatException nfe) {
+                    return null;
+                }
+                str = str.substring(index+1);
+                index = str.indexOf("]");
+                if (index < 0) {
+                    return null;
+                }
+                num = str.substring(0, index).trim();
+                try {
+                    y = Integer.parseInt(num);
+                } catch (NumberFormatException nfe) {
+                    return null;
+                }
+                str = str.substring(index+1);
+                p.addPoint(x, y);
+            }
+            if (str.length() > 0) {
+                return null;
+            }
+            if (p.npoints < 3) {
+                return null;
+            }
+            return new Poly(p);
+        }
+
+        private Polygon poly;
+
+        public Poly() {
+            this.poly = new Polygon();
+        }
+
+        private Poly(Polygon p) {
+            this.poly = p;
+        }
+
+        public void randomize() {
+            poly.reset();
+            poly.addPoint(randIntCoord(), randIntCoord());
+            poly.addPoint(randIntCoord(), randIntCoord());
+            poly.addPoint(randIntCoord(), randIntCoord());
+            poly.addPoint(randIntCoord(), randIntCoord());
+            poly.addPoint(randIntCoord(), randIntCoord());
+        }
+
+        public Shape getShape() {
+            return poly;
+        }
+
+        public String toString() {
+            StringBuffer sb = new StringBuffer(100);
+            sb.append("Poly(");
+            for (int i = 0; i < poly.npoints; i++) {
+                if (i != 0) {
+                    sb.append(", ");
+                }
+                sb.append("[");
+                sb.append(poly.xpoints[i]);
+                sb.append(", ");
+                sb.append(poly.ypoints[i]);
+                sb.append("]");
+            }
+            sb.append(")");
+            return sb.toString();
+        }
+    }
+
+    public static class Path extends AnnotatedShapeOp {
+        public static Path tryparse(String str) {
+            str = str.trim();
+            if (!str.startsWith("Path(")) {
+                return null;
+            }
+            str = str.substring(5);
+            GeneralPath gp = new GeneralPath();
+            float coords[] = new float[6];
+            int numsegs = 0;
+            while (true) {
+                int type;
+                int n;
+                str = str.trim();
+                if (str.startsWith(")")) {
+                    str = str.substring(1);
+                    break;
+                }
+                if (str.startsWith("M[")) {
+                    type = PathIterator.SEG_MOVETO;
+                    n = 2;
+                } else if (str.startsWith("L[")) {
+                    type = PathIterator.SEG_LINETO;
+                    n = 2;
+                } else if (str.startsWith("Q[")) {
+                    type = PathIterator.SEG_QUADTO;
+                    n = 4;
+                } else if (str.startsWith("C[")) {
+                    type = PathIterator.SEG_CUBICTO;
+                    n = 6;
+                } else if (str.startsWith("E[")) {
+                    type = PathIterator.SEG_CLOSE;
+                    n = 0;
+                } else {
+                    return null;
+                }
+                str = str.substring(2);
+                if (n == 0) {
+                    if (str.startsWith("]")) {
+                        str = str.substring(1);
+                    } else {
+                        return null;
+                    }
+                }
+                for (int i = 0; i < n; i++) {
+                    int index;
+                    if (i < n-1) {
+                        index = str.indexOf(",");
+                    } else {
+                        index = str.indexOf("]");
+                    }
+                    if (index < 0) {
+                        return null;
+                    }
+                    String num = str.substring(0, index);
+                    try {
+                        coords[i] = Float.parseFloat(num);
+                    } catch (NumberFormatException nfe) {
+                        return null;
+                    }
+                    str = str.substring(index+1).trim();
+                }
+                switch (type) {
+                case PathIterator.SEG_MOVETO:
+                    gp.moveTo(coords[0], coords[1]);
+                    break;
+                case PathIterator.SEG_LINETO:
+                    gp.lineTo(coords[0], coords[1]);
+                    break;
+                case PathIterator.SEG_QUADTO:
+                    gp.quadTo(coords[0], coords[1],
+                              coords[2], coords[3]);
+                    break;
+                case PathIterator.SEG_CUBICTO:
+                    gp.curveTo(coords[0], coords[1],
+                               coords[2], coords[3],
+                               coords[4], coords[5]);
+                    break;
+                case PathIterator.SEG_CLOSE:
+                    gp.closePath();
+                    break;
+                }
+                numsegs++;
+            }
+            if (str.length() > 0) {
+                return null;
+            }
+            if (numsegs < 2) {
+                return null;
+            }
+            return new Path(gp);
+        }
+
+        private GeneralPath path;
+
+        public Path() {
+            this.path = new GeneralPath();
+        }
+
+        private Path(GeneralPath gp) {
+            this.path = gp;
+        }
+
+        public void randomize() {
+            path.reset();
+            path.moveTo(randFltCoord(), randFltCoord());
+            for (int i = randInt(5)+3; i > 0; --i) {
+                switch(randInt(5)) {
+                case 0:
+                    path.moveTo(randFltCoord(), randFltCoord());
+                    break;
+                case 1:
+                    path.lineTo(randFltCoord(), randFltCoord());
+                    break;
+                case 2:
+                    path.quadTo(randFltCoord(), randFltCoord(),
+                                randFltCoord(), randFltCoord());
+                    break;
+                case 3:
+                    path.curveTo(randFltCoord(), randFltCoord(),
+                                 randFltCoord(), randFltCoord(),
+                                 randFltCoord(), randFltCoord());
+                    break;
+                case 4:
+                    path.closePath();
+                    break;
+                }
+            }
+        }
+
+        public Shape getShape() {
+            return path;
+        }
+
+        public String toString() {
+            StringBuffer sb = new StringBuffer(100);
+            sb.append("Path(");
+            PathIterator pi = path.getPathIterator(null);
+            float coords[] = new float[6];
+            boolean first = true;
+            while (!pi.isDone()) {
+                int n;
+                char c;
+                switch(pi.currentSegment(coords)) {
+                case PathIterator.SEG_MOVETO:
+                    c = 'M';
+                    n = 2;
+                    break;
+                case PathIterator.SEG_LINETO:
+                    c = 'L';
+                    n = 2;
+                    break;
+                case PathIterator.SEG_QUADTO:
+                    c = 'Q';
+                    n = 4;
+                    break;
+                case PathIterator.SEG_CUBICTO:
+                    c = 'C';
+                    n = 6;
+                    break;
+                case PathIterator.SEG_CLOSE:
+                    c = 'E';
+                    n = 0;
+                    break;
+                default:
+                    throw new InternalError("Unknown segment!");
+                }
+                sb.append(c);
+                sb.append("[");
+                for (int i = 0; i < n; i++) {
+                    if (i != 0) {
+                        sb.append(",");
+                    }
+                    sb.append(coords[i]);
+                }
+                sb.append("]");
+                pi.next();
+            }
+            sb.append(")");
+            return sb.toString();
+        }
+    }
+
+    public static class Rect extends AnnotatedShapeOp {
+        public static Rect tryparse(String str) {
+            str = str.trim();
+            if (!str.startsWith("Rect(")) {
+                return null;
+            }
+            str = str.substring(5);
+            double coords[] = new double[4];
+            boolean foundparen = false;
+            for (int i = 0; i < coords.length; i++) {
+                int index = str.indexOf(",");
+                if (index < 0) {
+                    if (i < coords.length-1) {
+                        return null;
+                    }
+                    index = str.indexOf(")");
+                    if (index < 0) {
+                        return null;
+                    }
+                    foundparen = true;
+                }
+                String num = str.substring(0, index);
+                try {
+                    coords[i] = Double.parseDouble(num);
+                } catch (NumberFormatException nfe) {
+                    return null;
+                }
+                str = str.substring(index+1);
+            }
+            if (!foundparen || str.length() > 0) {
+                return null;
+            }
+            Rect r = new Rect();
+            r.rect.setRect(coords[0], coords[1],
+                           coords[2], coords[3]);
+            return r;
+        }
+
+        private Rectangle2D rect = new Rectangle2D.Double();
+
+        public void randomize() {
+            rect.setRect(randDblCoord(), randDblCoord(),
+                         randDblCoord(), randDblCoord());
+        }
+
+        public Shape getShape() {
+            return rect;
+        }
+
+        public String toString() {
+            return ("Rect("+
+                    rect.getX()+", "+
+                    rect.getY()+", "+
+                    rect.getWidth()+", "+
+                    rect.getHeight()
+                    +")");
+        }
+    }
+
+    public static class Line extends AnnotatedShapeOp {
+        public static Line tryparse(String str) {
+            str = str.trim();
+            if (!str.startsWith("Line(")) {
+                return null;
+            }
+            str = str.substring(5);
+            double coords[] = new double[4];
+            boolean foundparen = false;
+            for (int i = 0; i < coords.length; i++) {
+                int index = str.indexOf(",");
+                if (index < 0) {
+                    if (i < coords.length-1) {
+                        return null;
+                    }
+                    index = str.indexOf(")");
+                    if (index < 0) {
+                        return null;
+                    }
+                    foundparen = true;
+                }
+                String num = str.substring(0, index);
+                try {
+                    coords[i] = Double.parseDouble(num);
+                } catch (NumberFormatException nfe) {
+                    return null;
+                }
+                str = str.substring(index+1);
+            }
+            if (!foundparen || str.length() > 0) {
+                return null;
+            }
+            Line l = new Line();
+            l.line.setLine(coords[0], coords[1],
+                           coords[2], coords[3]);
+            return l;
+        }
+
+        private Line2D line = new Line2D.Double();
+
+        public void randomize() {
+            line.setLine(randDblCoord(), randDblCoord(),
+                         randDblCoord(), randDblCoord());
+        }
+
+        public Shape getShape() {
+            return line;
+        }
+
+        public String toString() {
+            return ("Line("+
+                    line.getX1()+", "+
+                    line.getY1()+", "+
+                    line.getX2()+", "+
+                    line.getY2()
+                    +")");
+        }
+    }
+
+    public static class RectMethod extends AnnotatedRenderOp {
+        public static RectMethod tryparse(String str) {
+            str = str.trim();
+            if (!str.startsWith("RectMethod(")) {
+                return null;
+            }
+            str = str.substring(11);
+            int coords[] = new int[4];
+            boolean foundparen = false;
+            for (int i = 0; i < coords.length; i++) {
+                int index = str.indexOf(",");
+                if (index < 0) {
+                    if (i < coords.length-1) {
+                        return null;
+                    }
+                    index = str.indexOf(")");
+                    if (index < 0) {
+                        return null;
+                    }
+                    foundparen = true;
+                }
+                String num = str.substring(0, index).trim();
+                try {
+                    coords[i] = Integer.parseInt(num);
+                } catch (NumberFormatException nfe) {
+                    return null;
+                }
+                str = str.substring(index+1);
+            }
+            if (!foundparen || str.length() > 0) {
+                return null;
+            }
+            RectMethod rm = new RectMethod();
+            rm.rect.setBounds(coords[0], coords[1],
+                              coords[2], coords[3]);
+            return rm;
+        }
+
+        private Rectangle rect = new Rectangle();
+
+        public void randomize() {
+            rect.setBounds(randIntCoord(), randIntCoord(),
+                           randIntCoord(), randIntCoord());
+        }
+
+        public void fill(Graphics2D g2d) {
+            g2d.fillRect(rect.x, rect.y, rect.width, rect.height);
+        }
+
+        public void draw(Graphics2D g2d) {
+            g2d.drawRect(rect.x, rect.y, rect.width, rect.height);
+        }
+
+        public String toString() {
+            return ("RectMethod("+
+                    rect.x+", "+
+                    rect.y+", "+
+                    rect.width+", "+
+                    rect.height
+                    +")");
+        }
+    }
+
+    public static class LineMethod extends AnnotatedRenderOp {
+        public static LineMethod tryparse(String str) {
+            str = str.trim();
+            if (!str.startsWith("LineMethod(")) {
+                return null;
+            }
+            str = str.substring(11);
+            int coords[] = new int[4];
+            boolean foundparen = false;
+            for (int i = 0; i < coords.length; i++) {
+                int index = str.indexOf(",");
+                if (index < 0) {
+                    if (i < coords.length-1) {
+                        return null;
+                    }
+                    index = str.indexOf(")");
+                    if (index < 0) {
+                        return null;
+                    }
+                    foundparen = true;
+                }
+                String num = str.substring(0, index).trim();
+                try {
+                    coords[i] = Integer.parseInt(num);
+                } catch (NumberFormatException nfe) {
+                    return null;
+                }
+                str = str.substring(index+1);
+            }
+            if (!foundparen || str.length() > 0) {
+                return null;
+            }
+            LineMethod lm = new LineMethod();
+            lm.line = coords;
+            return lm;
+        }
+
+        private int line[] = new int[4];
+
+        public void randomize() {
+            line[0] = randIntCoord();
+            line[1] = randIntCoord();
+            line[2] = randIntCoord();
+            line[3] = randIntCoord();
+        }
+
+        public void fill(Graphics2D g2d) {
+        }
+
+        public void draw(Graphics2D g2d) {
+            g2d.drawLine(line[0], line[1], line[2], line[3]);
+        }
+
+        public String toString() {
+            return ("LineMethod("+
+                    line[0]+", "+
+                    line[1]+", "+
+                    line[2]+", "+
+                    line[3]
+                    +")");
+        }
+    }
+
+    public static class ErrorWindow extends Frame {
+        ImageCanvas unclipped;
+        ImageCanvas reference;
+        ImageCanvas actual;
+        ImageCanvas diff;
+
+        public ErrorWindow() {
+            super("Error Comparison Window");
+
+            unclipped = new ImageCanvas();
+            reference = new ImageCanvas();
+            actual = new ImageCanvas();
+            diff = new ImageCanvas();
+
+            setLayout(new SmartGridLayout(0, 2, 5, 5));
+            addImagePanel(unclipped, "Unclipped rendering");
+            addImagePanel(reference, "Clipped reference");
+            addImagePanel(actual, "Actual clipped");
+            addImagePanel(diff, "Difference");
+
+            addWindowListener(new WindowAdapter() {
+                public void windowClosing(WindowEvent e) {
+                    setVisible(false);
+                }
+            });
+        }
+
+        public void addImagePanel(ImageCanvas ic, String label) {
+            add(ic);
+            add(new Label(label));
+        }
+
+        public void setImages(BufferedImage imgref, BufferedImage imgtst) {
+            unclipped.setImage(imgref);
+            reference.setReference(imgref);
+            actual.setImage(imgtst);
+            diff.setDiff(reference.getImage(), imgtst);
+            invalidate();
+            pack();
+            repaint();
+        }
+
+        public void setVisible(boolean vis) {
+            super.setVisible(vis);
+            synchronized (this) {
+                notifyAll();
+            }
+        }
+
+        public synchronized void waitForHide() {
+            while (isShowing()) {
+                try {
+                    wait();
+                } catch (InterruptedException e) {
+                    System.exit(2);
+                }
+            }
+        }
+    }
+
+    public static class SmartGridLayout implements LayoutManager {
+        int rows;
+        int cols;
+        int hgap;
+        int vgap;
+
+        public SmartGridLayout(int r, int c, int h, int v) {
+            this.rows = r;
+            this.cols = c;
+            this.hgap = h;
+            this.vgap = v;
+        }
+
+        public void addLayoutComponent(String name, Component comp) {
+        }
+
+        public void removeLayoutComponent(Component comp) {
+        }
+
+        public int[][] getGridSizes(Container parent, boolean min) {
+            int ncomponents = parent.getComponentCount();
+            int nrows = rows;
+            int ncols = cols;
+
+            if (nrows > 0) {
+                ncols = (ncomponents + nrows - 1) / nrows;
+            } else {
+                nrows = (ncomponents + ncols - 1) / ncols;
+            }
+            int widths[] = new int[ncols+1];
+            int heights[] = new int[nrows+1];
+            int x = 0;
+            int y = 0;
+            for (int i = 0 ; i < ncomponents ; i++) {
+                Component comp = parent.getComponent(i);
+                Dimension d = (min
+                               ? comp.getMinimumSize()
+                               : comp.getPreferredSize());
+                if (widths[x] < d.width) {
+                    widths[x] = d.width;
+                }
+                if (heights[y] < d.height) {
+                    heights[y] = d.height;
+                }
+                x++;
+                if (x >= ncols) {
+                    x = 0;
+                    y++;
+                }
+            }
+            for (int i = 0; i < ncols; i++) {
+                widths[ncols] += widths[i];
+            }
+            for (int i = 0; i < nrows; i++) {
+                heights[nrows] += heights[i];
+            }
+            return new int[][] { widths, heights };
+        }
+
+        public Dimension getSize(Container parent, boolean min) {
+            int sizes[][] = getGridSizes(parent, min);
+            int widths[] = sizes[0];
+            int heights[] = sizes[1];
+            int nrows = heights.length-1;
+            int ncols = widths.length-1;
+            int w = widths[ncols];
+            int h = heights[nrows];
+            Insets insets = parent.getInsets();
+            return new Dimension(insets.left+insets.right + w+(ncols+1)*hgap,
+                                 insets.top+insets.bottom + h+(nrows+1)*vgap);
+        }
+
+        public Dimension preferredLayoutSize(Container parent) {
+            return getSize(parent, false);
+        }
+
+        public Dimension minimumLayoutSize(Container parent) {
+            return getSize(parent, true);
+        }
+
+        public void layoutContainer(Container parent) {
+            int pref[][] = getGridSizes(parent, false);
+            int min[][] = getGridSizes(parent, true);
+            int minwidths[] = min[0];
+            int minheights[] = min[1];
+            int prefwidths[] = pref[0];
+            int prefheights[] = pref[1];
+            int nrows = minheights.length - 1;
+            int ncols = minwidths.length - 1;
+            Insets insets = parent.getInsets();
+            int w = parent.getWidth() - insets.left - insets.right;
+            int h = parent.getHeight() - insets.top - insets.bottom;
+            w = w - (ncols+1)*hgap;
+            h = h - (nrows+1)*vgap;
+            int widths[] = calculateSizes(w, ncols, minwidths, prefwidths);
+            int heights[] = calculateSizes(h, nrows, minheights, prefheights);
+            int ncomponents = parent.getComponentCount();
+            int x = insets.left + hgap;
+            int y = insets.top + vgap;
+            int r = 0;
+            int c = 0;
+            for (int i = 0; i < ncomponents; i++) {
+                parent.getComponent(i).setBounds(x, y, widths[c], heights[r]);
+                x += widths[c++] + hgap;
+                if (c >= ncols) {
+                    c = 0;
+                    x = insets.left + hgap;
+                    y += heights[r++] + vgap;
+                    if (r >= nrows) {
+                        // just in case
+                        break;
+                    }
+                }
+            }
+        }
+
+        public static int[] calculateSizes(int total, int num,
+                                           int minsizes[], int prefsizes[])
+        {
+            if (total <= minsizes[num]) {
+                return minsizes;
+            }
+            if (total >= prefsizes[num]) {
+                return prefsizes;
+            }
+            int sizes[] = new int[total];
+            int prevhappy = 0;
+            int nhappy = 0;
+            int happysize = 0;
+            do {
+                int addsize = (total - happysize) / (num - nhappy);
+                happysize = 0;
+                for (int i = 0; i < num; i++) {
+                    if (sizes[i] >= prefsizes[i] ||
+                        minsizes[i] + addsize > prefsizes[i])
+                    {
+                        happysize += (sizes[i] = prefsizes[i]);
+                        nhappy++;
+                    } else {
+                        sizes[i] = minsizes[i] + addsize;
+                    }
+                }
+            } while (nhappy < num && nhappy > prevhappy);
+            return sizes;
+        }
+    }
+
+    public static class ImageCanvas extends Canvas {
+        BufferedImage image;
+
+        public void setImage(BufferedImage img) {
+            this.image = img;
+        }
+
+        public BufferedImage getImage() {
+            return image;
+        }
+
+        public void checkImage(int w, int h) {
+            if (image == null ||
+                image.getWidth() < w ||
+                image.getHeight() < h)
+            {
+                image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+            }
+        }
+
+        public void setReference(BufferedImage img) {
+            checkImage(img.getWidth(), img.getHeight());
+            Graphics g = image.createGraphics();
+            g.drawImage(img, 0, 0, null);
+            g.setColor(Color.white);
+            g.fillRect(0, 0, 30, 10);
+            g.fillRect(30, 0, 10, 30);
+            g.fillRect(10, 30, 30, 10);
+            g.fillRect(0, 10, 10, 30);
+            g.dispose();
+        }
+
+        public void setDiff(BufferedImage imgref, BufferedImage imgtst) {
+            int w = Math.max(imgref.getWidth(), imgtst.getWidth());
+            int h = Math.max(imgref.getHeight(), imgtst.getHeight());
+            checkImage(w, h);
+            Graphics g = image.createGraphics();
+            g.drawImage(imgref, 0, 0, null);
+            g.setXORMode(Color.white);
+            g.drawImage(imgtst, 0, 0, null);
+            g.setPaintMode();
+            g.setColor(new Color(1f, 1f, 0f, 0.25f));
+            g.fillRect(10, 10, 20, 20);
+            g.setColor(new Color(1f, 0f, 0f, 0.25f));
+            g.fillRect(0, 0, 30, 10);
+            g.fillRect(30, 0, 10, 30);
+            g.fillRect(10, 30, 30, 10);
+            g.fillRect(0, 10, 10, 30);
+            g.dispose();
+        }
+
+        public Dimension getPreferredSize() {
+            if (image == null) {
+                return new Dimension();
+            } else {
+                return new Dimension(image.getWidth(), image.getHeight());
+            }
+        }
+
+        public void paint(Graphics g) {
+            g.drawImage(image, 0, 0, null);
+        }
+    }
+}
--- a/jdk/test/java/awt/Insets/WindowWithWarningTest/WindowWithWarningTest.html	Wed Jan 19 17:01:50 2011 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-<html>
-<!--
-        @test
-        @bug 6391770
-        @summary Content of the Window should be laid out in the area left after WarningWindow was added.
-        @author Yuri Nesterenko
-        @run applet WindowWithWarningTest.html
--->
-
-  <head>
-    <title>WindowWithWarningTest</title>
-  </head>
-  <pre>
-  This test will run automatically.
-  </pre>
-  <body>
-    <applet code="WindowWithWarningTest.class" width=350 height=300></applet>
-  </body>
-</html>
-
--- a/jdk/test/java/awt/Insets/WindowWithWarningTest/WindowWithWarningTest.java	Wed Jan 19 17:01:50 2011 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,315 +0,0 @@
-/*
- * Copyright (c) 2006, 2008, 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 6391770
-  @summary Content of the Window should be laid out in the area left after WarningWindow was added.
-  @author yuri nesterenko: area=
-  @run applet WindowWithWarningTest.html
-*/
-
-// Note there is no @ in front of test above.  This is so that the
-//  harness will not mistake this file as a test file.  It should
-//  only see the html file as a test file. (the harness runs all
-//  valid test files, so it would run this test twice if this file
-//  were valid as well as the html file.)
-// Also, note the area= after Your Name in the author tag.  Here, you
-//  should put which functional area the test falls in.  See the
-//  AWT-core home page -> test areas and/or -> AWT team  for a list of
-//  areas.
-// Note also the 'AutomaticAppletTest.html' in the run tag.  This should
-//  be changed to the name of the test.
-
-
-/**
- * WindowWithWarningTest.java
- *
- * summary:
- */
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-//Automated tests should run as applet tests if possible because they
-// get their environments cleaned up, including AWT threads, any
-// test created threads, and any system resources used by the test
-// such as file descriptors.  (This is normally not a problem as
-// main tests usually run in a separate VM, however on some platforms
-// such as the Mac, separate VMs are not possible and non-applet
-// tests will cause problems).  Also, you don't have to worry about
-// synchronisation stuff in Applet tests they way you do in main
-// tests...
-
-
-public class WindowWithWarningTest extends Applet
-{
-    //Declare things used in the test, like buttons and labels here
-    boolean buttonClicked = false;
-    public static final int MAX_COUNT = 100;
-
-    public void init()
-    {
-        //Create instructions for the user here, as well as set up
-        // the environment -- set the layout manager, add buttons,
-        // etc.
-
-        this.setLayout (new BorderLayout ());
-
-        String[] instructions =
-        {
-            "This is an AUTOMATIC test",
-            "simply wait until it is done"
-        };
-        //Sysout.createDialog( );
-        //Sysout.printInstructions( instructions );
-
-    }//End  init()
-    public void start ()
-    {
-        //Get things going.  Request focus, set size, et cetera
-        System.setSecurityManager( new SecurityManager() {
-        // deny AWTPermission("showWindowWithoutWarningBanner")
-            public boolean checkTopLevelWindow(Object window) {
-                return false;
-            }
-         });
-        JFrame frame = new JFrame("Window Test");
-        frame.setBounds(50, 50, 200, 200);
-        frame.show();
-
-        JWindow window = new JWindow( frame );
-        JButton jbutton1 = new JButton( "First" );
-        jbutton1.addMouseListener( new MouseAdapter() {
-            public void mousePressed( MouseEvent me ) {
-                buttonClicked = true;
-            }
-         });
-        JButton jbutton2 = new JButton( "Second" );
-        window.setLocation( 300, 300 );
-
-        window.add("North", jbutton1);
-        window.add("South", jbutton2);
-
-        window.pack();
-        window.show();
-        //wait for frame to show:
-        getLocation( frame );
-        window.toFront();
-
-        Dimension size0 = window.getSize();
-        Dimension size1 = null;
-        try {
-            Robot robot = new Robot();
-
-            robot.delay(500);
-            window.pack();
-            robot.delay(500);
-            window.pack();
-            // size1 must be the same as size0
-            size1 = window.getSize();
-            robot.delay(500);
-            Point pt = jbutton1.getLocationOnScreen();
-            robot.mouseMove((int) jbutton1.getLocationOnScreen().x + jbutton1.getWidth() / 2,
-                            (int) jbutton1.getLocationOnScreen().y + jbutton1.getHeight() / 2);
-            robot.delay(500);
-            robot.mousePress(MouseEvent.BUTTON1_MASK);
-            robot.delay(100);
-            robot.mouseRelease(MouseEvent.BUTTON1_MASK);
-            robot.delay(2000);
-         }catch(Exception e) {
-            throw new RuntimeException( "Exception "+e );
-         }
-         if( !size0.equals(size1) ) {
-            throw new RuntimeException( "Wrong Window size after multiple pack()s");
-         }
-         if( !buttonClicked ) {
-            throw new RuntimeException( "Button was not clicked");
-         }
-         window.dispose();
-         frame.dispose();
-
-         System.out.println("Test Passed.");
-    }// start()
-    public static Point getLocation( Component co ) throws RuntimeException {
-       Point pt = null;
-       boolean bFound = false;
-       int count = 0;
-       while( !bFound ) {
-          try {
-             pt = co.getLocationOnScreen();
-             bFound = true;
-          }catch( Exception ex ) {
-             bFound = false;
-             count++;
-          }
-          if( !bFound && count > MAX_COUNT ) {
-             throw new RuntimeException("don't see a component to get location");
-          }
-       }
-       return pt;
-    }
-
-
-}// class AutomaticAppletTest
-
-
-/****************************************************
- Standard Test Machinery
- DO NOT modify anything below -- it's a standard
-  chunk of code whose purpose is to make user
-  interaction uniform, and thereby make it simpler
-  to read and understand someone else's test.
- ****************************************************/
-
-/**
- This is part of the standard test machinery.
- It creates a dialog (with the instructions), and is the interface
-  for sending text messages to the user.
- To print the instructions, send an array of strings to Sysout.createDialog
-  WithInstructions method.  Put one line of instructions per array entry.
- To display a message for the tester to see, simply call Sysout.println
-  with the string to be displayed.
- This mimics System.out.println but works within the test harness as well
-  as standalone.
- */
-
-class Sysout
-{
-    private static TestDialog dialog;
-
-    public static void createDialogWithInstructions( String[] instructions )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        dialog.printInstructions( instructions );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
-    }
-
-    public static void createDialog( )
-    {
-        dialog = new TestDialog( new Frame(), "Instructions" );
-        String[] defInstr = { "Instructions will appear here. ", "" } ;
-        dialog.printInstructions( defInstr );
-        dialog.setVisible(true);
-        println( "Any messages for the tester will display here." );
-    }
-
-
-    public static void printInstructions( String[] instructions )
-    {
-        dialog.printInstructions( instructions );
-    }
-
-
-    public static void println( String messageIn )
-    {
-        dialog.displayMessage( messageIn );
-    }
-
-}// Sysout  class
-
-/**
-  This is part of the standard test machinery.  It provides a place for the
-   test instructions to be displayed, and a place for interactive messages
-   to the user to be displayed.
-  To have the test instructions displayed, see Sysout.
-  To have a message to the user be displayed, see Sysout.
-  Do not call anything in this dialog directly.
-  */
-class TestDialog extends Dialog
-{
-
-    TextArea instructionsText;
-    TextArea messageText;
-    int maxStringLength = 80;
-
-    //DO NOT call this directly, go through Sysout
-    public TestDialog( Frame frame, String name )
-    {
-        super( frame, name );
-        int scrollBoth = TextArea.SCROLLBARS_BOTH;
-        instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth );
-        add( "North", instructionsText );
-
-        messageText = new TextArea( "", 5, maxStringLength, scrollBoth );
-        add("Center", messageText);
-
-        pack();
-
-        show();
-    }// TestDialog()
-
-    //DO NOT call this directly, go through Sysout
-    public void printInstructions( String[] instructions )
-    {
-        //Clear out any current instructions
-        instructionsText.setText( "" );
-
-        //Go down array of instruction strings
-
-        String printStr, remainingStr;
-        for( int i=0; i < instructions.length; i++ )
-        {
-            //chop up each into pieces maxSringLength long
-            remainingStr = instructions[ i ];
-            while( remainingStr.length() > 0 )
-            {
-                //if longer than max then chop off first max chars to print
-                if( remainingStr.length() >= maxStringLength )
-                {
-                    //Try to chop on a word boundary
-                    int posOfSpace = remainingStr.
-                        lastIndexOf( ' ', maxStringLength - 1 );
-
-                    if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1;
-
-                    printStr = remainingStr.substring( 0, posOfSpace + 1 );
-                    remainingStr = remainingStr.substring( posOfSpace + 1 );
-                }
-                //else just print
-                else
-                {
-                    printStr = remainingStr;
-                    remainingStr = "";
-                }
-
-                instructionsText.append( printStr + "\n" );
-
-            }// while
-
-        }// for
-
-    }//printInstructions()
-
-    //DO NOT call this directly, go through Sysout
-    public void displayMessage( String messageIn )
-    {
-        messageText.append( messageIn + "\n" );
-        System.out.println(messageIn);
-    }
-
-}// TestDialog  class
--- a/jdk/test/java/awt/PrintJob/Text/StringWidth.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/java/awt/PrintJob/Text/StringWidth.java	Wed Jan 19 21:51:10 2011 -0800
@@ -60,7 +60,6 @@
     pg.dispose();
     pj.end();
     setVisible(false);
-    System.exit(0);
   }
 
   public static void main(String[] args) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/IncorrectSampleMaskTest.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6782574
+ * @summary Test verifies that incorrect sample masks are correctly handled
+ *          by the constructor of the SinglePixelPackedSampleModel class
+ *          and do not cause internal error in the medialib glue code.
+ *
+ * @run     main IncorrectSampleMaskTest
+ */
+
+import java.awt.geom.AffineTransform;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImageOp;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DataBufferUShort;
+import java.awt.image.Raster;
+import java.awt.image.RasterOp;
+import java.awt.image.WritableRaster;
+import java.awt.image.SinglePixelPackedSampleModel;
+
+public class IncorrectSampleMaskTest {
+    public static void main(String[] args) {
+        int[] dataTypes = new int[] {
+            DataBuffer.TYPE_BYTE,
+            DataBuffer.TYPE_USHORT,
+            DataBuffer.TYPE_INT };
+
+        for (int type : dataTypes) {
+            doTest(type);
+        }
+    }
+
+    private static final int w = 100;
+    private static final int h = 100;
+
+    private static AffineTransform at =
+        AffineTransform.getScaleInstance(0.5, 0.5);
+
+    private static RasterOp op =
+        new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
+
+    private static void doTest(int dataType) {
+        int maxSize = DataBuffer.getDataTypeSize(dataType);
+        System.out.println("Type size: " + maxSize);
+
+        int theMask = (int)(1L << (maxSize + 2)) - 1;
+        System.out.printf("theMask=%x\n", theMask);
+
+        SinglePixelPackedSampleModel sm =
+            new SinglePixelPackedSampleModel(dataType, w, h,
+                                             new int[] { theMask });
+
+
+        int[] sampleSize = sm.getSampleSize();
+        for (int s : sampleSize) {
+            if (s > maxSize) {
+                throw new RuntimeException("Test failed: sample size is too big:" + s);
+            }
+        }
+
+        System.out.println("Test medialib...");
+        DataBuffer buf = createDataBuffer(dataType);
+
+        WritableRaster wr = Raster.createWritableRaster(sm, buf, null);
+
+        op.filter(wr, null);
+        System.out.println("Test PASSED.");
+    }
+
+    private static DataBuffer createDataBuffer(int type) {
+        switch (type) {
+        case DataBuffer.TYPE_BYTE: {
+            byte[] buf = new byte[w * h];
+            return new DataBufferByte(buf, buf.length);
+        }
+        case DataBuffer.TYPE_USHORT: {
+            short[] buf = new short[w * h];
+            return new DataBufferUShort(buf, buf.length);
+        }
+        case DataBuffer.TYPE_INT: {
+            int[] buf = new int[w * h];
+            return new DataBufferInt(buf, buf.length);
+        }
+        default :
+            throw new RuntimeException("Unsupported data type.");
+        }
+    }
+}
--- a/jdk/test/java/awt/xembed/server/TestXEmbedServer.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/java/awt/xembed/server/TestXEmbedServer.java	Wed Jan 19 21:51:10 2011 -0800
@@ -31,6 +31,9 @@
 import java.awt.datatransfer.*;
 
 public abstract class TestXEmbedServer {
+    // vertical position of server AND client windows
+    private static final int VERTICAL_POSITION = 200;
+
     private static final Logger log = Logger.getLogger("test.xembed");
     Frame f;
     Canvas client;
@@ -161,10 +164,10 @@
         dummy = new JFrame("Dummy");
         dummy.getContentPane().add(new JButton("Button"));
         dummy.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
-        dummy.setBounds(0, 0, 100, 100);
+        dummy.setBounds(0, VERTICAL_POSITION, 100, 100);
         dummy.setVisible(true);
 
-        f.setBounds(300, 0, 800, 300);
+        f.setBounds(300, VERTICAL_POSITION, 800, 300);
         f.setVisible(true);
     }
 
--- a/jdk/test/java/io/Serializable/NPEProvoker/NPEProvoker.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/java/io/Serializable/NPEProvoker/NPEProvoker.java	Wed Jan 19 21:51:10 2011 -0800
@@ -56,7 +56,7 @@
     public static void main(String[] args) {
         System.err.println("\n Regression test for bug 6541870\n");
         try {
-            ArrayList<NPEProvoker> list = new ArrayList<NPEProvoker>();
+            ArrayList<NPEProvoker> list = new ArrayList<>();
             list.add(new NPEProvoker());
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             ObjectOutputStream oos = new ObjectOutputStream(baos);
--- a/jdk/test/java/lang/instrument/ilib/Inject.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/java/lang/instrument/ilib/Inject.java	Wed Jan 19 21:51:10 2011 -0800
@@ -107,7 +107,7 @@
     class IndexedInjector implements TrackerInjector {
         int counter = 0;
         int tracker;
-        List<Info> infoList = new ArrayList<Info>();
+        List<Info> infoList = new ArrayList<>();
 
         public int stackSize(int currentSize) {
             return currentSize + 1;
--- a/jdk/test/java/lang/instrument/ilib/InjectBytecodes.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/java/lang/instrument/ilib/InjectBytecodes.java	Wed Jan 19 21:51:10 2011 -0800
@@ -50,7 +50,7 @@
     private final Injector[] after  = new Injector[256];
     private final String className;
     private final String methodName;
-    private final Map<Integer,byte[]> snippets = new HashMap<Integer,byte[]>();
+    private final Map<Integer,byte[]> snippets = new HashMap<>();
 
     private int pos;
     private int newPos;
--- a/jdk/test/java/lang/reflect/Generics/TestPlainArrayNotGeneric.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/java/lang/reflect/Generics/TestPlainArrayNotGeneric.java	Wed Jan 19 21:51:10 2011 -0800
@@ -103,7 +103,7 @@
         }
     }
 
-    private static final Set<Type> checking = new HashSet<Type>();
+    private static final Set<Type> checking = new HashSet<>();
 
     private static void check(Type t, String what) {
         if (t == null || !checking.add(t))
--- a/jdk/test/java/util/Random/DistinctSeeds.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/java/util/Random/DistinctSeeds.java	Wed Jan 19 21:51:10 2011 -0800
@@ -59,7 +59,7 @@
             }
         }
         final int threadCount = 2;
-        List<RandomCollector> collectors = new ArrayList<RandomCollector>();
+        List<RandomCollector> collectors = new ArrayList<>();
         List<Thread> threads = new ArrayList<Thread>();
         for (int i = 0; i < threadCount; i++) {
             RandomCollector r = new RandomCollector();
--- a/jdk/test/java/util/logging/ClassLoaderLeakTest.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/java/util/logging/ClassLoaderLeakTest.java	Wed Jan 19 21:51:10 2011 -0800
@@ -89,7 +89,7 @@
 
          MyClassLoader appClassLoader = new MyClassLoader(urls, "test0");
          WeakReference<MyClassLoader> ref =
-                 new WeakReference<MyClassLoader>(appClassLoader);
+                 new WeakReference<>(appClassLoader);
 
 
          Thread appThread = new Thread(appsThreadGroup, launcher, "AppThread-0");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/zip/ZipFile/FinalizeZipFile.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7007609 7009618
+ * @summary Check that ZipFile objects are always collected
+ */
+
+import java.io.*;
+import java.nio.*;
+import java.util.Random;
+import java.util.zip.*;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class FinalizeZipFile {
+
+    private final static CountDownLatch finalizersDone = new CountDownLatch(3);
+
+    private static class InstrumentedZipFile extends ZipFile {
+
+        public InstrumentedZipFile(File f) throws Exception {
+            super(f);
+            System.out.printf("Using %s%n", f.getPath());
+        }
+        protected void finalize() throws IOException {
+            System.out.printf("Killing %s%n", getName());
+            super.finalize();
+            finalizersDone.countDown();
+        }
+    }
+
+    private static void makeGarbage() throws Throwable {
+        final Random rnd = new Random();
+        final String javaHome = System.getProperty("java.home");
+        // Create some ZipFiles.
+        // Find some .jar files in JDK's lib directory.
+        final File lib = new File(javaHome, "lib");
+        check(lib.isDirectory());
+        final File[] jars = lib.listFiles(
+            new FilenameFilter() {
+                public boolean accept(File dir, String name) {
+                    return name.endsWith(".jar");}});
+        check(jars.length > 1);
+
+        new InstrumentedZipFile(jars[rnd.nextInt(jars.length)]).close();
+        new InstrumentedZipFile(jars[rnd.nextInt(jars.length)]).close();
+
+        // Create a ZipFile and get an input stream from it
+        ZipFile zf = new InstrumentedZipFile(jars[rnd.nextInt(jars.length)]);
+        ZipEntry ze = zf.getEntry("META-INF/MANIFEST.MF");
+        InputStream is = zf.getInputStream(ze);
+    }
+
+    public static void realMain(String[] args) throws Throwable {
+        makeGarbage();
+
+        System.gc();
+        finalizersDone.await(5, TimeUnit.SECONDS);
+
+        // Not all ZipFiles were collected?
+        equal(finalizersDone.getCount(), 0L);
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    static volatile int passed = 0, failed = 0;
+    static void pass() {passed++;}
+    static void fail() {failed++; Thread.dumpStack();}
+    static void fail(String msg) {System.out.println(msg); fail();}
+    static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    static void check(boolean cond) {if (cond) pass(); else fail();}
+    static void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else 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);
+        if (failed > 0) throw new AssertionError("Some tests failed");}
+}
+
--- a/jdk/test/javax/script/E4XErrorTest.java	Wed Jan 19 17:01:50 2011 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2005, 2008, 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 6346734 6705893
- * @summary We do *not* support E4X (ECMAScript for XML) in our
- * implementation. We want to throw error on XML literals
- * as early as possible rather than at "runtime" - i.e., when
- * engine looks for "XML" constructor.
- */
-
-import javax.script.*;
-import java.util.Locale;
-
-public class E4XErrorTest {
-
-        public static void main(String[] args) throws Exception {
-            ScriptEngineManager manager = new ScriptEngineManager();
-            ScriptEngine jsengine = Helper.getJsEngine(manager);
-            if (jsengine == null) {
-                System.out.println("Warning: No js engine found; test vacuously passes.");
-                return;
-            }
-
-            // The test below depends on the error message content
-            // that is loaded from resource bundles.  So, we force
-            // English Locale to compare correct value..
-            Locale.setDefault(Locale.US);
-
-            try {
-                jsengine.eval("var v = <html></html>;");
-            } catch (ScriptException se) {
-                String msg = se.getMessage();
-                if (msg.indexOf("syntax error") == -1) {
-                    throw new RuntimeException("syntax error expected, got " +
-                                       msg);
-                }
-                return;
-            }
-            // should not reach here.. exception should have been thrown.
-            throw new RuntimeException("Huh! E4X is supported??");
-        }
-}
--- a/jdk/test/javax/script/VersionTest.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/javax/script/VersionTest.java	Wed Jan 19 21:51:10 2011 -0800
@@ -32,8 +32,8 @@
 
 public class VersionTest  {
 
-        private static final String JS_LANG_VERSION = "1.6";
-        private static final String JS_ENGINE_VERSION = "1.6 release 2";
+        private static final String JS_LANG_VERSION = "1.8";
+        private static final String JS_ENGINE_VERSION = "1.7 release 3 PRERELEASE";
 
         public static void main(String[] args) throws Exception {
             ScriptEngineManager manager = new ScriptEngineManager();
--- a/jdk/test/javax/swing/SwingWorker/6480289/bug6480289.java	Wed Jan 19 17:01:50 2011 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2007, 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 6480289
- * @author Igor Kushnirskiy
- * @summary tests if consequent workers are executed on the same thread and that VM can exit.
- */
-
-import java.util.*;
-import javax.swing.SwingWorker;
-
-public class bug6480289 {
-    private static final int ITERATIONS = 5;
-    private static final Map<Thread, Integer> threadMap =
-        Collections.synchronizedMap(new HashMap<Thread, Integer>());
-    public static void main(String[] args) throws Exception {
-
-        for (int i = 0; i < ITERATIONS; i++) {
-            if (i != 0) {
-                Thread.sleep(1000 * 5);
-            }
-            SwingWorker<?,?> worker =
-                new SwingWorker<Void, Void>() {
-                    @Override
-                    protected Void doInBackground() {
-                        Integer value = threadMap.get(Thread.currentThread());
-                        value = Integer.valueOf(
-                            ((value == null) ? 0 : value.intValue())
-                            + 1);
-                        threadMap.put(Thread.currentThread(), value);
-                        return null;
-                    }
-                };
-            worker.execute();
-        }
-        if (threadMap.keySet().size() != 1) {
-            throw new RuntimeException("failed. More than one thread.");
-        }
-    }
-}
--- a/jdk/test/sun/security/krb5/auto/BasicKrb5Test.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/sun/security/krb5/auto/BasicKrb5Test.java	Wed Jan 19 21:51:10 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -25,6 +25,34 @@
  * @test
  * @bug 6706974
  * @summary Add krb5 test infrastructure
+ * @run main/othervm BasicKrb5Test
+ * @run main/othervm BasicKrb5Test des-cbc-crc
+ * @run main/othervm BasicKrb5Test des-cbc-md5
+ * @run main/othervm BasicKrb5Test des3-cbc-sha1
+ * @run main/othervm BasicKrb5Test aes128-cts
+ * @run main/othervm BasicKrb5Test aes256-cts
+ * @run main/othervm BasicKrb5Test rc4-hmac
+ * @run main/othervm BasicKrb5Test -s
+ * @run main/othervm BasicKrb5Test des-cbc-crc -s
+ * @run main/othervm BasicKrb5Test des-cbc-md5 -s
+ * @run main/othervm BasicKrb5Test des3-cbc-sha1 -s
+ * @run main/othervm BasicKrb5Test aes128-cts -s
+ * @run main/othervm BasicKrb5Test aes256-cts -s
+ * @run main/othervm BasicKrb5Test rc4-hmac -s
+ * @run main/othervm BasicKrb5Test -C
+ * @run main/othervm BasicKrb5Test des-cbc-crc -C
+ * @run main/othervm BasicKrb5Test des-cbc-md5 -C
+ * @run main/othervm BasicKrb5Test des3-cbc-sha1 -C
+ * @run main/othervm BasicKrb5Test aes128-cts -C
+ * @run main/othervm BasicKrb5Test aes256-cts -C
+ * @run main/othervm BasicKrb5Test rc4-hmac -C
+ * @run main/othervm BasicKrb5Test -s -C
+ * @run main/othervm BasicKrb5Test des-cbc-crc -s -C
+ * @run main/othervm BasicKrb5Test des-cbc-md5 -s -C
+ * @run main/othervm BasicKrb5Test des3-cbc-sha1 -s -C
+ * @run main/othervm BasicKrb5Test aes128-cts -s -C
+ * @run main/othervm BasicKrb5Test aes256-cts -s -C
+ * @run main/othervm BasicKrb5Test rc4-hmac -s -C
  */
 
 import org.ietf.jgss.GSSName;
@@ -39,6 +67,7 @@
  */
 public class BasicKrb5Test {
 
+    private static boolean conf = true;
     /**
      * @param args empty or etype
      */
@@ -46,8 +75,10 @@
             throws Exception {
 
         String etype = null;
-        if (args.length > 0) {
-            etype = args[0];
+        for (String arg: args) {
+            if (arg.equals("-s")) Context.usingStream = true;
+            else if(arg.equals("-C")) conf = false;
+            else etype = arg;
         }
 
         // Creates and starts the KDC. This line must be put ahead of etype check
@@ -56,8 +87,9 @@
 
         System.out.println("Testing etype " + etype);
         if (etype != null && !EType.isSupported(Config.getInstance().getType(etype))) {
+            // aes256 is not enabled on all systems
             System.out.println("Not supported.");
-            System.exit(0);
+            return;
         }
 
         new BasicKrb5Test().go(OneKDC.SERVER, OneKDC.BACKEND);
@@ -71,6 +103,7 @@
 
         c.startAsClient(server, GSSUtil.GSS_KRB5_MECH_OID);
         c.x().requestCredDeleg(true);
+        c.x().requestConf(conf);
         s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
 
         c.status();
@@ -90,6 +123,7 @@
         s = null;
 
         s2.startAsClient(backend, GSSUtil.GSS_KRB5_MECH_OID);
+        s2.x().requestConf(conf);
         b.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
 
         s2.status();
--- a/jdk/test/sun/security/krb5/auto/Context.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/sun/security/krb5/auto/Context.java	Wed Jan 19 21:51:10 2011 -0800
@@ -42,7 +42,8 @@
 import com.sun.security.jgss.ExtendedGSSContext;
 import com.sun.security.jgss.InquireType;
 import com.sun.security.jgss.AuthorizationDataEntry;
-import java.io.File;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 
 /**
  * Context of a JGSS subject, encapsulating Subject and GSSContext.
@@ -78,6 +79,8 @@
     private String name;
     private GSSCredential cred;     // see static method delegated().
 
+    static boolean usingStream = false;
+
     private Context() {}
 
     /**
@@ -365,7 +368,14 @@
             public byte[] run(Context me, byte[] dummy) throws Exception {
                 System.out.println("wrap");
                 MessageProp p1 = new MessageProp(0, true);
-                byte[] out = me.x.wrap(messageBytes, 0, messageBytes.length, p1);
+                byte[] out;
+                if (usingStream) {
+                    ByteArrayOutputStream os = new ByteArrayOutputStream();
+                    me.x.wrap(new ByteArrayInputStream(messageBytes), os, p1);
+                    out = os.toByteArray();
+                } else {
+                    out = me.x.wrap(messageBytes, 0, messageBytes.length, p1);
+                }
                 System.out.println(printProp(p1));
                 return out;
             }
@@ -375,27 +385,46 @@
             @Override
             public byte[] run(Context me, byte[] input) throws Exception {
                 MessageProp p1 = new MessageProp(0, true);
-                byte[] bytes = me.x.unwrap(input, 0, input.length, p1);
+                byte[] bytes;
+                if (usingStream) {
+                    ByteArrayOutputStream os = new ByteArrayOutputStream();
+                    me.x.unwrap(new ByteArrayInputStream(input), os, p1);
+                    bytes = os.toByteArray();
+                } else {
+                    bytes = me.x.unwrap(input, 0, input.length, p1);
+                }
                 if (!Arrays.equals(messageBytes, bytes))
                     throw new Exception("wrap/unwrap mismatch");
                 System.out.println("unwrap");
                 System.out.println(printProp(p1));
                 p1 = new MessageProp(0, true);
                 System.out.println("getMIC");
-                bytes = me.x.getMIC(bytes, 0, bytes.length, p1);
+                if (usingStream) {
+                    ByteArrayOutputStream os = new ByteArrayOutputStream();
+                    me.x.getMIC(new ByteArrayInputStream(messageBytes), os, p1);
+                    bytes = os.toByteArray();
+                } else {
+                    bytes = me.x.getMIC(messageBytes, 0, messageBytes.length, p1);
+                }
                 System.out.println(printProp(p1));
                 return bytes;
             }
         }, t);
+
         // Re-unwrap should make p2.isDuplicateToken() returns true
         s1.doAs(new Action() {
             @Override
             public byte[] run(Context me, byte[] input) throws Exception {
                 MessageProp p1 = new MessageProp(0, true);
                 System.out.println("verifyMIC");
-                me.x.verifyMIC(input, 0, input.length,
-                        messageBytes, 0, messageBytes.length,
-                        p1);
+                if (usingStream) {
+                    me.x.verifyMIC(new ByteArrayInputStream(input),
+                            new ByteArrayInputStream(messageBytes), p1);
+                } else {
+                    me.x.verifyMIC(input, 0, input.length,
+                            messageBytes, 0, messageBytes.length,
+                            p1);
+                }
                 System.out.println(printProp(p1));
                 return null;
             }
@@ -416,7 +445,9 @@
         sb.append(prop.isGapToken()?"gap, ":"");
         sb.append(prop.isOldToken()?"old, ":"");
         sb.append(prop.isUnseqToken()?"unseq, ":"");
-        sb.append(prop.getMinorString()+ "(" + prop.getMinorStatus()+")");
+        if (prop.getMinorStatus() != 0) {
+            sb.append(prop.getMinorString()+ "(" + prop.getMinorStatus()+")");
+        }
         return sb.toString();
     }
 
@@ -442,7 +473,13 @@
                         return null;
                     } else {
                         System.out.println(c.name + " call initSecContext");
-                        return me.x.initSecContext(input, 0, input.length);
+                        if (usingStream) {
+                            ByteArrayOutputStream os = new ByteArrayOutputStream();
+                            me.x.initSecContext(new ByteArrayInputStream(input), os);
+                            return os.size() == 0 ? null : os.toByteArray();
+                        } else {
+                            return me.x.initSecContext(input, 0, input.length);
+                        }
                     }
                 }
             }, t);
@@ -460,7 +497,13 @@
                         return null;
                     } else {
                         System.out.println(s.name + " called acceptSecContext");
-                        return me.x.acceptSecContext(input, 0, input.length);
+                        if (usingStream) {
+                            ByteArrayOutputStream os = new ByteArrayOutputStream();
+                            me.x.acceptSecContext(new ByteArrayInputStream(input), os);
+                            return os.size() == 0 ? null : os.toByteArray();
+                        } else {
+                            return me.x.acceptSecContext(input, 0, input.length);
+                        }
                     }
                 }
             }, t);
--- a/jdk/test/sun/security/krb5/auto/basic.sh	Wed Jan 19 17:01:50 2011 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-#
-# Copyright (c) 2008, 2009, 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 6706974
-# @summary Add krb5 test infrastructure
-# @run shell/timeout=300 basic.sh
-#
-
-if [ "${TESTSRC}" = "" ] ; then
-  TESTSRC="."
-fi
-if [ "${TESTJAVA}" = "" ] ; then
-  echo "TESTJAVA not set.  Test cannot execute."
-  echo "FAILED!!!"
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    SEP=";"
-    ;;
-  CYGWIN* )
-    FS="/"
-    SEP=";"
-    ;;
-  * )
-    FS="/"
-    SEP=":"
-    ;;
-esac
-
-${TESTJAVA}${FS}bin${FS}javac -XDignore.symbol.file -d . \
-    ${TESTSRC}${FS}BasicKrb5Test.java \
-    ${TESTSRC}${FS}KDC.java \
-    ${TESTSRC}${FS}OneKDC.java \
-    ${TESTSRC}${FS}Action.java \
-    ${TESTSRC}${FS}Context.java \
-    || exit 10
-
-# Add $TESTSRC to classpath so that customized nameservice can be used
-J="${TESTJAVA}${FS}bin${FS}java -cp $TESTSRC${SEP}. BasicKrb5Test"
-
-$J || exit 100
-$J des-cbc-crc || exit 1
-$J des-cbc-md5 || exit 3
-$J des3-cbc-sha1 || exit 16
-$J aes128-cts || exit 17
-$J aes256-cts || exit 18
-$J rc4-hmac || exit 23
-
-exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/Provider/ConfigShortPath.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/**
+ * @test
+ * @bug 6581254
+ * @summary Allow "~" in config to support windows short path
+ * @author Valerie Peng
+ */
+
+import java.security.*;
+import java.io.*;
+
+public class ConfigShortPath {
+
+    public static void main(String[] args) {
+        String testSrc = System.getProperty("test.src", ".");
+        String configFile = testSrc + File.separator + "csp.cfg";
+        System.out.println("Testing against " + configFile);
+        try {
+            Provider p = new sun.security.pkcs11.SunPKCS11(configFile);
+        } catch (ProviderException pe) {
+            String cause = pe.getCause().getMessage();
+            if (cause.indexOf("Unexpected token") != -1) {
+                // re-throw to indicate test failure
+                throw pe;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs11/Provider/csp.cfg	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,4 @@
+showInfo = false 
+name = NSSTrust 
+nssSecmodDirectory = C:/DOCUME~1/dtftest/LOCALS~1/Temp/Work/exec/jsn_7.0_int-7.0_nightly_sec_win_32_part2-2007-07-16-09-06-04-0209/dtftest.Windows_2003.x86/NSS//db
+nssLibraryDirectory = Y:/xml/CC_DTF/knight_ws/suites/jsn_7.0_int/security/tools/lib/nss/WINNT/ 
--- a/jdk/test/sun/tools/jstat/gcNewCapacityOutput1.awk	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/sun/tools/jstat/gcNewCapacityOutput1.awk	Wed Jan 19 21:51:10 2011 -0800
@@ -4,7 +4,7 @@
 # specific values.
 #
 #  NGCMN      NGCMX       NGC      S0CMX     S0C     S1CMX     S1C       ECMX        EC      YGC   FGC 
-#    2176.0     7232.0     2176.0     64.0    192.0    192.0     64.0     6848.0     2048.0     1     0
+#    2176.0     7232.0     2176.0    192.0     64.0    192.0     64.0     6848.0     2048.0     1     0
 
 
 BEGIN	{
--- a/jdk/test/tools/launcher/Settings.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/jdk/test/tools/launcher/Settings.java	Wed Jan 19 21:51:10 2011 -0800
@@ -74,8 +74,15 @@
 
     static void runTestOptionDefault() throws IOException {
         TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-Xmx512m", "-Xss128k",
-                "-XshowSettings", "-jar", testJar.getAbsolutePath());
+        tr = TestHelper.doExec(TestHelper.javaCmd, "-Xms64m", "-Xmx512m",
+                "-Xss128k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
+        containsAllOptions(tr);
+        if (!tr.isOK()) {
+            System.out.println(tr.status);
+            throw new RuntimeException("test fails");
+        }
+        tr = TestHelper.doExec(TestHelper.javaCmd, "-Xms65536k", "-Xmx712m",
+                "-Xss122880", "-XshowSettings", "-jar", testJar.getAbsolutePath());
         containsAllOptions(tr);
         if (!tr.isOK()) {
             System.out.println(tr.status);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/pack200/T7007157.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Map;
+import java.util.jar.JarFile;
+import java.util.jar.Pack200;
+/*
+ * @test
+ * @bug 7007157
+ * @summary make sure the strip command works on an attribute
+ * @compile -XDignore.symbol.file Utils.java T7007157.java
+ * @run main T7007157
+ * @author ksrini
+ */
+public class T7007157 {
+
+    public static void main(String... args) throws IOException {
+        File sdkHome = Utils.JavaSDK;
+        File testJar = new File(new File(sdkHome, "lib"), "tools.jar");
+        JarFile jarFile = new JarFile(testJar);
+        File packFile = new File("foo.pack");
+        Pack200.Packer packer = Pack200.newPacker();
+        Map<String, String> p = packer.properties();
+        // Take the time optimization vs. space
+        p.put(packer.EFFORT, "1");  // CAUTION: do not use 0.
+        // Make the memory consumption as effective as possible
+        p.put(packer.SEGMENT_LIMIT, "10000");
+        // ignore all JAR deflation requests to save time
+        p.put(packer.DEFLATE_HINT, packer.FALSE);
+        // save the file ordering of the original JAR
+        p.put(packer.KEEP_FILE_ORDER, packer.TRUE);
+        // strip the StackMapTables
+        p.put(packer.CODE_ATTRIBUTE_PFX + "StackMapTable", packer.STRIP);
+        FileOutputStream fos = null;
+        try {
+            // Write out to a jtreg scratch area
+            fos = new FileOutputStream(packFile);
+            // Call the packer
+            packer.pack(jarFile, fos);
+        } finally {
+            Utils.close(fos);
+            Utils.close(jarFile);
+        }
+    }
+}
--- a/langtools/.hgtags	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/.hgtags	Wed Jan 19 21:51:10 2011 -0800
@@ -98,3 +98,5 @@
 1bf969e9792f977a8593496681539840a54fe644 jdk7-b121
 11e7b4c0476e4d6085d8d28c4aa2833d46714a2a jdk7-b122
 a3b5b531542a372f30e014b1543a619a15a90780 jdk7-b123
+4868a36f6fd8972505c466013813eeb28f0482ea jdk7-b124
+4b0560c72b529d4b952924b2da94d8436af79d05 jdk7-b125
--- a/langtools/make/Makefile	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/make/Makefile	Wed Jan 19 21:51:10 2011 -0800
@@ -187,7 +187,7 @@
 clobber: clean
 
 # All ant targets of interest
-ANT_TARGETS = build clean sanity post-sanity diagnostics # for now
+ANT_TARGETS = build clean sanity post-sanity diagnostics build-all-tools  # for now
 
 # Create diagnostics log (careful, ant 1.8.0 -diagnostics always does an exit 1)
 $(OUTPUTDIR)/build/ant-diagnostics.log:
--- a/langtools/src/share/bin/launcher.sh-template	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/src/share/bin/launcher.sh-template	Wed Jan 19 21:51:10 2011 -0800
@@ -26,6 +26,12 @@
 #
 
 mydir="`dirname $0`"
+case `uname -s` in
+    CYGWIN*)
+      mydir=`cygpath -m $mydir`
+      ;;
+esac
+
 mylib="`dirname $mydir`"/lib
 
 # By default, put the jar file and its dependencies on the bootclasspath.
--- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Wed Jan 19 21:51:10 2011 -0800
@@ -266,82 +266,116 @@
         System.out.println(message);
     }
 
+
     /**
-     * Insert all files in subdirectory `subdirectory' of `directory' which end
-     * in one of the extensions in `extensions' into packageSym.
+     * Insert all files in subdirectory subdirectory of directory directory
+     * which match fileKinds into resultList
      */
     private void listDirectory(File directory,
                                RelativeDirectory subdirectory,
                                Set<JavaFileObject.Kind> fileKinds,
                                boolean recurse,
-                               ListBuffer<JavaFileObject> l) {
-        Archive archive = archives.get(directory);
+                               ListBuffer<JavaFileObject> resultList) {
+        File d = subdirectory.getFile(directory);
+        if (!caseMapCheck(d, subdirectory))
+            return;
 
-        boolean isFile = fsInfo.isFile(directory);
+        File[] files = d.listFiles();
+        if (files == null)
+            return;
 
-        if (archive != null || isFile) {
-            if (archive == null) {
-                try {
-                    archive = openArchive(directory);
-                } catch (IOException ex) {
-                    log.error("error.reading.file",
-                       directory, getMessage(ex));
-                    return;
-                }
-            }
+        if (sortFiles != null)
+            Arrays.sort(files, sortFiles);
 
-            List<String> files = archive.getFiles(subdirectory);
-            if (files != null) {
-                for (String file; !files.isEmpty(); files = files.tail) {
-                    file = files.head;
-                    if (isValidFile(file, fileKinds)) {
-                        l.append(archive.getFileObject(subdirectory, file));
-                    }
+        for (File f: files) {
+            String fname = f.getName();
+            if (f.isDirectory()) {
+                if (recurse && SourceVersion.isIdentifier(fname)) {
+                    listDirectory(directory,
+                                  new RelativeDirectory(subdirectory, fname),
+                                  fileKinds,
+                                  recurse,
+                                  resultList);
                 }
-            }
-            if (recurse) {
-                for (RelativeDirectory s: archive.getSubdirectories()) {
-                    if (subdirectory.contains(s)) {
-                        // Because the archive map is a flat list of directories,
-                        // the enclosing loop will pick up all child subdirectories.
-                        // Therefore, there is no need to recurse deeper.
-                        listDirectory(directory, s, fileKinds, false, l);
-                    }
-                }
-            }
-        } else {
-            File d = subdirectory.getFile(directory);
-            if (!caseMapCheck(d, subdirectory))
-                return;
-
-            File[] files = d.listFiles();
-            if (files == null)
-                return;
-
-            if (sortFiles != null)
-                Arrays.sort(files, sortFiles);
-
-            for (File f: files) {
-                String fname = f.getName();
-                if (f.isDirectory()) {
-                    if (recurse && SourceVersion.isIdentifier(fname)) {
-                        listDirectory(directory,
-                                      new RelativeDirectory(subdirectory, fname),
-                                      fileKinds,
-                                      recurse,
-                                      l);
-                    }
-                } else {
-                    if (isValidFile(fname, fileKinds)) {
-                        JavaFileObject fe =
-                            new RegularFileObject(this, fname, new File(d, fname));
-                        l.append(fe);
-                    }
+            } else {
+                if (isValidFile(fname, fileKinds)) {
+                    JavaFileObject fe =
+                        new RegularFileObject(this, fname, new File(d, fname));
+                    resultList.append(fe);
                 }
             }
         }
     }
 
+    /**
+     * Insert all files in subdirectory subdirectory of archive archive
+     * which match fileKinds into resultList
+     */
+    private void listArchive(Archive archive,
+                               RelativeDirectory subdirectory,
+                               Set<JavaFileObject.Kind> fileKinds,
+                               boolean recurse,
+                               ListBuffer<JavaFileObject> resultList) {
+        // Get the files directly in the subdir
+        List<String> files = archive.getFiles(subdirectory);
+        if (files != null) {
+            for (; !files.isEmpty(); files = files.tail) {
+                String file = files.head;
+                if (isValidFile(file, fileKinds)) {
+                    resultList.append(archive.getFileObject(subdirectory, file));
+                }
+            }
+        }
+        if (recurse) {
+            for (RelativeDirectory s: archive.getSubdirectories()) {
+                if (subdirectory.contains(s)) {
+                    // Because the archive map is a flat list of directories,
+                    // the enclosing loop will pick up all child subdirectories.
+                    // Therefore, there is no need to recurse deeper.
+                    listArchive(archive, s, fileKinds, false, resultList);
+                }
+            }
+        }
+    }
+
+    /**
+     * container is a directory, a zip file, or a non-existant path.
+     * Insert all files in subdirectory subdirectory of container which
+     * match fileKinds into resultList
+     */
+    private void listContainer(File container,
+                               RelativeDirectory subdirectory,
+                               Set<JavaFileObject.Kind> fileKinds,
+                               boolean recurse,
+                               ListBuffer<JavaFileObject> resultList) {
+        Archive archive = archives.get(container);
+        if (archive == null) {
+            // archives are not created for directories.
+            if  (fsInfo.isDirectory(container)) {
+                listDirectory(container,
+                              subdirectory,
+                              fileKinds,
+                              recurse,
+                              resultList);
+                return;
+            }
+
+            // Not a directory; either a file or non-existant, create the archive
+            try {
+                archive = openArchive(container);
+            } catch (IOException ex) {
+                log.error("error.reading.file",
+                          container, getMessage(ex));
+                return;
+            }
+        }
+        listArchive(archive,
+                    subdirectory,
+                    fileKinds,
+                    recurse,
+                    resultList);
+    }
+
     private boolean isValidFile(String s, Set<JavaFileObject.Kind> fileKinds) {
         JavaFileObject.Kind kind = getKind(s);
         return fileKinds.contains(kind);
@@ -434,95 +468,92 @@
     private static final RelativeDirectory symbolFilePrefix
             = new RelativeDirectory("META-INF/sym/rt.jar/");
 
-    /** Open a new zip file directory.
+    /** Open a new zip file directory, and cache it.
      */
     protected Archive openArchive(File zipFileName) throws IOException {
-        Archive archive = archives.get(zipFileName);
-        if (archive == null) {
-            File origZipFileName = zipFileName;
-            if (!ignoreSymbolFile && paths.isBootClassPathRtJar(zipFileName)) {
-                File file = zipFileName.getParentFile().getParentFile(); // ${java.home}
-                if (new File(file.getName()).equals(new File("jre")))
-                    file = file.getParentFile();
-                // file == ${jdk.home}
-                for (String name : symbolFileLocation)
-                    file = new File(file, name);
-                // file == ${jdk.home}/lib/ct.sym
-                if (file.exists())
-                    zipFileName = file;
-            }
+        File origZipFileName = zipFileName;
+        if (!ignoreSymbolFile && paths.isBootClassPathRtJar(zipFileName)) {
+            File file = zipFileName.getParentFile().getParentFile(); // ${java.home}
+            if (new File(file.getName()).equals(new File("jre")))
+                file = file.getParentFile();
+            // file == ${jdk.home}
+            for (String name : symbolFileLocation)
+                file = new File(file, name);
+            // file == ${jdk.home}/lib/ct.sym
+            if (file.exists())
+                zipFileName = file;
+        }
 
-            try {
+        Archive archive;
+        try {
 
-                ZipFile zdir = null;
+            ZipFile zdir = null;
 
-                boolean usePreindexedCache = false;
-                String preindexCacheLocation = null;
+            boolean usePreindexedCache = false;
+            String preindexCacheLocation = null;
 
-                if (!useZipFileIndex) {
-                    zdir = new ZipFile(zipFileName);
-                }
-                else {
-                    usePreindexedCache = options.isSet("usezipindex");
-                    preindexCacheLocation = options.get("java.io.tmpdir");
-                    String optCacheLoc = options.get("cachezipindexdir");
+            if (!useZipFileIndex) {
+                zdir = new ZipFile(zipFileName);
+            }
+            else {
+                usePreindexedCache = options.isSet("usezipindex");
+                preindexCacheLocation = options.get("java.io.tmpdir");
+                String optCacheLoc = options.get("cachezipindexdir");
 
-                    if (optCacheLoc != null && optCacheLoc.length() != 0) {
-                        if (optCacheLoc.startsWith("\"")) {
-                            if (optCacheLoc.endsWith("\"")) {
-                                optCacheLoc = optCacheLoc.substring(1, optCacheLoc.length() - 1);
-                            }
-                           else {
-                                optCacheLoc = optCacheLoc.substring(1);
-                            }
+                if (optCacheLoc != null && optCacheLoc.length() != 0) {
+                    if (optCacheLoc.startsWith("\"")) {
+                        if (optCacheLoc.endsWith("\"")) {
+                            optCacheLoc = optCacheLoc.substring(1, optCacheLoc.length() - 1);
+                        }
+                        else {
+                            optCacheLoc = optCacheLoc.substring(1);
                         }
+                    }
 
-                        File cacheDir = new File(optCacheLoc);
-                        if (cacheDir.exists() && cacheDir.canWrite()) {
-                            preindexCacheLocation = optCacheLoc;
-                            if (!preindexCacheLocation.endsWith("/") &&
-                                !preindexCacheLocation.endsWith(File.separator)) {
-                                preindexCacheLocation += File.separator;
-                            }
+                    File cacheDir = new File(optCacheLoc);
+                    if (cacheDir.exists() && cacheDir.canWrite()) {
+                        preindexCacheLocation = optCacheLoc;
+                        if (!preindexCacheLocation.endsWith("/") &&
+                            !preindexCacheLocation.endsWith(File.separator)) {
+                            preindexCacheLocation += File.separator;
                         }
                     }
                 }
+            }
 
-                if (origZipFileName == zipFileName) {
-                    if (!useZipFileIndex) {
-                        archive = new ZipArchive(this, zdir);
-                    } else {
-                        archive = new ZipFileIndexArchive(this,
+            if (origZipFileName == zipFileName) {
+                if (!useZipFileIndex) {
+                    archive = new ZipArchive(this, zdir);
+                } else {
+                    archive = new ZipFileIndexArchive(this,
                                 ZipFileIndex.getZipFileIndex(zipFileName,
                                     null,
                                     usePreindexedCache,
                                     preindexCacheLocation,
                                     options.isSet("writezipindexfiles")));
-                    }
+                }
+            } else {
+                if (!useZipFileIndex) {
+                    archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix);
                 }
                 else {
-                    if (!useZipFileIndex) {
-                        archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix);
-                    }
-                    else {
-                        archive = new ZipFileIndexArchive(this,
+                    archive = new ZipFileIndexArchive(this,
                                 ZipFileIndex.getZipFileIndex(zipFileName,
                                     symbolFilePrefix,
                                     usePreindexedCache,
                                     preindexCacheLocation,
                                     options.isSet("writezipindexfiles")));
-                    }
                 }
-            } catch (FileNotFoundException ex) {
-                archive = new MissingArchive(zipFileName);
-            } catch (IOException ex) {
-                if (zipFileName.exists())
-                    log.error("error.reading.file", zipFileName, getMessage(ex));
-                archive = new MissingArchive(zipFileName);
             }
+        } catch (FileNotFoundException ex) {
+            archive = new MissingArchive(zipFileName);
+        } catch (IOException ex) {
+            if (zipFileName.exists())
+                log.error("error.reading.file", zipFileName, getMessage(ex));
+            archive = new MissingArchive(zipFileName);
+        }
 
-            archives.put(origZipFileName, archive);
-        }
+        archives.put(origZipFileName, archive);
         return archive;
     }
 
@@ -589,8 +620,7 @@
         ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>();
 
         for (File directory : path)
-            listDirectory(directory, subdirectory, kinds, recurse, results);
-
+            listContainer(directory, subdirectory, kinds, recurse, results);
         return results.toList();
     }
 
@@ -659,19 +689,22 @@
             return null;
 
         for (File dir: path) {
-            if (dir.isDirectory()) {
-                File f = name.getFile(dir);
-                if (f.exists())
-                    return new RegularFileObject(this, f);
-            } else {
-                Archive a = openArchive(dir);
-                if (a.contains(name)) {
-                    return a.getFileObject(name.dirname(), name.basename());
+            Archive a = archives.get(dir);
+            if (a == null) {
+                if (fsInfo.isDirectory(dir)) {
+                    File f = name.getFile(dir);
+                    if (f.exists())
+                        return new RegularFileObject(this, f);
+                    continue;
                 }
-
+                // Not a directory, create the archive
+                a = openArchive(dir);
+            }
+            // Process the archive
+            if (a.contains(name)) {
+                return a.getFileObject(name.dirname(), name.basename());
             }
         }
-
         return null;
     }
 
@@ -836,8 +869,9 @@
             return false;
         if (!path.equals(uri.getPath())) // implicitly checks for embedded . and ..
             return false;
-        char first = path.charAt(0);
-        return first != '.' && first != '/';
+        if (path.startsWith("/") || path.startsWith("./") || path.startsWith("../"))
+            return false;
+        return true;
     }
 
     // Convenience method
--- a/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java	Wed Jan 19 21:51:10 2011 -0800
@@ -286,9 +286,8 @@
         }
 
         public void addFile(File file, boolean warn) {
-            File canonFile = fsInfo.getCanonicalFile(file);
-            if (contains(file) || canonicalValues.contains(canonFile)) {
-                /* Discard duplicates and avoid infinite recursion */
+            if (contains(file)) {
+                // discard duplicates
                 return;
             }
 
@@ -298,7 +297,17 @@
                     log.warning(Lint.LintCategory.PATH,
                             "path.element.not.found", file);
                 }
-            } else if (fsInfo.isFile(file)) {
+                super.add(file);
+                return;
+            }
+
+            File canonFile = fsInfo.getCanonicalFile(file);
+            if (canonicalValues.contains(canonFile)) {
+                /* Discard duplicates and avoid infinite recursion */
+                return;
+            }
+
+            if (fsInfo.isFile(file)) {
                 /* File is an ordinary file. */
                 if (!isArchive(file)) {
                     /* Not a recognized extension; open it to see if
@@ -322,11 +331,11 @@
             }
 
             /* Now what we have left is either a directory or a file name
-               confirming to archive naming convention */
+               conforming to archive naming convention */
             super.add(file);
             canonicalValues.add(canonFile);
 
-            if (expandJarClassPaths && fsInfo.exists(file) && fsInfo.isFile(file))
+            if (expandJarClassPaths && fsInfo.isFile(file))
                 addJarClassPath(file, warn);
         }
 
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Jan 19 21:51:10 2011 -0800
@@ -77,6 +77,8 @@
     protected static final Context.Key<ClassReader> classReaderKey =
         new Context.Key<ClassReader>();
 
+    public static final int INITIAL_BUFFER_SIZE = 0x0fff0;
+
     Annotate annotate;
 
     /** Switch: verbose output.
@@ -185,7 +187,7 @@
 
     /** The buffer containing the currently read class file.
      */
-    byte[] buf = new byte[0x0fff0];
+    byte[] buf = new byte[INITIAL_BUFFER_SIZE];
 
     /** The current input pointer.
      */
@@ -2419,8 +2421,14 @@
                 }
             }
         }
+        /*
+         * ensureCapacity will increase the buffer as needed, taking note that
+         * the new buffer will always be greater than the needed and never
+         * exactly equal to the needed size or bp. If equal then the read (above)
+         * will infinitely loop as buf.length - bp == 0.
+         */
         private static byte[] ensureCapacity(byte[] buf, int needed) {
-            if (buf.length < needed) {
+            if (buf.length <= needed) {
                 byte[] old = buf;
                 buf = new byte[Integer.highestOneBit(needed) << 1];
                 System.arraycopy(old, 0, buf, 0, old.length);
--- a/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java	Wed Jan 19 21:51:10 2011 -0800
@@ -376,7 +376,8 @@
                 new SimpleFileVisitor<Path>() {
             @Override
             public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
-                if (SourceVersion.isIdentifier(dir.getName().toString())) // JSR 292?
+                Path name = dir.getName();
+                if (name == null || SourceVersion.isIdentifier(name.toString())) // JSR 292?
                     return FileVisitResult.CONTINUE;
                 else
                     return FileVisitResult.SKIP_SUBTREE;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6567415/T6567415.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6567415
+ * @summary Test to ensure javac does not go into an infinite loop, while
+ *               reading a classfile of a specific length.
+ * @compile -XDignore.symbol.file T6567415.java
+ * @run main T6567415
+ * @author ksrini
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+
+/*
+ * this test compiles Bar.java into a classfile and enlarges the file to the
+ * magic file length, then use this mutated file on the classpath to compile
+ * Foo.java which references Bar.java and Ka-boom. QED.
+ */
+public class T6567415 {
+    final static String TEST_FILE_NAME = "Bar";
+    final static String TEST_JAVA = TEST_FILE_NAME + ".java";
+    final static String TEST_CLASS = TEST_FILE_NAME + ".class";
+
+    final static String TEST2_FILE_NAME = "Foo";
+    final static String TEST2_JAVA = TEST2_FILE_NAME + ".java";
+
+    /*
+     * the following is the initial buffer length set in ClassReader.java
+     * thus this value needs to change if ClassReader buf length changes.
+     */
+
+    final static int BAD_FILE_LENGTH =
+            com.sun.tools.javac.jvm.ClassReader.INITIAL_BUFFER_SIZE;
+
+    static void createClassFile() throws IOException {
+        FileOutputStream fos = null;
+        try {
+            fos = new FileOutputStream(TEST_JAVA);
+            PrintStream ps = new PrintStream(fos);
+            ps.println("public class " + TEST_FILE_NAME + " {}");
+        } finally {
+            fos.close();
+        }
+        String cmds[] = {TEST_JAVA};
+        com.sun.tools.javac.Main.compile(cmds);
+    }
+
+    static void enlargeClassFile() throws IOException {
+        File f = new File(TEST_CLASS);
+        if (!f.exists()) {
+            System.out.println("file not found: " + TEST_CLASS);
+            System.exit(1);
+        }
+        File tfile = new File(f.getAbsolutePath() + ".tmp");
+        f.renameTo(tfile);
+
+        RandomAccessFile raf = null;
+        FileChannel wfc = null;
+
+        FileInputStream fis = null;
+        FileChannel rfc = null;
+
+        try {
+            raf =  new RandomAccessFile(f, "rw");
+            wfc = raf.getChannel();
+
+            fis = new FileInputStream(tfile);
+            rfc = fis.getChannel();
+
+            ByteBuffer bb = MappedByteBuffer.allocate(BAD_FILE_LENGTH);
+            rfc.read(bb);
+            bb.rewind();
+            wfc.write(bb);
+            wfc.truncate(BAD_FILE_LENGTH);
+        } finally {
+            wfc.close();
+            raf.close();
+            rfc.close();
+            fis.close();
+        }
+        System.out.println("file length = " + f.length());
+    }
+
+    static void createJavaFile() throws IOException {
+        FileOutputStream fos = null;
+        try {
+            fos = new FileOutputStream(TEST2_JAVA);
+            PrintStream ps = new PrintStream(fos);
+            ps.println("public class " + TEST2_FILE_NAME +
+                    " {" + TEST_FILE_NAME + " b = new " +
+                    TEST_FILE_NAME  + " ();}");
+        } finally {
+            fos.close();
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        createClassFile();
+        enlargeClassFile();
+        createJavaFile();
+        Thread t = new Thread () {
+            @Override
+            public void run() {
+                String cmds[] = {"-verbose", "-cp", ".", TEST2_JAVA};
+                int ret = com.sun.tools.javac.Main.compile(cmds);
+                System.out.println("test compilation returns: " + ret);
+            }
+        };
+        t.start();
+        t.join(1000*10);
+        System.out.println(t.getState());
+        if (t.isAlive()) {
+            throw new RuntimeException("Error: compilation is looping");
+        }
+    }
+}
--- a/langtools/test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java	Wed Jan 19 21:51:10 2011 -0800
@@ -24,8 +24,10 @@
 // key: compiler.warn.type.parameter.on.polymorphic.signature
 // key: compiler.err.unreported.exception.need.to.catch.or.throw
 
-import java.dyn.InvokeDynamic;
+import java.dyn.MethodHandle;
 
 class TypeParameterOnPolymorphicSignature {
-    { InvokeDynamic.<void>call("",123); }
+    void test(MethodHandle mh) {
+        mh.<void>invokeExact("",123);
+    }
 }
--- a/langtools/test/tools/javac/failover/CheckAttributedTree.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java	Wed Jan 19 21:51:10 2011 -0800
@@ -252,6 +252,13 @@
             error("File " + file + " ignored");
     }
 
+    // See CR:  6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout
+    StringWriter sw = new StringWriter();
+    PrintWriter pw = new PrintWriter(sw);
+    Reporter r = new Reporter(pw);
+    JavacTool tool = JavacTool.create();
+    StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
+
     /**
      * Read a file.
      * @param file the file to be read
@@ -260,12 +267,8 @@
      * @throws TreePosTest.ParseException if any errors occur while parsing the file
      */
     List<Pair<JCCompilationUnit, JCTree>> read(File file) throws IOException, AttributionException {
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        Reporter r = new Reporter(pw);
         JavacTool tool = JavacTool.create();
-        Charset cs = (encoding == null ? null : Charset.forName(encoding));
-        StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
+        r.errors = 0;
         Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
         String[] opts = { "-XDshouldStopPolicy=ATTR", "-XDverboseCompilePolicy" };
         JavacTask task = tool.getTask(pw, fm, r, Arrays.asList(opts), null, files);
--- a/langtools/test/tools/javac/meth/InvokeDyn.java	Wed Jan 19 17:01:50 2011 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6754038 6979327
- * @summary Generate call sites for method handle
- * @author jrose
- *
- * @library ..
- * @compile -source 7 -target 7 -XDinvokedynamic -XDallowTransitionalJSR292=no InvokeDyn.java
- */
-//No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn
-
-/*
- * Standalone testing:
- * <code>
- * $ cd $MY_REPO_DIR/langtools
- * $ (cd make; make)
- * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeDyn.java
- * $ javap -c -classpath dist meth.InvokeDyn
- * </code>
- */
-
-package meth;
-
-import java.dyn.*;
-
-public class InvokeDyn {
-    class CS extends CallSite {
-        CS(Object x, Object y, Object z) { throw new RuntimeException(); }
-    }
-    //@BootstrapMethod(CS.class)  //note: requires 6964498
-    void test() throws Throwable {
-        Object x = "hello";
-        Object ojunk; int ijunk;
-        ojunk = InvokeDynamic.greet(x, "world", 123);
-        ojunk = InvokeDynamic.greet(x, "mundus", 456);
-        ojunk = InvokeDynamic.greet(x, "kosmos", 789);
-        ojunk = (String) InvokeDynamic.cogitate(10.11121, 3.14);
-        //InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null);
-        ijunk = (int) InvokeDynamic.invoke("goodbye");
-    }
-}
--- a/langtools/test/tools/javac/meth/InvokeDynTrans.java	Wed Jan 19 17:01:50 2011 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6754038 6979327
- * @summary Generate call sites for method handle
- * @author jrose
- *
- * @library ..
- * @compile/fail/ref=InvokeDynTrans.out -Werror -XDrawDiagnostics -source 7 -target 7 InvokeDynTrans.java
- */
-//No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn
-
-/*
- * Standalone testing:
- * <code>
- * $ cd $MY_REPO_DIR/langtools
- * $ (cd make; make)
- * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeDyn.java
- * $ javap -c -classpath dist meth.InvokeDyn
- * </code>
- */
-
-package meth;
-
-import java.dyn.InvokeDynamic;
-
-public class InvokeDynTrans {
-    void test() throws Throwable {
-        Object x = "hello";
-        InvokeDynamic.greet(x, "world", 123);
-        InvokeDynamic.greet(x, "mundus", 456);
-        InvokeDynamic.greet(x, "kosmos", 789);
-        InvokeDynamic.<String>cogitate(10.11121, 3.14);
-        //InvokeDynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
-        InvokeDynamic.<int>invoke("goodbye");
-    }
-}
--- a/langtools/test/tools/javac/meth/XlintWarn.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/test/tools/javac/meth/XlintWarn.java	Wed Jan 19 21:51:10 2011 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6999067
+ * @bug 6999067 7010194
  * @summary cast for invokeExact call gets redundant cast to <type> warnings
  * @author mcimadamore
  *
@@ -34,9 +34,7 @@
 
 class XlintWarn {
     void test(MethodHandle mh) throws Throwable {
-        int i1 = (int)mh.invoke();
-        int i2 = (int)mh.invokeExact();
-        int i3 = (int)mh.invokeVarargs();
-        int i4 = (int)InvokeDynamic.test();
+        int i1 = (int)mh.invokeExact();
+        int i2 = (int)mh.invokeVarargs();
     }
 }
--- a/langtools/test/tools/javac/nio/compileTest/CompileTest.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/test/tools/javac/nio/compileTest/CompileTest.java	Wed Jan 19 21:51:10 2011 -0800
@@ -23,7 +23,7 @@
 
 /**
  * @test
- * @bug 6906175 6915476 6915497
+ * @bug 6906175 6915476 6915497 7006564
  * @summary Path-based JavaFileManager
  * @compile -g HelloPathWorld.java
  * @run main CompileTest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/filer/TestValidRelativeNames.java	Wed Jan 19 21:51:10 2011 -0800
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6999891
+ * @summary Test valid relative names for Filer.createResource and Filer.getResource
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
+ * @compile TestValidRelativeNames.java
+ * @compile/process -processor TestValidRelativeNames -Amode=create java.lang.Object
+ * @compile/process -processor TestValidRelativeNames -Amode=get    java.lang.Object
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.tools.Diagnostic;
+import javax.tools.StandardLocation;
+
+@SupportedOptions("mode")
+public class TestValidRelativeNames extends JavacTestingAbstractProcessor {
+    enum Kind { READER_WRITER, INPUT_OUTPUT_STREAM };
+
+    static final String[] validRelativeNames = {
+            "foo", "foo.bar", ".foo", ".foo.bar", "foodir/bar", "foodir/.bar"
+    };
+
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        if (roundEnv.processingOver()) {
+            String mode = options.get("mode");
+            for (String relativeBase: validRelativeNames) {
+                for (Kind kind: Kind.values()) {
+                    if (mode.equals("create"))
+                        testCreate(relativeBase, kind);
+                    else
+                        testGet(relativeBase, kind);
+                }
+            }
+        }
+
+        return true;
+    }
+
+    void testCreate(String relativeBase, Kind kind) {
+        String relative = getRelative(relativeBase, kind);
+        System.out.println("test create relative path: " + relative + ", kind: " + kind);
+        try {
+            switch (kind) {
+                case READER_WRITER:
+                    try (Writer writer = filer.createResource(
+                            StandardLocation.CLASS_OUTPUT, "", relative).openWriter()) {
+                        writer.write(relative);
+                    }
+                    break;
+
+                case INPUT_OUTPUT_STREAM:
+                    try (OutputStream out = filer.createResource(
+                            StandardLocation.CLASS_OUTPUT, "", relative).openOutputStream()) {
+                        out.write(relative.getBytes());
+                    }
+                    break;
+            }
+        } catch (Exception e) {
+            messager.printMessage(Diagnostic.Kind.ERROR,
+                    "relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e);
+        }
+    }
+
+    void testGet(String relativeBase, Kind kind) {
+        String relative = getRelative(relativeBase, kind);
+        System.out.println("test get relative path: " + relative + ", kind: " + kind);
+        try {
+            switch (kind) {
+                case READER_WRITER:
+                    try (Reader reader = new BufferedReader(filer.getResource(
+                            StandardLocation.CLASS_OUTPUT, "", relative).openReader(true))) {
+                        StringBuilder sb = new StringBuilder();
+                        char[] buf = new char[1024];
+                        int n;
+                        while ((n = reader.read(buf, 0, buf.length)) > 0)
+                            sb.append(new String(buf, 0, n));
+                        if (!sb.toString().equals(relative)) {
+                            messager.printMessage(Diagnostic.Kind.ERROR, "unexpected content: " + sb);
+                        }
+                    }
+                    break;
+
+                case INPUT_OUTPUT_STREAM:
+                    try (InputStream in = new DataInputStream(filer.getResource(
+                            StandardLocation.CLASS_OUTPUT, "", relative).openInputStream())) {
+                        StringBuilder sb = new StringBuilder();
+                        byte[] buf = new byte[1024];
+                        int n;
+                        while ((n = in.read(buf, 0, buf.length)) > 0)
+                            sb.append(new String(buf, 0, n));
+                        if (!sb.toString().equals(relative)) {
+                            messager.printMessage(Diagnostic.Kind.ERROR, "unexpected content: " + sb);
+                        }
+                    }
+                    break;
+            }
+        } catch (Exception e) {
+            messager.printMessage(Diagnostic.Kind.ERROR,
+                    "relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e);
+        }
+    }
+
+    String getRelative(String relativeBase, Kind kind) {
+        String suffix = (kind == Kind.READER_WRITER ? "RW" : "IOS");
+        return relativeBase.replace("foo", "foo" + suffix);
+    }
+}
+
--- a/langtools/test/tools/javac/tree/AbstractTreeScannerTest.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/test/tools/javac/tree/AbstractTreeScannerTest.java	Wed Jan 19 21:51:10 2011 -0800
@@ -143,6 +143,13 @@
 
     abstract int test(JCCompilationUnit t);
 
+    // See CR:  6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout
+    StringWriter sw = new StringWriter();
+    PrintWriter pw = new PrintWriter(sw);
+    Reporter r = new Reporter(pw);
+    JavacTool tool = JavacTool.create();
+    StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
+
     /**
      * Read a file.
      * @param file the file to be read
@@ -151,11 +158,8 @@
      * @throws TreePosTest.ParseException if any errors occur while parsing the file
      */
     JCCompilationUnit read(File file) throws IOException, ParseException {
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        Reporter r = new Reporter(pw);
         JavacTool tool = JavacTool.create();
-        StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
+        r.errors = 0;
         Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
         JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files);
         Iterable<? extends CompilationUnitTree> trees = task.parse();
--- a/langtools/test/tools/javac/tree/TreePosTest.java	Wed Jan 19 17:01:50 2011 +0300
+++ b/langtools/test/tools/javac/tree/TreePosTest.java	Wed Jan 19 21:51:10 2011 -0800
@@ -249,6 +249,13 @@
             error("File " + file + " ignored");
     }
 
+    // See CR:  6982992 Tests CheckAttributedTree.java, JavacTreeScannerTest.java, and SourceTreeeScannerTest.java timeout
+    StringWriter sw = new StringWriter();
+    PrintWriter pw = new PrintWriter(sw);
+    Reporter r = new Reporter(pw);
+    JavacTool tool = JavacTool.create();
+    StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
+
     /**
      * Read a file.
      * @param file the file to be read
@@ -257,12 +264,8 @@
      * @throws TreePosTest.ParseException if any errors occur while parsing the file
      */
     JCCompilationUnit read(File file) throws IOException, ParseException {
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        Reporter r = new Reporter(pw);
         JavacTool tool = JavacTool.create();
-        Charset cs = (encoding == null ? null : Charset.forName(encoding));
-        StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
+        r.errors = 0;
         Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
         JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files);
         Iterable<? extends CompilationUnitTree> trees = task.parse();