Merge
authorasaha
Tue, 21 Jul 2009 13:02:23 -0700
changeset 3473 b9abeee84734
parent 3470 a48a6dab9eb6 (current diff)
parent 3314 1e9d33caef08 (diff)
child 3474 03b89988f7a3
Merge
jdk/src/share/classes/java/awt/Window.java
jdk/src/share/classes/java/beans/MetaData.java
jdk/src/share/classes/sun/swing/AccessibleMethod.java
--- a/.hgtags	Wed Jul 15 10:46:42 2009 -0700
+++ b/.hgtags	Tue Jul 21 13:02:23 2009 -0700
@@ -37,3 +37,5 @@
 5a10e4d0b14d7beac53a7b2213ae6864afe1fd3e jdk7-b60
 dbb955b1ee59b876dd1f133952b557b48b1d7732 jdk7-b61
 6107cbff3130c747d243c25a7874cd59db5744a8 jdk7-b62
+dfd8506f74c3731bb169ce93c72612d78ee0413b jdk7-b63
+d22867c5f1b295a0a2b3b4bc8999a2676f6e20c3 jdk7-b64
--- a/.hgtags-top-repo	Wed Jul 15 10:46:42 2009 -0700
+++ b/.hgtags-top-repo	Tue Jul 21 13:02:23 2009 -0700
@@ -37,3 +37,5 @@
 39565502682c7085369bd09e51640919dc741097 jdk7-b60
 472c21584cfd7e9c0229ad6a100366a5c03d2976 jdk7-b61
 c7ed15ab92ce36a09d264a5e34025884b2d7607f jdk7-b62
+57f7e028c7ad1806500ae89eb3f4cd9a51b10e18 jdk7-b63
+269c1ec4435dfb7b452ae6e3bdde005d55c5c830 jdk7-b64
--- a/README-builds.html	Wed Jul 15 10:46:42 2009 -0700
+++ b/README-builds.html	Tue Jul 21 13:02:23 2009 -0700
@@ -120,6 +120,7 @@
                         <th>Base OS and Architecture</th>
                         <th>OS</th>
                         <th>C/C++ Compiler</th>
+                        <th>BOOT JDK</th>
                     </tr>
                 </thead>
                 <tbody>
@@ -127,57 +128,65 @@
                         <td>Linux X86 (32-bit)</td>
                         <td>Fedora 9</td>
                         <td>gcc 4 </td>
+                        <td>JDK 6u14 FCS </td>
                     </tr>
                     <tr>
                         <td>Linux X64 (64-bit)</td>
                         <td>Fedora 9</td>
                         <td>gcc 4 </td>
+                        <td>JDK 6u14 FCS </td>
                     </tr>
                     <tr>
                         <td>Solaris SPARC (32-bit)</td>
-                        <td>Solaris 10 + patches 
+                        <td>Solaris 10u2 + patches 
                             <br>
                             See <a href="http://sunsolve.sun.com/pub-cgi/show.pl?target=patches/JavaSE" target="_blank">
                             SunSolve</a> for patch downloads.
                         </td>
                         <td>Sun Studio 12</td>
+                        <td>JDK 6u14 FCS </td>
                     </tr>
                     <tr>
                         <td>Solaris SPARCV9 (64-bit)</td>
-                        <td>Solaris 10 + patches
+                        <td>Solaris 10u2 + patches
                             <br>
                             See <a href="http://sunsolve.sun.com/pub-cgi/show.pl?target=patches/JavaSE" target="_blank">
                             SunSolve</a> for patch downloads.
                         </td>
                         <td>Sun Studio 12</td>
+                        <td>JDK 6u14 FCS </td>
                     </tr>
                     <tr>
                         <td>Solaris X86 (32-bit)</td>
-                        <td>Solaris 10 + patches
+                        <td>Solaris 10u2 + patches
                             <br>
                             See <a href="http://sunsolve.sun.com/pub-cgi/show.pl?target=patches/JavaSE" target="_blank">
                             SunSolve</a> for patch downloads.
                         </td>
                         <td>Sun Studio 12</td>
+                        <td>JDK 6u14 FCS </td>
                     </tr>
                     <tr>
                         <td>Solaris X64 (64-bit)</td>
-                        <td>Solaris 10 + patches
+                        <td>Solaris 10u2 + patches
                             <br>
                             See <a href="http://sunsolve.sun.com/pub-cgi/show.pl?target=patches/JavaSE" target="_blank">
                             SunSolve</a> for patch downloads.
                         </td>
                         <td>Sun Studio 12</td>
+                        <td>JDK 6u14 FCS </td>
                     </tr>
                     <tr>
                         <td>Windows X86 (32-bit)</td>
                         <td>Windows XP</td>
                         <td>Microsoft Visual Studio C++ 2008 Standard Edition</td>
+                        <td>JDK 6u14 FCS </td>
                     </tr>
                     <tr>
                         <td>Windows X64 (64-bit)</td>
                         <td>Windows Server 2003 - Enterprise x64 Edition</td>
                         <td>Microsoft Platform SDK - April 2005</td>
+                        <td>JDK 6u14 FCS </td>
                     </tr>
                 </tbody>
             </table>
--- a/corba/.hgtags	Wed Jul 15 10:46:42 2009 -0700
+++ b/corba/.hgtags	Tue Jul 21 13:02:23 2009 -0700
@@ -37,3 +37,5 @@
 f1e1cccbd13aa96d2d8bd872782ff764010bc22c jdk7-b60
 e906b16a12a9a63b615898afa5d9673cbd1c5ab8 jdk7-b61
 65b66117dbd70a493e9644aeb4033cf95a4e3c99 jdk7-b62
+d20e45cd539f20405ff843652069cfd7550c5ab3 jdk7-b63
+047dd27fddb607f8135296b3754131f6e13cb8c7 jdk7-b64
--- a/corba/make/common/Defs-windows.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/corba/make/common/Defs-windows.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -365,10 +365,10 @@
     COPYRIGHT_YEAR = 2007 
 endif
 
-RC_FLAGS += -d "J2SE_BUILD_ID=$(FULL_VERSION)" \
-            -d "J2SE_COMPANY=$(COMPANY_NAME)" \
-            -d "J2SE_COMPONENT=$(PRODUCT_NAME) Platform SE binary" \
-            -d "J2SE_VER=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(J2SE_UPDATE_VER).$(COOKED_BUILD_NUMBER)" \
-            -d "J2SE_COPYRIGHT=Copyright \xA9 $(COPYRIGHT_YEAR)" \
-            -d "J2SE_NAME=$(PRODUCT_NAME) Platform SE $(JDK_MINOR_VERSION) $(J2SE_UPDATE_META_TAG)" \
-            -d "J2SE_FVER=$(JDK_VERSION)"
+RC_FLAGS += -d "JDK_BUILD_ID=$(FULL_VERSION)" \
+            -d "JDK_COMPANY=$(COMPANY_NAME)" \
+            -d "JDK_COMPONENT=$(PRODUCT_NAME) Platform SE binary" \
+            -d "JDK_VER=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)" \
+            -d "JDK_COPYRIGHT=Copyright \xA9 $(COPYRIGHT_YEAR)" \
+            -d "JDK_NAME=$(PRODUCT_NAME) Platform SE $(JDK_MINOR_VERSION) $(JDK_UPDATE_META_TAG)" \
+            -d "JDK_FVER=$(JDK_VERSION)"
--- a/corba/make/common/Library.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/corba/make/common/Library.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -158,9 +158,9 @@
 endif
 	@$(ECHO) Created $@ 
 
-RC_FLAGS += /D "J2SE_FNAME=$(LIBRARY).dll" \
-            /D "J2SE_INTERNAL_NAME=$(LIBRARY)" \
-            /D "J2SE_FTYPE=0x2L"
+RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
+            /D "JDK_INTERNAL_NAME=$(LIBRARY)" \
+            /D "JDK_FTYPE=0x2L"
 
 $(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
 ifndef LOCAL_RESOURCE_FILE
--- a/corba/make/org/omg/idl/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/corba/make/org/omg/idl/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -32,6 +32,12 @@
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
 
+# This program must contain a manifest that defines the execution level
+# needed to follow standard Vista User Access Control Guidelines
+# This must be set before Program.gmk is included
+#
+BUILD_MANIFEST=true
+
 #
 # Files
 #
--- a/corba/src/windows/resource/version.rc	Wed Jul 15 10:46:42 2009 -0700
+++ b/corba/src/windows/resource/version.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -37,8 +37,8 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION    J2SE_FVER
- PRODUCTVERSION J2SE_FVER
+ FILEVERSION    JDK_FVER
+ PRODUCTVERSION JDK_FVER
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -48,22 +48,22 @@
  // FILEOS 0x4 is Win32, 0x40004 is Win32 NT only
  FILEOS 0x4L
  // FILETYPE should be 0x1 for .exe and 0x2 for .dll
- FILETYPE J2SE_FTYPE
+ FILETYPE JDK_FTYPE
  FILESUBTYPE 0x0L
 BEGIN
     BLOCK "StringFileInfo"
     BEGIN
         BLOCK "000004b0"
         BEGIN
-            VALUE "CompanyName",      XSTR(J2SE_COMPANY)       "\0"
-            VALUE "FileDescription",  XSTR(J2SE_COMPONENT)     "\0"
-            VALUE "FileVersion",      XSTR(J2SE_VER)           "\0"
-            VALUE "Full Version",     XSTR(J2SE_BUILD_ID)      "\0"
-	    VALUE "InternalName",     XSTR(J2SE_INTERNAL_NAME) "\0"
-            VALUE "LegalCopyright",   XSTR(J2SE_COPYRIGHT)     "\0"
-            VALUE "OriginalFilename", XSTR(J2SE_FNAME)         "\0"
-            VALUE "ProductName",      XSTR(J2SE_NAME)          "\0"
-            VALUE "ProductVersion",   XSTR(J2SE_VER)           "\0"
+            VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
+            VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
+            VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
+            VALUE "Full Version",     XSTR(JDK_BUILD_ID)      "\0"
+	    VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
+            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
+            VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
+            VALUE "ProductName",      XSTR(JDK_NAME)          "\0"
+            VALUE "ProductVersion",   XSTR(JDK_VER)           "\0"
         END
     END
     BLOCK "VarFileInfo"
--- a/hotspot/.hgtags	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/.hgtags	Tue Jul 21 13:02:23 2009 -0700
@@ -37,3 +37,5 @@
 a77eddcd510c3972717c025cfcef9a60bfa4ecac jdk7-b60
 27b728fd1281ab62e9d7e4424f8bbb6ca438d803 jdk7-b61
 a88386380bdaaa5ab4ffbedf22c57bac5dbec034 jdk7-b62
+32c83fb84370a35344676991a48440378e6b6c8a jdk7-b63
+ba36394eb84b949b31212bdb32a518a8f92bab5b jdk7-b64
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/DebugInfoReadStream.java	Tue Jul 21 13:02:23 2009 -0700
@@ -24,23 +24,64 @@
 
 package sun.jvm.hotspot.code;
 
+import java.util.*;
+
 import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.runtime.VM;
+import sun.jvm.hotspot.utilities.*;
 
 public class DebugInfoReadStream extends CompressedReadStream {
   private NMethod code;
   private int InvocationEntryBCI;
+  private List objectPool; // ArrayList<ObjectValue>
 
   public DebugInfoReadStream(NMethod code, int offset) {
     super(code.scopesDataBegin(), offset);
     InvocationEntryBCI = VM.getVM().getInvocationEntryBCI();
     this.code = code;
+    this.objectPool = null;
+  }
+
+  public DebugInfoReadStream(NMethod code, int offset, List objectPool) {
+    super(code.scopesDataBegin(), offset);
+    InvocationEntryBCI = VM.getVM().getInvocationEntryBCI();
+    this.code = code;
+    this.objectPool = objectPool;
   }
 
   public OopHandle readOopHandle() {
     return code.getOopAt(readInt());
   }
 
+  ScopeValue readObjectValue() {
+    int id = readInt();
+    if (Assert.ASSERTS_ENABLED) {
+      Assert.that(objectPool != null, "object pool does not exist");
+      for (Iterator itr = objectPool.iterator(); itr.hasNext();) {
+        ObjectValue ov = (ObjectValue) itr.next();
+        Assert.that(ov.id() != id, "should not be read twice");
+      }
+    }
+    ObjectValue result = new ObjectValue(id);
+    // Cache the object since an object field could reference it.
+    objectPool.add(result);
+    result.readObject(this);
+    return result;
+  }
+
+  ScopeValue getCachedObject() {
+    int id = readInt();
+    Assert.that(objectPool != null, "object pool does not exist");
+    for (Iterator itr = objectPool.iterator(); itr.hasNext();) {
+      ObjectValue ov = (ObjectValue) itr.next();
+      if (ov.id() == id) {
+        return ov;
+      }
+    }
+    Assert.that(false, "should not reach here");
+    return null;
+  }
+
   public int readBCI() {
     return readInt() + InvocationEntryBCI;
   }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/MonitorValue.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/MonitorValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -29,6 +29,7 @@
 public class MonitorValue {
   private ScopeValue owner;
   private Location   basicLock;
+  private boolean    eliminated;
 
   // FIXME: not useful yet
   //  MonitorValue(ScopeValue* owner, Location basic_lock);
@@ -36,10 +37,12 @@
   public MonitorValue(DebugInfoReadStream stream) {
     basicLock = new Location(stream);
     owner     = ScopeValue.readFrom(stream);
+    eliminated= stream.readBoolean();
   }
 
   public ScopeValue owner()     { return owner; }
   public Location   basicLock() { return basicLock; }
+  public boolean   eliminated() { return eliminated; }
 
   // FIXME: not yet implementable
   //  void write_on(DebugInfoWriteStream* stream);
@@ -50,5 +53,8 @@
     tty.print(",");
     basicLock().printOn(tty);
     tty.print("}");
+    if (eliminated) {
+      tty.print(" (eliminated)");
+    }
   }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ObjectValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ *
+ */
+
+package sun.jvm.hotspot.code;
+
+import java.io.*;
+import java.util.*;
+
+import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.utilities.*;
+
+/** An ObjectValue describes an object eliminated by escape analysis. */
+
+public class ObjectValue extends ScopeValue {
+  private int        id;
+  private ScopeValue klass;
+  private List       fieldsValue; // ArrayList<ScopeValue>
+
+  // Field "boolean visited" is not implemented here since
+  // it is used only a during debug info creation.
+
+  public ObjectValue(int id) {
+    this.id = id;
+    klass   = null;
+    fieldsValue = new ArrayList();
+  }
+
+  public boolean isObject() { return true; }
+  public int id() { return id; }
+  public ScopeValue getKlass() { return klass; }
+  public List getFieldsValue() { return fieldsValue; }
+  public ScopeValue getFieldAt(int i) { return (ScopeValue)fieldsValue.get(i); }
+  public int fieldsSize() { return fieldsValue.size(); }
+
+  // Field "value" is always NULL here since it is used
+  // only during deoptimization of a compiled frame
+  // pointing to reallocated object.
+  public OopHandle getValue() { return null; }
+
+  /** Serialization of debugging information */
+
+  void readObject(DebugInfoReadStream stream) {
+    klass = readFrom(stream);
+    Assert.that(klass.isConstantOop(), "should be constant klass oop");
+    int length = stream.readInt();
+    for (int i = 0; i < length; i++) {
+      ScopeValue val = readFrom(stream);
+      fieldsValue.add(val);
+    }
+  }
+
+  // Printing
+
+  public void print() {
+    printOn(System.out);
+  }
+
+  public void printOn(PrintStream tty) {
+    tty.print("scalarObj[" + id + "]");
+  }
+
+  void printFieldsOn(PrintStream tty) {
+    if (fieldsValue.size() > 0) {
+      ((ScopeValue)fieldsValue.get(0)).printOn(tty);
+    }
+    for (int i = 1; i < fieldsValue.size(); i++) {
+      tty.print(", ");
+      ((ScopeValue)fieldsValue.get(i)).printOn(tty);
+    }
+  }
+
+};
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java	Tue Jul 21 13:02:23 2009 -0700
@@ -27,8 +27,10 @@
 import java.io.*;
 import java.util.*;
 
+import sun.jvm.hotspot.debugger.*;
 import sun.jvm.hotspot.oops.*;
 import sun.jvm.hotspot.runtime.*;
+import sun.jvm.hotspot.utilities.*;
 
 /** ScopeDescs contain the information that makes source-level
     debugging of nmethods possible; each scopeDesc describes a method
@@ -45,10 +47,31 @@
   private int     localsDecodeOffset;
   private int     expressionsDecodeOffset;
   private int     monitorsDecodeOffset;
+  /** Scalar replaced bjects pool */
+  private List    objects; // ArrayList<ScopeValue>
+
 
   public ScopeDesc(NMethod code, int decodeOffset) {
     this.code = code;
     this.decodeOffset = decodeOffset;
+    this.objects      = decodeObjectValues(DebugInformationRecorder.SERIALIZED_NULL);
+
+    // Decode header
+    DebugInfoReadStream stream  = streamAt(decodeOffset);
+
+    senderDecodeOffset = stream.readInt();
+    method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle());
+    bci    = stream.readBCI();
+    // Decode offsets for body and sender
+    localsDecodeOffset      = stream.readInt();
+    expressionsDecodeOffset = stream.readInt();
+    monitorsDecodeOffset    = stream.readInt();
+  }
+
+  public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset) {
+    this.code = code;
+    this.decodeOffset = decodeOffset;
+    this.objects      = decodeObjectValues(objectDecodeOffset);
 
     // Decode header
     DebugInfoReadStream stream  = streamAt(decodeOffset);
@@ -81,6 +104,11 @@
     return decodeMonitorValues(monitorsDecodeOffset);
   }
 
+  /** Returns a List&lt;MonitorValue&gt; */
+  public List getObjects() {
+    return objects;
+  }
+
   /** Stack walking. Returns null if this is the outermost scope. */
   public ScopeDesc sender() {
     if (isTop()) {
@@ -131,7 +159,7 @@
   //
 
   private DebugInfoReadStream streamAt(int decodeOffset) {
-    return new DebugInfoReadStream(code, decodeOffset);
+    return new DebugInfoReadStream(code, decodeOffset, objects);
   }
 
   /** Returns a List&lt;ScopeValue&gt; or null if no values were present */
@@ -161,4 +189,22 @@
     }
     return res;
   }
+
+  /** Returns a List&lt;ObjectValue&gt; or null if no values were present */
+  private List decodeObjectValues(int decodeOffset) {
+    if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) {
+      return null;
+    }
+    List res = new ArrayList();
+    DebugInfoReadStream stream = new DebugInfoReadStream(code, decodeOffset, res);
+    int length = stream.readInt();
+    for (int i = 0; i < length; i++) {
+      // Objects values are pushed to 'res' array during read so that
+      // object's fields could reference it (OBJECT_ID_CODE).
+      ScopeValue.readFrom(stream);
+      // res.add(ScopeValue.readFrom(stream));
+    }
+    Assert.that(res.size() == length, "inconsistent debug information");
+    return res;
+  }
 }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeValue.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/code/ScopeValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -49,12 +49,15 @@
   static final int CONSTANT_OOP_CODE    = 2;
   static final int CONSTANT_LONG_CODE   = 3;
   static final int CONSTANT_DOUBLE_CODE = 4;
+  static final int CONSTANT_OBJECT_CODE = 5;
+  static final int CONSTANT_OBJECT_ID_CODE = 6;
 
   public boolean isLocation()       { return false; }
   public boolean isConstantInt()    { return false; }
   public boolean isConstantDouble() { return false; }
   public boolean isConstantLong()   { return false; }
   public boolean isConstantOop()    { return false; }
+  public boolean isObject()         { return false; }
 
   public static ScopeValue readFrom(DebugInfoReadStream stream) {
     switch (stream.readInt()) {
@@ -68,6 +71,10 @@
       return new ConstantLongValue(stream);
     case CONSTANT_DOUBLE_CODE:
       return new ConstantDoubleValue(stream);
+    case CONSTANT_OBJECT_CODE:
+      return stream.readObjectValue();
+    case CONSTANT_OBJECT_ID_CODE:
+      return stream.getCachedObject();
     default:
       Assert.that(false, "should not reach here");
       return null;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ObjectReferenceImpl.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ObjectReferenceImpl.java	Tue Jul 21 13:02:23 2009 -0700
@@ -249,6 +249,7 @@
             OopHandle givenHandle = obj.getHandle();
             for (Iterator itr = monitors.iterator(); itr.hasNext();) {
                 MonitorInfo mi = (MonitorInfo) itr.next();
+                if (mi.eliminated() && frame.isCompiledFrame()) continue; // skip eliminated monitor
                 if (givenHandle.equals(mi.owner())) {
                     res++;
                 }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ThreadReferenceImpl.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/ThreadReferenceImpl.java	Tue Jul 21 13:02:23 2009 -0700
@@ -301,6 +301,9 @@
             List frameMonitors = frame.getMonitors();  // List<MonitorInfo>
             for (Iterator miItr = frameMonitors.iterator(); miItr.hasNext(); ) {
                 sun.jvm.hotspot.runtime.MonitorInfo mi = (sun.jvm.hotspot.runtime.MonitorInfo) miItr.next();
+                if (mi.eliminated() && frame.isCompiledFrame()) {
+                  continue; // skip eliminated monitor
+                }
                 OopHandle obj = mi.owner();
                 if (obj == null) {
                     // this monitor doesn't have an owning object so skip it
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java	Tue Jul 21 13:02:23 2009 -0700
@@ -131,8 +131,18 @@
     List result = new ArrayList(monitors.size());
     for (int i = 0; i < monitors.size(); i++) {
       MonitorValue mv = (MonitorValue) monitors.get(i);
-      StackValue ownerSV = createStackValue(mv.owner()); // it is an oop
-      result.add(new MonitorInfo(ownerSV.getObject(), resolveMonitorLock(mv.basicLock())));
+      ScopeValue ov = mv.owner();
+      StackValue ownerSV = createStackValue(ov); // it is an oop
+      if (ov.isObject()) { // The owner object was scalar replaced
+        Assert.that(mv.eliminated() && ownerSV.objIsScalarReplaced(), "monitor should be eliminated for scalar replaced object");
+        // Put klass for scalar replaced object.
+        ScopeValue kv = ((ObjectValue)ov).getKlass();
+        Assert.that(kv.isConstantOop(), "klass should be oop constant for scalar replaced object");
+        OopHandle k = ((ConstantOopReadValue)kv).getValue();
+        result.add(new MonitorInfo(k, resolveMonitorLock(mv.basicLock()), mv.eliminated(), true));
+      } else {
+        result.add(new MonitorInfo(ownerSV.getObject(), resolveMonitorLock(mv.basicLock()), mv.eliminated(), false));
+      }
     }
     return result;
   }
@@ -212,12 +222,12 @@
           // long or is unused.  He always saves a long.  Here we know
           // a long was saved, but we only want an narrow oop back.  Narrow the
           // saved long to the narrow oop that the JVM wants.
-          return new StackValue(valueAddr.getCompOopHandleAt(VM.getVM().getIntSize()));
+          return new StackValue(valueAddr.getCompOopHandleAt(VM.getVM().getIntSize()), 0);
         } else {
-          return new StackValue(valueAddr.getCompOopHandleAt(0));
+          return new StackValue(valueAddr.getCompOopHandleAt(0), 0);
         }
       } else if( loc.holdsOop() ) {  // Holds an oop?
-        return new StackValue(valueAddr.getOopHandleAt(0));
+        return new StackValue(valueAddr.getOopHandleAt(0), 0);
       } else if( loc.holdsDouble() ) {
         // Double value in a single stack slot
         return new StackValue(valueAddr.getJIntAt(0) & 0xFFFFFFFF);
@@ -277,7 +287,7 @@
       return new StackValue(((ConstantIntValue) sv).getValue() & 0xFFFFFFFF);
     } else if (sv.isConstantOop()) {
       // constant oop
-      return new StackValue(((ConstantOopReadValue) sv).getValue());
+      return new StackValue(((ConstantOopReadValue) sv).getValue(), 0);
     } else if (sv.isConstantDouble()) {
       // Constant double in a single stack slot
       double d = ((ConstantDoubleValue) sv).getValue();
@@ -285,6 +295,9 @@
     } else if (VM.getVM().isLP64() && sv.isConstantLong()) {
       // Constant long in a single stack slot
       return new StackValue(((ConstantLongValue) sv).getValue() & 0xFFFFFFFF);
+    } else if (sv.isObject()) {
+      // Scalar replaced object in compiled frame
+      return new StackValue(((ObjectValue)sv).getValue(), 1);
     }
 
     // Unknown ScopeValue type
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/InterpretedVFrame.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/InterpretedVFrame.java	Tue Jul 21 13:02:23 2009 -0700
@@ -61,7 +61,7 @@
       StackValue sv;
       if (oopMask.isOop(i)) {
         // oop value
-        sv = new StackValue(addr.getOopHandleAt(0));
+        sv = new StackValue(addr.getOopHandleAt(0), 0);
       } else {
         // integer
         // Fetch a signed integer the size of a stack slot
@@ -95,7 +95,7 @@
       StackValue sv;
       if (oopMask.isOop(i + nofLocals)) {
         // oop value
-        sv = new StackValue(addr.getOopHandleAt(0));
+        sv = new StackValue(addr.getOopHandleAt(0), 0);
       } else {
         // integer
         // Fetch a signed integer the size of a stack slot
@@ -113,7 +113,7 @@
     for (BasicObjectLock current = getFrame().interpreterFrameMonitorEnd();
          current.address().lessThan(getFrame().interpreterFrameMonitorBegin().address());
          current = getFrame().nextMonitorInInterpreterFrame(current)) {
-      result.add(new MonitorInfo(current.obj(), current.lock()));
+      result.add(new MonitorInfo(current.obj(), current.lock(), false, false));
     }
     return result;
   }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/MonitorInfo.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/MonitorInfo.java	Tue Jul 21 13:02:23 2009 -0700
@@ -25,16 +25,39 @@
 package sun.jvm.hotspot.runtime;
 
 import sun.jvm.hotspot.debugger.*;
+import sun.jvm.hotspot.utilities.*;
 
 public class MonitorInfo {
   private OopHandle owner;
   private BasicLock lock;
+  private OopHandle ownerKlass;
+  private boolean eliminated;
+  private boolean ownerIsScalarReplaced;
 
-  public MonitorInfo(OopHandle owner, BasicLock lock) {
-    this.owner = owner;
-    this.lock  = lock;
+  public MonitorInfo(OopHandle owner, BasicLock lock, boolean eliminated, boolean ownerIsScalarReplaced) {
+    if (!ownerIsScalarReplaced) {
+      this.owner = owner;
+      this.ownerKlass = null;
+    } else {
+      Assert.that(eliminated, "monitor should be eliminated for scalar replaced object");
+      this.owner = null;
+      this.ownerKlass = owner;
+    }
+    this.eliminated = eliminated;
+    this.ownerIsScalarReplaced = ownerIsScalarReplaced;
   }
 
-  public OopHandle owner() { return owner; }
+  public OopHandle owner() {
+   Assert.that(!ownerIsScalarReplaced, "should not be called for scalar replaced object");
+   return owner;
+  }
+
+  public OopHandle ownerKlass() {
+   Assert.that(ownerIsScalarReplaced, "should not be called for not scalar replaced object");
+   return ownerKlass;
+  }
+
   public BasicLock lock()  { return lock; }
+  public boolean eliminated() { return eliminated; }
+  public boolean ownerIsScalarReplaced() { return ownerIsScalarReplaced; }
 }
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StackValue.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StackValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -37,9 +37,11 @@
     type = BasicType.getTConflict();
   }
 
-  public StackValue(OopHandle h) {
+  public StackValue(OopHandle h, long scalar_replaced) {
     handleValue = h;
     type = BasicType.getTObject();
+    integerValue = scalar_replaced;
+    Assert.that(integerValue == 0 || handleValue == null, "not null object should not be marked as scalar replaced");
   }
 
   public StackValue(long i) {
@@ -59,6 +61,13 @@
     return handleValue;
   }
 
+  boolean objIsScalarReplaced() {
+    if (Assert.ASSERTS_ENABLED) {
+      Assert.that(type == BasicType.getTObject(), "type check");
+    }
+    return integerValue != 0;
+  }
+
   public long getInteger() {
     if (Assert.ASSERTS_ENABLED) {
       Assert.that(type == BasicType.getTInt(), "type check");
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/tree/OopTreeNodeAdapter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/ui/tree/OopTreeNodeAdapter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -161,6 +161,8 @@
           child = new OopTreeNodeAdapter(field.getValue(getObj()), field.getID(), getTreeTableMode());
         } catch (AddressException e) {
           child = new BadOopTreeNodeAdapter(field.getValueAsOopHandle(getObj()), field.getID(), getTreeTableMode());
+        } catch (UnknownOopException e) {
+          child = new BadOopTreeNodeAdapter(field.getValueAsOopHandle(getObj()), field.getID(), getTreeTableMode());
         }
       }
       ++curField;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaThread.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/JSJavaThread.java	Tue Jul 21 13:02:23 2009 -0700
@@ -135,6 +135,10 @@
                     List frameMonitors = frame.getMonitors();  // List<MonitorInfo>
                     for (Iterator miItr = frameMonitors.iterator(); miItr.hasNext(); ) {
                         MonitorInfo mi = (MonitorInfo) miItr.next();
+
+                        if (mi.eliminated() && frame.isCompiledFrame()) {
+                          continue; // skip eliminated monitor
+                        }
                         OopHandle obj = mi.owner();
                         if (obj == null) {
                             // this monitor doesn't have an owning object so skip it
--- a/hotspot/make/hotspot_version	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/make/hotspot_version	Tue Jul 21 13:02:23 2009 -0700
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=16
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=05
+HS_BUILD_NUMBER=06
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=7
--- a/hotspot/make/solaris/makefiles/adlc.make	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/make/solaris/makefiles/adlc.make	Tue Jul 21 13:02:23 2009 -0700
@@ -68,7 +68,9 @@
 
 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
 # Compiler warnings are treated as errors
-CFLAGS_WARN = +w -errwarn
+ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
+  CFLAGS_WARN = +w -errwarn
+endif
 CFLAGS += $(CFLAGS_WARN)
 
 ifeq ("${Platform_compiler}", "sparcWorks")
--- a/hotspot/make/solaris/makefiles/optimized.make	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/make/solaris/makefiles/optimized.make	Tue Jul 21 13:02:23 2009 -0700
@@ -41,7 +41,7 @@
 endif
 
 # Workaround SS11 bug 6345274 (all platforms) (Fixed in SS11 patch and SS12)
-ifeq ($(COMPILER_REV_NUMERIC),508))
+ifeq ($(COMPILER_REV_NUMERIC),508)
 OPT_CFLAGS/ciTypeFlow.o = $(OPT_CFLAGS/O2)
 endif # COMPILER_REV_NUMERIC == 508
 
--- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -371,7 +371,7 @@
   }
   __ move(value.result(), array_addr, null_check_info);
   if (obj_store) {
-    // Is this precise?
+    // Precise card mark
     post_barrier(LIR_OprFact::address(array_addr), value.result());
   }
 }
@@ -685,11 +685,8 @@
   LIR_Opr result = rlock_result(x);
   __ cmove(lir_cond_equal, LIR_OprFact::intConst(1), LIR_OprFact::intConst(0), result);
   if (type == objectType) {  // Write-barrier needed for Object fields.
-#ifdef PRECISE_CARDMARK
+    // Precise card mark since could either be object or array
     post_barrier(addr, val.result());
-#else
-    post_barrier(obj.result(), val.result());
-#endif // PRECISE_CARDMARK
   }
 }
 
--- a/hotspot/src/cpu/sparc/vm/sparc.ad	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/cpu/sparc/vm/sparc.ad	Tue Jul 21 13:02:23 2009 -0700
@@ -1891,17 +1891,17 @@
 // The intptr_t operand types, defined by textual substitution.
 // (Cf. opto/type.hpp.  This lets us avoid many, many other ifdefs.)
 #ifdef _LP64
-#define immX     immL
-#define immX13   immL13
-#define immX13m7 immL13m7
-#define iRegX    iRegL
-#define g1RegX   g1RegL
+#define immX      immL
+#define immX13    immL13
+#define immX13m7  immL13m7
+#define iRegX     iRegL
+#define g1RegX    g1RegL
 #else
-#define immX     immI
-#define immX13   immI13
-#define immX13m7 immI13m7
-#define iRegX    iRegI
-#define g1RegX   g1RegI
+#define immX      immI
+#define immX13    immI13
+#define immX13m7  immI13m7
+#define iRegX     iRegI
+#define g1RegX    g1RegI
 #endif
 
 //----------ENCODING BLOCK-----------------------------------------------------
@@ -3446,6 +3446,15 @@
   interface(CONST_INTER);
 %}
 
+// Integer Immediate: 8-bit
+operand immI8() %{
+  predicate(Assembler::is_simm(n->get_int(), 8));
+  match(ConI);
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
 // Integer Immediate: 13-bit
 operand immI13() %{
   predicate(Assembler::is_simm13(n->get_int()));
@@ -3466,6 +3475,15 @@
   interface(CONST_INTER);
 %}
 
+// Integer Immediate: 16-bit
+operand immI16() %{
+  predicate(Assembler::is_simm(n->get_int(), 16));
+  match(ConI);
+  op_cost(0);
+  format %{ %}
+  interface(CONST_INTER);
+%}
+
 // Unsigned (positive) Integer Immediate: 13-bit
 operand immU13() %{
   predicate((0 <= n->get_int()) && Assembler::is_simm13(n->get_int()));
@@ -5544,7 +5562,7 @@
   ins_encode %{
     __ ldub($mem$$Address, $dst$$Register);
   %}
-  ins_pipe(iload_mask_mem);
+  ins_pipe(iload_mem);
 %}
 
 // Load Unsigned Byte (8bit UNsigned) into a Long Register
@@ -5557,7 +5575,22 @@
   ins_encode %{
     __ ldub($mem$$Address, $dst$$Register);
   %}
-  ins_pipe(iload_mask_mem);
+  ins_pipe(iload_mem);
+%}
+
+// Load Unsigned Byte (8 bit UNsigned) with 8-bit mask into Long Register
+instruct loadUB2L_immI8(iRegL dst, memory mem, immI8 mask) %{
+  match(Set dst (ConvI2L (AndI (LoadUB mem) mask)));
+  ins_cost(MEMORY_REF_COST + DEFAULT_COST);
+
+  size(2*4);
+  format %{ "LDUB   $mem,$dst\t# ubyte & 8-bit mask -> long\n\t"
+            "AND    $dst,$mask,$dst" %}
+  ins_encode %{
+    __ ldub($mem$$Address, $dst$$Register);
+    __ and3($dst$$Register, $mask$$constant, $dst$$Register);
+  %}
+  ins_pipe(iload_mem);
 %}
 
 // Load Short (16bit signed)
@@ -5610,7 +5643,7 @@
   ins_encode %{
     __ lduh($mem$$Address, $dst$$Register);
   %}
-  ins_pipe(iload_mask_mem);
+  ins_pipe(iload_mem);
 %}
 
 // Load Unsigned Short/Char (16 bit UNsigned) to Byte (8 bit signed)
@@ -5636,7 +5669,56 @@
   ins_encode %{
     __ lduh($mem$$Address, $dst$$Register);
   %}
-  ins_pipe(iload_mask_mem);
+  ins_pipe(iload_mem);
+%}
+
+// Load Unsigned Short/Char (16bit UNsigned) with mask 0xFF into a Long Register
+instruct loadUS2L_immI_255(iRegL dst, indOffset13m7 mem, immI_255 mask) %{
+  match(Set dst (ConvI2L (AndI (LoadUS mem) mask)));
+  ins_cost(MEMORY_REF_COST);
+
+  size(4);
+  format %{ "LDUB   $mem+1,$dst\t! ushort/char & 0xFF -> long" %}
+  ins_encode %{
+    __ ldub($mem$$Address, $dst$$Register, 1);  // LSB is index+1 on BE
+  %}
+  ins_pipe(iload_mem);
+%}
+
+// Load Unsigned Short/Char (16bit UNsigned) with a 13-bit mask into a Long Register
+instruct loadUS2L_immI13(iRegL dst, memory mem, immI13 mask) %{
+  match(Set dst (ConvI2L (AndI (LoadUS mem) mask)));
+  ins_cost(MEMORY_REF_COST + DEFAULT_COST);
+
+  size(2*4);
+  format %{ "LDUH   $mem,$dst\t! ushort/char & 13-bit mask -> long\n\t"
+            "AND    $dst,$mask,$dst" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ lduh($mem$$Address, Rdst);
+    __ and3(Rdst, $mask$$constant, Rdst);
+  %}
+  ins_pipe(iload_mem);
+%}
+
+// Load Unsigned Short/Char (16bit UNsigned) with a 16-bit mask into a Long Register
+instruct loadUS2L_immI16(iRegL dst, memory mem, immI16 mask, iRegL tmp) %{
+  match(Set dst (ConvI2L (AndI (LoadUS mem) mask)));
+  effect(TEMP dst, TEMP tmp);
+  ins_cost(MEMORY_REF_COST + 2*DEFAULT_COST);
+
+  size(3*4);
+  format %{ "LDUH   $mem,$dst\t! ushort/char & 16-bit mask -> long\n\t"
+            "SET    $mask,$tmp\n\t"
+            "AND    $dst,$tmp,$dst" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    Register Rtmp = $tmp$$Register;
+    __ lduh($mem$$Address, Rdst);
+    __ set($mask$$constant, Rtmp);
+    __ and3(Rdst, Rtmp, Rdst);
+  %}
+  ins_pipe(iload_mem);
 %}
 
 // Load Integer
@@ -5718,6 +5800,68 @@
   ins_encode %{
     __ ldsw($mem$$Address, $dst$$Register);
   %}
+  ins_pipe(iload_mask_mem);
+%}
+
+// Load Integer with mask 0xFF into a Long Register
+instruct loadI2L_immI_255(iRegL dst, indOffset13m7 mem, immI_255 mask) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+  ins_cost(MEMORY_REF_COST);
+
+  size(4);
+  format %{ "LDUB   $mem+3,$dst\t! int & 0xFF -> long" %}
+  ins_encode %{
+    __ ldub($mem$$Address, $dst$$Register, 3);  // LSB is index+3 on BE
+  %}
+  ins_pipe(iload_mem);
+%}
+
+// Load Integer with mask 0xFFFF into a Long Register
+instruct loadI2L_immI_65535(iRegL dst, indOffset13m7 mem, immI_65535 mask) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+  ins_cost(MEMORY_REF_COST);
+
+  size(4);
+  format %{ "LDUH   $mem+2,$dst\t! int & 0xFFFF -> long" %}
+  ins_encode %{
+    __ lduh($mem$$Address, $dst$$Register, 2);  // LSW is index+2 on BE
+  %}
+  ins_pipe(iload_mem);
+%}
+
+// Load Integer with a 13-bit mask into a Long Register
+instruct loadI2L_immI13(iRegL dst, memory mem, immI13 mask) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+  ins_cost(MEMORY_REF_COST + DEFAULT_COST);
+
+  size(2*4);
+  format %{ "LDUW   $mem,$dst\t! int & 13-bit mask -> long\n\t"
+            "AND    $dst,$mask,$dst" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ lduw($mem$$Address, Rdst);
+    __ and3(Rdst, $mask$$constant, Rdst);
+  %}
+  ins_pipe(iload_mem);
+%}
+
+// Load Integer with a 32-bit mask into a Long Register
+instruct loadI2L_immI(iRegL dst, memory mem, immI mask, iRegL tmp) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+  effect(TEMP dst, TEMP tmp);
+  ins_cost(MEMORY_REF_COST + 2*DEFAULT_COST);
+
+  size(3*4);
+  format %{ "LDUW   $mem,$dst\t! int & 32-bit mask -> long\n\t"
+            "SET    $mask,$tmp\n\t"
+            "AND    $dst,$tmp,$dst" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    Register Rtmp = $tmp$$Register;
+    __ lduw($mem$$Address, Rdst);
+    __ set($mask$$constant, Rtmp);
+    __ and3(Rdst, Rtmp, Rdst);
+  %}
   ins_pipe(iload_mem);
 %}
 
--- a/hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/interp_masm_x86_32.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1372,6 +1372,8 @@
     // If no method data exists, go to profile_continue.
     test_method_data_pointer(mdp, profile_continue);
 
+    set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
+
     // The method data pointer needs to be updated.
     int mdp_delta = in_bytes(BitData::bit_data_size());
     if (TypeProfileCasts) {
--- a/hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/interp_masm_x86_64.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1409,6 +1409,8 @@
     // If no method data exists, go to profile_continue.
     test_method_data_pointer(mdp, profile_continue);
 
+    set_mdp_flag_at(mdp, BitData::null_seen_byte_constant());
+
     // The method data pointer needs to be updated.
     int mdp_delta = in_bytes(BitData::bit_data_size());
     if (TypeProfileCasts) {
--- a/hotspot/src/cpu/x86/vm/x86_32.ad	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/x86_32.ad	Tue Jul 21 13:02:23 2009 -0700
@@ -6885,8 +6885,9 @@
 %}
 
 // Load Byte (8bit signed) into Long Register
-instruct loadB2L(eRegL dst, memory mem) %{
+instruct loadB2L(eRegL dst, memory mem, eFlagsReg cr) %{
   match(Set dst (ConvI2L (LoadB mem)));
+  effect(KILL cr);
 
   ins_cost(375);
   format %{ "MOVSX8 $dst.lo,$mem\t# byte -> long\n\t"
@@ -6917,19 +6918,37 @@
 %}
 
 // Load Unsigned Byte (8 bit UNsigned) into Long Register
-instruct loadUB2L(eRegL dst, memory mem)
-%{
+instruct loadUB2L(eRegL dst, memory mem, eFlagsReg cr) %{
   match(Set dst (ConvI2L (LoadUB mem)));
+  effect(KILL cr);
 
   ins_cost(250);
   format %{ "MOVZX8 $dst.lo,$mem\t# ubyte -> long\n\t"
             "XOR    $dst.hi,$dst.hi" %}
 
   ins_encode %{
-    __ movzbl($dst$$Register, $mem$$Address);
-    __ xorl(HIGH_FROM_LOW($dst$$Register), HIGH_FROM_LOW($dst$$Register));
-  %}
-
+    Register Rdst = $dst$$Register;
+    __ movzbl(Rdst, $mem$$Address);
+    __ xorl(HIGH_FROM_LOW(Rdst), HIGH_FROM_LOW(Rdst));
+  %}
+
+  ins_pipe(ialu_reg_mem);
+%}
+
+// Load Unsigned Byte (8 bit UNsigned) with mask into Long Register
+instruct loadUB2L_immI8(eRegL dst, memory mem, immI8 mask, eFlagsReg cr) %{
+  match(Set dst (ConvI2L (AndI (LoadUB mem) mask)));
+  effect(KILL cr);
+
+  format %{ "MOVZX8 $dst.lo,$mem\t# ubyte & 8-bit mask -> long\n\t"
+            "XOR    $dst.hi,$dst.hi\n\t"
+            "AND    $dst.lo,$mask" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ movzbl(Rdst, $mem$$Address);
+    __ xorl(HIGH_FROM_LOW(Rdst), HIGH_FROM_LOW(Rdst));
+    __ andl(Rdst, $mask$$constant);
+  %}
   ins_pipe(ialu_reg_mem);
 %}
 
@@ -6960,8 +6979,9 @@
 %}
 
 // Load Short (16bit signed) into Long Register
-instruct loadS2L(eRegL dst, memory mem) %{
+instruct loadS2L(eRegL dst, memory mem, eFlagsReg cr) %{
   match(Set dst (ConvI2L (LoadS mem)));
+  effect(KILL cr);
 
   ins_cost(375);
   format %{ "MOVSX  $dst.lo,$mem\t# short -> long\n\t"
@@ -7004,8 +7024,9 @@
 %}
 
 // Load Unsigned Short/Char (16 bit UNsigned) into Long Register
-instruct loadUS2L(eRegL dst, memory mem) %{
+instruct loadUS2L(eRegL dst, memory mem, eFlagsReg cr) %{
   match(Set dst (ConvI2L (LoadUS mem)));
+  effect(KILL cr);
 
   ins_cost(250);
   format %{ "MOVZX  $dst.lo,$mem\t# ushort/char -> long\n\t"
@@ -7019,6 +7040,38 @@
   ins_pipe(ialu_reg_mem);
 %}
 
+// Load Unsigned Short/Char (16 bit UNsigned) with mask 0xFF into Long Register
+instruct loadUS2L_immI_255(eRegL dst, memory mem, immI_255 mask, eFlagsReg cr) %{
+  match(Set dst (ConvI2L (AndI (LoadUS mem) mask)));
+  effect(KILL cr);
+
+  format %{ "MOVZX8 $dst.lo,$mem\t# ushort/char & 0xFF -> long\n\t"
+            "XOR    $dst.hi,$dst.hi" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ movzbl(Rdst, $mem$$Address);
+    __ xorl(HIGH_FROM_LOW(Rdst), HIGH_FROM_LOW(Rdst));
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
+// Load Unsigned Short/Char (16 bit UNsigned) with a 16-bit mask into Long Register
+instruct loadUS2L_immI16(eRegL dst, memory mem, immI16 mask, eFlagsReg cr) %{
+  match(Set dst (ConvI2L (AndI (LoadUS mem) mask)));
+  effect(KILL cr);
+
+  format %{ "MOVZX  $dst.lo, $mem\t# ushort/char & 16-bit mask -> long\n\t"
+            "XOR    $dst.hi,$dst.hi\n\t"
+            "AND    $dst.lo,$mask" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ movzwl(Rdst, $mem$$Address);
+    __ xorl(HIGH_FROM_LOW(Rdst), HIGH_FROM_LOW(Rdst));
+    __ andl(Rdst, $mask$$constant);
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
 // Load Integer
 instruct loadI(eRegI dst, memory mem) %{
   match(Set dst (LoadI mem));
@@ -7082,8 +7135,9 @@
 %}
 
 // Load Integer into Long Register
-instruct loadI2L(eRegL dst, memory mem) %{
+instruct loadI2L(eRegL dst, memory mem, eFlagsReg cr) %{
   match(Set dst (ConvI2L (LoadI mem)));
+  effect(KILL cr);
 
   ins_cost(375);
   format %{ "MOV    $dst.lo,$mem\t# int -> long\n\t"
@@ -7099,9 +7153,57 @@
   ins_pipe(ialu_reg_mem);
 %}
 
+// Load Integer with mask 0xFF into Long Register
+instruct loadI2L_immI_255(eRegL dst, memory mem, immI_255 mask, eFlagsReg cr) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+  effect(KILL cr);
+
+  format %{ "MOVZX8 $dst.lo,$mem\t# int & 0xFF -> long\n\t"
+            "XOR    $dst.hi,$dst.hi" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ movzbl(Rdst, $mem$$Address);
+    __ xorl(HIGH_FROM_LOW(Rdst), HIGH_FROM_LOW(Rdst));
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
+// Load Integer with mask 0xFFFF into Long Register
+instruct loadI2L_immI_65535(eRegL dst, memory mem, immI_65535 mask, eFlagsReg cr) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+  effect(KILL cr);
+
+  format %{ "MOVZX  $dst.lo,$mem\t# int & 0xFFFF -> long\n\t"
+            "XOR    $dst.hi,$dst.hi" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ movzwl(Rdst, $mem$$Address);
+    __ xorl(HIGH_FROM_LOW(Rdst), HIGH_FROM_LOW(Rdst));
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
+// Load Integer with 32-bit mask into Long Register
+instruct loadI2L_immI(eRegL dst, memory mem, immI mask, eFlagsReg cr) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+  effect(KILL cr);
+
+  format %{ "MOV    $dst.lo,$mem\t# int & 32-bit mask -> long\n\t"
+            "XOR    $dst.hi,$dst.hi\n\t"
+            "AND    $dst.lo,$mask" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ movl(Rdst, $mem$$Address);
+    __ xorl(HIGH_FROM_LOW(Rdst), HIGH_FROM_LOW(Rdst));
+    __ andl(Rdst, $mask$$constant);
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
 // Load Unsigned Integer into Long Register
-instruct loadUI2L(eRegL dst, memory mem) %{
+instruct loadUI2L(eRegL dst, memory mem, eFlagsReg cr) %{
   match(Set dst (LoadUI2L mem));
+  effect(KILL cr);
 
   ins_cost(250);
   format %{ "MOV    $dst.lo,$mem\t# uint -> long\n\t"
@@ -7695,6 +7797,17 @@
   ins_pipe( ialu_mem_long_reg );
 %}
 
+// Store Long to Integer
+instruct storeL2I(memory mem, eRegL src) %{
+  match(Set mem (StoreI mem (ConvL2I src)));
+
+  format %{ "MOV    $mem,$src.lo\t# long -> int" %}
+  ins_encode %{
+    __ movl($mem$$Address, $src$$Register);
+  %}
+  ins_pipe(ialu_mem_reg);
+%}
+
 // Volatile Store Long.  Must be atomic, so move it into
 // the FP TOS and then do a 64-bit FIST.  Has to probe the
 // target address before the store (for null-ptr checks)
--- a/hotspot/src/cpu/x86/vm/x86_64.ad	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/cpu/x86/vm/x86_64.ad	Tue Jul 21 13:02:23 2009 -0700
@@ -6444,6 +6444,21 @@
   ins_pipe(ialu_reg_mem);
 %}
 
+// Load Unsigned Byte (8 bit UNsigned) with a 8-bit mask into Long Register
+instruct loadUB2L_immI8(rRegL dst, memory mem, immI8 mask, rFlagsReg cr) %{
+  match(Set dst (ConvI2L (AndI (LoadUB mem) mask)));
+  effect(KILL cr);
+
+  format %{ "movzbq  $dst, $mem\t# ubyte & 8-bit mask -> long\n\t"
+            "andl    $dst, $mask" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ movzbq(Rdst, $mem$$Address);
+    __ andl(Rdst, $mask$$constant);
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
 // Load Short (16 bit signed)
 instruct loadS(rRegI dst, memory mem)
 %{
@@ -6528,6 +6543,32 @@
   ins_pipe(ialu_reg_mem);
 %}
 
+// Load Unsigned Short/Char (16 bit UNsigned) with mask 0xFF into Long Register
+instruct loadUS2L_immI_255(rRegL dst, memory mem, immI_255 mask) %{
+  match(Set dst (ConvI2L (AndI (LoadUS mem) mask)));
+
+  format %{ "movzbq  $dst, $mem\t# ushort/char & 0xFF -> long" %}
+  ins_encode %{
+    __ movzbq($dst$$Register, $mem$$Address);
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
+// Load Unsigned Short/Char (16 bit UNsigned) with mask into Long Register
+instruct loadUS2L_immI16(rRegL dst, memory mem, immI16 mask, rFlagsReg cr) %{
+  match(Set dst (ConvI2L (AndI (LoadUS mem) mask)));
+  effect(KILL cr);
+
+  format %{ "movzwq  $dst, $mem\t# ushort/char & 16-bit mask -> long\n\t"
+            "andl    $dst, $mask" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ movzwq(Rdst, $mem$$Address);
+    __ andl(Rdst, $mask$$constant);
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
 // Load Integer
 instruct loadI(rRegI dst, memory mem)
 %{
@@ -6606,6 +6647,43 @@
   ins_pipe(ialu_reg_mem);
 %}
 
+// Load Integer with mask 0xFF into Long Register
+instruct loadI2L_immI_255(rRegL dst, memory mem, immI_255 mask) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+
+  format %{ "movzbq  $dst, $mem\t# int & 0xFF -> long" %}
+  ins_encode %{
+    __ movzbq($dst$$Register, $mem$$Address);
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
+// Load Integer with mask 0xFFFF into Long Register
+instruct loadI2L_immI_65535(rRegL dst, memory mem, immI_65535 mask) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+
+  format %{ "movzwq  $dst, $mem\t# int & 0xFFFF -> long" %}
+  ins_encode %{
+    __ movzwq($dst$$Register, $mem$$Address);
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
+// Load Integer with a 32-bit mask into Long Register
+instruct loadI2L_immI(rRegL dst, memory mem, immI mask, rFlagsReg cr) %{
+  match(Set dst (ConvI2L (AndI (LoadI mem) mask)));
+  effect(KILL cr);
+
+  format %{ "movl    $dst, $mem\t# int & 32-bit mask -> long\n\t"
+            "andl    $dst, $mask" %}
+  ins_encode %{
+    Register Rdst = $dst$$Register;
+    __ movl(Rdst, $mem$$Address);
+    __ andl(Rdst, $mask$$constant);
+  %}
+  ins_pipe(ialu_reg_mem);
+%}
+
 // Load Unsigned Integer into Long Register
 instruct loadUI2L(rRegL dst, memory mem)
 %{
@@ -11673,8 +11751,9 @@
 
   ins_cost(125);
   format %{ "movslq  $dst, $src\t# i2l" %}
-  opcode(0x63); // needs REX.W
-  ins_encode(REX_reg_reg_wide(dst, src), OpcP, reg_reg(dst,src));
+  ins_encode %{
+    __ movslq($dst$$Register, $src$$Register);
+  %}
   ins_pipe(ialu_reg_reg);
 %}
 
--- a/hotspot/src/share/tools/MakeDeps/Database.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/tools/MakeDeps/Database.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-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
@@ -39,7 +39,6 @@
   private HashMap<String,String> platformDepFiles;
   private long threshold;
   private int nOuterFiles;
-  private int nPrecompiledFiles;
   private boolean missingOk;
   private Platform plat;
   /** These allow you to specify files not in the include database
@@ -62,7 +61,6 @@
 
     threshold = t;
     nOuterFiles = 0;
-    nPrecompiledFiles = 0;
     missingOk = false;
     firstFile = null;
     lastFile = null;
@@ -343,7 +341,6 @@
             plat.getGIFileTemplate().getInvDir() +
             list.getName() +
             "\"");
-        nPrecompiledFiles += 1;
       }
     }
     inclFile.println();
@@ -408,22 +405,22 @@
       gd.println();
     }
 
-    if (nPrecompiledFiles > 0) {
-      // write Precompiled_Files = ...
-      gd.println("Precompiled_Files = \\");
-      for (Iterator iter = grandInclude.iterator(); iter.hasNext(); ) {
-        FileList list = (FileList) iter.next();
+    // write Precompiled_Files = ...
+    gd.println("Precompiled_Files = \\");
+    for (Iterator iter = grandInclude.iterator(); iter.hasNext(); ) {
+      FileList list = (FileList) iter.next();
+      if (list.getCount() >= threshold) {
         gd.println(list.getName() + " \\");
         String platformDep = platformDepFiles.get(list.getName());
         if (platformDep != null) {
-            // make sure changes to the platform dependent file will
-            // cause regeneration of the pch file.
-            gd.println(platformDep + " \\");
+          // make sure changes to the platform dependent file will
+          // cause regeneration of the pch file.
+          gd.println(platformDep + " \\");
         }
       }
-      gd.println();
-      gd.println();
     }
+    gd.println();
+    gd.println();
 
     gd.println("DTraced_Files = \\");
     for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
@@ -483,7 +480,6 @@
         }
 
         if (plat.includeGIDependencies()
-            && nPrecompiledFiles > 0
             && anII.getUseGrandInclude()) {
           gd.println("    $(Precompiled_Files) \\");
         }
--- a/hotspot/src/share/vm/adlc/output_h.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/adlc/output_h.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1367,11 +1367,11 @@
         else if (!strcmp(oper->ideal_type(_globalNames), "ConN")) {
           // Access the locally stored constant
           fprintf(fp,"  virtual intptr_t       constant() const {");
-          fprintf(fp,   " return _c0->make_oopptr()->get_con();");
+          fprintf(fp,   " return _c0->get_ptrtype()->get_con();");
           fprintf(fp, " }\n");
           // Generate query to determine if this pointer is an oop
           fprintf(fp,"  virtual bool           constant_is_oop() const {");
-          fprintf(fp,   " return _c0->make_oopptr()->isa_oop_ptr();");
+          fprintf(fp,   " return _c0->get_ptrtype()->isa_oop_ptr();");
           fprintf(fp, " }\n");
         }
         else if (!strcmp(oper->ideal_type(_globalNames), "ConL")) {
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1534,12 +1534,8 @@
   }
 
   if (is_oop) {
-#ifdef PRECISE_CARDMARK
-    // Precise cardmarks don't work
-    post_barrier(LIR_OprFact::address(address), value.result());
-#else
+    // Store to object so mark the card of the header
     post_barrier(object.result(), value.result());
-#endif // PRECISE_CARDMARK
   }
 
   if (is_volatile && os::is_MP()) {
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1233,6 +1233,41 @@
                CardTableModRefBS::card_shift);
   }
 
+  // It takes a region that's not empty (i.e., it has at least one
+  // live object in it and sets its corresponding bit on the region
+  // bitmap to 1. If the region is "starts humongous" it will also set
+  // to 1 the bits on the region bitmap that correspond to its
+  // associated "continues humongous" regions.
+  void set_bit_for_region(HeapRegion* hr) {
+    assert(!hr->continuesHumongous(), "should have filtered those out");
+
+    size_t index = hr->hrs_index();
+    if (!hr->startsHumongous()) {
+      // Normal (non-humongous) case: just set the bit.
+      _region_bm->par_at_put((BitMap::idx_t) index, true);
+    } else {
+      // Starts humongous case: calculate how many regions are part of
+      // this humongous region and then set the bit range. It might
+      // have been a bit more efficient to look at the object that
+      // spans these humongous regions to calculate their number from
+      // the object's size. However, it's a good idea to calculate
+      // this based on the metadata itself, and not the region
+      // contents, so that this code is not aware of what goes into
+      // the humongous regions (in case this changes in the future).
+      G1CollectedHeap* g1h = G1CollectedHeap::heap();
+      size_t end_index = index + 1;
+      while (end_index < g1h->n_regions()) {
+        HeapRegion* chr = g1h->region_at(end_index);
+        if (!chr->continuesHumongous()) {
+          break;
+        }
+        end_index += 1;
+      }
+      _region_bm->par_at_put_range((BitMap::idx_t) index,
+                                   (BitMap::idx_t) end_index, true);
+    }
+  }
+
   bool doHeapRegion(HeapRegion* hr) {
     if (_co_tracker != NULL)
       _co_tracker->update();
@@ -1241,13 +1276,13 @@
       _start_vtime_sec = os::elapsedVTime();
 
     if (hr->continuesHumongous()) {
-      HeapRegion* hum_start = hr->humongous_start_region();
-      // If the head region of the humongous region has been determined
-      // to be alive, then all the tail regions should be marked
-      // such as well.
-      if (_region_bm->at(hum_start->hrs_index())) {
-        _region_bm->par_at_put(hr->hrs_index(), 1);
-      }
+      // We will ignore these here and process them when their
+      // associated "starts humongous" region is processed (see
+      // set_bit_for_heap_region()). Note that we cannot rely on their
+      // associated "starts humongous" region to have their bit set to
+      // 1 since, due to the region chunking in the parallel region
+      // iteration, a "continues humongous" region might be visited
+      // before its associated "starts humongous".
       return false;
     }
 
@@ -1343,14 +1378,14 @@
           intptr_t(uintptr_t(tp) >> CardTableModRefBS::card_shift);
         mark_card_num_range(start_card_num, last_card_num);
         // This definitely means the region has live objects.
-        _region_bm->par_at_put(hr->hrs_index(), 1);
+        set_bit_for_region(hr);
       }
     }
 
     hr->add_to_marked_bytes(marked_bytes);
     // Update the live region bitmap.
     if (marked_bytes > 0) {
-      _region_bm->par_at_put(hr->hrs_index(), 1);
+      set_bit_for_region(hr);
     }
     hr->set_top_at_conc_mark_count(nextTop);
     _tot_live += hr->next_live_bytes();
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -902,6 +902,10 @@
                                     size_t word_size) {
   ResourceMark rm;
 
+  if (PrintHeapAtGC) {
+    Universe::print_heap_before_gc();
+  }
+
   if (full && DisableExplicitGC) {
     gclog_or_tty->print("\n\n\nDisabling Explicit GC\n\n\n");
     return;
@@ -927,7 +931,7 @@
     g1_policy()->record_full_collection_start();
 
     gc_prologue(true);
-    increment_total_collections();
+    increment_total_collections(true /* full gc */);
 
     size_t g1h_prev_used = used();
     assert(used() == recalculate_used(), "Should be equal");
@@ -1066,6 +1070,10 @@
     assert( check_young_list_empty(false, false),
             "young list should be empty at this point");
   }
+
+  if (PrintHeapAtGC) {
+    Universe::print_heap_after_gc();
+  }
 }
 
 void G1CollectedHeap::do_full_collection(bool clear_all_soft_refs) {
@@ -2325,9 +2333,37 @@
   }
 };
 
-void G1CollectedHeap::print() const { print_on(gclog_or_tty); }
+void G1CollectedHeap::print() const { print_on(tty); }
 
 void G1CollectedHeap::print_on(outputStream* st) const {
+  print_on(st, PrintHeapAtGCExtended);
+}
+
+void G1CollectedHeap::print_on(outputStream* st, bool extended) const {
+  st->print(" %-20s", "garbage-first heap");
+  st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K",
+            capacity()/K, used()/K);
+  st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")",
+            _g1_storage.low_boundary(),
+            _g1_storage.high(),
+            _g1_storage.high_boundary());
+  st->cr();
+  st->print("  region size " SIZE_FORMAT "K, ",
+            HeapRegion::GrainBytes/K);
+  size_t young_regions = _young_list->length();
+  st->print(SIZE_FORMAT " young (" SIZE_FORMAT "K), ",
+            young_regions, young_regions * HeapRegion::GrainBytes / K);
+  size_t survivor_regions = g1_policy()->recorded_survivor_regions();
+  st->print(SIZE_FORMAT " survivors (" SIZE_FORMAT "K)",
+            survivor_regions, survivor_regions * HeapRegion::GrainBytes / K);
+  st->cr();
+  perm()->as_gen()->print_on(st);
+  if (extended) {
+    print_on_extended(st);
+  }
+}
+
+void G1CollectedHeap::print_on_extended(outputStream* st) const {
   PrintRegionClosure blk(st);
   _hrs->iterate(&blk);
 }
@@ -2408,10 +2444,6 @@
 }
 
 void G1CollectedHeap::gc_prologue(bool full /* Ignored */) {
-  if (PrintHeapAtGC){
-    gclog_or_tty->print_cr(" {Heap before GC collections=%d:", total_collections());
-    Universe::print();
-  }
   assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer");
   // Call allocation profiler
   AllocationProfiler::iterate_since_last_gc();
@@ -2425,12 +2457,6 @@
   // is set.
   COMPILER2_PRESENT(assert(DerivedPointerTable::is_empty(),
                         "derived pointer present"));
-
-  if (PrintHeapAtGC){
-    gclog_or_tty->print_cr(" Heap after GC collections=%d:", total_collections());
-    Universe::print();
-    gclog_or_tty->print("} ");
-  }
 }
 
 void G1CollectedHeap::do_collection_pause() {
@@ -2559,241 +2585,250 @@
 
 void
 G1CollectedHeap::do_collection_pause_at_safepoint() {
-  char verbose_str[128];
-  sprintf(verbose_str, "GC pause ");
-  if (g1_policy()->in_young_gc_mode()) {
-    if (g1_policy()->full_young_gcs())
-      strcat(verbose_str, "(young)");
-    else
-      strcat(verbose_str, "(partial)");
-  }
-  if (g1_policy()->should_initiate_conc_mark())
-    strcat(verbose_str, " (initial-mark)");
-
-  GCCauseSetter x(this, GCCause::_g1_inc_collection_pause);
-
-  // if PrintGCDetails is on, we'll print long statistics information
-  // in the collector policy code, so let's not print this as the output
-  // is messy if we do.
-  gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
-  TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
-  TraceTime t(verbose_str, PrintGC && !PrintGCDetails, true, gclog_or_tty);
-
-  ResourceMark rm;
-  assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
-  assert(Thread::current() == VMThread::vm_thread(), "should be in vm thread");
-  guarantee(!is_gc_active(), "collection is not reentrant");
-  assert(regions_accounted_for(), "Region leakage!");
-
-  increment_gc_time_stamp();
-
-  if (g1_policy()->in_young_gc_mode()) {
-    assert(check_young_list_well_formed(),
-                "young list should be well formed");
-  }
-
-  if (GC_locker::is_active()) {
-    return; // GC is disabled (e.g. JNI GetXXXCritical operation)
-  }
-
-  bool abandoned = false;
-  { // Call to jvmpi::post_class_unload_events must occur outside of active GC
-    IsGCActiveMark x;
-
-    gc_prologue(false);
-    increment_total_collections();
+  if (PrintHeapAtGC) {
+    Universe::print_heap_before_gc();
+  }
+
+  {
+    char verbose_str[128];
+    sprintf(verbose_str, "GC pause ");
+    if (g1_policy()->in_young_gc_mode()) {
+      if (g1_policy()->full_young_gcs())
+        strcat(verbose_str, "(young)");
+      else
+        strcat(verbose_str, "(partial)");
+    }
+    if (g1_policy()->should_initiate_conc_mark())
+      strcat(verbose_str, " (initial-mark)");
+
+    GCCauseSetter x(this, GCCause::_g1_inc_collection_pause);
+
+    // if PrintGCDetails is on, we'll print long statistics information
+    // in the collector policy code, so let's not print this as the output
+    // is messy if we do.
+    gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
+    TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
+    TraceTime t(verbose_str, PrintGC && !PrintGCDetails, true, gclog_or_tty);
+
+    ResourceMark rm;
+    assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
+    assert(Thread::current() == VMThread::vm_thread(), "should be in vm thread");
+    guarantee(!is_gc_active(), "collection is not reentrant");
+    assert(regions_accounted_for(), "Region leakage!");
+
+    increment_gc_time_stamp();
+
+    if (g1_policy()->in_young_gc_mode()) {
+      assert(check_young_list_well_formed(),
+             "young list should be well formed");
+    }
+
+    if (GC_locker::is_active()) {
+      return; // GC is disabled (e.g. JNI GetXXXCritical operation)
+    }
+
+    bool abandoned = false;
+    { // Call to jvmpi::post_class_unload_events must occur outside of active GC
+      IsGCActiveMark x;
+
+      gc_prologue(false);
+      increment_total_collections(false /* full gc */);
 
 #if G1_REM_SET_LOGGING
-    gclog_or_tty->print_cr("\nJust chose CS, heap:");
-    print();
+      gclog_or_tty->print_cr("\nJust chose CS, heap:");
+      print();
 #endif
 
-    if (VerifyBeforeGC && total_collections() >= VerifyGCStartAt) {
-      HandleMark hm;  // Discard invalid handles created during verification
-      prepare_for_verify();
-      gclog_or_tty->print(" VerifyBeforeGC:");
-      Universe::verify(false);
-    }
-
-    COMPILER2_PRESENT(DerivedPointerTable::clear());
-
-    // We want to turn off ref discovery, if necessary, and turn it back on
-    // on again later if we do.
-    bool was_enabled = ref_processor()->discovery_enabled();
-    if (was_enabled) ref_processor()->disable_discovery();
-
-    // Forget the current alloc region (we might even choose it to be part
-    // of the collection set!).
-    abandon_cur_alloc_region();
-
-    // The elapsed time induced by the start time below deliberately elides
-    // the possible verification above.
-    double start_time_sec = os::elapsedTime();
-    GCOverheadReporter::recordSTWStart(start_time_sec);
-    size_t start_used_bytes = used();
-    if (!G1ConcMark) {
-      do_sync_mark();
-    }
-
-    g1_policy()->record_collection_pause_start(start_time_sec,
-                                               start_used_bytes);
-
-    guarantee(_in_cset_fast_test == NULL, "invariant");
-    guarantee(_in_cset_fast_test_base == NULL, "invariant");
-    _in_cset_fast_test_length = max_regions();
-    _in_cset_fast_test_base =
+      if (VerifyBeforeGC && total_collections() >= VerifyGCStartAt) {
+        HandleMark hm;  // Discard invalid handles created during verification
+        prepare_for_verify();
+        gclog_or_tty->print(" VerifyBeforeGC:");
+        Universe::verify(false);
+      }
+
+      COMPILER2_PRESENT(DerivedPointerTable::clear());
+
+      // We want to turn off ref discovery, if necessary, and turn it back on
+      // on again later if we do.
+      bool was_enabled = ref_processor()->discovery_enabled();
+      if (was_enabled) ref_processor()->disable_discovery();
+
+      // Forget the current alloc region (we might even choose it to be part
+      // of the collection set!).
+      abandon_cur_alloc_region();
+
+      // The elapsed time induced by the start time below deliberately elides
+      // the possible verification above.
+      double start_time_sec = os::elapsedTime();
+      GCOverheadReporter::recordSTWStart(start_time_sec);
+      size_t start_used_bytes = used();
+      if (!G1ConcMark) {
+        do_sync_mark();
+      }
+
+      g1_policy()->record_collection_pause_start(start_time_sec,
+                                                 start_used_bytes);
+
+      guarantee(_in_cset_fast_test == NULL, "invariant");
+      guarantee(_in_cset_fast_test_base == NULL, "invariant");
+      _in_cset_fast_test_length = max_regions();
+      _in_cset_fast_test_base =
                              NEW_C_HEAP_ARRAY(bool, _in_cset_fast_test_length);
-    memset(_in_cset_fast_test_base, false,
+      memset(_in_cset_fast_test_base, false,
                                      _in_cset_fast_test_length * sizeof(bool));
-    // We're biasing _in_cset_fast_test to avoid subtracting the
-    // beginning of the heap every time we want to index; basically
-    // it's the same with what we do with the card table.
-    _in_cset_fast_test = _in_cset_fast_test_base -
+      // We're biasing _in_cset_fast_test to avoid subtracting the
+      // beginning of the heap every time we want to index; basically
+      // it's the same with what we do with the card table.
+      _in_cset_fast_test = _in_cset_fast_test_base -
               ((size_t) _g1_reserved.start() >> HeapRegion::LogOfHRGrainBytes);
 
 #if SCAN_ONLY_VERBOSE
-    _young_list->print();
+      _young_list->print();
 #endif // SCAN_ONLY_VERBOSE
 
-    if (g1_policy()->should_initiate_conc_mark()) {
-      concurrent_mark()->checkpointRootsInitialPre();
-    }
-    save_marks();
-
-    // We must do this before any possible evacuation that should propagate
-    // marks.
-    if (mark_in_progress()) {
-      double start_time_sec = os::elapsedTime();
-
-      _cm->drainAllSATBBuffers();
-      double finish_mark_ms = (os::elapsedTime() - start_time_sec) * 1000.0;
-      g1_policy()->record_satb_drain_time(finish_mark_ms);
-
-    }
-    // Record the number of elements currently on the mark stack, so we
-    // only iterate over these.  (Since evacuation may add to the mark
-    // stack, doing more exposes race conditions.)  If no mark is in
-    // progress, this will be zero.
-    _cm->set_oops_do_bound();
-
-    assert(regions_accounted_for(), "Region leakage.");
-
-    if (mark_in_progress())
-      concurrent_mark()->newCSet();
-
-    // Now choose the CS.
-    g1_policy()->choose_collection_set();
-
-    // We may abandon a pause if we find no region that will fit in the MMU
-    // pause.
-    bool abandoned = (g1_policy()->collection_set() == NULL);
-
-    // Nothing to do if we were unable to choose a collection set.
-    if (!abandoned) {
+      if (g1_policy()->should_initiate_conc_mark()) {
+        concurrent_mark()->checkpointRootsInitialPre();
+      }
+      save_marks();
+
+      // We must do this before any possible evacuation that should propagate
+      // marks.
+      if (mark_in_progress()) {
+        double start_time_sec = os::elapsedTime();
+
+        _cm->drainAllSATBBuffers();
+        double finish_mark_ms = (os::elapsedTime() - start_time_sec) * 1000.0;
+        g1_policy()->record_satb_drain_time(finish_mark_ms);
+      }
+      // Record the number of elements currently on the mark stack, so we
+      // only iterate over these.  (Since evacuation may add to the mark
+      // stack, doing more exposes race conditions.)  If no mark is in
+      // progress, this will be zero.
+      _cm->set_oops_do_bound();
+
+      assert(regions_accounted_for(), "Region leakage.");
+
+      if (mark_in_progress())
+        concurrent_mark()->newCSet();
+
+      // Now choose the CS.
+      g1_policy()->choose_collection_set();
+
+      // We may abandon a pause if we find no region that will fit in the MMU
+      // pause.
+      bool abandoned = (g1_policy()->collection_set() == NULL);
+
+      // Nothing to do if we were unable to choose a collection set.
+      if (!abandoned) {
 #if G1_REM_SET_LOGGING
-      gclog_or_tty->print_cr("\nAfter pause, heap:");
-      print();
+        gclog_or_tty->print_cr("\nAfter pause, heap:");
+        print();
 #endif
 
-      setup_surviving_young_words();
-
-      // Set up the gc allocation regions.
-      get_gc_alloc_regions();
-
-      // Actually do the work...
-      evacuate_collection_set();
-      free_collection_set(g1_policy()->collection_set());
-      g1_policy()->clear_collection_set();
-
-      FREE_C_HEAP_ARRAY(bool, _in_cset_fast_test_base);
-      // this is more for peace of mind; we're nulling them here and
-      // we're expecting them to be null at the beginning of the next GC
-      _in_cset_fast_test = NULL;
-      _in_cset_fast_test_base = NULL;
-
-      release_gc_alloc_regions(false /* totally */);
-
-      cleanup_surviving_young_words();
-
-      if (g1_policy()->in_young_gc_mode()) {
-        _young_list->reset_sampled_info();
-        assert(check_young_list_empty(true),
-               "young list should be empty");
+        setup_surviving_young_words();
+
+        // Set up the gc allocation regions.
+        get_gc_alloc_regions();
+
+        // Actually do the work...
+        evacuate_collection_set();
+        free_collection_set(g1_policy()->collection_set());
+        g1_policy()->clear_collection_set();
+
+        FREE_C_HEAP_ARRAY(bool, _in_cset_fast_test_base);
+        // this is more for peace of mind; we're nulling them here and
+        // we're expecting them to be null at the beginning of the next GC
+        _in_cset_fast_test = NULL;
+        _in_cset_fast_test_base = NULL;
+
+        release_gc_alloc_regions(false /* totally */);
+
+        cleanup_surviving_young_words();
+
+        if (g1_policy()->in_young_gc_mode()) {
+          _young_list->reset_sampled_info();
+          assert(check_young_list_empty(true),
+                 "young list should be empty");
 
 #if SCAN_ONLY_VERBOSE
-        _young_list->print();
+          _young_list->print();
 #endif // SCAN_ONLY_VERBOSE
 
-        g1_policy()->record_survivor_regions(_young_list->survivor_length(),
-                                             _young_list->first_survivor_region(),
-                                             _young_list->last_survivor_region());
-        _young_list->reset_auxilary_lists();
+          g1_policy()->record_survivor_regions(_young_list->survivor_length(),
+                                          _young_list->first_survivor_region(),
+                                          _young_list->last_survivor_region());
+          _young_list->reset_auxilary_lists();
+        }
+      } else {
+        COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
       }
-    } else {
-      COMPILER2_PRESENT(DerivedPointerTable::update_pointers());
-    }
-
-    if (evacuation_failed()) {
-      _summary_bytes_used = recalculate_used();
-    } else {
-      // The "used" of the the collection set have already been subtracted
-      // when they were freed.  Add in the bytes evacuated.
-      _summary_bytes_used += g1_policy()->bytes_in_to_space();
-    }
-
-    if (g1_policy()->in_young_gc_mode() &&
-        g1_policy()->should_initiate_conc_mark()) {
-      concurrent_mark()->checkpointRootsInitialPost();
-      set_marking_started();
-      doConcurrentMark();
-    }
+
+      if (evacuation_failed()) {
+        _summary_bytes_used = recalculate_used();
+      } else {
+        // The "used" of the the collection set have already been subtracted
+        // when they were freed.  Add in the bytes evacuated.
+        _summary_bytes_used += g1_policy()->bytes_in_to_space();
+      }
+
+      if (g1_policy()->in_young_gc_mode() &&
+          g1_policy()->should_initiate_conc_mark()) {
+        concurrent_mark()->checkpointRootsInitialPost();
+        set_marking_started();
+        doConcurrentMark();
+      }
 
 #if SCAN_ONLY_VERBOSE
-    _young_list->print();
+      _young_list->print();
 #endif // SCAN_ONLY_VERBOSE
 
-    double end_time_sec = os::elapsedTime();
-    double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS;
-    g1_policy()->record_pause_time_ms(pause_time_ms);
-    GCOverheadReporter::recordSTWEnd(end_time_sec);
-    g1_policy()->record_collection_pause_end(abandoned);
-
-    assert(regions_accounted_for(), "Region leakage.");
-
-    if (VerifyAfterGC && total_collections() >= VerifyGCStartAt) {
-      HandleMark hm;  // Discard invalid handles created during verification
-      gclog_or_tty->print(" VerifyAfterGC:");
-      prepare_for_verify();
-      Universe::verify(false);
-    }
-
-    if (was_enabled) ref_processor()->enable_discovery();
-
-    {
-      size_t expand_bytes = g1_policy()->expansion_amount();
-      if (expand_bytes > 0) {
-        size_t bytes_before = capacity();
-        expand(expand_bytes);
+      double end_time_sec = os::elapsedTime();
+      double pause_time_ms = (end_time_sec - start_time_sec) * MILLIUNITS;
+      g1_policy()->record_pause_time_ms(pause_time_ms);
+      GCOverheadReporter::recordSTWEnd(end_time_sec);
+      g1_policy()->record_collection_pause_end(abandoned);
+
+      assert(regions_accounted_for(), "Region leakage.");
+
+      if (VerifyAfterGC && total_collections() >= VerifyGCStartAt) {
+        HandleMark hm;  // Discard invalid handles created during verification
+        gclog_or_tty->print(" VerifyAfterGC:");
+        prepare_for_verify();
+        Universe::verify(false);
       }
-    }
-
-    if (mark_in_progress()) {
-      concurrent_mark()->update_g1_committed();
-    }
+
+      if (was_enabled) ref_processor()->enable_discovery();
+
+      {
+        size_t expand_bytes = g1_policy()->expansion_amount();
+        if (expand_bytes > 0) {
+          size_t bytes_before = capacity();
+          expand(expand_bytes);
+        }
+      }
+
+      if (mark_in_progress()) {
+        concurrent_mark()->update_g1_committed();
+      }
 
 #ifdef TRACESPINNING
-    ParallelTaskTerminator::print_termination_counts();
+      ParallelTaskTerminator::print_termination_counts();
 #endif
 
-    gc_epilogue(false);
-  }
-
-  assert(verify_region_lists(), "Bad region lists.");
-
-  if (ExitAfterGCNum > 0 && total_collections() == ExitAfterGCNum) {
-    gclog_or_tty->print_cr("Stopping after GC #%d", ExitAfterGCNum);
-    print_tracing_info();
-    vm_exit(-1);
+      gc_epilogue(false);
+    }
+
+    assert(verify_region_lists(), "Bad region lists.");
+
+    if (ExitAfterGCNum > 0 && total_collections() == ExitAfterGCNum) {
+      gclog_or_tty->print_cr("Stopping after GC #%d", ExitAfterGCNum);
+      print_tracing_info();
+      vm_exit(-1);
+    }
+  }
+
+  if (PrintHeapAtGC) {
+    Universe::print_heap_after_gc();
   }
 }
 
@@ -5357,7 +5392,7 @@
   assert(_free_region_list == NULL, "Postcondition of loop.");
   if (_free_region_list_size != 0) {
     gclog_or_tty->print_cr("Size is %d.", _free_region_list_size);
-    print();
+    print_on(gclog_or_tty, true /* extended */);
   }
   assert(_free_region_list_size == 0, "Postconditions of loop.");
 }
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1061,8 +1061,14 @@
 
   // Override; it uses the "prev" marking information
   virtual void verify(bool allow_dirty, bool silent);
+  // Default behavior by calling print(tty);
   virtual void print() const;
+  // This calls print_on(st, PrintHeapAtGCExtended).
   virtual void print_on(outputStream* st) const;
+  // If extended is true, it will print out information for all
+  // regions in the heap by calling print_on_extended(st).
+  virtual void print_on(outputStream* st, bool extended) const;
+  virtual void print_on_extended(outputStream* st) const;
 
   virtual void print_gc_threads_on(outputStream* st) const;
   virtual void gc_threads_do(ThreadClosure* tc) const;
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1097,6 +1097,10 @@
     _recorded_survivor_tail    = tail;
   }
 
+  size_t recorded_survivor_regions() {
+    return _recorded_survivor_regions;
+  }
+
   void record_thread_age_table(ageTable* age_table)
   {
     _survivors_age_table.merge_par(age_table);
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -703,7 +703,7 @@
   }
   if (vl_cl.failures()) {
     gclog_or_tty->print_cr("Heap:");
-    G1CollectedHeap::heap()->print();
+    G1CollectedHeap::heap()->print_on(gclog_or_tty, true /* extended */);
     gclog_or_tty->print_cr("");
   }
   if (VerifyDuringGC &&
--- a/hotspot/src/share/vm/opto/block.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/block.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -357,6 +357,9 @@
 #ifndef PRODUCT
   , _trace_opto_pipelining(TraceOptoPipelining || C->method_has_option("TraceOptoPipelining"))
 #endif
+#ifdef ASSERT
+  , _raw_oops(a)
+#endif
 {
   ResourceMark rm;
   // I'll need a few machine-specific GotoNodes.  Make an Ideal GotoNode,
--- a/hotspot/src/share/vm/opto/block.hpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/block.hpp	Tue Jul 21 13:02:23 2009 -0700
@@ -380,6 +380,10 @@
   bool _trace_opto_pipelining;  // tracing flag
 #endif
 
+#ifdef ASSERT
+  Unique_Node_List _raw_oops;
+#endif
+
   // Build dominators
   void Dominators();
 
--- a/hotspot/src/share/vm/opto/buildOopMap.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/buildOopMap.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -74,9 +74,11 @@
   // this block.
   Block *_b;                    // Block for this struct
   OopFlow *_next;               // Next free OopFlow
+                                // or NULL if dead/conflict
+  Compile* C;
 
-  OopFlow( short *callees, Node **defs ) : _callees(callees), _defs(defs),
-    _b(NULL), _next(NULL) { }
+  OopFlow( short *callees, Node **defs, Compile* c ) : _callees(callees), _defs(defs),
+    _b(NULL), _next(NULL), C(c) { }
 
   // Given reaching-defs for this block start, compute it for this block end
   void compute_reach( PhaseRegAlloc *regalloc, int max_reg, Dict *safehash );
@@ -88,7 +90,7 @@
   void clone( OopFlow *flow, int max_size);
 
   // Make a new OopFlow from scratch
-  static OopFlow *make( Arena *A, int max_size );
+  static OopFlow *make( Arena *A, int max_size, Compile* C );
 
   // Build an oopmap from the current flow info
   OopMap *build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, int* live );
@@ -180,11 +182,11 @@
 }
 
 //------------------------------make-------------------------------------------
-OopFlow *OopFlow::make( Arena *A, int max_size ) {
+OopFlow *OopFlow::make( Arena *A, int max_size, Compile* C ) {
   short *callees = NEW_ARENA_ARRAY(A,short,max_size+1);
   Node **defs    = NEW_ARENA_ARRAY(A,Node*,max_size+1);
   debug_only( memset(defs,0,(max_size+1)*sizeof(Node*)) );
-  OopFlow *flow = new (A) OopFlow(callees+1, defs+1);
+  OopFlow *flow = new (A) OopFlow(callees+1, defs+1, C);
   assert( &flow->_callees[OptoReg::Bad] == callees, "Ok to index at OptoReg::Bad" );
   assert( &flow->_defs   [OptoReg::Bad] == defs   , "Ok to index at OptoReg::Bad" );
   return flow;
@@ -288,7 +290,7 @@
               m = m->in(idx);
             }
           }
-         guarantee( 0, "must find derived/base pair" );
+          guarantee( 0, "must find derived/base pair" );
         }
       found: ;
         Node *base = n->in(i+1); // Base is other half of pair
@@ -347,6 +349,13 @@
     } else {
       // Other - some reaching non-oop value
       omap->set_value( r);
+#ifdef ASSERT
+      if( t->isa_rawptr() && C->cfg()->_raw_oops.member(def) ) {
+        def->dump();
+        n->dump();
+        assert(false, "there should be a oop in OopMap instead of a live raw oop at safepoint");
+      }
+#endif
     }
 
   }
@@ -562,7 +571,7 @@
 
   // Do the first block 'by hand' to prime the worklist
   Block *entry = _cfg->_blocks[1];
-  OopFlow *rootflow = OopFlow::make(A,max_reg);
+  OopFlow *rootflow = OopFlow::make(A,max_reg,this);
   // Initialize to 'bottom' (not 'top')
   memset( rootflow->_callees, OptoReg::Bad, max_reg*sizeof(short) );
   memset( rootflow->_defs   ,            0, max_reg*sizeof(Node*) );
@@ -628,7 +637,7 @@
       // Carry it forward.
     } else {                    // Draw a new OopFlow from the freelist
       if( !free_list )
-        free_list = OopFlow::make(A,max_reg);
+        free_list = OopFlow::make(A,max_reg,C);
       flow = free_list;
       assert( flow->_b == NULL, "oopFlow is not free" );
       free_list = flow->_next;
--- a/hotspot/src/share/vm/opto/c2compiler.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -104,7 +104,9 @@
     initialize();
   }
   bool subsume_loads = true;
-  bool do_escape_analysis = DoEscapeAnalysis;
+  bool do_escape_analysis = DoEscapeAnalysis &&
+                            !(env->jvmti_can_hotswap_or_post_breakpoint() ||
+                              env->jvmti_can_examine_or_deopt_anywhere());
   while (!env->failing()) {
     // Attempt to compile while subsuming loads into machine instructions.
     Compile C(env, this, target, entry_bci, subsume_loads, do_escape_analysis);
--- a/hotspot/src/share/vm/opto/gcm.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/gcm.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1130,6 +1130,9 @@
         Node *def = self->in(1);
         if (def != NULL && def->bottom_type()->base() == Type::RawPtr) {
           early->add_inst(self);
+#ifdef ASSERT
+          _raw_oops.push(def);
+#endif
           continue;
         }
         break;
--- a/hotspot/src/share/vm/opto/graphKit.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/graphKit.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1378,7 +1378,7 @@
                            Node* adr,
                            uint adr_idx,
                            Node *val,
-                           const Type* val_type,
+                           const TypeOopPtr* val_type,
                            BasicType bt) {
   BarrierSet* bs = Universe::heap()->barrier_set();
   set_control(ctl);
@@ -1436,7 +1436,7 @@
                                     Node* adr,
                                     const TypePtr* adr_type,
                                     Node *val,
-                                    const Type* val_type,
+                                    const TypeOopPtr* val_type,
                                     BasicType bt) {
   uint adr_idx = C->get_alias_index(adr_type);
   Node* store;
@@ -1451,7 +1451,7 @@
                                    Node* adr,
                                    const TypePtr* adr_type,
                                    Node *val,
-                                   const Type* val_type,
+                                   const TypeOopPtr* val_type,
                                    BasicType bt) {
   uint adr_idx = C->get_alias_index(adr_type);
   Node* store;
@@ -1466,12 +1466,29 @@
                                      Node* adr,
                                      const TypePtr* adr_type,
                                      Node *val,
-                                     const Type* val_type,
                                      BasicType bt) {
-  uint adr_idx = C->get_alias_index(adr_type);
-  Node* store;
+  Compile::AliasType* at = C->alias_type(adr_type);
+  const TypeOopPtr* val_type = NULL;
+  if (adr_type->isa_instptr()) {
+    if (at->field() != NULL) {
+      // known field.  This code is a copy of the do_put_xxx logic.
+      ciField* field = at->field();
+      if (!field->type()->is_loaded()) {
+        val_type = TypeInstPtr::BOTTOM;
+      } else {
+        val_type = TypeOopPtr::make_from_klass(field->type()->as_klass());
+      }
+    }
+  } else if (adr_type->isa_aryptr()) {
+    val_type = adr_type->is_aryptr()->elem()->make_oopptr();
+  }
+  if (val_type == NULL) {
+    val_type = TypeInstPtr::BOTTOM;
+  }
+
+  uint adr_idx = at->index();
   pre_barrier(ctl, obj, adr, adr_idx, val, val_type, bt);
-  store = store_to_memory(control(), adr, val, bt, adr_idx);
+  Node* store = store_to_memory(control(), adr, val, bt, adr_idx);
   post_barrier(control(), store, obj, adr, adr_idx, val, bt, true);
   return store;
 }
@@ -3202,7 +3219,7 @@
                                     Node* adr,
                                     uint alias_idx,
                                     Node* val,
-                                    const Type* val_type,
+                                    const TypeOopPtr* val_type,
                                     BasicType bt) {
   IdealKit ideal(gvn(), control(), merged_memory(), true);
 #define __ ideal.
--- a/hotspot/src/share/vm/opto/graphKit.hpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/graphKit.hpp	Tue Jul 21 13:02:23 2009 -0700
@@ -454,7 +454,7 @@
                             Node* adr,  // actual adress to store val at
                             const TypePtr* adr_type,
                             Node* val,
-                            const Type* val_type,
+                            const TypeOopPtr* val_type,
                             BasicType bt);
 
   Node* store_oop_to_array(Node* ctl,
@@ -462,7 +462,7 @@
                            Node* adr,  // actual adress to store val at
                            const TypePtr* adr_type,
                            Node* val,
-                           const Type* val_type,
+                           const TypeOopPtr* val_type,
                            BasicType bt);
 
   // Could be an array or object we don't know at compile time (unsafe ref.)
@@ -471,12 +471,11 @@
                              Node* adr,  // actual adress to store val at
                              const TypePtr* adr_type,
                              Node* val,
-                             const Type* val_type,
                              BasicType bt);
 
   // For the few case where the barriers need special help
   void pre_barrier(Node* ctl, Node* obj, Node* adr, uint adr_idx,
-                   Node* val, const Type* val_type, BasicType bt);
+                   Node* val, const TypeOopPtr* val_type, BasicType bt);
 
   void post_barrier(Node* ctl, Node* store, Node* obj, Node* adr, uint adr_idx,
                     Node* val, BasicType bt, bool use_precise);
@@ -599,7 +598,7 @@
                             Node* adr,
                             uint alias_idx,
                             Node* val,
-                            const Type* val_type,
+                            const TypeOopPtr* val_type,
                             BasicType bt);
 
   void g1_write_barrier_post(Node* store,
--- a/hotspot/src/share/vm/opto/library_call.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -165,6 +165,7 @@
   bool inline_native_getLength();
   bool inline_array_copyOf(bool is_copyOfRange);
   bool inline_array_equals();
+  void copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark);
   bool inline_native_clone(bool is_virtual);
   bool inline_native_Reflection_getCallerClass();
   bool inline_native_AtomicLong_get();
@@ -181,7 +182,6 @@
                           Node* src,  Node* src_offset,
                           Node* dest, Node* dest_offset,
                           Node* copy_length,
-                          int nargs,  // arguments on stack for debug info
                           bool disjoint_bases = false,
                           bool length_never_negative = false,
                           RegionNode* slow_region = NULL);
@@ -202,17 +202,16 @@
   void generate_slow_arraycopy(const TypePtr* adr_type,
                                Node* src,  Node* src_offset,
                                Node* dest, Node* dest_offset,
-                               Node* copy_length,
-                               int nargs);
+                               Node* copy_length);
   Node* generate_checkcast_arraycopy(const TypePtr* adr_type,
                                      Node* dest_elem_klass,
                                      Node* src,  Node* src_offset,
                                      Node* dest, Node* dest_offset,
-                                     Node* copy_length, int nargs);
+                                     Node* copy_length);
   Node* generate_generic_arraycopy(const TypePtr* adr_type,
                                    Node* src,  Node* src_offset,
                                    Node* dest, Node* dest_offset,
-                                   Node* copy_length, int nargs);
+                                   Node* copy_length);
   void generate_unchecked_arraycopy(const TypePtr* adr_type,
                                     BasicType basic_elem_type,
                                     bool disjoint_bases,
@@ -2178,9 +2177,8 @@
       // Possibly an oop being stored to Java heap or native memory
       if (!TypePtr::NULL_PTR->higher_equal(_gvn.type(heap_base_oop))) {
         // oop to Java heap.
-        (void) store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, val->bottom_type(), type);
+        (void) store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type);
       } else {
-
         // We can't tell at compile time if we are storing in the Java heap or outside
         // of it. So we need to emit code to conditionally do the proper type of
         // store.
@@ -2189,7 +2187,7 @@
         kit.declares_done();
         // QQQ who knows what probability is here??
         kit.if_then(heap_base_oop, BoolTest::ne, null(), PROB_UNLIKELY(0.999)); {
-          (void) store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, val->bottom_type(), type);
+          (void) store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type);
         } kit.else_(); {
           (void) store_to_memory(control(), adr, val, type, adr_type, is_volatile);
         } kit.end_if();
@@ -2394,7 +2392,7 @@
   case T_OBJECT:
      // reference stores need a store barrier.
     // (They don't if CAS fails, but it isn't worth checking.)
-    pre_barrier(control(), base, adr, alias_idx, newval, value_type, T_OBJECT);
+    pre_barrier(control(), base, adr, alias_idx, newval, value_type->make_oopptr(), T_OBJECT);
 #ifdef _LP64
     if (adr->bottom_type()->is_ptr_to_narrowoop()) {
       Node *newval_enc = _gvn.transform(new (C, 2) EncodePNode(newval, newval->bottom_type()->make_narrowoop()));
@@ -2489,7 +2487,7 @@
   bool require_atomic_access = true;
   Node* store;
   if (type == T_OBJECT) // reference stores need a store barrier.
-    store = store_oop_to_unknown(control(), base, adr, adr_type, val, value_type, type);
+    store = store_oop_to_unknown(control(), base, adr, adr_type, val, type);
   else {
     store = store_to_memory(control(), adr, val, type, adr_type, require_atomic_access);
   }
@@ -3230,7 +3228,8 @@
     Node* orig_tail = _gvn.transform( new(C, 3) SubINode(orig_length, start) );
     Node* moved = generate_min_max(vmIntrinsics::_min, orig_tail, length);
 
-    Node* newcopy = new_array(klass_node, length, nargs);
+    const bool raw_mem_only = true;
+    Node* newcopy = new_array(klass_node, length, nargs, raw_mem_only);
 
     // Generate a direct call to the right arraycopy function(s).
     // We know the copy is disjoint but we might not know if the
@@ -3241,7 +3240,7 @@
     bool length_never_negative = true;
     generate_arraycopy(TypeAryPtr::OOPS, T_OBJECT,
                        original, start, newcopy, intcon(0), moved,
-                       nargs, disjoint_bases, length_never_negative);
+                       disjoint_bases, length_never_negative);
 
     push(newcopy);
   }
@@ -3883,6 +3882,98 @@
   return true;
 }
 
+//------------------------clone_coping-----------------------------------
+// Helper function for inline_native_clone.
+void LibraryCallKit::copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark) {
+  assert(obj_size != NULL, "");
+  Node* raw_obj = alloc_obj->in(1);
+  assert(alloc_obj->is_CheckCastPP() && raw_obj->is_Proj() && raw_obj->in(0)->is_Allocate(), "");
+
+  if (ReduceBulkZeroing) {
+    // We will be completely responsible for initializing this object -
+    // mark Initialize node as complete.
+    AllocateNode* alloc = AllocateNode::Ideal_allocation(alloc_obj, &_gvn);
+    // The object was just allocated - there should be no any stores!
+    guarantee(alloc != NULL && alloc->maybe_set_complete(&_gvn), "");
+  }
+
+  // Cast to Object for arraycopy.
+  // We can't use the original CheckCastPP since it should be moved
+  // after the arraycopy to prevent stores flowing above it.
+  Node* new_obj = new(C, 2) CheckCastPPNode(alloc_obj->in(0), raw_obj,
+                                            TypeInstPtr::NOTNULL);
+  new_obj = _gvn.transform(new_obj);
+  // Substitute in the locally valid dest_oop.
+  replace_in_map(alloc_obj, new_obj);
+
+  // Copy the fastest available way.
+  // TODO: generate fields copies for small objects instead.
+  Node* src  = obj;
+  Node* dest = new_obj;
+  Node* size = _gvn.transform(obj_size);
+
+  // Exclude the header but include array length to copy by 8 bytes words.
+  // Can't use base_offset_in_bytes(bt) since basic type is unknown.
+  int base_off = is_array ? arrayOopDesc::length_offset_in_bytes() :
+                            instanceOopDesc::base_offset_in_bytes();
+  // base_off:
+  // 8  - 32-bit VM
+  // 12 - 64-bit VM, compressed oops
+  // 16 - 64-bit VM, normal oops
+  if (base_off % BytesPerLong != 0) {
+    assert(UseCompressedOops, "");
+    if (is_array) {
+      // Exclude length to copy by 8 bytes words.
+      base_off += sizeof(int);
+    } else {
+      // Include klass to copy by 8 bytes words.
+      base_off = instanceOopDesc::klass_offset_in_bytes();
+    }
+    assert(base_off % BytesPerLong == 0, "expect 8 bytes alignment");
+  }
+  src  = basic_plus_adr(src,  base_off);
+  dest = basic_plus_adr(dest, base_off);
+
+  // Compute the length also, if needed:
+  Node* countx = size;
+  countx = _gvn.transform( new (C, 3) SubXNode(countx, MakeConX(base_off)) );
+  countx = _gvn.transform( new (C, 3) URShiftXNode(countx, intcon(LogBytesPerLong) ));
+
+  const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
+  bool disjoint_bases = true;
+  generate_unchecked_arraycopy(raw_adr_type, T_LONG, disjoint_bases,
+                               src, NULL, dest, NULL, countx);
+
+  // If necessary, emit some card marks afterwards.  (Non-arrays only.)
+  if (card_mark) {
+    assert(!is_array, "");
+    // Put in store barrier for any and all oops we are sticking
+    // into this object.  (We could avoid this if we could prove
+    // that the object type contains no oop fields at all.)
+    Node* no_particular_value = NULL;
+    Node* no_particular_field = NULL;
+    int raw_adr_idx = Compile::AliasIdxRaw;
+    post_barrier(control(),
+                 memory(raw_adr_type),
+                 new_obj,
+                 no_particular_field,
+                 raw_adr_idx,
+                 no_particular_value,
+                 T_OBJECT,
+                 false);
+  }
+
+  // Move the original CheckCastPP after arraycopy.
+  _gvn.hash_delete(alloc_obj);
+  alloc_obj->set_req(0, control());
+  // Replace raw memory edge with new CheckCastPP to have a live oop
+  // at safepoints instead of raw value.
+  assert(new_obj->is_CheckCastPP() && new_obj->in(1) == alloc_obj->in(1), "sanity");
+  alloc_obj->set_req(1, new_obj);    // cast to the original type
+  _gvn.hash_find_insert(alloc_obj);  // put back into GVN table
+  // Restore in the locally valid dest_oop.
+  replace_in_map(new_obj, alloc_obj);
+}
 
 //------------------------inline_native_clone----------------------------
 // Here are the simple edge cases:
@@ -3917,8 +4008,9 @@
   // paths into result_reg:
   enum {
     _slow_path = 1,     // out-of-line call to clone method (virtual or not)
-    _objArray_path,     // plain allocation, plus arrayof_oop_arraycopy
-    _fast_path,         // plain allocation, plus a CopyArray operation
+    _objArray_path,     // plain array allocation, plus arrayof_oop_arraycopy
+    _array_path,        // plain array allocation, plus arrayof_long_arraycopy
+    _instance_path,     // plain instance allocation, plus arrayof_long_arraycopy
     PATH_LIMIT
   };
   RegionNode* result_reg = new(C, PATH_LIMIT) RegionNode(PATH_LIMIT);
@@ -3933,18 +4025,6 @@
   int raw_adr_idx = Compile::AliasIdxRaw;
   const bool raw_mem_only = true;
 
-  // paths into alloc_reg (on the fast path, just before the CopyArray):
-  enum { _typeArray_alloc = 1, _instance_alloc, ALLOC_LIMIT };
-  RegionNode* alloc_reg = new(C, ALLOC_LIMIT) RegionNode(ALLOC_LIMIT);
-  PhiNode*    alloc_val = new(C, ALLOC_LIMIT) PhiNode(alloc_reg, raw_adr_type);
-  PhiNode*    alloc_siz = new(C, ALLOC_LIMIT) PhiNode(alloc_reg, TypeX_X);
-  PhiNode*    alloc_i_o = new(C, ALLOC_LIMIT) PhiNode(alloc_reg, Type::ABIO);
-  PhiNode*    alloc_mem = new(C, ALLOC_LIMIT) PhiNode(alloc_reg, Type::MEMORY,
-                                                      raw_adr_type);
-  record_for_igvn(alloc_reg);
-
-  bool card_mark = false;  // (see below)
-
   Node* array_ctl = generate_array_guard(obj_klass, (RegionNode*)NULL);
   if (array_ctl != NULL) {
     // It's an array.
@@ -3954,16 +4034,6 @@
     Node* obj_size = NULL;
     Node* alloc_obj = new_array(obj_klass, obj_length, nargs,
                                 raw_mem_only, &obj_size);
-    assert(obj_size != NULL, "");
-    Node* raw_obj = alloc_obj->in(1);
-    assert(raw_obj->is_Proj() && raw_obj->in(0)->is_Allocate(), "");
-    if (ReduceBulkZeroing) {
-      AllocateNode* alloc = AllocateNode::Ideal_allocation(alloc_obj, &_gvn);
-      if (alloc != NULL) {
-        // We will be completely responsible for initializing this object.
-        alloc->maybe_set_complete(&_gvn);
-      }
-    }
 
     if (!use_ReduceInitialCardMarks()) {
       // If it is an oop array, it requires very special treatment,
@@ -3977,7 +4047,7 @@
         bool length_never_negative = true;
         generate_arraycopy(TypeAryPtr::OOPS, T_OBJECT,
                            obj, intcon(0), alloc_obj, intcon(0),
-                           obj_length, nargs,
+                           obj_length,
                            disjoint_bases, length_never_negative);
         result_reg->init_req(_objArray_path, control());
         result_val->init_req(_objArray_path, alloc_obj);
@@ -3992,19 +4062,24 @@
     // the object.
 
     // Otherwise, there are no card marks to worry about.
-    alloc_val->init_req(_typeArray_alloc, raw_obj);
-    alloc_siz->init_req(_typeArray_alloc, obj_size);
-    alloc_reg->init_req(_typeArray_alloc, control());
-    alloc_i_o->init_req(_typeArray_alloc, i_o());
-    alloc_mem->init_req(_typeArray_alloc, memory(raw_adr_type));
+
+    if (!stopped()) {
+      copy_to_clone(obj, alloc_obj, obj_size, true, false);
+
+      // Present the results of the copy.
+      result_reg->init_req(_array_path, control());
+      result_val->init_req(_array_path, alloc_obj);
+      result_i_o ->set_req(_array_path, i_o());
+      result_mem ->set_req(_array_path, reset_memory());
+    }
   }
 
-  // We only go to the fast case code if we pass a number of guards.
+  // We only go to the instance fast case code if we pass a number of guards.
   // The paths which do not pass are accumulated in the slow_region.
   RegionNode* slow_region = new (C, 1) RegionNode(1);
   record_for_igvn(slow_region);
   if (!stopped()) {
-    // It's an instance.  Make the slow-path tests.
+    // It's an instance (we did array above).  Make the slow-path tests.
     // If this is a virtual call, we generate a funny guard.  We grab
     // the vtable entry corresponding to clone() from the target object.
     // If the target method which we are calling happens to be the
@@ -4031,25 +4106,14 @@
     PreserveJVMState pjvms(this);
     Node* obj_size = NULL;
     Node* alloc_obj = new_instance(obj_klass, NULL, raw_mem_only, &obj_size);
-    assert(obj_size != NULL, "");
-    Node* raw_obj = alloc_obj->in(1);
-    assert(raw_obj->is_Proj() && raw_obj->in(0)->is_Allocate(), "");
-    if (ReduceBulkZeroing) {
-      AllocateNode* alloc = AllocateNode::Ideal_allocation(alloc_obj, &_gvn);
-      if (alloc != NULL && !alloc->maybe_set_complete(&_gvn))
-        alloc = NULL;
-    }
-    if (!use_ReduceInitialCardMarks()) {
-      // Put in store barrier for any and all oops we are sticking
-      // into this object.  (We could avoid this if we could prove
-      // that the object type contains no oop fields at all.)
-      card_mark = true;
-    }
-    alloc_val->init_req(_instance_alloc, raw_obj);
-    alloc_siz->init_req(_instance_alloc, obj_size);
-    alloc_reg->init_req(_instance_alloc, control());
-    alloc_i_o->init_req(_instance_alloc, i_o());
-    alloc_mem->init_req(_instance_alloc, memory(raw_adr_type));
+
+    copy_to_clone(obj, alloc_obj, obj_size, false, !use_ReduceInitialCardMarks());
+
+    // Present the results of the slow call.
+    result_reg->init_req(_instance_path, control());
+    result_val->init_req(_instance_path, alloc_obj);
+    result_i_o ->set_req(_instance_path, i_o());
+    result_mem ->set_req(_instance_path, reset_memory());
   }
 
   // Generate code for the slow case.  We make a call to clone().
@@ -4065,82 +4129,12 @@
     result_mem ->set_req(_slow_path, reset_memory());
   }
 
-  // The object is allocated, as an array and/or an instance.  Now copy it.
-  set_control( _gvn.transform(alloc_reg) );
-  set_i_o(     _gvn.transform(alloc_i_o) );
-  set_memory(  _gvn.transform(alloc_mem), raw_adr_type );
-  Node* raw_obj  = _gvn.transform(alloc_val);
-
-  if (!stopped()) {
-    // Copy the fastest available way.
-    // (No need for PreserveJVMState, since we're using it all up now.)
-    // TODO: generate fields/elements copies for small objects instead.
-    Node* src  = obj;
-    Node* dest = raw_obj;
-    Node* size = _gvn.transform(alloc_siz);
-
-    // Exclude the header.
-    int base_off = instanceOopDesc::base_offset_in_bytes();
-    if (UseCompressedOops) {
-      assert(base_off % BytesPerLong != 0, "base with compressed oops");
-      // With compressed oops base_offset_in_bytes is 12 which creates
-      // the gap since countx is rounded by 8 bytes below.
-      // Copy klass and the gap.
-      base_off = instanceOopDesc::klass_offset_in_bytes();
-    }
-    src  = basic_plus_adr(src,  base_off);
-    dest = basic_plus_adr(dest, base_off);
-
-    // Compute the length also, if needed:
-    Node* countx = size;
-    countx = _gvn.transform( new (C, 3) SubXNode(countx, MakeConX(base_off)) );
-    countx = _gvn.transform( new (C, 3) URShiftXNode(countx, intcon(LogBytesPerLong) ));
-
-    // Select an appropriate instruction to initialize the range.
-    // The CopyArray instruction (if supported) can be optimized
-    // into a discrete set of scalar loads and stores.
-    bool disjoint_bases = true;
-    generate_unchecked_arraycopy(raw_adr_type, T_LONG, disjoint_bases,
-                                 src, NULL, dest, NULL, countx);
-
-    // Now that the object is properly initialized, type it as an oop.
-    // Use a secondary InitializeNode memory barrier.
-    InitializeNode* init = insert_mem_bar_volatile(Op_Initialize, raw_adr_idx,
-                                                   raw_obj)->as_Initialize();
-    init->set_complete(&_gvn);  // (there is no corresponding AllocateNode)
-    Node* new_obj = new(C, 2) CheckCastPPNode(control(), raw_obj,
-                                              TypeInstPtr::NOTNULL);
-    new_obj = _gvn.transform(new_obj);
-
-    // If necessary, emit some card marks afterwards.  (Non-arrays only.)
-    if (card_mark) {
-      Node* no_particular_value = NULL;
-      Node* no_particular_field = NULL;
-      post_barrier(control(),
-                   memory(raw_adr_type),
-                   new_obj,
-                   no_particular_field,
-                   raw_adr_idx,
-                   no_particular_value,
-                   T_OBJECT,
-                   false);
-    }
-    // Present the results of the slow call.
-    result_reg->init_req(_fast_path, control());
-    result_val->init_req(_fast_path, new_obj);
-    result_i_o ->set_req(_fast_path, i_o());
-    result_mem ->set_req(_fast_path, reset_memory());
-  }
-
   // Return the combined state.
   set_control(    _gvn.transform(result_reg) );
   set_i_o(        _gvn.transform(result_i_o) );
   set_all_memory( _gvn.transform(result_mem) );
 
-  // Cast the result to a sharper type, since we know what clone does.
-  Node* new_obj = _gvn.transform(result_val);
-  Node* cast    = new (C, 2) CheckCastPPNode(control(), new_obj, toop);
-  push(_gvn.transform(cast));
+  push(_gvn.transform(result_val));
 
   return true;
 }
@@ -4279,8 +4273,7 @@
 
     // Call StubRoutines::generic_arraycopy stub.
     generate_arraycopy(TypeRawPtr::BOTTOM, T_CONFLICT,
-                       src, src_offset, dest, dest_offset, length,
-                       nargs);
+                       src, src_offset, dest, dest_offset, length);
 
     // Do not let reads from the destination float above the arraycopy.
     // Since we cannot type the arrays, we don't know which slices
@@ -4303,8 +4296,7 @@
     // The component types are not the same or are not recognized.  Punt.
     // (But, avoid the native method wrapper to JVM_ArrayCopy.)
     generate_slow_arraycopy(TypePtr::BOTTOM,
-                            src, src_offset, dest, dest_offset, length,
-                            nargs);
+                            src, src_offset, dest, dest_offset, length);
     return true;
   }
 
@@ -4361,7 +4353,7 @@
   const TypePtr* adr_type = TypeAryPtr::get_array_body_type(dest_elem);
   generate_arraycopy(adr_type, dest_elem,
                      src, src_offset, dest, dest_offset, length,
-                     nargs, false, false, slow_region);
+                     false, false, slow_region);
 
   return true;
 }
@@ -4406,7 +4398,6 @@
                                    Node* src,  Node* src_offset,
                                    Node* dest, Node* dest_offset,
                                    Node* copy_length,
-                                   int nargs,
                                    bool disjoint_bases,
                                    bool length_never_negative,
                                    RegionNode* slow_region) {
@@ -4418,7 +4409,6 @@
 
   Node* original_dest      = dest;
   AllocateArrayNode* alloc = NULL;  // used for zeroing, if needed
-  Node* raw_dest           = NULL;  // used before zeroing, if needed
   bool  must_clear_dest    = false;
 
   // See if this is the initialization of a newly-allocated array.
@@ -4437,15 +4427,18 @@
     // "You break it, you buy it."
     InitializeNode* init = alloc->initialization();
     assert(init->is_complete(), "we just did this");
-    assert(dest->Opcode() == Op_CheckCastPP, "sanity");
+    assert(dest->is_CheckCastPP(), "sanity");
     assert(dest->in(0)->in(0) == init, "dest pinned");
-    raw_dest = dest->in(1);  // grab the raw pointer!
-    original_dest = dest;
-    dest = raw_dest;
+
+    // Cast to Object for arraycopy.
+    // We can't use the original CheckCastPP since it should be moved
+    // after the arraycopy to prevent stores flowing above it.
+    Node* new_obj = new(C, 2) CheckCastPPNode(dest->in(0), dest->in(1),
+                                              TypeInstPtr::NOTNULL);
+    dest = _gvn.transform(new_obj);
+    // Substitute in the locally valid dest_oop.
+    replace_in_map(original_dest, dest);
     adr_type = TypeRawPtr::BOTTOM;  // all initializations are into raw memory
-    // Decouple the original InitializeNode, turning it into a simple membar.
-    // We will build a new one at the end of this routine.
-    init->set_req(InitializeNode::RawAddress, top());
     // From this point on, every exit path is responsible for
     // initializing any non-copied parts of the object to zero.
     must_clear_dest = true;
@@ -4488,7 +4481,7 @@
     assert(!must_clear_dest, "");
     Node* cv = generate_generic_arraycopy(adr_type,
                                           src, src_offset, dest, dest_offset,
-                                          copy_length, nargs);
+                                          copy_length);
     if (cv == NULL)  cv = intcon(-1);  // failure (no stub available)
     checked_control = control();
     checked_i_o     = i_o();
@@ -4507,16 +4500,24 @@
       generate_negative_guard(copy_length, slow_region);
     }
 
+    // copy_length is 0.
     if (!stopped() && must_clear_dest) {
       Node* dest_length = alloc->in(AllocateNode::ALength);
       if (_gvn.eqv_uncast(copy_length, dest_length)
           || _gvn.find_int_con(dest_length, 1) <= 0) {
-        // There is no zeroing to do.
+        // There is no zeroing to do. No need for a secondary raw memory barrier.
       } else {
         // Clear the whole thing since there are no source elements to copy.
         generate_clear_array(adr_type, dest, basic_elem_type,
                              intcon(0), NULL,
                              alloc->in(AllocateNode::AllocSize));
+        // Use a secondary InitializeNode as raw memory barrier.
+        // Currently it is needed only on this path since other
+        // paths have stub or runtime calls as raw memory barriers.
+        InitializeNode* init = insert_mem_bar_volatile(Op_Initialize,
+                                                       Compile::AliasIdxRaw,
+                                                       top())->as_Initialize();
+        init->set_complete(&_gvn);  // (there is no corresponding AllocateNode)
       }
     }
 
@@ -4638,8 +4639,7 @@
       Node* cv = generate_checkcast_arraycopy(adr_type,
                                               dest_elem_klass,
                                               src, src_offset, dest, dest_offset,
-                                              copy_length,
-                                              nargs);
+                                              copy_length);
       if (cv == NULL)  cv = intcon(-1);  // failure (no stub available)
       checked_control = control();
       checked_i_o     = i_o();
@@ -4701,8 +4701,8 @@
     slow_i_o2  ->init_req(1, slow_i_o);
     slow_mem2  ->init_req(1, slow_mem);
     slow_reg2  ->init_req(2, control());
-    slow_i_o2  ->init_req(2, i_o());
-    slow_mem2  ->init_req(2, memory(adr_type));
+    slow_i_o2  ->init_req(2, checked_i_o);
+    slow_mem2  ->init_req(2, checked_mem);
 
     slow_control = _gvn.transform(slow_reg2);
     slow_i_o     = _gvn.transform(slow_i_o2);
@@ -4747,21 +4747,9 @@
                            alloc->in(AllocateNode::AllocSize));
     }
 
-    if (dest != original_dest) {
-      // Promote from rawptr to oop, so it looks right in the call's GC map.
-      dest = _gvn.transform( new(C,2) CheckCastPPNode(control(), dest,
-                                                      TypeInstPtr::NOTNULL) );
-
-      // Edit the call's debug-info to avoid referring to original_dest.
-      // (The problem with original_dest is that it isn't ready until
-      // after the InitializeNode completes, but this stuff is before.)
-      // Substitute in the locally valid dest_oop.
-      replace_in_map(original_dest, dest);
-    }
-
     generate_slow_arraycopy(adr_type,
                             src, src_offset, dest, dest_offset,
-                            copy_length, nargs);
+                            copy_length);
 
     result_region->init_req(slow_call_path, control());
     result_i_o   ->init_req(slow_call_path, i_o());
@@ -4781,16 +4769,16 @@
 
   if (dest != original_dest) {
     // Pin the "finished" array node after the arraycopy/zeroing operations.
-    // Use a secondary InitializeNode memory barrier.
-    InitializeNode* init = insert_mem_bar_volatile(Op_Initialize,
-                                                   Compile::AliasIdxRaw,
-                                                   raw_dest)->as_Initialize();
-    init->set_complete(&_gvn);  // (there is no corresponding AllocateNode)
     _gvn.hash_delete(original_dest);
     original_dest->set_req(0, control());
+    // Replace raw memory edge with new CheckCastPP to have a live oop
+    // at safepoints instead of raw value.
+    assert(dest->is_CheckCastPP() && dest->in(1) == original_dest->in(1), "sanity");
+    original_dest->set_req(1, dest);       // cast to the original type
     _gvn.hash_find_insert(original_dest);  // put back into GVN table
+    // Restore in the locally valid dest_oop.
+    replace_in_map(dest, original_dest);
   }
-
   // The memory edges above are precise in order to model effects around
   // array copies accurately to allow value numbering of field loads around
   // arraycopy.  Such field loads, both before and after, are common in Java
@@ -5074,16 +5062,13 @@
 LibraryCallKit::generate_slow_arraycopy(const TypePtr* adr_type,
                                         Node* src,  Node* src_offset,
                                         Node* dest, Node* dest_offset,
-                                        Node* copy_length,
-                                        int nargs) {
-  _sp += nargs; // any deopt will start just before call to enclosing method
+                                        Node* copy_length) {
   Node* call = make_runtime_call(RC_NO_LEAF | RC_UNCOMMON,
                                  OptoRuntime::slow_arraycopy_Type(),
                                  OptoRuntime::slow_arraycopy_Java(),
                                  "slow_arraycopy", adr_type,
                                  src, src_offset, dest, dest_offset,
                                  copy_length);
-  _sp -= nargs;
 
   // Handle exceptions thrown by this fellow:
   make_slow_call_ex(call, env()->Throwable_klass(), false);
@@ -5095,8 +5080,7 @@
                                              Node* dest_elem_klass,
                                              Node* src,  Node* src_offset,
                                              Node* dest, Node* dest_offset,
-                                             Node* copy_length,
-                                             int nargs) {
+                                             Node* copy_length) {
   if (stopped())  return NULL;
 
   address copyfunc_addr = StubRoutines::checkcast_arraycopy();
@@ -5137,8 +5121,7 @@
 LibraryCallKit::generate_generic_arraycopy(const TypePtr* adr_type,
                                            Node* src,  Node* src_offset,
                                            Node* dest, Node* dest_offset,
-                                           Node* copy_length,
-                                           int nargs) {
+                                           Node* copy_length) {
   if (stopped())  return NULL;
 
   address copyfunc_addr = StubRoutines::generic_arraycopy();
--- a/hotspot/src/share/vm/opto/loopopts.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/loopopts.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -667,7 +667,6 @@
   }
 }
 
-#ifdef _LP64
 static bool merge_point_safe(Node* region) {
   // 4799512: Stop split_if_with_blocks from splitting a block with a ConvI2LNode
   // having a PhiNode input. This sidesteps the dangerous case where the split
@@ -676,20 +675,25 @@
   // uses.
   // A better fix for this problem can be found in the BugTraq entry, but
   // expediency for Mantis demands this hack.
+  // 6855164: If the merge point has a FastLockNode with a PhiNode input, we stop
+  // split_if_with_blocks from splitting a block because we could not move around
+  // the FastLockNode.
   for (DUIterator_Fast imax, i = region->fast_outs(imax); i < imax; i++) {
     Node* n = region->fast_out(i);
     if (n->is_Phi()) {
       for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
         Node* m = n->fast_out(j);
-        if (m->Opcode() == Op_ConvI2L) {
+        if (m->is_FastLock())
           return false;
-        }
+#ifdef _LP64
+        if (m->Opcode() == Op_ConvI2L)
+          return false;
+#endif
       }
     }
   }
   return true;
 }
-#endif
 
 
 //------------------------------place_near_use---------------------------------
@@ -771,12 +775,10 @@
       if( get_loop(n_ctrl->in(j)) != n_loop )
         return;
 
-#ifdef _LP64
     // Check for safety of the merge point.
     if( !merge_point_safe(n_ctrl) ) {
       return;
     }
-#endif
 
     // Split compare 'n' through the merge point if it is profitable
     Node *phi = split_thru_phi( n, n_ctrl, policy );
--- a/hotspot/src/share/vm/opto/matcher.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/matcher.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -141,6 +141,10 @@
 
 //---------------------------match---------------------------------------------
 void Matcher::match( ) {
+  if( MaxLabelRootDepth < 100 ) { // Too small?
+    assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");
+    MaxLabelRootDepth = 100;
+  }
   // One-time initialization of some register masks.
   init_spill_mask( C->root()->in(1) );
   _return_addr_mask = return_addr();
--- a/hotspot/src/share/vm/opto/mulnode.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/mulnode.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -430,31 +430,28 @@
   // x & x => x
   if (phase->eqv(in(1), in(2))) return in(1);
 
-  Node *load = in(1);
-  const TypeInt *t2 = phase->type( in(2) )->isa_int();
-  if( t2 && t2->is_con() ) {
+  Node* in1 = in(1);
+  uint op = in1->Opcode();
+  const TypeInt* t2 = phase->type(in(2))->isa_int();
+  if (t2 && t2->is_con()) {
     int con = t2->get_con();
     // Masking off high bits which are always zero is useless.
     const TypeInt* t1 = phase->type( in(1) )->isa_int();
     if (t1 != NULL && t1->_lo >= 0) {
-      jint t1_support = ((jint)1 << (1 + log2_intptr(t1->_hi))) - 1;
+      jint t1_support = right_n_bits(1 + log2_intptr(t1->_hi));
       if ((t1_support & con) == t1_support)
-        return load;
+        return in1;
     }
-    uint lop = load->Opcode();
-    if( lop == Op_LoadUS &&
-        con == 0x0000FFFF )     // Already zero-extended
-      return load;
     // Masking off the high bits of a unsigned-shift-right is not
     // needed either.
-    if( lop == Op_URShiftI ) {
-      const TypeInt *t12 = phase->type( load->in(2) )->isa_int();
-      if( t12 && t12->is_con() ) {  // Shift is by a constant
+    if (op == Op_URShiftI) {
+      const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
+      if (t12 && t12->is_con()) {  // Shift is by a constant
         int shift = t12->get_con();
         shift &= BitsPerJavaInteger - 1;  // semantics of Java shifts
         int mask = max_juint >> shift;
-        if( (mask&con) == mask )  // If AND is useless, skip it
-          return load;
+        if ((mask & con) == mask)  // If AND is useless, skip it
+          return in1;
       }
     }
   }
@@ -476,26 +473,17 @@
     return new (phase->C, 3) AndINode(load,phase->intcon(mask&0xFFFF));
 
   // Masking bits off of a Short?  Loading a Character does some masking
-  if( lop == Op_LoadS &&
-      (mask & 0xFFFF0000) == 0 ) {
+  if (lop == Op_LoadS && (mask & 0xFFFF0000) == 0 ) {
     Node *ldus = new (phase->C, 3) LoadUSNode(load->in(MemNode::Control),
-                                  load->in(MemNode::Memory),
-                                  load->in(MemNode::Address),
-                                  load->adr_type());
+                                              load->in(MemNode::Memory),
+                                              load->in(MemNode::Address),
+                                              load->adr_type());
     ldus = phase->transform(ldus);
-    return new (phase->C, 3) AndINode(ldus, phase->intcon(mask&0xFFFF));
+    return new (phase->C, 3) AndINode(ldus, phase->intcon(mask & 0xFFFF));
   }
 
-  // Masking sign bits off of a Byte?  Do an unsigned byte load.
-  if (lop == Op_LoadB && mask == 0x000000FF) {
-    return new (phase->C, 3) LoadUBNode(load->in(MemNode::Control),
-                                        load->in(MemNode::Memory),
-                                        load->in(MemNode::Address),
-                                        load->adr_type());
-  }
-
-  // Masking sign bits off of a Byte plus additional lower bits?  Do
-  // an unsigned byte load plus an and.
+  // Masking sign bits off of a Byte?  Do an unsigned byte load plus
+  // an and.
   if (lop == Op_LoadB && (mask & 0xFFFFFF00) == 0) {
     Node* ldub = new (phase->C, 3) LoadUBNode(load->in(MemNode::Control),
                                               load->in(MemNode::Memory),
@@ -605,8 +593,13 @@
   Node* in1 = in(1);
   uint op = in1->Opcode();
 
-  // Masking sign bits off of an integer?  Do an unsigned integer to long load.
-  if (op == Op_ConvI2L && in1->in(1)->Opcode() == Op_LoadI && mask == 0x00000000FFFFFFFFL) {
+  // Masking sign bits off of an integer?  Do an unsigned integer to
+  // long load.
+  // NOTE: This check must be *before* we try to convert the AndLNode
+  // to an AndINode and commute it with ConvI2LNode because
+  // 0xFFFFFFFFL masks the whole integer and we get a sign extension,
+  // which is wrong.
+  if (op == Op_ConvI2L && in1->in(1)->Opcode() == Op_LoadI && mask == CONST64(0x00000000FFFFFFFF)) {
     Node* load = in1->in(1);
     return new (phase->C, 3) LoadUI2LNode(load->in(MemNode::Control),
                                           load->in(MemNode::Memory),
@@ -614,9 +607,22 @@
                                           load->adr_type());
   }
 
+  // Are we masking a long that was converted from an int with a mask
+  // that fits in 32-bits?  Commute them and use an AndINode.
+  if (op == Op_ConvI2L && (mask & CONST64(0xFFFFFFFF00000000)) == 0) {
+    // If we are doing an UI2L conversion (i.e. the mask is
+    // 0x00000000FFFFFFFF) we cannot convert the AndL to an AndI
+    // because the AndI would be optimized away later in Identity.
+    if (mask != CONST64(0x00000000FFFFFFFF)) {
+      Node* andi = new (phase->C, 3) AndINode(in1->in(1), phase->intcon(mask));
+      andi = phase->transform(andi);
+      return new (phase->C, 2) ConvI2LNode(andi);
+    }
+  }
+
   // Masking off sign bits?  Dont make them!
   if (op == Op_RShiftL) {
-    const TypeInt *t12 = phase->type(in1->in(2))->isa_int();
+    const TypeInt* t12 = phase->type(in1->in(2))->isa_int();
     if( t12 && t12->is_con() ) { // Shift is by a constant
       int shift = t12->get_con();
       shift &= BitsPerJavaLong - 1;  // semantics of Java shifts
@@ -626,7 +632,7 @@
       if( (sign_bits_mask & mask) == 0 ) {
         // Use zero-fill shift instead
         Node *zshift = phase->transform(new (phase->C, 3) URShiftLNode(in1->in(1), in1->in(2)));
-        return new (phase->C, 3) AndLNode( zshift, in(2) );
+        return new (phase->C, 3) AndLNode(zshift, in(2));
       }
     }
   }
--- a/hotspot/src/share/vm/opto/parse2.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/parse2.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1565,7 +1565,7 @@
     c = pop();                  // Oop to store
     b = pop();                  // index (already used)
     a = pop();                  // the array itself
-    const Type* elemtype  = _gvn.type(a)->is_aryptr()->elem();
+    const TypeOopPtr* elemtype  = _gvn.type(a)->is_aryptr()->elem()->make_oopptr();
     const TypeAryPtr* adr_type = TypeAryPtr::OOPS;
     Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT);
     break;
--- a/hotspot/src/share/vm/opto/parse3.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/parse3.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -222,7 +222,7 @@
   // Store the value.
   Node* store;
   if (bt == T_OBJECT) {
-    const TypePtr* field_type;
+    const TypeOopPtr* field_type;
     if (!field->type()->is_loaded()) {
       field_type = TypeInstPtr::BOTTOM;
     } else {
@@ -361,7 +361,7 @@
     guarantee(length_con >= 0, "non-constant multianewarray");
     ciArrayKlass* array_klass_1 = array_klass->as_obj_array_klass()->element_klass()->as_array_klass();
     const TypePtr* adr_type = TypeAryPtr::OOPS;
-    const Type*    elemtype = _gvn.type(array)->is_aryptr()->elem();
+    const TypeOopPtr*    elemtype = _gvn.type(array)->is_aryptr()->elem()->make_oopptr();
     const intptr_t header   = arrayOopDesc::base_offset_in_bytes(T_OBJECT);
     for (jint i = 0; i < length_con; i++) {
       Node*    elem   = expand_multianewarray(array_klass_1, &lengths[1], ndimensions-1, nargs);
--- a/hotspot/src/share/vm/opto/type.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/type.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -487,6 +487,23 @@
   return false;
 }
 
+//----------------------interface_vs_oop---------------------------------------
+#ifdef ASSERT
+bool Type::interface_vs_oop(const Type *t) const {
+  bool result = false;
+
+  const TypeInstPtr* this_inst = this->isa_instptr();
+  const TypeInstPtr*    t_inst =    t->isa_instptr();
+  if( this_inst && this_inst->is_loaded() && t_inst && t_inst->is_loaded() ) {
+    bool this_interface = this_inst->klass()->is_interface();
+    bool    t_interface =    t_inst->klass()->is_interface();
+    result = this_interface ^ t_interface;
+  }
+
+  return result;
+}
+#endif
+
 //------------------------------meet-------------------------------------------
 // Compute the MEET of two types.  NOT virtual.  It enforces that meet is
 // commutative and the lattice is symmetric.
@@ -507,16 +524,8 @@
   // Interface meet Oop is Not Symmetric:
   // Interface:AnyNull meet Oop:AnyNull == Interface:AnyNull
   // Interface:NotNull meet Oop:NotNull == java/lang/Object:NotNull
-  const TypeInstPtr* this_inst = this->isa_instptr();
-  const TypeInstPtr*    t_inst =    t->isa_instptr();
-  bool interface_vs_oop = false;
-  if( this_inst && this_inst->is_loaded() && t_inst && t_inst->is_loaded() ) {
-    bool this_interface = this_inst->klass()->is_interface();
-    bool    t_interface =    t_inst->klass()->is_interface();
-    interface_vs_oop = this_interface ^ t_interface;
-  }
-
-  if( !interface_vs_oop && (t2t != t->_dual || t2this != _dual) ) {
+
+  if( !interface_vs_oop(t) && (t2t != t->_dual || t2this != _dual) ) {
     tty->print_cr("=== Meet Not Symmetric ===");
     tty->print("t   =                   ");         t->dump(); tty->cr();
     tty->print("this=                   ");            dump(); tty->cr();
@@ -1800,6 +1809,17 @@
   return (intptr_t)_elem + (intptr_t)_size;
 }
 
+//----------------------interface_vs_oop---------------------------------------
+#ifdef ASSERT
+bool TypeAry::interface_vs_oop(const Type *t) const {
+  const TypeAry* t_ary = t->is_ary();
+  if (t_ary) {
+    return _elem->interface_vs_oop(t_ary->_elem);
+  }
+  return false;
+}
+#endif
+
 //------------------------------dump2------------------------------------------
 #ifndef PRODUCT
 void TypeAry::dump2( Dict &d, uint depth, outputStream *st ) const {
@@ -3389,6 +3409,17 @@
   return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id() );
 }
 
+//----------------------interface_vs_oop---------------------------------------
+#ifdef ASSERT
+bool TypeAryPtr::interface_vs_oop(const Type *t) const {
+  const TypeAryPtr* t_aryptr = t->isa_aryptr();
+  if (t_aryptr) {
+    return _ary->interface_vs_oop(t_aryptr->_ary);
+  }
+  return false;
+}
+#endif
+
 //------------------------------dump2------------------------------------------
 #ifndef PRODUCT
 void TypeAryPtr::dump2( Dict &d, uint depth, outputStream *st ) const {
@@ -3453,27 +3484,27 @@
 //------------------------------hash-------------------------------------------
 // Type-specific hashing function.
 int TypeNarrowOop::hash(void) const {
-  return _ooptype->hash() + 7;
+  return _ptrtype->hash() + 7;
 }
 
 
 bool TypeNarrowOop::eq( const Type *t ) const {
   const TypeNarrowOop* tc = t->isa_narrowoop();
   if (tc != NULL) {
-    if (_ooptype->base() != tc->_ooptype->base()) {
+    if (_ptrtype->base() != tc->_ptrtype->base()) {
       return false;
     }
-    return tc->_ooptype->eq(_ooptype);
+    return tc->_ptrtype->eq(_ptrtype);
   }
   return false;
 }
 
 bool TypeNarrowOop::singleton(void) const {    // TRUE if type is a singleton
-  return _ooptype->singleton();
+  return _ptrtype->singleton();
 }
 
 bool TypeNarrowOop::empty(void) const {
-  return _ooptype->empty();
+  return _ptrtype->empty();
 }
 
 //------------------------------xmeet------------------------------------------
@@ -3507,7 +3538,7 @@
     return this;
 
   case NarrowOop: {
-    const Type* result = _ooptype->xmeet(t->make_ptr());
+    const Type* result = _ptrtype->xmeet(t->make_ptr());
     if (result->isa_ptr()) {
       return TypeNarrowOop::make(result->is_ptr());
     }
@@ -3523,13 +3554,13 @@
 }
 
 const Type *TypeNarrowOop::xdual() const {    // Compute dual right now.
-  const TypePtr* odual = _ooptype->dual()->is_ptr();
+  const TypePtr* odual = _ptrtype->dual()->is_ptr();
   return new TypeNarrowOop(odual);
 }
 
 const Type *TypeNarrowOop::filter( const Type *kills ) const {
   if (kills->isa_narrowoop()) {
-    const Type* ft =_ooptype->filter(kills->is_narrowoop()->_ooptype);
+    const Type* ft =_ptrtype->filter(kills->is_narrowoop()->_ptrtype);
     if (ft->empty())
       return Type::TOP;           // Canonical empty value
     if (ft->isa_ptr()) {
@@ -3537,7 +3568,7 @@
     }
     return ft;
   } else if (kills->isa_ptr()) {
-    const Type* ft = _ooptype->join(kills);
+    const Type* ft = _ptrtype->join(kills);
     if (ft->empty())
       return Type::TOP;           // Canonical empty value
     return ft;
@@ -3548,13 +3579,13 @@
 
 
 intptr_t TypeNarrowOop::get_con() const {
-  return _ooptype->get_con();
+  return _ptrtype->get_con();
 }
 
 #ifndef PRODUCT
 void TypeNarrowOop::dump2( Dict & d, uint depth, outputStream *st ) const {
   st->print("narrowoop: ");
-  _ooptype->dump2(d, depth, st);
+  _ptrtype->dump2(d, depth, st);
 }
 #endif
 
--- a/hotspot/src/share/vm/opto/type.hpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/opto/type.hpp	Tue Jul 21 13:02:23 2009 -0700
@@ -190,6 +190,11 @@
   // Currently, it also works around limitations involving interface types.
   virtual const Type *filter( const Type *kills ) const;
 
+#ifdef ASSERT
+  // One type is interface, the other is oop
+  virtual bool interface_vs_oop(const Type *t) const;
+#endif
+
   // Returns true if this pointer points at memory which contains a
   // compressed oop references.
   bool is_ptr_to_narrowoop() const;
@@ -227,6 +232,11 @@
 
   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
   const TypePtr* make_ptr() const;
+
+  // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
+  // Asserts if the underlying type is not an oopptr or narrowoop.
+  const TypeOopPtr* make_oopptr() const;
+
   // Returns this compressed pointer or the equivalent compressed version
   // of this pointer type.
   const TypeNarrowOop* make_narrowoop() const;
@@ -546,6 +556,10 @@
   virtual const Type *xmeet( const Type *t ) const;
   virtual const Type *xdual() const;    // Compute dual right now.
   bool ary_must_be_exact() const;  // true if arrays of such are never generic
+#ifdef ASSERT
+  // One type is interface, the other is oop
+  virtual bool interface_vs_oop(const Type *t) const;
+#endif
 #ifndef PRODUCT
   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 #endif
@@ -867,6 +881,10 @@
   }
   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
   // sharpen the type of an int which is used as an array size
+#ifdef ASSERT
+  // One type is interface, the other is oop
+  virtual bool interface_vs_oop(const Type *t) const;
+#endif
 #ifndef PRODUCT
   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
 #endif
@@ -919,13 +937,13 @@
 // between the normal and the compressed form.
 class TypeNarrowOop : public Type {
 protected:
-  const TypePtr* _ooptype; // Could be TypePtr::NULL_PTR
+  const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
 
-  TypeNarrowOop( const TypePtr* ooptype): Type(NarrowOop),
-    _ooptype(ooptype) {
-    assert(ooptype->offset() == 0 ||
-           ooptype->offset() == OffsetBot ||
-           ooptype->offset() == OffsetTop, "no real offsets");
+  TypeNarrowOop( const TypePtr* ptrtype): Type(NarrowOop),
+    _ptrtype(ptrtype) {
+    assert(ptrtype->offset() == 0 ||
+           ptrtype->offset() == OffsetBot ||
+           ptrtype->offset() == OffsetTop, "no real offsets");
   }
 public:
   virtual bool eq( const Type *t ) const;
@@ -949,8 +967,8 @@
   }
 
   // returns the equivalent ptr type for this compressed pointer
-  const TypePtr *make_oopptr() const {
-    return _ooptype;
+  const TypePtr *get_ptrtype() const {
+    return _ptrtype;
   }
 
   static const TypeNarrowOop *BOTTOM;
@@ -1137,10 +1155,14 @@
 }
 
 inline const TypePtr* Type::make_ptr() const {
-  return (_base == NarrowOop) ? is_narrowoop()->make_oopptr() :
+  return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
                                 (isa_ptr() ? is_ptr() : NULL);
 }
 
+inline const TypeOopPtr* Type::make_oopptr() const {
+  return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
+}
+
 inline const TypeNarrowOop* Type::make_narrowoop() const {
   return (_base == NarrowOop) ? is_narrowoop() :
                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -606,6 +606,7 @@
     if (!mons->is_empty()) {
       for (int i = 0; i < mons->length(); i++) {
         MonitorInfo *mi = mons->at(i);
+        if (mi->owner_is_scalar_replaced()) continue;
 
         // see if owner of the monitor is our object
         if (mi->owner() != NULL && mi->owner() == hobj()) {
@@ -726,6 +727,8 @@
   for (int i = 0; i < mons->length(); i++) {
     MonitorInfo *mi = mons->at(i);
 
+    if (mi->owner_is_scalar_replaced()) continue;
+
     oop obj = mi->owner();
     if (obj == NULL) {
       // this monitor doesn't have an owning object so skip it
--- a/hotspot/src/share/vm/runtime/biasedLocking.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/runtime/biasedLocking.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -121,6 +121,7 @@
         // Walk monitors youngest to oldest
         for (int i = len - 1; i >= 0; i--) {
           MonitorInfo* mon_info = monitors->at(i);
+          if (mon_info->owner_is_scalar_replaced()) continue;
           oop owner = mon_info->owner();
           if (owner != NULL) {
             info->append(mon_info);
@@ -694,6 +695,7 @@
           // Walk monitors youngest to oldest
           for (int i = len - 1; i >= 0; i--) {
             MonitorInfo* mon_info = monitors->at(i);
+            if (mon_info->owner_is_scalar_replaced()) continue;
             oop owner = mon_info->owner();
             if (owner != NULL) {
               markOop mark = owner->mark();
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -933,7 +933,7 @@
   GrowableArray<MonitorInfo*>* monitors = cvf->monitors();
   for (int i = 0; i < monitors->length(); i++) {
     MonitorInfo* mon_info = monitors->at(i);
-    if (mon_info->owner() != NULL && !mon_info->eliminated()) {
+    if (!mon_info->eliminated() && mon_info->owner() != NULL) {
       objects_to_revoke->append(Handle(mon_info->owner()));
     }
   }
--- a/hotspot/src/share/vm/runtime/globals.hpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Tue Jul 21 13:02:23 2009 -0700
@@ -1994,6 +1994,10 @@
   product_rw(bool, PrintHeapAtGC, false,                                    \
           "Print heap layout before and after each GC")                     \
                                                                             \
+  product_rw(bool, PrintHeapAtGCExtended, false,                            \
+          "Prints extended information about the layout of the heap "       \
+          "when -XX:+PrintHeapAtGC is set")                                 \
+                                                                            \
   product(bool, PrintHeapAtSIGBREAK, true,                                  \
           "Print heap layout in response to SIGBREAK")                      \
                                                                             \
--- a/hotspot/src/share/vm/runtime/stackValue.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/runtime/stackValue.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -146,8 +146,9 @@
     value.jl = ((ConstantLongValue *)sv)->value();
     return new StackValue(value.p);
 #endif
-  } else if (sv->is_object()) {
-    return new StackValue(((ObjectValue *)sv)->value());
+  } else if (sv->is_object()) { // Scalar replaced object in compiled frame
+    Handle ov = ((ObjectValue *)sv)->value();
+    return new StackValue(ov, (ov.is_null()) ? 1 : 0);
   }
 
   // Unknown ScopeValue type
--- a/hotspot/src/share/vm/runtime/stackValue.hpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/runtime/stackValue.hpp	Tue Jul 21 13:02:23 2009 -0700
@@ -34,9 +34,11 @@
     _i     = value;
   }
 
-  StackValue(Handle value) {
+  StackValue(Handle value, intptr_t scalar_replaced = 0) {
     _type    = T_OBJECT;
+    _i       = scalar_replaced;
     _o       = value;
+    assert(_i == 0 || _o.is_null(), "not null object should not be marked as scalar replaced");
   }
 
   StackValue() {
@@ -56,6 +58,11 @@
     return _o;
   }
 
+  bool obj_is_scalar_replaced() const {
+    assert(type() == T_OBJECT, "type check");
+    return _i != 0;
+  }
+
   void set_obj(Handle value) {
     assert(type() == T_OBJECT, "type check");
     _o = value;
--- a/hotspot/src/share/vm/runtime/vframe.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vframe.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -106,6 +106,7 @@
 
   for (int index = (mons->length()-1); index >= 0; index--) {
     MonitorInfo* monitor = mons->at(index);
+    if (monitor->eliminated() && is_compiled_frame()) continue; // skip eliminated monitor
     oop obj = monitor->owner();
     if (obj == NULL) continue; // skip unowned monitor
     //
@@ -162,6 +163,18 @@
     bool found_first_monitor = false;
     for (int index = (mons->length()-1); index >= 0; index--) {
       MonitorInfo* monitor = mons->at(index);
+      if (monitor->eliminated() && is_compiled_frame()) { // Eliminated in compiled code
+        if (monitor->owner_is_scalar_replaced()) {
+          Klass* k = Klass::cast(monitor->owner_klass());
+          st->print("\t- eliminated <owner is scalar replaced> (a %s)", k->external_name());
+        } else {
+          oop obj = monitor->owner();
+          if (obj != NULL) {
+            print_locked_object_class_name(st, obj, "eliminated");
+          }
+        }
+        continue;
+      }
       if (monitor->owner() != NULL) {
 
         // First, assume we have the monitor locked. If we haven't found an
@@ -171,11 +184,11 @@
 
         const char *lock_state = "locked"; // assume we have the monitor locked
         if (!found_first_monitor && frame_count == 0) {
-         markOop mark = monitor->owner()->mark();
-         if (mark->has_monitor() &&
-             mark->monitor() == thread()->current_pending_monitor()) {
+          markOop mark = monitor->owner()->mark();
+          if (mark->has_monitor() &&
+              mark->monitor() == thread()->current_pending_monitor()) {
             lock_state = "waiting to lock";
-         }
+          }
         }
 
         found_first_monitor = true;
@@ -206,7 +219,7 @@
   for (BasicObjectLock* current = (fr().previous_monitor_in_interpreter_frame(fr().interpreter_frame_monitor_begin()));
        current >= fr().interpreter_frame_monitor_end();
        current = fr().previous_monitor_in_interpreter_frame(current)) {
-    result->push(new MonitorInfo(current->obj(), current->lock(), false));
+    result->push(new MonitorInfo(current->obj(), current->lock(), false, false));
   }
   return result;
 }
@@ -531,8 +544,18 @@
   tty->print_cr("\tmonitor list:");
   for (int index = (list->length()-1); index >= 0; index--) {
     MonitorInfo* monitor = list->at(index);
-    tty->print("\t  obj\t"); monitor->owner()->print_value();
-    tty->print("(" INTPTR_FORMAT ")", (address)monitor->owner());
+    tty->print("\t  obj\t");
+    if (monitor->owner_is_scalar_replaced()) {
+      Klass* k = Klass::cast(monitor->owner_klass());
+      tty->print("( is scalar replaced %s)", k->external_name());
+    } else if (monitor->owner() == NULL) {
+      tty->print("( null )");
+    } else {
+      monitor->owner()->print_value();
+      tty->print("(" INTPTR_FORMAT ")", (address)monitor->owner());
+    }
+    if (monitor->eliminated() && is_compiled_frame())
+      tty->print(" ( lock is eliminated )");
     tty->cr();
     tty->print("\t  ");
     monitor->lock()->print_on(tty);
--- a/hotspot/src/share/vm/runtime/vframe.hpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vframe.hpp	Tue Jul 21 13:02:23 2009 -0700
@@ -230,18 +230,36 @@
  private:
   oop        _owner; // the object owning the monitor
   BasicLock* _lock;
+  oop        _owner_klass; // klass if owner was scalar replaced
   bool       _eliminated;
+  bool       _owner_is_scalar_replaced;
  public:
   // Constructor
-  MonitorInfo(oop owner, BasicLock* lock, bool eliminated) {
-    _owner = owner;
+  MonitorInfo(oop owner, BasicLock* lock, bool eliminated, bool owner_is_scalar_replaced) {
+    if (!owner_is_scalar_replaced) {
+      _owner = owner;
+      _owner_klass = NULL;
+    } else {
+      assert(eliminated, "monitor should be eliminated for scalar replaced object");
+      _owner = NULL;
+      _owner_klass = owner;
+    }
     _lock  = lock;
     _eliminated = eliminated;
+    _owner_is_scalar_replaced = owner_is_scalar_replaced;
   }
   // Accessors
-  oop        owner() const { return _owner; }
+  oop        owner() const {
+    assert(!_owner_is_scalar_replaced, "should not be called for scalar replaced object");
+    return _owner;
+  }
+  klassOop   owner_klass() const {
+    assert(_owner_is_scalar_replaced, "should not be called for not scalar replaced object");
+    return (klassOop)_owner_klass;
+  }
   BasicLock* lock()  const { return _lock;  }
   bool eliminated()  const { return _eliminated; }
+  bool owner_is_scalar_replaced()  const { return _owner_is_scalar_replaced; }
 };
 
 class vframeStreamCommon : StackObj {
--- a/hotspot/src/share/vm/runtime/vframeArray.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vframeArray.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -61,6 +61,7 @@
     // Migrate the BasicLocks from the stack to the monitor chunk
     for (index = 0; index < list->length(); index++) {
       MonitorInfo* monitor = list->at(index);
+      assert(!monitor->owner_is_scalar_replaced(), "object should be reallocated already");
       assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
       BasicObjectLock* dest = _monitors->at(index);
       dest->set_obj(monitor->owner());
@@ -89,6 +90,7 @@
     StackValue* value = locs->at(index);
     switch(value->type()) {
       case T_OBJECT:
+        assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
         // preserve object type
         _locals->add( new StackValue((intptr_t) (value->get_obj()()), T_OBJECT ));
         break;
@@ -113,6 +115,7 @@
     StackValue* value = exprs->at(index);
     switch(value->type()) {
       case T_OBJECT:
+        assert(!value->obj_is_scalar_replaced(), "object should be reallocated already");
         // preserve object type
         _expressions->add( new StackValue((intptr_t) (value->get_obj()()), T_OBJECT ));
         break;
--- a/hotspot/src/share/vm/runtime/vframe_hp.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/hotspot/src/share/vm/runtime/vframe_hp.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -190,7 +190,7 @@
     // Casting away const
     frame& fr = (frame&) _fr;
     MonitorInfo* info = new MonitorInfo(fr.compiled_synchronized_native_monitor_owner(nm),
-                                        fr.compiled_synchronized_native_monitor(nm), false);
+                                        fr.compiled_synchronized_native_monitor(nm), false, false);
     monitors->push(info);
     return monitors;
   }
@@ -201,8 +201,20 @@
   GrowableArray<MonitorInfo*>* result = new GrowableArray<MonitorInfo*>(monitors->length());
   for (int index = 0; index < monitors->length(); index++) {
     MonitorValue* mv = monitors->at(index);
-    StackValue *owner_sv = create_stack_value(mv->owner()); // it is an oop
-    result->push(new MonitorInfo(owner_sv->get_obj()(), resolve_monitor_lock(mv->basic_lock()), mv->eliminated()));
+    ScopeValue*   ov = mv->owner();
+    StackValue *owner_sv = create_stack_value(ov); // it is an oop
+    if (ov->is_object() && owner_sv->obj_is_scalar_replaced()) { // The owner object was scalar replaced
+      assert(mv->eliminated(), "monitor should be eliminated for scalar replaced object");
+      // Put klass for scalar replaced object.
+      ScopeValue* kv = ((ObjectValue *)ov)->klass();
+      assert(kv->is_constant_oop(), "klass should be oop constant for scalar replaced object");
+      KlassHandle k(((ConstantOopReadValue*)kv)->value()());
+      result->push(new MonitorInfo(k->as_klassOop(), resolve_monitor_lock(mv->basic_lock()),
+                                   mv->eliminated(), true));
+    } else {
+      result->push(new MonitorInfo(owner_sv->get_obj()(), resolve_monitor_lock(mv->basic_lock()),
+                                   mv->eliminated(), false));
+    }
   }
   return result;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/5057225/Test5057225.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,140 @@
+/*
+ * 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 5057225
+ * @summary Remove useless I2L conversions
+ *
+ * @run main/othervm -Xcomp -XX:CompileOnly=Test5057225.doload Test5057225
+ */
+
+import java.net.URLClassLoader;
+
+public class Test5057225 {
+    static byte[]  ba = new byte[]  { -1 };
+    static short[] sa = new short[] { -1 };
+    static int[]   ia = new int[]   { -1 };
+
+    static final long[] BYTE_MASKS = {
+         0x0FL,
+         0x7FL,  // 7-bit
+         0xFFL,
+    };
+
+    static final long[] SHORT_MASKS = {
+        0x000FL,
+        0x007FL,  // 7-bit
+        0x00FFL,
+        0x0FFFL,
+        0x3FFFL,  // 14-bit
+        0x7FFFL,  // 15-bit
+        0xFFFFL,
+    };
+
+    static final long[] INT_MASKS = {
+        0x0000000FL,
+        0x0000007FL,  // 7-bit
+        0x000000FFL,
+        0x00000FFFL,
+        0x00003FFFL,  // 14-bit
+        0x00007FFFL,  // 15-bit
+        0x0000FFFFL,
+        0x00FFFFFFL,
+        0x7FFFFFFFL,  // 31-bit
+        0xFFFFFFFFL,
+    };
+
+    public static void main(String[] args) throws Exception {
+        for (int i = 0; i < BYTE_MASKS.length; i++) {
+            System.setProperty("value", "" + BYTE_MASKS[i]);
+            loadAndRunClass("Test5057225$loadUB2L");
+        }
+
+        for (int i = 0; i < SHORT_MASKS.length; i++) {
+            System.setProperty("value", "" + SHORT_MASKS[i]);
+            loadAndRunClass("Test5057225$loadUS2L");
+        }
+
+        for (int i = 0; i < INT_MASKS.length; i++) {
+            System.setProperty("value", "" + INT_MASKS[i]);
+            loadAndRunClass("Test5057225$loadUI2L");
+        }
+    }
+
+    static void check(long result, long expected) {
+        if (result != expected)
+            throw new InternalError(result + " != " + expected);
+    }
+
+    static void loadAndRunClass(String classname) throws Exception {
+        Class cl = Class.forName(classname);
+        URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
+        ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
+        Class c = loader.loadClass(classname);
+        Runnable r = (Runnable) c.newInstance();
+        r.run();
+    }
+
+    public static class loadUB2L implements Runnable {
+        static final long MASK;
+        static {
+            long value = 0;
+            try {
+                value = Long.decode(System.getProperty("value"));
+            } catch (Throwable e) {}
+            MASK = value;
+        }
+
+        public void run() { check(doload(ba), MASK); }
+        static long doload(byte[] ba) { return ba[0] & MASK; }
+    }
+
+    public static class loadUS2L implements Runnable {
+        static final long MASK;
+        static {
+            long value = 0;
+            try {
+                value = Long.decode(System.getProperty("value"));
+            } catch (Throwable e) {}
+            MASK = value;
+        }
+
+        public void run() { check(doload(sa), MASK); }
+        static long doload(short[] sa) { return sa[0] & MASK; }
+    }
+
+    public static class loadUI2L implements Runnable {
+        static final long MASK;
+        static {
+            long value = 0;
+            try {
+                value = Long.decode(System.getProperty("value"));
+            } catch (Throwable e) {}
+            MASK = value;
+        }
+
+        public void run() { check(doload(ia), MASK); }
+        static long doload(int[] ia) { return ia[0] & MASK; }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6837094/Test.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,94 @@
+/*
+ * 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 6837094
+ * @summary False positive for "meet not symmetric" failure
+ *
+ * @run main/othervm -Xbatch -XX:CompileOnly=Test.collectIs,Test$Factory$1.getArray,Test$Factory$2.getArray Test
+ */
+
+import java.util.Set;
+import java.util.HashSet;
+
+public class Test {
+
+  private interface Factory<M extends Interface> {
+    Factory<Child0> Zero = new Factory<Child0>() {
+      public Child0[] getArray() { return new Child0[1]; }
+    };
+
+    Factory<Child1> One = new Factory<Child1>() {
+      public Child1[] getArray() { return new Child1[1]; }
+    };
+
+    M[] getArray();
+  }
+
+  /**
+   * C2 asserts when compiling this method. Bimorphic inlining happens at
+   * getArray call site. A Phi in the catch block tries to join the meet type
+   * from he inline site (Parent[]) with the type expected by CI (Interface[]).
+   *
+   * C2 throws an assert when it doesn't need to.
+   */
+  private static <I extends Interface> void collectIs(
+      Factory<I> factory, Set<Interface> s) {
+    for (I i : factory.getArray()) {
+      try {
+        s.add(i);
+      } catch (Exception e) {
+      }
+    }
+  }
+
+  static public void main(String argv[]) {
+    Set<Interface> s = new HashSet();
+
+    for (int i = 0; i < 25000; i++) {
+      collectIs(Factory.Zero, s);
+      collectIs(Factory.One, s);
+    }
+  }
+}
+
+/**
+ * Establish necessary class hierarchy
+ */
+
+interface Interface {
+}
+
+class Parent {
+}
+
+class Child0 extends Parent implements Interface {
+}
+
+class Child1 extends Parent implements Interface {
+}
+
+class Child2 extends Parent implements Interface {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6849574/Test.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,44 @@
+/*
+ * 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 6849574
+ * @summary VM crash using NonBlockingHashMap (high_scale_lib)
+ *
+ * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+VerifyBeforeGC Test
+ */
+
+import java.util.concurrent.atomic.*;
+
+public class Test extends Thread {
+
+    public static void main(String[] args) {
+        AtomicReferenceArray a = new AtomicReferenceArray(10000);
+        for (int i = 0; i < 100000; i++) {
+            a.getAndSet(9999, new Object());
+            if (i > 99990) System.gc();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6855164/Test.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,55 @@
+/*
+ * 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 6855164
+ * @summary SIGSEGV during compilation of method involving loop over CharSequence
+ * @run main/othervm -Xbatch Test
+ */
+
+public class Test{
+    public static void main(String[] args) throws Exception {
+        StringBuffer builder = new StringBuffer();
+
+        for(int i = 0; i < 100; i++)
+            builder.append("I am the very model of a modern major general\n");
+
+        for(int j = 0; j < builder.length(); j++){
+            previousSpaceIndex(builder, j);
+        }
+    }
+
+    private static final int previousSpaceIndex(CharSequence sb, int seek) {
+        seek--;
+        while (seek > 0) {
+            if (sb.charAt(seek) == ' ') {
+                while (seek > 0 && sb.charAt(seek - 1) == ' ')
+                    seek--;
+                return seek;
+            }
+            seek--;
+        }
+        return 0;
+    }
+}
--- a/jaxp/.hgtags	Wed Jul 15 10:46:42 2009 -0700
+++ b/jaxp/.hgtags	Tue Jul 21 13:02:23 2009 -0700
@@ -37,3 +37,5 @@
 259aef5045a155eb6a2f8dd0e2429c6dbe0f652f jdk7-b60
 f1ac756616eaaad795f77f7f5e7f7c7bfdc9c1de jdk7-b61
 a97dd57a62604c35c79bc2fa77a612ed547f6135 jdk7-b62
+ae449e9c04c1fe651bd30f0f4d4cc24ba794e0c4 jdk7-b63
+a10eec7a1edf536f39b5828d8623054dbc62c2b7 jdk7-b64
--- a/jaxws/.hgtags	Wed Jul 15 10:46:42 2009 -0700
+++ b/jaxws/.hgtags	Tue Jul 21 13:02:23 2009 -0700
@@ -37,3 +37,5 @@
 3b054db3e277ca224fe6576c59ed6f4ab5ed0bb5 jdk7-b60
 aeabf802f2a1ca72b87d7397c5ece58058e000a9 jdk7-b61
 75c801c13ea1ddebc58b1a8c8da9318d72750e62 jdk7-b62
+b8a6e883c0a6708f6d818815040525d472262495 jdk7-b63
+aaa25dfd3de68c6f1a1d3ef8c45fd99f76bca6dd jdk7-b64
--- a/jdk/.hgtags	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/.hgtags	Tue Jul 21 13:02:23 2009 -0700
@@ -38,3 +38,5 @@
 f72c0dc047b9b2e797beee68ae0b50decb1f020d jdk7-b61
 12e11fab9a839a9666a996a8f9a02fd8fa03aab6 jdk7-b62
 2ed6ed6b5bfc7dd724925b90dbb31223df59c25d jdk7-b63
+a50217eb3ee10b9f9547e0708e5c9625405083ef jdk7-b64
+382a27aa78d3236fa123c60577797a887fe93e09 jdk7-b65
--- a/jdk/make/com/sun/java/pack/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/com/sun/java/pack/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -91,10 +91,10 @@
   CXXFLAGS_COMMON += $(MS_RUNTIME_OPTION)
   LDOUTPUT = -Fe
 
-  # J2SE name required here
-  RC_FLAGS += /D "J2SE_FNAME=$(PGRM).exe" \
-	/D "J2SE_INTERNAL_NAME=$(PGRM)" \
-	/D "J2SE_FTYPE=0x1L"
+  # JDK name required here
+  RC_FLAGS += /D "JDK_FNAME=$(PGRM).exe" \
+	/D "JDK_INTERNAL_NAME=$(PGRM)" \
+	/D "JDK_FTYPE=0x1L"
 
   RES = $(OBJDIR)/$(PGRM).res
 else
@@ -133,13 +133,19 @@
 	$(MAKE) $(UNPACK_EXE) STANDALONE=true LDMAPFLAGS_OPT= LDMAPFLAGS_DBG=
 
 ifeq ($(PLATFORM), windows)
+IMVERSIONVALUE=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION).$(JDK_UPDATE_VER).$(COOKED_BUILD_NUMBER)
+SED_ALL_MANIFEST=$(SED) -e 's%IMVERSION%$(IMVERSIONVALUE)%g'
+updatefiles:: 
+	$(CAT) $(TOPDIR)/src/windows/resource/unpack200_proto.exe.manifest | $(SED_ALL_MANIFEST) > $(OBJDIR)/unpack200.exe.manifest
 winres::  $(RES)
 else
+updatefiles::
+	$(ECHO) "Manifest not required for Unix"
 winres::
 	$(ECHO) "Resource files not required for Unix"
 endif
 
-$(UNPACK_EXE): $(UNPACK_EXE_FILES_o) winres 
+$(UNPACK_EXE): $(UNPACK_EXE_FILES_o) updatefiles winres
 	$(prep-target)
 	$(LINKER)  $(LDDFLAGS) $(UNPACK_EXE_FILES_o) $(RES) $(LIBCXX) $(LDOUTPUT)$(TEMPDIR)/unpack200$(EXE_SUFFIX)
 ifdef MT
--- a/jdk/make/common/Defs-windows.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/common/Defs-windows.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
+# Copyright 1999-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
@@ -464,11 +464,48 @@
 JDK_RC_FVER = \
     $(JDK_MINOR_VERSION),$(JDK_MICRO_VERSION),$(JDK_UPDATE_VER),$(COOKED_BUILD_NUMBER)
 
-# J2SE name required here
-RC_FLAGS += -d "J2SE_BUILD_ID=$(JDK_RC_BUILD_ID)" \
-            -d "J2SE_COMPANY=$(JDK_RC_COMPANY)" \
-            -d "J2SE_COMPONENT=$(JDK_RC_COMPONENT)" \
-            -d "J2SE_VER=$(JDK_RC_VER)" \
-            -d "J2SE_COPYRIGHT=$(JDK_RC_COPYRIGHT)" \
-            -d "J2SE_NAME=$(JDK_RC_NAME)" \
-            -d "J2SE_FVER=$(JDK_RC_FVER)"
+# JDK name required here
+RC_FLAGS += -d "JDK_BUILD_ID=$(JDK_RC_BUILD_ID)" \
+            -d "JDK_COMPANY=$(JDK_RC_COMPANY)" \
+            -d "JDK_COMPONENT=$(JDK_RC_COMPONENT)" \
+            -d "JDK_VER=$(JDK_RC_VER)" \
+            -d "JDK_COPYRIGHT=$(JDK_RC_COPYRIGHT)" \
+            -d "JDK_NAME=$(JDK_RC_NAME)" \
+            -d "JDK_FVER=$(JDK_RC_FVER)"
+
+# Enable 7-Zip LZMA file (de)compression for Java Kernel if it is available
+ifeq ($(ARCH_DATA_MODEL), 32)
+  ifneq ($(KERNEL), off)
+    # This is a hack to use until  7-Zip (and UPX) bundles can be put
+    # under /java/devtools.
+    ifndef DEPLOY_TOPDIR
+      DEPLOY_TOPDIR=$(JDK_TOPDIR)/../deploy
+    endif
+    # Uncomment this block to cause build failure if above assumption false
+    #DCHK = $(shell if [ ! -d $(DEPLOY_TOPDIR) ] ; then \
+    #  $(ECHO) deploy_not_a_peer_of_j2se ; \
+    #fi )
+    #ifeq ($(DCHK), deploy_not_a_peer_of_j2se)
+    #  If a build failure points to control coming here it means
+    #  it means deploy is not in the same directory
+    #  as j2se. Java Kernel can't tolerate that for the time being.
+    #endif
+    EC_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/lzma ] ; then \
+      $(ECHO) true ; \
+    else \
+      $(ECHO) false ; \
+    fi )
+    ifeq ($(EC_TMP), true)
+      EXTRA_COMP_INSTALL_PATH = lib\\\\deploy\\\\lzma.dll
+      # Crazy but true: deploy/make/plugin/jinstall/Makefile.jkernel does
+      # not include deploy/make/common/Defs-windows.gmk, either directly
+      # or indirectly. But it does include this file, so redundantly declare
+      # these variables that are in deploy/make/common/Defs-windows.gmk for
+      # the sake of the Java Kernel part of the deploy build. Whew!
+      EXTRA_COMP_LIB_NAME = lzma.dll
+      EXTRA_COMP_PATH = $(OUTPUTDIR)/tmp/deploy/lzma/win32/obj
+      EXTRA_COMP_CMD_PATH = $(EXTRA_COMP_PATH)/lzma.exe
+      EXTRA_COMP_LIB_PATH = $(EXTRA_COMP_PATH)/$(EXTRA_COMP_LIB_NAME)
+    endif
+  endif
+endif
--- a/jdk/make/common/Library.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/common/Library.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -207,10 +207,10 @@
 endif
 	@$(ECHO) Created $@ 
 
-# J2SE name required here
-RC_FLAGS += /D "J2SE_FNAME=$(LIBRARY).dll" \
-            /D "J2SE_INTERNAL_NAME=$(LIBRARY)" \
-            /D "J2SE_FTYPE=0x2L"
+# JDK name required here
+RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
+            /D "JDK_INTERNAL_NAME=$(LIBRARY)" \
+            /D "JDK_FTYPE=0x2L"
 
 $(OBJDIR)/$(LIBRARY).res: $(VERSIONINFO_RESOURCE)
 ifndef LOCAL_RESOURCE_FILE
--- a/jdk/make/common/Program.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/common/Program.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -123,10 +123,10 @@
 #
 ifeq ($(PLATFORM), windows)
 
-# J2SE name required here
-RC_FLAGS += /D "J2SE_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
-	    /D "J2SE_INTERNAL_NAME=$(PROGRAM)" \
-	    /D "J2SE_FTYPE=0x1L"
+# JDK name required here
+RC_FLAGS += /D "JDK_FNAME=$(PROGRAM)$(EXE_SUFFIX)" \
+	    /D "JDK_INTERNAL_NAME=$(PROGRAM)" \
+	    /D "JDK_FTYPE=0x1L"
 
 $(OBJDIR)/$(PROGRAM).res: $(VERSIONINFO_RESOURCE)
 	@$(prep-target)
--- a/jdk/make/common/Release.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/common/Release.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -789,6 +789,11 @@
 	$(CD) $(JRE_IMAGE_DIR)/lib && \
             $(RM) java.$(LIB_SUFFIX) jvm.$(LIB_SUFFIX) \
                   hpi.$(LIB_SUFFIX) awt.$(LIB_SUFFIX) jawt.$(LIB_SUFFIX)
+  ifeq ($(ARCH_DATA_MODEL), 32)
+	@# The Java Kernel JRE image ships with a special VM.  It is not included
+	@# in the full JRE image, so remove it.  Also, is it only for 32-bit windows.
+	$(CD) $(JRE_IMAGE_DIR)/bin && $(RM) -r kernel
+  endif
 endif # Windows
 ifneq ($(PLATFORM), windows)
 	$(call copy-man-pages,$(JRE_IMAGE_DIR),$(JRE_MAN_PAGES))
--- a/jdk/make/common/shared/Compiler-msvc.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/common/shared/Compiler-msvc.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -35,8 +35,8 @@
   LIBEXE       = $(COMPILER_PATH)lib
   LINK         = $(COMPILER_PATH)link
   RC           = $(MSDEVTOOLS_PATH)rc
+  RSC          = $(MSDEVTOOLS_PATH)rc
   LINK32       = $(LINK)
-  RSC          = $(RC)
  
   # Fill in unknown values
   COMPILER_NAME=Unknown MSVC Compiler
@@ -98,6 +98,9 @@
     endif
     ifeq ($(CC_MAJORVER), 14)
       ifeq ($(ARCH), amd64)
+        #rebase and midl moved out of Visual Studio into the SDK:
+        REBASE     = $(MSDEVTOOLS_PATH)/rebase
+        MTL        = $(MSDEVTOOLS_PATH)/midl.exe
         ifeq ($(CC_MICROVER), 30701)
           # This should be: CC_VER=14.00.30701 LINK_VER=8.00.30701
 	  # WARNING: it says 14, but it is such an early build it doesn't
@@ -110,6 +113,8 @@
 	  COMPILER_NAME=Microsoft Platform SDK - April 2005 Edition (3790.1830)
           COMPILER_VERSION=VS2005
         endif
+      else
+        REBASE         = $(COMPILER_PATH)../rebase
       endif
     endif
     ifeq ($(CC_MAJORVER), 15)
@@ -120,7 +125,6 @@
     endif
     # This will cause problems if ALT_COMPILER_PATH is defined to ""
     # which is a directive to use the PATH.
-    REBASE         = $(COMPILER_PATH)../REBASE
     ifndef COMPILER_PATH
       COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
     endif
--- a/jdk/make/common/shared/Defs-utils.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/common/shared/Defs-utils.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -72,6 +72,7 @@
 AR             = $(UTILS_CCS_BIN_PATH)ar
 AS             = $(UTILS_CCS_BIN_PATH)as
 BASENAME       = $(UTILS_COMMAND_PATH)basename
+BZIP2          = $(UTILS_COMMAND_PATH)bzip2
 CAT            = $(UTILS_COMMAND_PATH)cat
 CHMOD          = $(UTILS_COMMAND_PATH)chmod
 CMP            = $(UTILS_USR_BIN_PATH)cmp
@@ -157,6 +158,7 @@
   endif
   # Re-define some utilities
   LEX            =# override GNU Make intrinsic: no lex on windows
+  SHA1SUM        = $(UNIXCOMMAND_PATH)openssl sha1
 endif
 
 # Linux specific
--- a/jdk/make/common/shared/Defs-windows.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/common/shared/Defs-windows.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -520,7 +520,7 @@
   xALT_INSTALL_MSSDK :="$(subst \,/,$(ALT_INSTALL_MSSDK))"
   INSTALL_MSSDK      :=$(call FullPath,$(xALT_INSTALL_MSSDK))
 else
-  INSTALL_MSSDK      :=$(_psdk)
+  INSTALL_MSSDK      :=$(_ms_sdk)
 endif
 INSTALL_MSSDK:=$(call AltCheckSpaces,INSTALL_MSSDK)
 
@@ -631,7 +631,12 @@
 ifdef ALT_HOTSPOT_IMPORT_PATH
   HOTSPOT_IMPORT_PATH :=$(call FullPath,$(ALT_HOTSPOT_IMPORT_PATH))
 else
-  HOTSPOT_IMPORT_PATH =$(JDK_IMPORT_PATH)
+  # Default locations include the current $OUTPUTDIR, RE Promotions,
+  # and a JDK.  Please be aware the JDK does not include a Kernel VM.
+  _HOTSPOT_IMPORT_PATH1 = $(OUTPUTDIR)/hotspot/import
+  _HOTSPOT_IMPORT_PATH2 = $(PROMOTED_BUILD_DISTDIR)/hotspot/import
+  _HOTSPOT_IMPORT_PATH3 = $(JDK_IMPORT_PATH)
+   HOTSPOT_IMPORT_PATH := $(call DirExists,$(_HOTSPOT_IMPORT_PATH1),$(_HOTSPOT_IMPORT_PATH2),$(_HOTSPOT_IMPORT_PATH3))
 endif
 HOTSPOT_IMPORT_PATH:=$(call AltCheckSpaces,HOTSPOT_IMPORT_PATH)
 HOTSPOT_IMPORT_PATH:=$(call AltCheckValue,HOTSPOT_IMPORT_PATH)
@@ -665,4 +670,3 @@
 endif
 HOTSPOT_LIB_PATH:=$(call AltCheckSpaces,HOTSPOT_LIB_PATH)
 HOTSPOT_LIB_PATH:=$(call AltCheckValue,HOTSPOT_LIB_PATH)
-
--- a/jdk/make/common/shared/Defs.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/common/shared/Defs.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -292,6 +292,7 @@
 PROMOTED_RE_AREA = $(SLASH_JAVA)/re/jdk/$(JDK_VERSION)/promoted
 PROMOTED_BUILD_LATEST = latest
 PROMOTED_BUILD_BASEDIR = $(PROMOTED_RE_AREA)/$(PROMOTED_BUILD_LATEST)
+PROMOTED_BUILD_DISTDIR = $(PROMOTED_BUILD_BASEDIR)/dist/$(PLATFORM)-$(ARCH)
 PROMOTED_BUILD_BINARIES = $(PROMOTED_BUILD_BASEDIR)/binaries
 
 # PARALLEL_COMPILE_JOBS: is the number of compiles done in parallel.
--- a/jdk/make/common/shared/Sanity.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/common/shared/Sanity.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -1568,10 +1568,50 @@
 	    "" >> $(ERROR_FILE) ; \
 	fi
   endif
+	@#
+	@# Check for presence of headers required for new Java Plug-In ("plugin2")
+	@#
+	@if [ ! -r $(subst \,/,$(MOZILLA_HEADERS_PATH))/plugin2_mozilla_headers/npapi.h ]; then \
+	  $(ECHO) "ERROR: You do not have access to valid Mozilla header files for the new Java Plug-In. \n" \
+	    "      Please check your access to \n" \
+	    "          $(subst \,/,$(MOZILLA_HEADERS_PATH))/plugin2_mozilla_headers/npapi.h \n" \
+	    "      and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_MOZILLA_HEADERS_PATH, \n" \
+	    "" >> $(ERROR_FILE) ; \
+	fi
 endif
 
 
 ######################################################
+# Make sure Java Kernel VM is accessible
+######################################################
+sane-kernel-vm:
+ifeq ($(PLATFORM), windows)
+  ifeq ($(ARCH_DATA_MODEL), 32)
+	@if [ ! -r $(HOTSPOT_KERNEL_PATH)/jvm.dll ]; then \
+	    $(ECHO) "WARNING: Your HOTSPOT_IMPORT_PATH does not include a Kernel VM... \n" \
+		    "     The kernel installer may not be built (unless hotspot is also). \n" \
+		    "     $(HOTSPOT_KERNEL_PATH)/jvm.dll \n" \
+		    "     Please check the value of ALT_HOTSPOT_IMPORT_PATH. \n" \
+		    >> $(WARNING_FILE) ; \
+	fi
+  endif
+endif
+
+
+######################################################
+# SECURITY_BASELINE_131 test
+######################################################
+security_baseline_131:
+ifeq ($(PLATFORM), windows)
+	@if [ -z "$(SECURITY_BASELINE_131)" ]; then \
+	    $(ECHO) "WARNING: Your SECURITY_BASELINE_131 setting is empty.\n" \
+		"        Setting it to the default value of 1.3.1_20.\n" \
+		"        It is recommended to set SECURITY_BASELINE_131.\n" \
+		"" >> $(WARNING_FILE) ; \
+	fi
+endif
+
+######################################################
 # SECURITY_BASELINE_142 test
 ######################################################
 security_baseline_142:
@@ -1597,6 +1637,19 @@
 	fi
 endif
 
+######################################################
+# SECURITY_BASELINE_160 test
+######################################################
+security_baseline_160:
+ifeq ($(PLATFORM), windows)
+	@if [ -z "$(SECURITY_BASELINE_160)" ]; then \
+	    $(ECHO) "WARNING: Your SECURITY_BASELINE_160 setting is empty.\n" \
+		"        Setting it to the default value of 1.6.0_11.\n" \
+		"        It is recommended to set SECURITY_BASELINE_160.\n" \
+		"" >> $(WARNING_FILE) ; \
+	fi
+endif
+
 
 ######################################################
 # this should be the last rule in any target's sanity rule.
--- a/jdk/make/docs/CORE_PKGS.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/docs/CORE_PKGS.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -217,6 +217,7 @@
   javax.swing.plaf.basic                         \
   javax.swing.plaf.metal                         \
   javax.swing.plaf.multi                         \
+  javax.swing.plaf.nimbus                        \
   javax.swing.plaf.synth                         \
   javax.tools                                    \
   javax.transaction                              \
--- a/jdk/make/java/java/FILES_c.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/java/java/FILES_c.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -64,6 +64,7 @@
 	jio.c \
 	logging.c \
 	jni_util.c \
+	jni_util_md.c \
 	jdk_util.c \
 	jdk_util_md.c \
 	check_version.c \
--- a/jdk/make/java/redist/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/java/redist/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -119,10 +119,15 @@
 	$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMMAP_NAME) \
 	$(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMPDB_NAME)
 
-# Hotspot client is only available on 32-bit builds
+# Add .map and .pdb files to the import path for client and kernel VMs. 
+# These are only available on 32-bit windows builds. 
 ifeq ($(ARCH_DATA_MODEL), 32)
   IMPORT_LIST += $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMMAP_NAME) \
                  $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVMPDB_NAME)
+  ifeq ($(DO_KERNEL), true)
+    IMPORT_LIST += $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMMAP_NAME) \
+                   $(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMPDB_NAME)
+  endif
 endif
 
 $(LIBDIR)/$(JVMLIB_NAME): $(HOTSPOT_LIB_PATH)/$(JVMLIB_NAME)
@@ -134,6 +139,10 @@
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_CLIENT_PATH)/$(JVMMAP_NAME)  $@
 
+$(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMMAP_NAME):
+	@$(prep-target)
+	-$(CP) $(HOTSPOT_KERNEL_PATH)/$(JVMMAP_NAME)  $@
+
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMMAP_NAME):
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_SERVER_PATH)/$(JVMMAP_NAME) $@
@@ -142,6 +151,10 @@
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_CLIENT_PATH)/$(JVMPDB_NAME)  $@
 
+$(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVMPDB_NAME):
+	@$(prep-target)
+	-$(CP) $(HOTSPOT_KERNEL_PATH)/$(JVMPDB_NAME)  $@
+
 $(LIB_LOCATION)/$(SERVER_LOCATION)/$(JVMPDB_NAME): 
 	@$(prep-target)
 	-$(CP) $(HOTSPOT_SERVER_PATH)/$(JVMPDB_NAME) $@
@@ -195,6 +208,9 @@
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/$(JVM_NAME): $(HOTSPOT_CLIENT_PATH)/$(JVM_NAME)
 	$(install-import-file)
 
+$(LIB_LOCATION)/$(KERNEL_LOCATION)/$(JVM_NAME): $(HOTSPOT_KERNEL_PATH)/$(JVM_NAME)
+	$(install-file)
+
 $(LIB_LOCATION)/$(LIBJSIG_NAME): $(HOTSPOT_SERVER_PATH)/$(LIBJSIG_NAME)
 	$(install-import-file)
 
@@ -224,6 +240,9 @@
 $(LIB_LOCATION)/$(CLIENT_LOCATION)/Xusage.txt : $(HOTSPOT_CLIENT_PATH)/Xusage.txt
 	$(install-import-file)
 
+$(LIB_LOCATION)/$(KERNEL_LOCATION)/Xusage.txt : $(HOTSPOT_KERNEL_PATH)/Xusage.txt
+	$(install-file)
+
 ifeq ($(INCLUDE_SA), true)
 # The Serviceability Agent is built in the Hotspot workspace.
 # It contains two files:
--- a/jdk/make/jpda/tty/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/jpda/tty/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -33,6 +33,12 @@
 PROGRAM = jdb
 include $(BUILDDIR)/common/Defs.gmk
 
+# This program must contain a manifest that defines the execution level
+# needed to follow standard Vista User Access Control Guidelines
+# This must be set before Program.gmk is included
+#
+BUILD_MANIFEST=true
+
 #
 # Java Files to compile are found automatically.
 #
--- a/jdk/make/sun/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/sun/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -59,7 +59,7 @@
   RENDER_SUBDIR = dcpr
 endif
 # nio need to be compiled before awt to have all charsets ready
-SUBDIRS = jar security javazic misc net audio $(RENDER_SUBDIR) image \
+SUBDIRS = jar security javazic misc jkernel net audio $(RENDER_SUBDIR) image \
 	  nio awt splashscreen $(XAWT_SUBDIR) \
           $(HEADLESS_SUBDIR) $(DGA_SUBDIR) \
 	  font jpeg cmm applet rmi beans $(JDBC_SUBDIR) \
--- a/jdk/make/sun/applet/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/sun/applet/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -32,6 +32,12 @@
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
 
+# This program must contain a manifest that defines the execution level
+# needed to follow standard Vista User Access Control Guidelines
+# This must be set before Program.gmk is included
+#
+BUILD_MANIFEST=true
+
 #
 # Files to compile.
 #
--- a/jdk/make/sun/jar/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/sun/jar/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -32,6 +32,13 @@
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
 
+# This program must contain a manifest that defines the execution level
+# needed to follow standard Vista User Access Control Guidelines
+# This must be set before Program.gmk is included
+#
+BUILD_MANIFEST=true
+
+
 #
 # Files
 #
--- a/jdk/make/sun/javazic/tzdata_jdk/jdk11_full_backward	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/sun/javazic/tzdata_jdk/jdk11_full_backward	Tue Jul 21 13:02:23 2009 -0700
@@ -54,9 +54,9 @@
 Link Pacific/Guadalcanal SST
 Link Asia/Saigon VST
 
-# The follwong link is required to generate J2SE 1.2.x and 1.3.x
+# The follwong link is required to generate JDK 1.2.x and 1.3.x
 # compatible zones. In the Olson public source, MET is defined as
-# GMT+1:00 with the C-Eur rules. In J2SE, MET is defined as an alias
+# GMT+1:00 with the C-Eur rules. In JDK, MET is defined as an alias
 # of Asia/Tehran. This line must be removed if a full set of Olson
 # zones is generated. Otherwise, MET appears twice in the
 # ZoneInfoMappings.IDs table.
--- a/jdk/make/sun/jconsole/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/sun/jconsole/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -32,6 +32,13 @@
 PRODUCT = sun
 include $(BUILDDIR)/common/Defs.gmk
 
+# This program must contain a manifest that defines the execution level
+# needed to follow standard Vista User Access Control Guidelines
+# This must be set before Program.gmk is included
+#
+BUILD_MANIFEST=true
+
+
 JARFILE = $(LIBDIR)/jconsole.jar
 
 OTHER_JAVACFLAGS += -encoding iso8859-1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/sun/jkernel/FILES_c_windows.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,42 @@
+#
+# Copyright 2008 - 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.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 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.
+#
+
+FILES_cpp = \
+	stdafx.cpp \
+	kernel.cpp \
+	DownloadDialog.cpp \
+	DownloadHelper.cpp \
+	DownloadHelper.cpp
+
+
+FILES_rc = kernel.rc
+
+# FILES_export definitions for Win32
+
+FILES_export = \
+	sun/jkernel/DownloadManager.java \
+	sun/jkernel/Mutex.java \
+	sun/jkernel/Bundle.java \
+	sun/jkernel/BackgroundDownloader.java \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/sun/jkernel/FILES_java.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,41 @@
+#
+# Copyright 2008 - 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.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 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.
+#
+
+FILES_java = \
+	$(TARGDIR)sun/jkernel/BackgroundDownloader.java \
+	$(TARGDIR)sun/jkernel/Bundle.java \
+	$(TARGDIR)sun/jkernel/ByteArrayToFromHexDigits.java \
+	$(TARGDIR)sun/jkernel/BundleCheck.java \
+	$(TARGDIR)sun/jkernel/DownloadManager.java \
+	$(TARGDIR)sun/jkernel/Mutex.java \
+	$(TARGDIR)sun/jkernel/StandaloneByteArrayAccess.java \
+	$(TARGDIR)sun/jkernel/StandaloneMessageDigest.java \
+	$(TARGDIR)sun/jkernel/StandaloneSHA.java \
+
+FILES_export = \
+     sun/jkernel/DownloadManager.java \
+     sun/jkernel/Mutex.java \
+     sun/jkernel/Bundle.java \
+     sun/jkernel/BackgroundDownloader.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/sun/jkernel/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,90 @@
+#
+# Copyright 2008 - 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.  Sun designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Sun 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 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.
+#
+
+BUILDDIR = ../..
+PACKAGE = sun.jkernel
+LIBRARY = jkernel
+PRODUCT = sun
+
+include $(BUILDDIR)/common/Defs.gmk
+
+#
+# Use highest optimization level
+#
+_OPT = $(CC_HIGHEST_OPT)
+
+# This re-directs all the class files to a separate location
+CLASSDESTDIR = $(TEMPDIR)/classes
+
+
+#
+# Java source files
+#
+include FILES_java.gmk
+AUTO_FILES_JAVA_DIRS = sun/jkernel
+
+LOCALE_SUFFIXES = $(JDK_LOCALES)
+
+#
+# Native source files
+#
+
+ifeq ($(ARCH_DATA_MODEL), 32) 
+
+ifeq ($(PLATFORM), windows)
+
+include FILES_c_windows.gmk
+
+vpath %.cpp   $(PLATFORM_SRC)/native/sun/jkernel
+
+
+VERSIONINFO_RESOURCE = $(PLATFORM_SRC)/native/sun/jkernel/kernel.rc
+
+LDLIBS += urlmon.lib wininet.lib shlwapi.lib version.lib comctl32.lib gdi32.lib -def:$(PLATFORM_SRC)/native/sun/jkernel/kernel.def
+
+include $(BUILDDIR)/common/Library.gmk
+
+endif
+
+endif
+
+#
+# Resources
+#
+include $(TOPDIR)/make/common/internal/Resources.gmk
+
+#
+# Rules
+#
+include $(BUILDDIR)/common/Classes.gmk
+
+# If extra compression is going to be available in the deploy build enable 
+# its use here by defining the JRE-relative pathname of the shared library
+
+ifeq ($(PLATFORM), windows)
+  ifdef EXTRA_COMP_INSTALL_PATH
+    CPPFLAGS += -DEXTRA_COMP_INSTALL_PATH=$(EXTRA_COMP_INSTALL_PATH)
+  endif
+endif
--- a/jdk/make/sun/native2ascii/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/sun/native2ascii/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -33,6 +33,13 @@
 OTHER_JAVACFLAGS += -Xlint:serial -Werror
 include $(BUILDDIR)/common/Defs.gmk
 
+# This program must contain a manifest that defines the execution level
+# needed to follow standard Vista User Access Control Guidelines
+# This must be set before Program.gmk is included
+#
+BUILD_MANIFEST=true
+
+
 #
 # Files
 #
--- a/jdk/make/sun/rmi/rmic/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/sun/rmi/rmic/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -33,6 +33,13 @@
 include $(BUILDDIR)/common/Defs.gmk
 
 #
+# This program must contain a manifest that defines the execution level
+# needed to follow standard Vista User Access Control Guidelines
+# This must be set before Program.gmk is included
+#
+BUILD_MANIFEST=true
+
+#
 # Files
 #
 include FILES.gmk
--- a/jdk/make/sun/serialver/Makefile	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/sun/serialver/Makefile	Tue Jul 21 13:02:23 2009 -0700
@@ -33,6 +33,14 @@
 include $(BUILDDIR)/common/Defs.gmk
 
 #
+# This program must contain a manifest that defines the execution level
+# needed to follow standard Vista User Access Control Guidelines
+# This must be set before Program.gmk is included
+#
+BUILD_MANIFEST=true
+
+
+#
 # Files
 #
 AUTO_FILES_JAVA_DIRS = sun/tools/serialver
--- a/jdk/make/sun/xawt/mapfile-vers	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/make/sun/xawt/mapfile-vers	Tue Jul 21 13:02:23 2009 -0700
@@ -125,6 +125,7 @@
         Java_sun_awt_X11_XlibWrapper_XFree;
         Java_sun_awt_X11_XlibWrapper_ServerVendor;
         Java_sun_awt_X11_XlibWrapper_VendorRelease;
+        Java_sun_awt_X11_XlibWrapper_IsXsunKPBehavior;
         Java_sun_awt_X11_XlibWrapper_SetToolkitErrorHandler;
         Java_sun_awt_X11_XlibWrapper_XSetErrorHandler;
         Java_sun_awt_X11_XlibWrapper_CallErrorHandler;
--- a/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/com/sun/java/swing/SwingUtilities3.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2002-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
@@ -27,13 +27,17 @@
 
 import sun.awt.EventQueueDelegate;
 import sun.awt.AppContext;
+import java.util.Collections;
 import java.util.Map;
+import java.util.WeakHashMap;
 import java.util.concurrent.Callable;
 import java.awt.AWTEvent;
 import java.awt.EventQueue;
 import java.awt.Component;
+import java.awt.Container;
 import javax.swing.JComponent;
 import javax.swing.RepaintManager;
+import javax.swing.SwingUtilities;
 
 /**
  * A collection of utility methods for Swing.
@@ -69,6 +73,43 @@
                                     repaintManager);
     }
 
+    private static final Map<Container, Boolean> vsyncedMap =
+        Collections.synchronizedMap(new WeakHashMap<Container, Boolean>());
+
+    /**
+     * Sets vsyncRequested state for the {@code rootContainer}.  If
+     * {@code isRequested} is {@code true} then vsynced
+     * {@code BufferStrategy} is enabled for this {@code rootContainer}.
+     *
+     * Note: requesting vsynced painting does not guarantee one. The outcome
+     * depends on current RepaintManager's RepaintManager.PaintManager
+     * and on the capabilities of the graphics hardware/software and what not.
+     *
+     * @param rootContainer topmost container. Should be either {@code Window}
+     *  or {@code Applet}
+     * @param isRequested the value to set vsyncRequested state to
+     */
+    public static void setVsyncRequested(Container rootContainer,
+                                         boolean isRequested) {
+        assert SwingUtilities.getRoot(rootContainer) == rootContainer;
+        if (isRequested) {
+            vsyncedMap.put(rootContainer, Boolean.TRUE);
+        } else {
+            vsyncedMap.remove(rootContainer);
+        }
+    }
+
+    /**
+     * Checks if vsync painting is requested for {@code rootContainer}
+     *
+     * @param rootContainer topmost container. Should be either Window or Applet
+     * @return {@code true} if vsync painting is requested for {@code rootContainer}
+     */
+    public static boolean isVsyncRequested(Container rootContainer) {
+        assert SwingUtilities.getRoot(rootContainer) == rootContainer;
+        return Boolean.TRUE == vsyncedMap.get(rootContainer);
+    }
+
     /**
      * Returns delegate {@code RepaintManager} for {@code component} hierarchy.
      */
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/gtk/GTKLookAndFeel.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2002-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
@@ -139,7 +139,7 @@
                                     });
                     isSunDesktop = val.booleanValue();
             }
-            if (isSunDesktop) {
+            if (isSunDesktop && !sun.java2d.SunGraphicsEnvironment.isOpenSolaris) {
                 isSunCJK = true;
             }
         }
--- a/jdk/src/share/classes/java/awt/AWTEvent.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/awt/AWTEvent.java	Tue Jul 21 13:02:23 2009 -0700
@@ -32,6 +32,7 @@
 import java.lang.reflect.Field;
 import java.util.logging.Logger;
 import java.util.logging.Level;
+import sun.awt.AWTAccessor;
 
 /**
  * The root event class for all AWT events.
@@ -230,6 +231,12 @@
         if (!GraphicsEnvironment.isHeadless()) {
             initIDs();
         }
+        AWTAccessor.setAWTEventAccessor(
+            new AWTAccessor.AWTEventAccessor() {
+                public void setPosted(AWTEvent ev) {
+                    ev.isPosted = true;
+                }
+            });
     }
 
     private static synchronized Field get_InputEvent_CanAccessSystemClipboard() {
--- a/jdk/src/share/classes/java/awt/Component.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Component.java	Tue Jul 21 13:02:23 2009 -0700
@@ -861,6 +861,17 @@
             public boolean isVisible_NoClientCode(Component comp) {
                 return comp.isVisible_NoClientCode();
             }
+            public void setRequestFocusController
+                (RequestFocusController requestController)
+            {
+                 Component.setRequestFocusController(requestController);
+            }
+            public AppContext getAppContext(Component comp) {
+                 return comp.appContext;
+            }
+            public void setAppContext(Component comp, AppContext appContext) {
+                 comp.appContext = appContext;
+            }
         });
     }
 
@@ -9824,31 +9835,6 @@
 
     // ****************** END OF MIXING CODE ********************************
 
-    private static boolean doesClassImplement(Class cls, String interfaceName) {
-        if (cls == null) return false;
-
-        for (Class c : cls.getInterfaces()) {
-            if (c.getName().equals(interfaceName)) {
-                return true;
-            }
-        }
-        return doesClassImplement(cls.getSuperclass(), interfaceName);
-    }
-
-    /**
-     * Checks that the given object implements the given interface.
-     * @param obj Object to be checked
-     * @param interfaceName The name of the interface. Must be fully-qualified interface name.
-     * @return true, if this object implements the given interface,
-     *         false, otherwise, or if obj or interfaceName is null
-     */
-    static boolean doesImplement(Object obj, String interfaceName) {
-        if (obj == null) return false;
-        if (interfaceName == null) return false;
-
-        return doesClassImplement(obj.getClass(), interfaceName);
-    }
-
     // Note that the method is overriden in the Window class,
     // a window doesn't need to be updated in the Z-order.
     void updateZOrder() {
--- a/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/awt/ContainerOrderFocusTraversalPolicy.java	Tue Jul 21 13:02:23 2009 -0700
@@ -425,15 +425,13 @@
             }
             if (log.isLoggable(Level.FINE)) log.fine("### Cycle is " + cycle);
 
-            for (int i = 0; i < cycle.size(); i++) {
-                Component comp = cycle.get(i);
+            for (Component comp : cycle) {
                 if (accept(comp)) {
                     return comp;
-                } else if (comp instanceof Container && comp != aContainer) {
-                    Container cont = (Container)comp;
-                    if (cont.isFocusTraversalPolicyProvider()) {
-                        return cont.getFocusTraversalPolicy().getDefaultComponent(cont);
-                    }
+                } else if (comp != aContainer &&
+                           (comp = getComponentDownCycle(comp, FORWARD_TRAVERSAL)) != null)
+                {
+                    return comp;
                 }
             }
         }
--- a/jdk/src/share/classes/java/awt/Dialog.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Dialog.java	Tue Jul 21 13:02:23 2009 -0700
@@ -262,12 +262,6 @@
         TOOLKIT_EXCLUDE
     };
 
-    /**
-     * @since 1.6
-     */
-    private final static ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE =
-        ModalExclusionType.APPLICATION_EXCLUDE;
-
     /* operations with this list should be synchronized on tree lock*/
     transient static IdentityArrayList<Dialog> modalDialogs = new IdentityArrayList<Dialog>();
 
--- a/jdk/src/share/classes/java/awt/EventQueue.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/awt/EventQueue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -43,6 +43,7 @@
 import sun.awt.PeerEvent;
 import sun.awt.SunToolkit;
 import sun.awt.EventQueueItem;
+import sun.awt.AWTAccessor;
 
 /**
  * <code>EventQueue</code> is a platform-independent class
@@ -154,6 +155,18 @@
 
     private static final Logger eventLog = Logger.getLogger("java.awt.event.EventQueue");
 
+    static {
+        AWTAccessor.setEventQueueAccessor(
+            new AWTAccessor.EventQueueAccessor() {
+                public EventQueue getNextQueue(EventQueue eventQueue) {
+                    return eventQueue.nextQueue;
+                }
+                public Thread getDispatchThread(EventQueue eventQueue) {
+                    return eventQueue.dispatchThread;
+                }
+            });
+    }
+
     public EventQueue() {
         for (int i = 0; i < NUM_PRIORITIES; i++) {
             queues[i] = new Queue();
--- a/jdk/src/share/classes/java/awt/MenuComponent.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/awt/MenuComponent.java	Tue Jul 21 13:02:23 2009 -0700
@@ -30,6 +30,7 @@
 import java.io.ObjectInputStream;
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
+import sun.awt.AWTAccessor;
 import javax.accessibility.*;
 
 /**
@@ -109,6 +110,22 @@
      */
     private static final long serialVersionUID = -4536902356223894379L;
 
+    static {
+        AWTAccessor.setMenuComponentAccessor(
+            new AWTAccessor.MenuComponentAccessor() {
+                public AppContext getAppContext(MenuComponent menuComp) {
+                    return menuComp.appContext;
+                }
+                public void setAppContext(MenuComponent menuComp,
+                                          AppContext appContext) {
+                    menuComp.appContext = appContext;
+                }
+                public MenuContainer getParent(MenuComponent menuComp) {
+                    return menuComp.parent;
+                }
+            });
+    }
+
     /**
      * Creates a <code>MenuComponent</code>.
      * @exception HeadlessException if
--- a/jdk/src/share/classes/java/awt/PopupMenu.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/awt/PopupMenu.java	Tue Jul 21 13:02:23 2009 -0700
@@ -28,6 +28,7 @@
 import java.awt.peer.PopupMenuPeer;
 import javax.accessibility.*;
 
+import sun.awt.AWTAccessor;
 
 /**
  * A class that implements a menu which can be dynamically popped up
@@ -48,6 +49,15 @@
 
     transient boolean isTrayIconPopup = false;
 
+    static {
+        AWTAccessor.setPopupMenuAccessor(
+            new AWTAccessor.PopupMenuAccessor() {
+                public boolean isTrayIconPopup(PopupMenu popupMenu) {
+                    return popupMenu.isTrayIconPopup;
+                }
+            });
+    }
+
     /*
      * JDK 1.1 serialVersionUID
      */
--- a/jdk/src/share/classes/java/awt/Window.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/awt/Window.java	Tue Jul 21 13:02:23 2009 -0700
@@ -3658,7 +3658,7 @@
     private static void setLayersOpaque(Component component, boolean isOpaque) {
         // Shouldn't use instanceof to avoid loading Swing classes
         //    if it's a pure AWT application.
-        if (Component.doesImplement(component, "javax.swing.RootPaneContainer")) {
+        if (SunToolkit.isInstanceOf(component, "javax.swing.RootPaneContainer")) {
             javax.swing.RootPaneContainer rpc = (javax.swing.RootPaneContainer)component;
             javax.swing.JRootPane root = rpc.getRootPane();
             javax.swing.JLayeredPane lp = root.getLayeredPane();
@@ -3839,6 +3839,10 @@
             {
                 return window.calculateSecurityWarningPosition(x, y, w, h);
             }
+
+            public void setLWRequestStatus(Window changed, boolean status) {
+                changed.syncLWRequests = status;
+            }
         }); // WindowAccessor
     } // static
 
--- a/jdk/src/share/classes/java/awt/color/ICC_Profile.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/awt/color/ICC_Profile.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1844,10 +1844,18 @@
             }
 
         if (!f.isFile()) { /* try the directory of built-in profiles */
-                dir = System.getProperty("java.home") +
-                    File.separatorChar + "lib" + File.separatorChar + "cmm";
-                fullPath = dir + File.separatorChar + fileName;
+            dir = System.getProperty("java.home") +
+                File.separatorChar + "lib" + File.separatorChar + "cmm";
+            fullPath = dir + File.separatorChar + fileName;
                 f = new File(fullPath);
+                if (!f.isFile()) {
+                    //make sure file was installed in the kernel mode
+                    try {
+                        //kernel uses platform independent paths =>
+                        //   should not use platform separator char
+                        sun.jkernel.DownloadManager.downloadFile("lib/cmm/"+fileName);
+                    } catch (IOException ioe) {}
+                }
             }
 
         if (f.isFile()) {
--- a/jdk/src/share/classes/java/beans/MetaData.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/beans/MetaData.java	Tue Jul 21 13:02:23 2009 -0700
@@ -93,7 +93,7 @@
 
     protected Expression instantiate(Object oldInstance, Encoder out) {
         Enum e = (Enum) oldInstance;
-        return new Expression(e, Enum.class, "valueOf", new Object[]{e.getClass(), e.name()});
+        return new Expression(e, Enum.class, "valueOf", new Object[]{e.getDeclaringClass(), e.name()});
     }
 }
 
--- a/jdk/src/share/classes/java/lang/ClassLoader.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java	Tue Jul 21 13:02:23 2009 -0700
@@ -58,6 +58,7 @@
 import sun.misc.VM;
 import sun.reflect.Reflection;
 import sun.security.util.SecurityConstants;
+import sun.jkernel.DownloadManager;
 
 /**
  * A class loader is an object that is responsible for loading classes. The
@@ -1280,6 +1281,21 @@
      * Find resources from the VM's built-in classloader.
      */
     private static URL getBootstrapResource(String name) {
+        try {
+            // If this is a known JRE resource, ensure that its bundle is
+            // downloaded.  If it isn't known, we just ignore the download
+            // failure and check to see if we can find the resource anyway
+            // (which is possible if the boot class path has been modified).
+            if (sun.misc.VM.isBootedKernelVM()) {
+                sun.jkernel.DownloadManager.getBootClassPathEntryForResource(
+                    name);
+            }
+        } catch (NoClassDefFoundError e) {
+            // This happens while Java itself is being compiled; DownloadManager
+            // isn't accessible when this code is first invoked.  It isn't an
+            // issue, as if we can't find DownloadManager, we can safely assume
+            // that additional code is not available for download.
+        }
         URLClassPath ucp = getBootstrapClassPath();
         Resource res = ucp.getResource(name);
         return res != null ? res.getURL() : null;
@@ -1305,13 +1321,9 @@
 
     // Returns the URLClassPath that is used for finding system resources.
     static URLClassPath getBootstrapClassPath() {
-        if (bootstrapClassPath == null) {
-            bootstrapClassPath = sun.misc.Launcher.getBootstrapClassPath();
-        }
-        return bootstrapClassPath;
+        return sun.misc.Launcher.getBootstrapClassPath();
     }
 
-    private static URLClassPath bootstrapClassPath;
 
     /**
      * Returns an input stream for reading the specified resource.
@@ -1800,6 +1812,24 @@
     // Invoked in the java.lang.Runtime class to implement load and loadLibrary.
     static void loadLibrary(Class fromClass, String name,
                             boolean isAbsolute) {
+        try {
+            if (VM.isBootedKernelVM() && !DownloadManager.isJREComplete() &&
+                    !DownloadManager.isCurrentThreadDownloading()) {
+                DownloadManager.downloadFile("bin/" +
+                    System.mapLibraryName(name));
+                // it doesn't matter if the downloadFile call returns false --
+                // it probably just means that this is a user library, as
+                // opposed to a JRE library
+            }
+        } catch (IOException e) {
+            throw new UnsatisfiedLinkError("Error downloading library " +
+                                                name + ": " + e);
+        } catch (NoClassDefFoundError e) {
+            // This happens while Java itself is being compiled; DownloadManager
+            // isn't accessible when this code is first invoked.  It isn't an
+            // issue, as if we can't find DownloadManager, we can safely assume
+            // that additional code is not available for download.
+        }
         ClassLoader loader =
             (fromClass == null) ? null : fromClass.getClassLoader();
         if (sys_paths == null) {
--- a/jdk/src/share/classes/java/lang/ClassNotFoundException.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/ClassNotFoundException.java	Tue Jul 21 13:02:23 2009 -0700
@@ -50,7 +50,7 @@
  * @see     java.lang.ClassLoader#loadClass(java.lang.String, boolean)
  * @since   JDK1.0
  */
-public class ClassNotFoundException extends Exception {
+public class ClassNotFoundException extends ReflectiveOperationException {
     /**
      * use serialVersionUID from JDK 1.1.X for interoperability
      */
--- a/jdk/src/share/classes/java/lang/Double.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/Double.java	Tue Jul 21 13:02:23 2009 -0700
@@ -529,6 +529,7 @@
      * @param  s   the string to be parsed.
      * @return the {@code double} value represented by the string
      *         argument.
+     * @throws NullPointerException  if the string is null
      * @throws NumberFormatException if the string does not contain
      *         a parsable {@code double}.
      * @see    java.lang.Double#valueOf(String)
--- a/jdk/src/share/classes/java/lang/Float.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/Float.java	Tue Jul 21 13:02:23 2009 -0700
@@ -438,12 +438,13 @@
      * represented by the specified {@code String}, as performed
      * by the {@code valueOf} method of class {@code Float}.
      *
-     * @param      s   the string to be parsed.
+     * @param  s the string to be parsed.
      * @return the {@code float} value represented by the string
      *         argument.
-     * @throws  NumberFormatException  if the string does not contain a
+     * @throws NullPointerException  if the string is null
+     * @throws NumberFormatException if the string does not contain a
      *               parsable {@code float}.
-     * @see        java.lang.Float#valueOf(String)
+     * @see    java.lang.Float#valueOf(String)
      * @since 1.2
      */
     public static float parseFloat(String s) throws NumberFormatException {
--- a/jdk/src/share/classes/java/lang/IllegalAccessException.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/IllegalAccessException.java	Tue Jul 21 13:02:23 2009 -0700
@@ -56,7 +56,7 @@
  * @see     java.lang.reflect.Constructor#newInstance(Object[])
  * @since   JDK1.0
  */
-public class IllegalAccessException extends Exception {
+public class IllegalAccessException extends ReflectiveOperationException {
     private static final long serialVersionUID = 6616958222490762034L;
 
     /**
--- a/jdk/src/share/classes/java/lang/InstantiationException.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/InstantiationException.java	Tue Jul 21 13:02:23 2009 -0700
@@ -43,7 +43,7 @@
  * @since   JDK1.0
  */
 public
-class InstantiationException extends Exception {
+class InstantiationException extends ReflectiveOperationException {
     private static final long serialVersionUID = -8441929162975509110L;
 
     /**
--- a/jdk/src/share/classes/java/lang/NoSuchFieldException.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/NoSuchFieldException.java	Tue Jul 21 13:02:23 2009 -0700
@@ -31,7 +31,7 @@
  * @author  unascribed
  * @since   JDK1.1
  */
-public class NoSuchFieldException extends Exception {
+public class NoSuchFieldException extends ReflectiveOperationException {
     private static final long serialVersionUID = -6143714805279938260L;
 
     /**
--- a/jdk/src/share/classes/java/lang/NoSuchMethodException.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/NoSuchMethodException.java	Tue Jul 21 13:02:23 2009 -0700
@@ -32,7 +32,7 @@
  * @since      JDK1.0
  */
 public
-class NoSuchMethodException extends Exception {
+class NoSuchMethodException extends ReflectiveOperationException {
     private static final long serialVersionUID = 5034388446362600923L;
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/lang/ReflectiveOperationException.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,91 @@
+/*
+ * 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package java.lang;
+
+/**
+ * Common superclass of exceptions thrown by reflective operations in
+ * core reflection.
+ *
+ * @see LinkageError
+ * @since 1.7
+ */
+public class ReflectiveOperationException extends Exception {
+    static final long serialVersionUID = 123456789L;
+
+    /**
+     * Constructs a new exception with {@code null} as its detail
+     * message.  The cause is not initialized, and may subsequently be
+     * initialized by a call to {@link #initCause}.
+     */
+    public ReflectiveOperationException() {
+        super();
+    }
+
+    /**
+     * Constructs a new exception with the specified detail message.
+     * The cause is not initialized, and may subsequently be
+     * initialized by a call to {@link #initCause}.
+     *
+     * @param   message   the detail message. The detail message is saved for
+     *          later retrieval by the {@link #getMessage()} method.
+     */
+    public ReflectiveOperationException(String message) {
+        super(message);
+    }
+
+    /**
+     * Constructs a new exception with the specified detail message
+     * and cause.
+     *
+     * <p>Note that the detail message associated with
+     * {@code cause} is <em>not</em> automatically incorporated in
+     * this exception's detail message.
+     *
+     * @param  message the detail message (which is saved for later retrieval
+     *         by the {@link #getMessage()} method).
+     * @param  cause the cause (which is saved for later retrieval by the
+     *         {@link #getCause()} method).  (A {@code null} value is
+     *         permitted, and indicates that the cause is nonexistent or
+     *         unknown.)
+     */
+    public ReflectiveOperationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    /**
+     * Constructs a new exception with the specified cause and a detail
+     * message of {@code (cause==null ? null : cause.toString())} (which
+     * typically contains the class and detail message of {@code cause}).
+     *
+     * @param  cause the cause (which is saved for later retrieval by the
+     *         {@link #getCause()} method).  (A {@code null} value is
+     *         permitted, and indicates that the cause is nonexistent or
+     *         unknown.)
+     */
+    public ReflectiveOperationException(Throwable cause) {
+        super(cause);
+    }
+}
--- a/jdk/src/share/classes/java/lang/System.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/System.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1106,12 +1106,22 @@
         initProperties(props);
         sun.misc.Version.init();
 
+        // Workaround until DownloadManager initialization is revisited.
+        // Make JavaLangAccess available early enough for internal
+        // Shutdown hooks to be registered
+        setJavaLangAccess();
+
         // Gets and removes system properties that configure the Integer
         // cache used to support the object identity semantics of autoboxing.
         // At this time, the size of the cache may be controlled by the
-        // -XX:AutoBoxCacheMax=<size> option.
+        // vm option -XX:AutoBoxCacheMax=<size>.
         Integer.getAndRemoveCacheProperties();
 
+        // Load the zip library now in order to keep java.util.zip.ZipFile
+        // from trying to use itself to load this library later.
+        loadLibrary("zip");
+
+
         FileInputStream fdIn = new FileInputStream(FileDescriptor.in);
         FileOutputStream fdOut = new FileOutputStream(FileDescriptor.out);
         FileOutputStream fdErr = new FileOutputStream(FileDescriptor.err);
@@ -1119,10 +1129,6 @@
         setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true));
         setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true));
 
-        // Load the zip library now in order to keep java.util.zip.ZipFile
-        // from trying to use itself to load this library later.
-        loadLibrary("zip");
-
         // Setup Java signal handlers for HUP, TERM, and INT (where available).
         Terminator.setup();
 
@@ -1152,7 +1158,9 @@
         // way as other threads; we must do it ourselves here.
         Thread current = Thread.currentThread();
         current.getThreadGroup().add(current);
+    }
 
+    private static void setJavaLangAccess() {
         // Allow privileged classes outside of java.lang
         sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
             public sun.reflect.ConstantPool getConstantPool(Class klass) {
--- a/jdk/src/share/classes/java/lang/reflect/InvocationTargetException.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/InvocationTargetException.java	Tue Jul 21 13:02:23 2009 -0700
@@ -39,7 +39,7 @@
  * @see Method
  * @see Constructor
  */
-public class InvocationTargetException extends Exception {
+public class InvocationTargetException extends ReflectiveOperationException {
     /**
      * Use serialVersionUID from JDK 1.1.X for interoperability
      */
--- a/jdk/src/share/classes/java/security/cert/CertPathHelperImpl.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/security/cert/CertPathHelperImpl.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2002-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
@@ -46,7 +46,7 @@
     /**
      * Initialize the helper framework. This method must be called from
      * the static initializer of each class that is the target of one of
-     * the methods in this class. This ensures that the helper if initialized
+     * the methods in this class. This ensures that the helper is initialized
      * prior to a tunneled call from the Sun provider.
      */
     synchronized static void initialize() {
@@ -59,4 +59,8 @@
             Set<GeneralNameInterface> names) {
         sel.setPathToNamesInternal(names);
     }
+
+    protected void implSetDateAndTime(X509CRLSelector sel, Date date, long skew) {
+        sel.setDateAndTime(date, skew);
+    }
 }
--- a/jdk/src/share/classes/java/security/cert/X509CRLSelector.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/security/cert/X509CRLSelector.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-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
@@ -72,6 +72,10 @@
  */
 public class X509CRLSelector implements CRLSelector {
 
+    static {
+        CertPathHelperImpl.initialize();
+    }
+
     private static final Debug debug = Debug.getInstance("certpath");
     private HashSet<Object> issuerNames;
     private HashSet<X500Principal> issuerX500Principals;
@@ -79,6 +83,7 @@
     private BigInteger maxCRL;
     private Date dateAndTime;
     private X509Certificate certChecking;
+    private long skew = 0;
 
     /**
      * Creates an <code>X509CRLSelector</code>. Initially, no criteria are set
@@ -417,7 +422,18 @@
         if (dateAndTime == null)
             this.dateAndTime = null;
         else
-            this.dateAndTime = (Date) dateAndTime.clone();
+            this.dateAndTime = new Date(dateAndTime.getTime());
+        this.skew = 0;
+    }
+
+    /**
+     * Sets the dateAndTime criterion and allows for the specified clock skew
+     * (in milliseconds) when checking against the validity period of the CRL.
+     */
+    void setDateAndTime(Date dateAndTime, long skew) {
+        this.dateAndTime =
+            (dateAndTime == null ? null : new Date(dateAndTime.getTime()));
+        this.skew = skew;
     }
 
     /**
@@ -657,8 +673,14 @@
                 }
                 return false;
             }
-            if (crlThisUpdate.after(dateAndTime)
-                  || nextUpdate.before(dateAndTime)) {
+            Date nowPlusSkew = dateAndTime;
+            Date nowMinusSkew = dateAndTime;
+            if (skew > 0) {
+                nowPlusSkew = new Date(dateAndTime.getTime() + skew);
+                nowMinusSkew = new Date(dateAndTime.getTime() - skew);
+            }
+            if (nowMinusSkew.after(nextUpdate)
+                || nowPlusSkew.before(crlThisUpdate)) {
                 if (debug != null) {
                     debug.println("X509CRLSelector.match: update out of range");
                 }
--- a/jdk/src/share/classes/java/text/SimpleDateFormat.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/text/SimpleDateFormat.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1030,9 +1030,9 @@
 
         case 1: // 'y' - YEAR
             if (calendar instanceof GregorianCalendar) {
-                if (count >= 4)
+                if (count != 2)
                     zeroPaddingNumber(value, count, maxIntCount, buffer);
-                else // count < 4
+                else // count == 2
                     zeroPaddingNumber(value, 2, 2, buffer); // clip 1996 to 96
             } else {
                 if (current == null) {
--- a/jdk/src/share/classes/java/util/zip/ZipEntry.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/java/util/zip/ZipEntry.java	Tue Jul 21 13:02:23 2009 -0700
@@ -109,7 +109,15 @@
      * @see #getTime()
      */
     public void setTime(long time) {
-        this.time = javaToDosTime(time);
+        // fix for bug 6625963: we bypass time calculations while Kernel is
+        // downloading bundles, since they aren't necessary and would cause
+        // the Kernel core to depend upon the (very large) time zone data
+        if (sun.misc.VM.isBootedKernelVM() &&
+            sun.jkernel.DownloadManager.isCurrentThreadDownloading()) {
+            this.time = sun.jkernel.DownloadManager.KERNEL_STATIC_MODTIME;
+        } else {
+            this.time = javaToDosTime(time);
+        }
     }
 
     /**
@@ -245,10 +253,14 @@
      * the first 0xFFFF bytes are output to the ZIP file entry.
      *
      * @param comment the comment string
-     *
+     * @exception IllegalArgumentException if the length of the specified
+     *            comment string is greater than 0xFFFF bytes
      * @see #getComment()
      */
     public void setComment(String comment) {
+        if (comment != null && comment.length() > 0xffff) {
+            throw new IllegalArgumentException("invalid entry comment length");
+        }
         this.comment = comment;
     }
 
--- a/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/BufferStrategyPaintManager.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2005-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
@@ -33,9 +33,14 @@
 import java.security.AccessController;
 import java.util.*;
 import java.util.logging.*;
+
+import com.sun.java.swing.SwingUtilities3;
+
 import sun.awt.SubRegionShowable;
 import sun.java2d.SunGraphics2D;
 import sun.security.action.GetPropertyAction;
+import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
+import sun.awt.SunToolkit;
 
 /**
  * A PaintManager implementation that uses a BufferStrategy for
@@ -73,12 +78,6 @@
     private static Method COMPONENT_CREATE_BUFFER_STRATEGY_METHOD;
     private static Method COMPONENT_GET_BUFFER_STRATEGY_METHOD;
 
-    /**
-     * Indicates whether or not we should try and get a flip buffer strategy
-     * first, default is false.
-     */
-    private static boolean TRY_FLIP;
-
     private static final Logger LOGGER = Logger.getLogger(
                            "javax.swing.BufferStrategyPaintManager");
 
@@ -151,12 +150,6 @@
      */
     private boolean disposeBufferOnEnd;
 
-
-    static {
-        TRY_FLIP = "true".equals(AccessController.doPrivileged(
-              new GetPropertyAction("swing.useFlipBufferStrategy", "false")));
-    }
-
     private static Method getGetBufferStrategyMethod() {
         if (COMPONENT_GET_BUFFER_STRATEGY_METHOD == null) {
             getMethods();
@@ -257,7 +250,7 @@
         try {
             BufferInfo info = getBufferInfo(c);
             BufferStrategy bufferStrategy;
-            if (info != null && !info.usingFlip && info.isInSync() &&
+            if (info != null && info.isInSync() &&
                 (bufferStrategy = info.getBufferStrategy(false)) != null) {
                 SubRegionShowable bsSubRegion =
                         (SubRegionShowable)bufferStrategy;
@@ -579,8 +572,9 @@
         rootJ = c;
         root = c;
         xOffset = yOffset = 0;
-        while (root != null && (!(root instanceof Window) &&
-                                !(root instanceof Applet))) {
+        while (root != null &&
+               (!(root instanceof Window) &&
+                !SunToolkit.isInstanceOf(root, "java.applet.Applet"))) {
             xOffset += root.getX();
             yOffset += root.getY();
             root = root.getParent();
@@ -685,8 +679,6 @@
         // same reason.
         private WeakReference<BufferStrategy> weakBS;
         private WeakReference<Container> root;
-        // Whether or not we're using flip bs or blit.
-        private boolean usingFlip;
         // Indicates whether or not the backbuffer and display are in sync.
         // This is set to true when a full repaint on the rootpane is done.
         private boolean inSync;
@@ -764,13 +756,6 @@
         }
 
         /**
-         * Returns true if using a flip buffer strategy.
-         */
-        public boolean usingFlip() {
-            return usingFlip;
-        }
-
-        /**
          * Returns true if the buffer strategy of the component differs
          * from current buffer strategy.
          */
@@ -814,23 +799,19 @@
          * blit.
          */
         private BufferStrategy createBufferStrategy() {
-            BufferCapabilities caps;
             Container root = getRoot();
             if (root == null) {
                 return null;
             }
             BufferStrategy bs = null;
-            if (TRY_FLIP) {
-                bs = createBufferStrategy(root,BufferCapabilities.FlipContents.
-                                          COPIED);
-                usingFlip = true;
+            if (SwingUtilities3.isVsyncRequested(root)) {
+                bs = createBufferStrategy(root, true);
                 if (LOGGER.isLoggable(Level.FINER)) {
-                    LOGGER.finer("createBufferStrategy: using flip strategy");
+                    LOGGER.finer("createBufferStrategy: using vsynced strategy");
                 }
             }
             if (bs == null) {
-                bs = createBufferStrategy(root, null);
-                usingFlip = false;
+                bs = createBufferStrategy(root, false);
             }
             if (!(bs instanceof SubRegionShowable)) {
                 // We do this for two reasons:
@@ -843,17 +824,24 @@
             return bs;
         }
 
-        // Creates and returns a buffer strategy of the requested type.  If
+        // Creates and returns a buffer strategy.  If
         // there is a problem creating the buffer strategy this will
         // eat the exception and return null.
         private BufferStrategy createBufferStrategy(Container root,
-                                     BufferCapabilities.FlipContents type) {
-            BufferCapabilities caps = new BufferCapabilities(
-                    new ImageCapabilities(true),
-                    new ImageCapabilities(true),
-                    type);
+                boolean isVsynced) {
+            BufferCapabilities caps;
+            if (isVsynced) {
+                caps = new ExtendedBufferCapabilities(
+                    new ImageCapabilities(true), new ImageCapabilities(true),
+                    BufferCapabilities.FlipContents.COPIED,
+                    ExtendedBufferCapabilities.VSyncType.VSYNC_ON);
+            } else {
+                caps = new BufferCapabilities(
+                    new ImageCapabilities(true), new ImageCapabilities(true),
+                    null);
+            }
             BufferStrategy bs = null;
-            if (root instanceof Applet) {
+            if (SunToolkit.isInstanceOf(root, "java.applet.Applet")) {
                 try {
                     getCreateBufferStrategyMethod().invoke(root, 2, caps);
                     bs = (BufferStrategy)getGetBufferStrategyMethod().
--- a/jdk/src/share/classes/javax/swing/JLayeredPane.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/JLayeredPane.java	Tue Jul 21 13:02:23 2009 -0700
@@ -30,6 +30,7 @@
 import java.awt.Color;
 import java.awt.Graphics;
 import java.awt.Rectangle;
+import sun.awt.SunToolkit;
 
 import javax.accessibility.*;
 
@@ -195,9 +196,12 @@
 
             for (Component c : getComponents()) {
                 layer = null;
-                if(c instanceof JInternalFrame || (c instanceof JComponent &&
-                         (layer = (Integer)((JComponent)c).getClientProperty(
-                          LAYER_PROPERTY)) != null)) {
+
+                if(SunToolkit.isInstanceOf(c, "javax.swing.JInternalFrame") ||
+                       (c instanceof JComponent &&
+                        (layer = (Integer)((JComponent)c).
+                                     getClientProperty(LAYER_PROPERTY)) != null))
+                {
                     if(layer != null && layer.equals(FRAME_CONTENT_LAYER))
                         continue;
                     layeredComponentFound = true;
--- a/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/LayoutFocusTraversalPolicy.java	Tue Jul 21 13:02:23 2009 -0700
@@ -29,6 +29,7 @@
 import java.awt.ComponentOrientation;
 import java.util.Comparator;
 import java.io.*;
+import sun.awt.SunToolkit;
 
 
 /**
@@ -226,11 +227,11 @@
      protected boolean accept(Component aComponent) {
         if (!super.accept(aComponent)) {
             return false;
-        } else if (aComponent instanceof JTable) {
+        } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JTable")) {
             // JTable only has ancestor focus bindings, we thus force it
             // to be focusable by returning true here.
             return true;
-        } else if (aComponent instanceof JComboBox) {
+        } else if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JComboBox")) {
             JComboBox box = (JComboBox)aComponent;
             return box.getUI().isFocusTraversable(box);
         } else if (aComponent instanceof JComponent) {
--- a/jdk/src/share/classes/javax/swing/LookAndFeel.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/LookAndFeel.java	Tue Jul 21 13:02:23 2009 -0700
@@ -32,6 +32,7 @@
 import java.awt.Component;
 import java.awt.SystemColor;
 import java.awt.Toolkit;
+import sun.awt.SunToolkit;
 
 import javax.swing.text.*;
 import javax.swing.border.*;
@@ -271,7 +272,7 @@
         // this is a special case because the JPasswordField's ancestor heirarchy
         // includes a class outside of javax.swing, thus we cannot call setUIProperty
         // directly.
-        if (c instanceof JPasswordField) {
+        if (SunToolkit.isInstanceOf(c, "javax.swing.JPasswordField")) {
             if (!((JPasswordField)c).customSetUIProperty(propertyName, propertyValue)) {
                 c.setUIProperty(propertyName, propertyValue);
             }
--- a/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/SortingFocusTraversalPolicy.java	Tue Jul 21 13:02:23 2009 -0700
@@ -444,11 +444,10 @@
         for (Component comp : cycle) {
             if (accept(comp)) {
                 return comp;
-            } else if (comp instanceof Container && comp != aContainer) {
-                Container cont = (Container)comp;
-                if (cont.isFocusTraversalPolicyProvider()) {
-                    return cont.getFocusTraversalPolicy().getDefaultComponent(cont);
-                }
+            } else if (comp != aContainer &&
+                       (comp = getComponentDownCycle(comp, FORWARD_TRAVERSAL)) != null)
+            {
+                return comp;
             }
         }
         return null;
--- a/jdk/src/share/classes/javax/swing/TransferHandler.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/TransferHandler.java	Tue Jul 21 13:02:23 2009 -0700
@@ -40,6 +40,7 @@
 import sun.swing.SwingUtilities2;
 import sun.awt.AppContext;
 import sun.swing.*;
+import sun.awt.SunToolkit;
 
 /**
  * This class is used to handle the transfer of a <code>Transferable</code>
@@ -283,19 +284,9 @@
                           ? ((DropTargetDragEvent)source).getLocation()
                           : ((DropTargetDropEvent)source).getLocation();
 
-            if (component instanceof JTextComponent) {
-                try {
-                    AccessibleMethod method
-                        = new AccessibleMethod(JTextComponent.class,
-                                               "dropLocationForPoint",
-                                               Point.class);
-
-                    dropLocation =
-                        (DropLocation)method.invokeNoChecked(component, p);
-                } catch (NoSuchMethodException e) {
-                    throw new AssertionError(
-                        "Couldn't locate method JTextComponent.dropLocationForPoint");
-                }
+            if (SunToolkit.isInstanceOf(component, "javax.swing.text.JTextComponent")) {
+                dropLocation = SwingAccessor.getJTextComponentAccessor().
+                                   dropLocationForPoint((JTextComponent)component, p);
             } else if (component instanceof JComponent) {
                 dropLocation = ((JComponent)component).dropLocationForPoint(p);
             }
@@ -1373,22 +1364,9 @@
                                         ? null
                                         : support.getDropLocation();
 
-            if (component instanceof JTextComponent) {
-                try {
-                    AccessibleMethod method =
-                        new AccessibleMethod(JTextComponent.class,
-                                             "setDropLocation",
-                                             DropLocation.class,
-                                             Object.class,
-                                             Boolean.TYPE);
-
-                    state =
-                        method.invokeNoChecked(component, dropLocation,
-                                               state, forDrop);
-                } catch (NoSuchMethodException e) {
-                    throw new AssertionError(
-                        "Couldn't locate method JTextComponet.setDropLocation");
-                }
+            if (SunToolkit.isInstanceOf(component, "javax.swing.text.JTextComponent")) {
+                state = SwingAccessor.getJTextComponentAccessor().
+                            setDropLocation((JTextComponent)component, dropLocation, state, forDrop);
             } else if (component instanceof JComponent) {
                 state = ((JComponent)component).setDropLocation(dropLocation, state, forDrop);
             }
--- a/jdk/src/share/classes/javax/swing/UIManager.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/UIManager.java	Tue Jul 21 13:02:23 2009 -0700
@@ -60,6 +60,7 @@
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import sun.awt.AppContext;
+import sun.awt.AWTAccessor;
 
 
 /**
@@ -1472,21 +1473,7 @@
                         return false;
                     }
                 });
-        try {
-            Method setRequestFocusControllerM = java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedExceptionAction<Method>() {
-                        public Method run() throws Exception {
-                            Method method =
-                            Component.class.getDeclaredMethod("setRequestFocusController",
-                                                              sun.awt.RequestFocusController.class);
-                            method.setAccessible(true);
-                            return method;
-                        }
-                    });
-            setRequestFocusControllerM.invoke(null, JComponent.focusController);
-        } catch (Exception e) {
-            // perhaps we should log this
-            assert false;
-        }
+        AWTAccessor.getComponentAccessor().
+            setRequestFocusController(JComponent.focusController);
     }
 }
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicInternalFrameUI.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -683,6 +683,7 @@
                 }
                 getDesktopManager().endResizingFrame(frame);
                 resizing = false;
+                updateFrameCursor();
             }
             _x = 0;
             _y = 0;
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -31,7 +31,6 @@
 import javax.swing.plaf.UIResource;
 import javax.swing.Painter;
 import java.awt.print.PrinterGraphics;
-import static javax.swing.plaf.nimbus.NimbusLookAndFeel.deriveARGB;
 
 /**
  * Convenient base class for defining Painter instances for rendering a
@@ -347,7 +346,7 @@
      */
     protected final Color decodeColor(Color color1, Color color2,
                                       float midPoint) {
-        return new Color(deriveARGB(color1, color2, midPoint));
+        return new Color(NimbusLookAndFeel.deriveARGB(color1, color2, midPoint));
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/Defaults.template	Tue Jul 21 13:02:23 2009 -0700
@@ -278,7 +278,7 @@
      * offset (if any), and whether it is to be bold, italic, or left in its
      * default form.</p>
      */
-    public static final class DerivedFont implements UIDefaults.ActiveValue {
+    static final class DerivedFont implements UIDefaults.ActiveValue {
         private float sizeOffset;
         private Boolean bold;
         private Boolean italic;
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java	Tue Jul 21 13:02:23 2009 -0700
@@ -436,15 +436,13 @@
      */
     static int deriveARGB(Color color1, Color color2, float midPoint) {
         int r = color1.getRed() +
-                (int) ((color2.getRed() - color1.getRed()) * midPoint + 0.5f);
+                Math.round((color2.getRed() - color1.getRed()) * midPoint);
         int g = color1.getGreen() +
-                (int) ((color2.getGreen() - color1.getGreen()) * midPoint +
-                        0.5f);
+                Math.round((color2.getGreen() - color1.getGreen()) * midPoint);
         int b = color1.getBlue() +
-                (int) ((color2.getBlue() - color1.getBlue()) * midPoint + 0.5f);
+                Math.round((color2.getBlue() - color1.getBlue()) * midPoint);
         int a = color1.getAlpha() +
-                (int) ((color2.getAlpha() - color1.getAlpha()) * midPoint +
-                        0.5f);
+                Math.round((color2.getAlpha() - color1.getAlpha()) * midPoint);
         return ((a & 0xFF) << 24) |
                 ((r & 0xFF) << 16) |
                 ((g & 0xFF) << 8) |
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/PainterImpl.template	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/PainterImpl.template	Tue Jul 21 13:02:23 2009 -0700
@@ -31,7 +31,7 @@
 import javax.swing.Painter;
 
 
-public final class ${PAINTER_NAME} extends AbstractRegionPainter {
+final class ${PAINTER_NAME} extends AbstractRegionPainter {
     //package private integers representing the available states that
     //this painter will paint. These are used when creating a new instance
     //of ${PAINTER_NAME} to determine which region/state is being painted
--- a/jdk/src/share/classes/javax/swing/plaf/nimbus/package.html	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/nimbus/package.html	Tue Jul 21 13:02:23 2009 -0700
@@ -38,7 +38,7 @@
 component states.
 
 <p>Nimbus allows customizing many of its properties, including painters, by
-altering the {@link UIDefaults} table. Here's an example:
+altering the {@link javax.swing.UIDefaults} table. Here's an example:
 <code><pre>
     UIManager.put("ProgressBar.tileWidth", myTileWidth);
     UIManager.put("ProgressBar[Enabled].backgroundPainter", myBgPainter);
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java	Tue Jul 21 13:02:23 2009 -0700
@@ -69,6 +69,7 @@
     }
 
     protected void installDefaults() {
+        super.installDefaults();
         updateStyle(chooser);
     }
 
--- a/jdk/src/share/classes/javax/swing/table/DefaultTableCellRenderer.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/table/DefaultTableCellRenderer.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1998-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
@@ -118,12 +118,12 @@
         if (System.getSecurityManager() != null) {
             if (border != null) return border;
             return SAFE_NO_FOCUS_BORDER;
-        } else {
+        } else if (border != null) {
             if (noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER) {
                 return border;
             }
-            return noFocusBorder;
         }
+        return noFocusBorder;
     }
 
     /**
--- a/jdk/src/share/classes/javax/swing/text/JTextComponent.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/javax/swing/text/JTextComponent.java	Tue Jul 21 13:02:23 2009 -0700
@@ -76,6 +76,7 @@
 import sun.swing.PrintingStatus;
 import sun.swing.SwingUtilities2;
 import sun.swing.text.TextComponentPrintable;
+import sun.swing.SwingAccessor;
 
 /**
  * <code>JTextComponent</code> is the base class for swing text
@@ -761,6 +762,23 @@
         return dropMode;
     }
 
+    static {
+        SwingAccessor.setJTextComponentAccessor(
+            new SwingAccessor.JTextComponentAccessor() {
+                public TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp,
+                                                                         Point p)
+                {
+                    return textComp.dropLocationForPoint(p);
+                }
+                public Object setDropLocation(JTextComponent textComp,
+                                              TransferHandler.DropLocation location,
+                                              Object state, boolean forDrop)
+                {
+                    return textComp.setDropLocation(location, state, forDrop);
+                }
+            });
+    }
+
 
     /**
      * Calculates a drop location in this component, representing where a
--- a/jdk/src/share/classes/sun/applet/AppletClassLoader.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/applet/AppletClassLoader.java	Tue Jul 21 13:02:23 2009 -0700
@@ -69,6 +69,7 @@
     private final Object grabReleaseSynchronizer = new Object();
 
     private boolean codebaseLookup = true;
+    private volatile boolean allowRecursiveDirectoryRead = true;
 
     /*
      * Creates a new AppletClassLoader for the specified base URL.
@@ -81,6 +82,11 @@
         acc = AccessController.getContext();
     }
 
+    public void disableRecursiveDirectoryRead() {
+        allowRecursiveDirectoryRead = false;
+    }
+
+
     /**
      * Set the codebase lookup flag.
      */
@@ -188,7 +194,21 @@
             byte[] b = (byte[]) AccessController.doPrivileged(
                                new PrivilegedExceptionAction() {
                 public Object run() throws IOException {
-                    return getBytes(new URL(base, path));
+                   try {
+                        URL finalURL = new URL(base, path);
+
+                        // Make sure the codebase won't be modified
+                        if (base.getProtocol().equals(finalURL.getProtocol()) &&
+                            base.getHost().equals(finalURL.getHost()) &&
+                            base.getPort() == finalURL.getPort()) {
+                            return getBytes(finalURL);
+                        }
+                        else {
+                            return null;
+                        }
+                    } catch (Exception e) {
+                        return null;
+                    }
                 }
             }, acc);
 
@@ -243,51 +263,48 @@
         }
 
         if (path != null) {
+            final String rawPath = path;
             if (!path.endsWith(File.separator)) {
                 int endIndex = path.lastIndexOf(File.separatorChar);
                 if (endIndex != -1) {
-                        path = path.substring(0, endIndex+1) + "-";
+                        path = path.substring(0, endIndex + 1) + "-";
                         perms.add(new FilePermission(path,
                             SecurityConstants.FILE_READ_ACTION));
                 }
             }
-            perms.add(new SocketPermission("localhost",
-                SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
-                    try {
-                        String host = InetAddress.getLocalHost().getHostName();
-                        perms.add(new SocketPermission(host,
-                            SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
-                    } catch (UnknownHostException uhe) {
-
-                    }
-                    return null;
-                }
-            });
+            final File f = new File(rawPath);
+            final boolean isDirectory = f.isDirectory();
+            // grant codebase recursive read permission
+            // this should only be granted to non-UNC file URL codebase and
+            // the codesource path must either be a directory, or a file
+            // that ends with .jar or .zip
+            if (allowRecursiveDirectoryRead && (isDirectory ||
+                    rawPath.toLowerCase().endsWith(".jar") ||
+                    rawPath.toLowerCase().endsWith(".zip"))) {
 
             Permission bperm;
-            try {
-                bperm = base.openConnection().getPermission();
-            } catch (java.io.IOException ioe) {
-                bperm = null;
-            }
-            if (bperm instanceof FilePermission) {
-                String bpath = bperm.getName();
-                if (bpath.endsWith(File.separator)) {
-                    bpath += "-";
+                try {
+                    bperm = base.openConnection().getPermission();
+                } catch (java.io.IOException ioe) {
+                    bperm = null;
                 }
-                perms.add(new FilePermission(bpath,
-                    SecurityConstants.FILE_READ_ACTION));
-            } else if ((bperm == null) && (base.getProtocol().equals("file"))) {
-                String bpath = base.getFile().replace('/', File.separatorChar);
-                bpath = ParseUtil.decode(bpath);
-                if (bpath.endsWith(File.separator)) {
-                    bpath += "-";
+                if (bperm instanceof FilePermission) {
+                    String bpath = bperm.getName();
+                    if (bpath.endsWith(File.separator)) {
+                        bpath += "-";
+                    }
+                    perms.add(new FilePermission(bpath,
+                        SecurityConstants.FILE_READ_ACTION));
+                } else if ((bperm == null) && (base.getProtocol().equals("file"))) {
+                    String bpath = base.getFile().replace('/', File.separatorChar);
+                    bpath = ParseUtil.decode(bpath);
+                    if (bpath.endsWith(File.separator)) {
+                        bpath += "-";
+                    }
+                    perms.add(new FilePermission(bpath, SecurityConstants.FILE_READ_ACTION));
                 }
-                perms.add(new FilePermission(bpath, SecurityConstants.FILE_READ_ACTION));
+
             }
-
         }
         return perms;
     }
@@ -702,7 +719,7 @@
      * Grab this AppletClassLoader and its ThreadGroup/AppContext, so they
      * won't be destroyed.
      */
-    void grab() {
+public     void grab() {
         synchronized(grabReleaseSynchronizer) {
             usageCount++;
         }
@@ -740,11 +757,7 @@
                 --usageCount;
             } else {
                 synchronized(threadGroupSynchronizer) {
-                    // Store app context in temp variable
-                    tempAppContext = appContext;
-                    usageCount = 0;
-                    appContext = null;
-                    threadGroup = null;
+                    tempAppContext = resetAppContext();
                 }
             }
         }
@@ -758,6 +771,29 @@
         }
     }
 
+    /*
+     * reset classloader's AppContext and ThreadGroup
+     * This method is for subclass PluginClassLoader to
+     * reset superclass's AppContext and ThreadGroup but do
+     * not dispose the AppContext. PluginClassLoader does not
+     * use UsageCount to decide whether to dispose AppContext
+     *
+     * @return previous AppContext
+     */
+    protected AppContext resetAppContext() {
+        AppContext tempAppContext = null;
+
+        synchronized(threadGroupSynchronizer) {
+            // Store app context in temp variable
+            tempAppContext = appContext;
+            usageCount = 0;
+            appContext = null;
+            threadGroup = null;
+        }
+        return tempAppContext;
+    }
+
+
     // Hash map to store applet compatibility info
     private HashMap jdk11AppletInfo = new HashMap();
     private HashMap jdk12AppletInfo = new HashMap();
--- a/jdk/src/share/classes/sun/applet/AppletPanel.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/applet/AppletPanel.java	Tue Jul 21 13:02:23 2009 -0700
@@ -80,7 +80,7 @@
     /**
      * The classloader for the applet.
      */
-    AppletClassLoader loader;
+    protected AppletClassLoader loader;
 
     /* applet event ids */
     public final static int APPLET_DISPOSE = 0;
@@ -116,7 +116,7 @@
     /**
      * The thread for the applet.
      */
-    Thread handler;
+    protected Thread handler;
 
 
     /**
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java	Tue Jul 21 13:02:23 2009 -0700
@@ -30,6 +30,7 @@
 import java.awt.image.BufferedImage;
 
 import sun.misc.Unsafe;
+import java.awt.peer.ComponentPeer;
 
 /**
  * The AWTAccessor utility class.
@@ -98,6 +99,21 @@
          * any client code.
          */
         boolean isVisible_NoClientCode(Component comp);
+
+        /**
+         * Sets the RequestFocusController.
+         */
+        void setRequestFocusController(RequestFocusController requestController);
+
+        /**
+         * Returns the appContext of the component.
+         */
+        AppContext getAppContext(Component comp);
+
+        /**
+         * Sets the appContext of the component.
+         */
+        void setAppContext(Component comp, AppContext appContext);
     }
 
     /*
@@ -153,23 +169,21 @@
          */
         Point2D calculateSecurityWarningPosition(Window window,
                 double x, double y, double w, double h);
+
+        /** Sets the synchronous status of focus requests on lightweight
+         * components in the specified window to the specified value.
+         */
+        void setLWRequestStatus(Window changed, boolean status);
     }
 
     /*
      * An accessor for the AWTEvent class.
      */
     public interface AWTEventAccessor {
-        /*
-         *
-         * Sets the flag on this AWTEvent indicating that it was
-         * generated by the system.
+        /**
+         * Marks the event as posted.
          */
-        void setSystemGenerated(AWTEvent ev);
-        /*
-         *
-         * Indicates whether this AWTEvent was generated by the system.
-         */
-        boolean isSystemGenerated(AWTEvent ev);
+        void setPosted(AWTEvent ev);
     }
 
     /*
@@ -216,6 +230,51 @@
     }
 
     /*
+     * An accessor for the MenuComponent class.
+     */
+    public interface MenuComponentAccessor {
+        /**
+         * Returns the appContext of the menu component.
+         */
+        AppContext getAppContext(MenuComponent menuComp);
+
+        /**
+         * Sets the appContext of the menu component.
+         */
+        void setAppContext(MenuComponent menuComp, AppContext appContext);
+
+        /**
+         * Returns the menu container of the menu component
+         */
+        MenuContainer getParent(MenuComponent menuComp);
+    }
+
+    /*
+     * An accessor for the EventQueue class
+     */
+    public interface EventQueueAccessor {
+        /*
+         * Gets the next event queue.
+         */
+        EventQueue getNextQueue(EventQueue eventQueue);
+        /*
+         * Gets the event dispatch thread.
+         */
+        Thread getDispatchThread(EventQueue eventQueue);
+    }
+
+    /*
+     * An accessor for the PopupMenu class
+     */
+    public interface PopupMenuAccessor {
+        /*
+         * Returns whether the popup menu is attached to a tray
+         */
+        boolean isTrayIconPopup(PopupMenu popupMenu);
+    }
+
+
+    /*
      * The java.awt.Component class accessor object.
      */
     private static ComponentAccessor componentAccessor;
@@ -241,6 +300,21 @@
     private static KeyboardFocusManagerAccessor kfmAccessor;
 
     /*
+     * The java.awt.MenuComponent class accessor object.
+     */
+    private static MenuComponentAccessor menuComponentAccessor;
+
+    /*
+     * The java.awt.EventQueue class accessor object.
+     */
+    private static EventQueueAccessor eventQueueAccessor;
+
+    /*
+     * The java.awt.PopupMenu class accessor object.
+     */
+    private static PopupMenuAccessor popupMenuAccessor;
+
+    /*
      * Set an accessor object for the java.awt.Component class.
      */
     public static void setComponentAccessor(ComponentAccessor ca) {
@@ -286,6 +360,9 @@
      * Retrieve the accessor object for the java.awt.AWTEvent class.
      */
     public static AWTEventAccessor getAWTEventAccessor() {
+        if (awtEventAccessor == null) {
+            unsafe.ensureClassInitialized(AWTEvent.class);
+        }
         return awtEventAccessor;
     }
 
@@ -322,4 +399,55 @@
         }
         return kfmAccessor;
     }
+
+    /*
+     * Set an accessor object for the java.awt.MenuComponent class.
+     */
+    public static void setMenuComponentAccessor(MenuComponentAccessor mca) {
+        menuComponentAccessor = mca;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.MenuComponent class.
+     */
+    public static MenuComponentAccessor getMenuComponentAccessor() {
+        if (menuComponentAccessor == null) {
+            unsafe.ensureClassInitialized(MenuComponent.class);
+        }
+        return menuComponentAccessor;
+    }
+
+    /*
+     * Set an accessor object for the java.awt.EventQueue class.
+     */
+    public static void setEventQueueAccessor(EventQueueAccessor eqa) {
+        eventQueueAccessor = eqa;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.EventQueue class.
+     */
+    public static EventQueueAccessor getEventQueueAccessor() {
+        if (eventQueueAccessor == null) {
+            unsafe.ensureClassInitialized(EventQueue.class);
+        }
+        return eventQueueAccessor;
+    }
+
+    /*
+     * Set an accessor object for the java.awt.PopupMenu class.
+     */
+    public static void setPopupMenuAccessor(PopupMenuAccessor pma) {
+        popupMenuAccessor = pma;
+    }
+
+    /*
+     * Retrieve the accessor object for the java.awt.PopupMenu class.
+     */
+    public static PopupMenuAccessor getPopupMenuAccessor() {
+        if (popupMenuAccessor == null) {
+            unsafe.ensureClassInitialized(PopupMenu.class);
+        }
+        return popupMenuAccessor;
+    }
 }
--- a/jdk/src/share/classes/sun/awt/SunToolkit.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/awt/SunToolkit.java	Tue Jul 21 13:02:23 2009 -0700
@@ -77,14 +77,7 @@
      */
     public static final int GRAB_EVENT_MASK = 0x80000000;
 
-    private static Field syncLWRequestsField;
     private static Method  wakeupMethod;
-    private static Field componentKeyField;
-    private static Field menuComponentKeyField;
-    private static Field trayIconKeyField;
-    private static Field componentAppContextField;
-    private static Field menuComponentAppContextField;
-    private static Field isPostedField;
     /* The key to put()/get() the PostEventQueue into/from the AppContext.
      */
     private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue";
@@ -422,32 +415,21 @@
     private static final Map appContextMap =
         Collections.synchronizedMap(new WeakHashMap());
 
-
     /**
      * Sets the appContext field of target. If target is not a Component or
      * MenuComponent, this returns false.
      */
-    private static boolean setAppContext(Object target, AppContext context)
-    {
-        if (!(target instanceof Component) && !(target instanceof MenuComponent)) {
+    private static boolean setAppContext(Object target,
+                                         AppContext context) {
+        if (target instanceof Component) {
+            AWTAccessor.getComponentAccessor().
+                setAppContext((Component)target, context);
+        } else if (target instanceof MenuComponent) {
+            AWTAccessor.getMenuComponentAccessor().
+                setAppContext((MenuComponent)target, context);
+        } else {
             return false;
         }
-        try{
-            if (target instanceof Component){
-                if (componentAppContextField == null) {
-                    componentAppContextField = getField(Component.class, "appContext");
-                }
-                componentAppContextField.set(target, context);
-            } else if (target instanceof MenuComponent) {
-                if (menuComponentAppContextField == null) {
-                    menuComponentAppContextField = getField(MenuComponent.class, "appContext");
-                }
-                menuComponentAppContextField.set(target, context);
-            }
-        } catch( IllegalAccessException e){
-            assert false;
-        }
-
         return true;
     }
 
@@ -456,23 +438,15 @@
      * Component or MenuComponent this returns null.
      */
     private static AppContext getAppContext(Object target) {
-        AppContext retObj = null;
-        try{
-            if (target instanceof Component){
-                if (componentAppContextField == null) {
-                    componentAppContextField = getField(Component.class, "appContext");
-                }
-                retObj = (AppContext) componentAppContextField.get(target);
-            } else if (target instanceof MenuComponent) {
-                if (menuComponentAppContextField == null) {
-                    menuComponentAppContextField = getField(MenuComponent.class, "appContext");
-                }
-                retObj = (AppContext) menuComponentAppContextField.get(target);
-            }
-        } catch( IllegalAccessException e){
-            assert false;
+        if (target instanceof Component) {
+            return AWTAccessor.getComponentAccessor().
+                       getAppContext((Component)target);
+        } else if (target instanceof MenuComponent) {
+            return AWTAccessor.getMenuComponentAccessor().
+                       getAppContext((MenuComponent)target);
+        } else {
+            return null;
         }
-        return retObj;
     }
 
     /*
@@ -520,16 +494,7 @@
       */
 
     public static void setLWRequestStatus(Window changed,boolean status){
-        if (syncLWRequestsField == null){
-            syncLWRequestsField = getField(Window.class, "syncLWRequests");
-        }
-        try{
-            if (syncLWRequestsField != null){
-                syncLWRequestsField.setBoolean(changed, status);
-            }
-        } catch( IllegalAccessException e){
-            assert false;
-        }
+        AWTAccessor.getWindowAccessor().setLWRequestStatus(changed, status);
     };
 
     public static void checkAndSetPolicy(Container cont, boolean isSwingCont)
@@ -637,18 +602,9 @@
      * Post AWTEvent of high priority.
      */
     public static void postPriorityEvent(final AWTEvent e) {
-        if (isPostedField == null) {
-            isPostedField = getField(AWTEvent.class, "isPosted");
-        }
         PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() {
                 public void run() {
-                    try {
-                        isPostedField.setBoolean(e, true);
-                    } catch (IllegalArgumentException e) {
-                        assert(false);
-                    } catch (IllegalAccessException e) {
-                        assert(false);
-                    }
+                    AWTAccessor.getAWTEventAccessor().setPosted(e);
                     ((Component)e.getSource()).dispatchEvent(e);
                 }
             }, PeerEvent.ULTIMATE_PRIORITY_EVENT);
@@ -757,36 +713,6 @@
     }
 
     /*
-     * Returns next queue for the given EventQueue which has private access
-     */
-    private static EventQueue getNextQueue(final Object o) {
-        EventQueue result = null;
-        try{
-            Field nextQueueField = getField(EventQueue.class,
-                                            "nextQueue");
-            result = (EventQueue)nextQueueField.get(o);
-        } catch( IllegalAccessException e){
-            assert false;
-        }
-        return result;
-    }
-
-    /*
-     * Returns dispatch thread for the given EventQueue which has private access
-     */
-    private static Thread getDispatchThread(final Object o) {
-        Thread result = null;
-        try{
-            Field dispatchThreadField = getField(EventQueue.class,
-                                                 "dispatchThread");
-            result = (Thread)dispatchThreadField.get(o);
-        } catch( IllegalAccessException e){
-            assert false;
-        }
-        return result;
-    }
-
-    /*
      * Returns true if the calling thread is the event dispatch thread
      * contained within AppContext which associated with the given target.
      * Use this call to ensure that a given task is being executed
@@ -796,13 +722,14 @@
         AppContext appContext = targetToAppContext(target);
         EventQueue eq = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
 
-        EventQueue next = getNextQueue(eq);
+        AWTAccessor.EventQueueAccessor accessor = AWTAccessor.getEventQueueAccessor();
+        EventQueue next = accessor.getNextQueue(eq);
         while (next != null) {
             eq = next;
-            next = getNextQueue(eq);
+            next = accessor.getNextQueue(eq);
         }
 
-        return (Thread.currentThread() == getDispatchThread(eq));
+        return (Thread.currentThread() == accessor.getDispatchThread(eq));
     }
 
     public Dimension getScreenSize() {
@@ -1356,22 +1283,7 @@
         return false;
     }
 
-    private static Dialog.ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE;
-
-    static {
-        DEFAULT_MODAL_EXCLUSION_TYPE = (Dialog.ModalExclusionType)AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
-                Dialog.ModalExclusionType defaultType = Dialog.ModalExclusionType.NO_EXCLUDE;
-                try {
-                    java.lang.reflect.Field f = Dialog.class.getDeclaredField("DEFAULT_MODAL_EXCLUSION_TYPE");
-                    f.setAccessible(true);
-                    defaultType = (Dialog.ModalExclusionType)f.get(null);
-                } catch (Exception e) {
-                }
-                return defaultType;
-            }
-        });
-    }
+    private static Dialog.ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE = null;
 
     /**
      * Returns whether the XEmbed server feature is requested by
@@ -1430,6 +1342,9 @@
      */
     public static void setModalExcluded(Window window)
     {
+        if (DEFAULT_MODAL_EXCLUSION_TYPE == null) {
+            DEFAULT_MODAL_EXCLUSION_TYPE = Dialog.ModalExclusionType.APPLICATION_EXCLUDE;
+        }
         window.setModalExclusionType(DEFAULT_MODAL_EXCLUSION_TYPE);
     }
 
@@ -1451,6 +1366,9 @@
      */
     public static boolean isModalExcluded(Window window)
     {
+        if (DEFAULT_MODAL_EXCLUSION_TYPE == null) {
+            DEFAULT_MODAL_EXCLUSION_TYPE = Dialog.ModalExclusionType.APPLICATION_EXCLUDE;
+        }
         return window.getModalExclusionType().compareTo(DEFAULT_MODAL_EXCLUSION_TYPE) >= 0;
     }
 
@@ -2104,6 +2022,42 @@
     public int getNumberOfButtons(){
         return 3;
     }
+
+    /**
+     * Checks that the given object implements/extends the given
+     * interface/class.
+     *
+     * Note that using the instanceof operator causes a class to be loaded.
+     * Using this method doesn't load a class and it can be used instead of
+     * the instanceof operator for performance reasons.
+     *
+     * @param obj Object to be checked
+     * @param type The name of the interface/class. Must be
+     * fully-qualified interface/class name.
+     * @return true, if this object implements/extends the given
+     *         interface/class, false, otherwise, or if obj or type is null
+     */
+    public static boolean isInstanceOf(Object obj, String type) {
+        if (obj == null) return false;
+        if (type == null) return false;
+
+        return isInstanceOf(obj.getClass(), type);
+    }
+
+    private static boolean isInstanceOf(Class cls, String type) {
+        if (cls == null) return false;
+
+        if (cls.getName().equals(type)) {
+            return true;
+        }
+
+        for (Class c : cls.getInterfaces()) {
+            if (c.getName().equals(type)) {
+                return true;
+            }
+        }
+        return isInstanceOf(cls.getSuperclass(), type);
+    }
 } // class SunToolkit
 
 
--- a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java	Tue Jul 21 13:02:23 2009 -0700
@@ -202,8 +202,16 @@
     private static ShellFolderManager shellFolderManager;
 
     static {
-        Class managerClass = (Class)Toolkit.getDefaultToolkit().
-            getDesktopProperty("Shell.shellFolderManager");
+        String managerClassName = (String)Toolkit.getDefaultToolkit().
+                                      getDesktopProperty("Shell.shellFolderManager");
+        Class managerClass = null;
+        try {
+            managerClass = Class.forName(managerClassName);
+        // swallow the exceptions below and use default shell folder
+        } catch(ClassNotFoundException e) {
+        } catch(NullPointerException e) {
+        }
+
         if (managerClass == null) {
             managerClass = ShellFolderManager.class;
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/BackgroundDownloader.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,209 @@
+/*
+ * Copyright 2008-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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+package sun.jkernel;
+
+import java.io.*;
+
+/**
+ * Invoked by DownloadManager to begin (in a new JRE) the process of downloading
+ * all remaining JRE components in the background.  A mutex is used to ensure
+ * that only one BackgroundDownloader can be active at a time.
+ *
+ */
+public class BackgroundDownloader {
+    public static final String BACKGROUND_DOWNLOAD_PROPERTY = "kernel.background.download";
+    // relative to the bundle directory
+    public static final String PID_PATH = "tmp" + File.separator + "background.pid";
+
+    // Time to wait before beginning to download components.  Gives the JRE
+    // which spawned this one a chance to get its downloads going.
+    private static final int WAIT_TIME = 10000;
+
+    private static Mutex backgroundMutex;
+
+    static synchronized Mutex getBackgroundMutex() {
+        if (backgroundMutex == null)
+            backgroundMutex = Mutex.create(DownloadManager.MUTEX_PREFIX + "background");
+        return backgroundMutex;
+    }
+
+    private static void doBackgroundDownloads() {
+        if (DownloadManager.isJREComplete())
+            return;
+        if (getBackgroundMutex().acquire(0)) { // give up and exit immediately if we can't acquire mutex
+            try {
+                writePid();
+                Thread.sleep(WAIT_TIME);
+                DownloadManager.doBackgroundDownloads(false);
+                DownloadManager.performCompletionIfNeeded();
+            }
+            catch (InterruptedException e) {
+            }
+            finally {
+                getBackgroundMutex().release();
+            }
+        }
+        else {
+            System.err.println("Unable to acquire background download mutex.");
+            System.exit(1);
+        }
+    }
+
+
+    /**
+     * Writes the current process ID to a file, so that the uninstaller can
+     * find and kill this process if needed.
+     */
+    private static void writePid() {
+        try {
+            File pid = new File(DownloadManager.getBundlePath(), PID_PATH);
+            pid.getParentFile().mkdirs();
+            PrintStream out = new PrintStream(new FileOutputStream(pid));
+            pid.deleteOnExit();
+            out.println(DownloadManager.getCurrentProcessId());
+            out.close();
+        }
+        catch (IOException e) {
+            e.printStackTrace();
+            System.exit(1);
+        }
+    }
+
+
+    /**
+     * Reads from an InputStream until exhausted, writing all data to the
+     * specified OutputStream.
+     */
+    private static void send(InputStream in, OutputStream out)
+                                throws IOException {
+        int c;
+        byte[] buffer = new byte[2048];
+        while ((c = in.read(buffer)) > 0)
+            out.write(buffer, 0, c);
+    }
+
+     /*
+      * Returns the value of the BACKGROUND_DOWNLOAD_PROPERTY.
+      * Checks if system property has been set first
+      * then checks if registry key to disable background download
+      * has been set.
+      */
+     public static boolean  getBackgroundDownloadProperty(){
+         /*
+          * Check registry key value
+          */
+         boolean bgDownloadEnabled = getBackgroundDownloadKey();
+
+         /*
+          * Check system property - it should override the registry
+          * key value.
+          */
+         if (System.getProperty(BACKGROUND_DOWNLOAD_PROPERTY) != null){
+             bgDownloadEnabled = Boolean.valueOf(
+                      System.getProperty(BACKGROUND_DOWNLOAD_PROPERTY));
+         }
+         return bgDownloadEnabled;
+
+    }
+
+    // This method is to retrieve the value of registry key
+    // that disables background download.
+    static native boolean getBackgroundDownloadKey();
+
+
+    static void startBackgroundDownloads() {
+        if (!getBackgroundDownloadProperty()){
+            // If getBackgroundDownloadProperty() returns false
+            // we're doing the downloads from this VM; we don't want to
+            // spawn another one
+            return;
+        }
+
+        // if System.err isn't initialized yet, it means the charsets aren't
+        // available yet and we're going to run into trouble down below.  Wait
+        // until it's ready.
+        while (System.err == null) {
+            try {
+                Thread.sleep(1000);
+            }
+            catch (InterruptedException e) {
+                return;
+            }
+        }
+
+        try {
+            String args = "-D" + BACKGROUND_DOWNLOAD_PROPERTY + "=false -Xmx256m";
+            String backgroundDownloadURL = DownloadManager.getBaseDownloadURL();
+
+            // only set KERNEL_DOWNLOAD_URL_PROPERTY if we override
+            // the default download url
+            if (backgroundDownloadURL != null &&
+                    backgroundDownloadURL.equals(
+                    DownloadManager.DEFAULT_DOWNLOAD_URL) == false) {
+                args += " -D" + DownloadManager.KERNEL_DOWNLOAD_URL_PROPERTY +
+                        "=" + backgroundDownloadURL;
+            };
+            args += " sun.jkernel.BackgroundDownloader";
+            final Process jvm = Runtime.getRuntime().exec("\"" + new File(System.getProperty("java.home"), "bin" +
+                   File.separator + "java.exe") + "\" " + args);
+            Thread outputReader = new Thread("kernelOutputReader") {
+                public void run() {
+                    try {
+                        InputStream in = jvm.getInputStream();
+                        send(in, new PrintStream(new ByteArrayOutputStream()));
+                    }
+                    catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            };
+            outputReader.setDaemon(true);
+            outputReader.start();
+
+            Thread errorReader = new Thread("kernelErrorReader") {
+                public void run() {
+                    try {
+                        InputStream in = jvm.getErrorStream();
+                        send(in, new PrintStream(new ByteArrayOutputStream()));
+                    }
+                    catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            };
+            errorReader.setDaemon(true);
+            errorReader.start();
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+            // TODO: error handling
+        }
+    }
+
+
+    public static void main(String[] arg) {
+        doBackgroundDownloads();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/Bundle.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,922 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+package sun.jkernel;
+
+import java.io.*;
+import java.net.HttpRetryException;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.jar.*;
+import java.util.zip.GZIPInputStream;
+
+/**
+ * Represents a bundle which may or may not currently be installed.
+ *
+ *@author Ethan Nicholas
+ */
+public class Bundle {
+    static {
+        if (!DownloadManager.jkernelLibLoaded) {
+            // This code can be invoked directly by the deploy build.
+            System.loadLibrary("jkernel");
+        }
+    }
+    /**
+     * Compress file sourcePath with "extra" algorithm (e.g. 7-Zip LZMA)
+     * if available, put the uncompressed data into file destPath and
+     * return true. If not available return false and do nothing with destPath.
+     *
+     * @param srcPath path to existing uncompressed file
+     * @param destPath path for the compressed file to be created
+     * @returns true if extra algorithm used, false if not
+     * @throws IOException if the extra compression code should be available
+     *     but cannot be located or linked to, the destination file already
+     *     exists or cannot be opened for writing, or the compression fails
+     */
+    public static native boolean extraCompress(String srcPath,
+        String destPath) throws IOException;
+
+    /**
+     * Decompress file sourcePath with "extra" algorithm (e.g. 7-Zip LZMA)
+     * if available, put the uncompressed data into file destPath and
+     * return true. If not available return false and do nothing with
+     * destPath.
+     * @param srcPath path to existing compressed file
+     * @param destPath path to uncompressed file to be created
+     * @returns true if extra algorithm used, false if not
+     * @throws IOException if the extra uncompression code should be available
+     *     but cannot be located or linked to, the destination file already
+     *     exists or cannot be opened for writing, or the uncompression fails
+     */
+    public static native boolean extraUncompress(String srcPath,
+        String destPath) throws IOException;
+
+    private static final String BUNDLE_JAR_ENTRY_NAME = "classes.jar";
+
+    /** The bundle is not present. */
+    protected static final int NOT_DOWNLOADED = 0;
+
+    /**
+     * The bundle is in the download queue but has not finished downloading.
+     */
+    protected static final int QUEUED = 1;
+
+    /** The bundle has finished downloading but is not installed. */
+    protected static final int DOWNLOADED = 2;
+
+    /** The bundle is fully installed and functional. */
+    protected static final int INSTALLED = 3;
+
+    /** Thread pool used to manage dependency downloads. */
+    private static ExecutorService threadPool;
+
+    /** Size of thread pool. */
+    static final int THREADS;
+
+    static {
+        String downloads = System.getProperty(
+                DownloadManager.KERNEL_SIMULTANEOUS_DOWNLOADS_PROPERTY);
+        if (downloads != null)
+            THREADS = Integer.parseInt(downloads.trim());
+        else
+            THREADS = 1;
+    }
+
+    /** Mutex used to safely access receipts file. */
+    private static Mutex receiptsMutex;
+
+    /** Maps bundle names to known bundle instances. */
+    private static Map<String, Bundle> bundles =
+            new HashMap<String, Bundle>();
+
+    /** Contains the names of currently-installed bundles. */
+    static Set<String> receipts = new HashSet<String>();
+
+    private static int bytesDownloaded;
+
+    /** Path where bundle receipts are written. */
+    private static File receiptPath = new File(DownloadManager.getBundlePath(),
+            "receipts");
+
+    /** The size of the receipts file the last time we saw it. */
+    private static int receiptsSize;
+
+    /** The bundle name, e.g. "java_awt". */
+    private String name;
+
+    /** The path to which we are saving the downloaded bundle file. */
+    private File localPath;
+
+    /**
+     * The path of the extracted JAR file containing the bundle's classes.
+     */
+    private File jarPath;
+
+    // for vista IE7 protected mode
+    private File lowJarPath;
+    private File lowJavaPath = null;
+
+    /** The current state (DOWNLOADED, INSTALLED, etc.). */
+    protected int state;
+
+    /**
+     * True if we should delete the downloaded bundle after installing it.
+     */
+    protected boolean deleteOnInstall = true;
+
+    private static Mutex getReceiptsMutex() {
+        if (receiptsMutex == null)
+            receiptsMutex = Mutex.create(DownloadManager.MUTEX_PREFIX +
+                    "receipts");
+        return receiptsMutex;
+    }
+
+
+    /**
+     * Reads the receipts file in order to seed the list of currently
+     * installed bundles.
+     */
+    static synchronized void loadReceipts() {
+        getReceiptsMutex().acquire();
+        try {
+            if (receiptPath.exists()) {
+                int size = (int) receiptPath.length();
+                if (size != receiptsSize) { // ensure that it has actually
+                                            // been modified
+                    DataInputStream in = null;
+                    try {
+                        receipts.clear();
+                        for (String bundleName : DownloadManager.getBundleNames()) {
+                            if ("true".equals(DownloadManager.getBundleProperty(bundleName,
+                                    DownloadManager.INSTALL_PROPERTY)))
+                                receipts.add(bundleName);
+                        }
+                        if (receiptPath.exists()) {
+                            in = new DataInputStream(new BufferedInputStream(
+                                    new FileInputStream(receiptPath)));
+                            String line;
+                            while ((line = in.readLine()) != null) {
+                                receipts.add(line.trim());
+                            }
+                        }
+                        receiptsSize = size;
+                    }
+                    catch (IOException e) {
+                        DownloadManager.log(e);
+                        // safe to continue, as the worst that happens is
+                        // we re-download existing bundles
+                    } finally {
+                        if (in != null) {
+                            try {
+                                in.close();
+                            } catch (IOException ioe) {
+                                DownloadManager.log(ioe);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        finally {
+            getReceiptsMutex().release();
+        }
+    }
+
+
+    /** Returns the bundle corresponding to the specified name. */
+    public static synchronized Bundle getBundle(String bundleId)
+            throws IOException {
+        Bundle result =(Bundle) bundles.get(bundleId);
+        if (result == null && (bundleId.equals("merged") ||
+                Arrays.asList(DownloadManager.getBundleNames()).contains(bundleId))) {
+            result = new Bundle();
+            result.name = bundleId;
+
+            if (DownloadManager.isWindowsVista()) {
+                result.localPath =
+                        new File(DownloadManager.getLocalLowTempBundlePath(),
+                                 bundleId + ".zip");
+                result.lowJavaPath = new File(
+                        DownloadManager.getLocalLowKernelJava() + bundleId);
+            } else {
+                result.localPath = new File(DownloadManager.getBundlePath(),
+                        bundleId + ".zip");
+            }
+
+            String jarPath = DownloadManager.getBundleProperty(bundleId,
+                    DownloadManager.JAR_PATH_PROPERTY);
+            if (jarPath != null) {
+                if (DownloadManager.isWindowsVista()) {
+                    result.lowJarPath = new File(
+                        DownloadManager.getLocalLowKernelJava() + bundleId,
+                        jarPath);
+                }
+                result.jarPath = new File(DownloadManager.JAVA_HOME,
+                        jarPath);
+
+            } else {
+
+                if (DownloadManager.isWindowsVista()) {
+                    result.lowJarPath = new File(
+                        DownloadManager.getLocalLowKernelJava() + bundleId +
+                            "\\lib\\bundles",
+                        bundleId + ".jar");
+                }
+
+                result.jarPath = new File(DownloadManager.getBundlePath(),
+                        bundleId + ".jar");
+
+            }
+
+            bundles.put(bundleId, result);
+        }
+        return result;
+    }
+
+
+    /**
+     * Returns the name of this bundle.  The name is typically defined by
+     * the bundles.xml file.
+     */
+    public String getName() {
+        return name;
+    }
+
+
+    /**
+     * Sets the name of this bundle.
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+
+    /**
+     * Returns the path to the bundle file on the local filesystem.  The file
+     * will only exist if the bundle has already been downloaded;  otherwise
+     * it will be created when download() is called.
+     */
+    public File getLocalPath() {
+        return localPath;
+    }
+
+
+    /**
+     * Sets the location of the bundle file on the local filesystem.  If the
+     * file already exists, the bundle will be considered downloaded;
+     * otherwise the file will be created when download() is called.
+     */
+    public void setLocalPath(File localPath) {
+        this.localPath = localPath;
+    }
+
+
+    /**
+     * Returns the path to the extracted JAR file containing this bundle's
+     * classes.  This file should only exist after the bundle has been
+     * installed.
+     */
+    public File getJarPath() {
+        return jarPath;
+    }
+
+
+    /**
+     * Sets the path to the extracted JAR file containing this bundle's
+     * classes.  This file will be created as part of installing the bundle.
+     */
+    public void setJarPath(File jarPath) {
+        this.jarPath = jarPath;
+    }
+
+
+    /**
+     * Returns the size of the bundle download in bytes.
+     */
+    public int getSize() {
+        return Integer.valueOf(DownloadManager.getBundleProperty(getName(),
+                DownloadManager.SIZE_PROPERTY));
+    }
+
+
+    /**
+     * Returns true if the bundle file (getLocalPath()) should be deleted
+     * when the bundle is successfully installed.  Defaults to true.
+     */
+    public boolean getDeleteOnInstall() {
+        return deleteOnInstall;
+    }
+
+
+    /**
+     * Sets whether the bundle file (getLocalPath()) should be deleted
+     * when the bundle is successfully installed.  Defaults to true.
+     */
+    public void setDeleteOnInstall(boolean deleteOnInstall) {
+        this.deleteOnInstall = deleteOnInstall;
+    }
+
+
+    /** Sets the current state of this bundle to match reality. */
+    protected void updateState() {
+        synchronized(Bundle.class) {
+            loadReceipts();
+            if (receipts.contains(name) ||
+                    "true".equals(DownloadManager.getBundleProperty(name,
+                    DownloadManager.INSTALL_PROPERTY)))
+                state = Bundle.INSTALLED;
+            else if (localPath.exists())
+                state = Bundle.DOWNLOADED;
+        }
+    }
+
+
+    private String getURL(boolean showUI) throws IOException {
+        Properties urls = DownloadManager.getBundleURLs(showUI);
+        String result = urls.getProperty(name + ".zip");
+        if (result == null) {
+            result = urls.getProperty(name);
+            if (result == null) {
+                DownloadManager.log("Unable to determine bundle URL for " + this);
+                DownloadManager.log("Bundle URLs: " + urls);
+                DownloadManager.sendErrorPing(DownloadManager.ERROR_NO_SUCH_BUNDLE);
+
+                throw new NullPointerException("Unable to determine URL " +
+                        "for bundle: " + this);
+            }
+        }
+        return result;
+    }
+
+
+    /**
+     * Downloads the bundle.  This method blocks until the download is
+     * complete.
+     *
+     *@param showProgress true to display a progress dialog
+     */
+    private void download(boolean showProgress) {
+        if (DownloadManager.isJREComplete())
+            return;
+        Mutex mutex = Mutex.create(DownloadManager.MUTEX_PREFIX + name +
+                ".download");
+        mutex.acquire();
+        try {
+            long start = System.currentTimeMillis();
+
+            boolean retry;
+
+            do {
+                retry = false;
+                updateState();
+                if (state == DOWNLOADED || state == INSTALLED) {
+                    return;
+                }
+                File tmp = null;
+                try {
+                    tmp = new File(localPath + ".tmp");
+
+                    // tmp.deleteOnExit();
+
+                    if (DownloadManager.getBaseDownloadURL().equals(
+                            DownloadManager.RESOURCE_URL)) {
+                        // RESOURCE_URL is used during build process, to
+                        // avoid actual network traffic.  This is called in
+                        // the SplitJRE DownloadTest to determine which
+                        // classes are needed to support downloads, but we
+                        // bypass the actual HTTP download to simplify the
+                        // build process (it's all native code, so from
+                        // DownloadTest's standpoint it doesn't matter if we
+                        // really call it or not).
+                        String path = "/" + name + ".zip";
+                        InputStream in =
+                                getClass().getResourceAsStream(path);
+                        if (in == null)
+                            throw new IOException("could not locate " +
+                                    "resource: " + path);
+                        FileOutputStream out = new FileOutputStream(tmp);
+                        DownloadManager.send(in, out);
+                        in.close();
+                        out.close();
+                    }
+                    else {
+                        try {
+                            String bundleURL = getURL(showProgress);
+                            DownloadManager.log("Downloading from: " +
+                                        bundleURL);
+                            DownloadManager.downloadFromURL(bundleURL, tmp,
+                                    name.replace('_', '.'), showProgress);
+                        }
+                        catch (HttpRetryException e) {
+                            // Akamai returned a 403, get new URL
+                            DownloadManager.flushBundleURLs();
+                            String bundleURL = getURL(showProgress);
+                            DownloadManager.log("Retrying at new " +
+                                        "URL: " + bundleURL);
+                            DownloadManager.downloadFromURL(bundleURL, tmp,
+                                    name.replace('_', '.'),
+                                    showProgress);
+                            // we intentionally don't do a 403 retry
+                            // again, to avoid infinite retries
+                        }
+                    }
+                    if (!tmp.exists() || tmp.length() == 0) {
+                        if (showProgress) {
+                            // since showProgress = true, native code should
+                            // have offered to retry.  Since we ended up here,
+                            // we conclude that download failed & user opted to
+                            // cancel.  Set complete to true to stop bugging
+                            // him in the future (if one bundle fails, the
+                            // rest are virtually certain to).
+                            DownloadManager.complete = true;
+                        }
+                        DownloadManager.fatalError(DownloadManager.ERROR_UNSPECIFIED);
+                    }
+
+                    /**
+                     * Bundle security
+                     *
+                     * Check for corruption/spoofing
+                     */
+
+
+                    /* Create a bundle check from the tmp file */
+                    BundleCheck gottenCheck = BundleCheck.getInstance(tmp);
+
+                    /* Get the check expected for the Bundle */
+                    BundleCheck expectedCheck = BundleCheck.getInstance(name);
+
+                    // Do they match?
+
+                    if (expectedCheck.equals(gottenCheck)) {
+
+                        // Security check OK, uncompress the bundle file
+                        // into the local path
+
+                        long uncompressedLength = tmp.length();
+                        localPath.delete();
+
+                        File uncompressedPath = new File(tmp.getPath() +
+                            ".jar0");
+                        if (! extraUncompress(tmp.getPath(),
+                            uncompressedPath.getPath())) {
+                            // Extra uncompression not available, fall
+                            // back to alternative if it is enabled.
+                            if (DownloadManager.debug) {
+                                DownloadManager.log("Uncompressing with GZIP");
+                            }
+                            GZIPInputStream in = new GZIPInputStream( new
+                                BufferedInputStream(new FileInputStream(tmp),
+                                DownloadManager.BUFFER_SIZE));
+                            BufferedOutputStream out = new BufferedOutputStream(
+                                new FileOutputStream(uncompressedPath),
+                                DownloadManager.BUFFER_SIZE);
+                            DownloadManager.send(in,out);
+                            in.close();
+                            out.close();
+                            if (! uncompressedPath.renameTo(localPath)) {
+                                throw new IOException("unable to rename " +
+                                    uncompressedPath + " to " + localPath);
+                            }
+                        } else {
+                            if (DownloadManager.debug) {
+                                DownloadManager.log("Uncompressing with LZMA");
+                            }
+                            if (! uncompressedPath.renameTo(localPath)) {
+                                throw new IOException("unable to rename " +
+                                    uncompressedPath + " to " + localPath);
+                            }
+                        }
+                        state = DOWNLOADED;
+                        bytesDownloaded += uncompressedLength;
+                        long time = (System.currentTimeMillis() -
+                                start);
+                        DownloadManager.log("Downloaded " + name +
+                                " in " + time + "ms.  Downloaded " +
+                                bytesDownloaded + " bytes this session.");
+
+                        // Normal completion
+                    } else {
+
+                        // Security check not OK: remove the temp file
+                        // and consult the user
+
+                        tmp.delete();
+
+                        DownloadManager.log(
+                                "DownloadManager: Security check failed for " +
+                                "bundle " + name);
+
+                        // only show dialog if we are not in silent mode
+                        if (showProgress) {
+                            retry = DownloadManager.askUserToRetryDownloadOrQuit(
+                                    DownloadManager.ERROR_UNSPECIFIED);
+                        }
+
+                        if (!retry) {
+                            // User wants to give up
+                            throw new RuntimeException(
+                                "Failed bundle security check and user " +
+                                "canceled");
+                        }
+                    }
+                }
+                catch (IOException e) {
+                    // Look for "out of space" using File.getUsableSpace()
+                    // here when downloadFromURL starts throwing IOException
+                    // (or preferably a distinct exception for this case).
+                    DownloadManager.log(e);
+                }
+            } while (retry);
+        } finally {
+            mutex.release();
+        }
+    }
+
+
+    /**
+     * Calls {@link #queueDownload()} on all of this bundle's dependencies.
+     */
+    void queueDependencies(boolean showProgress) {
+        try {
+            String dependencies =
+                    DownloadManager.getBundleProperty(name,
+                    DownloadManager.DEPENDENCIES_PROPERTY);
+            if (dependencies != null) {
+                StringTokenizer st = new StringTokenizer(dependencies,
+                        " ,");
+                while (st.hasMoreTokens()) {
+                    Bundle b = getBundle(st.nextToken());
+                    if (b != null && !b.isInstalled()) {
+                        if (DownloadManager.debug) {
+                            DownloadManager.log("Queueing " + b.name +
+                                    " as a dependency of " + name + "...");
+                        }
+                        b.install(showProgress, true, false);
+                    }
+                }
+            }
+        } catch (IOException e) {
+            // shouldn't happen
+            DownloadManager.log(e);
+        }
+    }
+
+
+    static synchronized ExecutorService getThreadPool() {
+        if (threadPool == null) {
+            threadPool = Executors.newFixedThreadPool(THREADS,
+                            new ThreadFactory () {
+                                public Thread newThread(Runnable r) {
+                                    Thread result = new Thread(r);
+                                    result.setDaemon(true);
+                                    return result;
+                                }
+                            }
+                        );
+        }
+        return threadPool;
+    }
+
+
+    private void unpackBundle() throws IOException {
+        File useJarPath = null;
+        if (DownloadManager.isWindowsVista()) {
+            useJarPath = lowJarPath;
+            File jarDir = useJarPath.getParentFile();
+            if (jarDir != null) {
+                jarDir.mkdirs();
+            }
+        } else {
+            useJarPath = jarPath;
+        }
+
+        DownloadManager.log("Unpacking " + this + " to " + useJarPath);
+
+        InputStream rawStream = new FileInputStream(localPath);
+        JarInputStream in = new JarInputStream(rawStream) {
+            public void close() throws IOException {
+                // prevent any sub-processes here from actually closing the
+                // input stream; we'll use rawsStream.close() when we're
+                // done with it
+            }
+        };
+
+        try {
+            File jarTmp = null;
+            JarEntry entry;
+            while ((entry = in.getNextJarEntry()) != null) {
+                String entryName = entry.getName();
+                if (entryName.equals("classes.pack")) {
+                    File packTmp = new File(useJarPath + ".pack");
+                    packTmp.getParentFile().mkdirs();
+                    DownloadManager.log("Writing temporary .pack file " + packTmp);
+                    OutputStream tmpOut = new FileOutputStream(packTmp);
+                    try {
+                        DownloadManager.send(in, tmpOut);
+                    } finally {
+                        tmpOut.close();
+                    }
+                    // we unpack to a temporary file and then, towards the end
+                    // of this method, use a (hopefully atomic) rename to put it
+                    // into its final location; this should avoid the problem of
+                    // partially-completed downloads.  Doing the rename last
+                    // allows us to check for the presence of the JAR file to
+                    // see whether the bundle has in fact been downloaded.
+                    jarTmp = new File(useJarPath + ".tmp");
+                    DownloadManager.log("Writing temporary .jar file " + jarTmp);
+                    unpack(packTmp, jarTmp);
+                    packTmp.delete();
+                } else if (!entryName.startsWith("META-INF")) {
+                    File dest;
+                    if (DownloadManager.isWindowsVista()) {
+                        dest = new File(lowJavaPath,
+                            entryName.replace('/', File.separatorChar));
+                    } else {
+                        dest = new File(DownloadManager.JAVA_HOME,
+                            entryName.replace('/', File.separatorChar));
+                    }
+                    if (entryName.equals(BUNDLE_JAR_ENTRY_NAME))
+                        dest = useJarPath;
+                    File destTmp = new File(dest + ".tmp");
+                    boolean exists = dest.exists();
+                    if (!exists) {
+                        DownloadManager.log(dest + ".mkdirs()");
+                        dest.getParentFile().mkdirs();
+                    }
+                    try {
+                        DownloadManager.log("Using temporary file " + destTmp);
+                        FileOutputStream out =
+                                new FileOutputStream(destTmp);
+                        try {
+                            byte[] buffer = new byte[2048];
+                            int c;
+                            while ((c = in.read(buffer)) > 0)
+                                out.write(buffer, 0, c);
+                        } finally {
+                            out.close();
+                        }
+                        if (exists)
+                            dest.delete();
+                        DownloadManager.log("Renaming from " + destTmp + " to " + dest);
+                        if (!destTmp.renameTo(dest)) {
+                            throw new IOException("unable to rename " +
+                                    destTmp + " to " + dest);
+                        }
+
+                    } catch (IOException e) {
+                        if (!exists)
+                            throw e;
+                        // otherwise the file already existed and the fact
+                        // that we failed to re-write it probably just
+                        // means that it was in use
+                    }
+                }
+            }
+
+            // rename the temporary jar into its final location
+            if (jarTmp != null) {
+                if (useJarPath.exists())
+                    jarTmp.delete();
+                else if (!jarTmp.renameTo(useJarPath)) {
+                    throw new IOException("unable to rename " + jarTmp +
+                            " to " + useJarPath);
+                }
+            }
+            if (DownloadManager.isWindowsVista()) {
+                // move bundle to real location
+                DownloadManager.log("Using broker to move " + name);
+                if (!DownloadManager.moveDirWithBroker(
+                        DownloadManager.getKernelJREDir() + name)) {
+                    throw new IOException("unable to create " + name);
+                }
+                DownloadManager.log("Broker finished " + name);
+            }
+            DownloadManager.log("Finished unpacking " + this);
+        } finally {
+            rawStream.close();
+        }
+        if (deleteOnInstall) {
+            localPath.delete();
+        }
+
+    }
+
+
+    public static void unpack(File pack, File jar) throws IOException {
+        Process p = Runtime.getRuntime().exec(DownloadManager.JAVA_HOME + File.separator +
+                "bin" + File.separator + "unpack200 -Hoff \"" + pack + "\" \"" + jar + "\"");
+        try {
+            p.waitFor();
+        }
+        catch (InterruptedException e) {
+        }
+    }
+
+
+    /**
+     * Unpacks and installs the bundle.  The bundle's classes are not
+     * immediately added to the boot class path; this happens when the VM
+     * attempts to load a class and calls getBootClassPathEntryForClass().
+     */
+    public void install() throws IOException {
+        install(true, false, true);
+    }
+
+
+    /**
+     * Unpacks and installs the bundle, optionally hiding the progress
+     * indicator.  The bundle's classes are not immediately added to the
+     * boot class path; this happens when the VM attempts to load a class
+     * and calls getBootClassPathEntryForClass().
+     *
+     *@param showProgress true to display a progress dialog
+     *@param downloadOnly true to download but not install
+     *@param block true to wait until the operation is complete before returning
+     */
+    public synchronized void install(final boolean showProgress,
+            final boolean downloadOnly, boolean block) throws IOException {
+        if (DownloadManager.isJREComplete())
+            return;
+        if (state == NOT_DOWNLOADED || state == QUEUED) {
+            // we allow an already-queued bundle to be placed into the queue
+            // again, to handle the case where the bundle is queued with
+            // downloadOnly true and then we try to queue it again with
+            // downloadOnly false -- the second queue entry will actually
+            // install it.
+            if (state != QUEUED) {
+                DownloadManager.addToTotalDownloadSize(getSize());
+                state = QUEUED;
+            }
+            if (getThreadPool().isShutdown()) {
+                if (state == NOT_DOWNLOADED || state == QUEUED)
+                    doInstall(showProgress, downloadOnly);
+            }
+            else {
+                Future task = getThreadPool().submit(new Runnable() {
+                    public void run() {
+                        try {
+                            if (state == NOT_DOWNLOADED || state == QUEUED ||
+                                    (!downloadOnly && state == DOWNLOADED)) {
+                                doInstall(showProgress, downloadOnly);
+                            }
+                        }
+                        catch (IOException e) {
+                            // ignore
+                        }
+                    }
+                });
+                queueDependencies(showProgress);
+                if (block) {
+                    try {
+                        task.get();
+                    }
+                    catch (Exception e) {
+                        throw new Error(e);
+                    }
+                }
+            }
+        }
+        else if (state == DOWNLOADED && !downloadOnly)
+            doInstall(showProgress, false);
+    }
+
+
+    private void doInstall(boolean showProgress, boolean downloadOnly)
+            throws IOException {
+        Mutex mutex = Mutex.create(DownloadManager.MUTEX_PREFIX + name +
+                ".install");
+        DownloadManager.bundleInstallStart();
+        try {
+            mutex.acquire();
+            updateState();
+            if (state == NOT_DOWNLOADED || state == QUEUED) {
+                download(showProgress);
+            }
+
+            if (state == DOWNLOADED && downloadOnly) {
+                return;
+            }
+
+            if (state == INSTALLED) {
+                return;
+            }
+            if (state != DOWNLOADED) {
+                DownloadManager.fatalError(DownloadManager.ERROR_UNSPECIFIED);
+            }
+
+            DownloadManager.log("Calling unpackBundle for " + this);
+            unpackBundle();
+            DownloadManager.log("Writing receipt for " + this);
+            writeReceipt();
+            updateState();
+            DownloadManager.log("Finished installing " + this + ", state=" + state);
+        } finally {
+            if (lowJavaPath != null) {
+                lowJavaPath.delete();
+            }
+            mutex.release();
+            DownloadManager.bundleInstallComplete();
+        }
+    }
+
+
+    synchronized void setState(int state) {
+        this.state = state;
+    }
+
+
+    /** Returns <code>true</code> if this bundle has been installed. */
+    public boolean isInstalled() {
+        synchronized (Bundle.class) {
+            updateState();
+            return state == INSTALLED;
+        }
+    }
+
+
+    /**
+     * Adds an entry to the receipts file indicating that this bundle has
+     * been successfully downloaded.
+     */
+    private void writeReceipt() {
+        getReceiptsMutex().acquire();
+        File useReceiptPath = null;
+        try {
+
+            try {
+
+                receipts.add(name);
+
+                if (DownloadManager.isWindowsVista()) {
+                    // write out receipts to locallow
+                    useReceiptPath = new File(
+                            DownloadManager.getLocalLowTempBundlePath(),
+                            "receipts");
+
+                    if (receiptPath.exists()) {
+                        // copy original file to locallow location
+                        DownloadManager.copyReceiptFile(receiptPath,
+                                useReceiptPath);
+                    }
+
+                    // update receipt in locallow path
+                    // only append if original receipt path exists
+                    FileOutputStream out = new FileOutputStream(useReceiptPath,
+                            receiptPath.exists());
+                    out.write((name + System.getProperty("line.separator")).getBytes("utf-8"));
+                    out.close();
+
+                    // use broker to move back to real path
+                    if (!DownloadManager.moveFileWithBroker(
+                            DownloadManager.getKernelJREDir()
+                        + "-bundles" + File.separator + "receipts")) {
+                        throw new IOException("failed to write receipts");
+                    }
+                } else {
+                    useReceiptPath = receiptPath;
+                    FileOutputStream out = new FileOutputStream(useReceiptPath,
+                            true);
+                    out.write((name + System.getProperty("line.separator")).getBytes("utf-8"));
+                    out.close();
+                }
+
+
+            } catch (IOException e) {
+                DownloadManager.log(e);
+                // safe to continue, as the worst that happens is we
+                // re-download existing bundles
+            }
+        }
+        finally {
+            getReceiptsMutex().release();
+        }
+    }
+
+
+    public String toString() {
+        return "Bundle[" + name + "]";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/BundleCheck.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,330 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/*
+ *
+ * The Java Kernel Bundle security check.
+ *
+ * This class is responsible for detail of creating, storing, dispensing, and
+ * updating bundle security checks and security checks for all the files
+ * extracted from a bundle. Security checks are cryptographic
+ * hashcodes that make it impractical to counterfeit a file. The security
+ * check algorithm is defined by peer class StandaloneMessageDigest. The
+ * cryptographic
+ * hashcodes are held in instances of this class as byte arrays and externally
+ * as hexidecimal string values for Bundle name Property keys. The properties
+ * are a resource in the Java Kernel core JRE rt.jar and accessed after a
+ * real or simulated bundle download by peer classes DownloadManager and
+ * Bundle. Build-time deployment class SplitJRE uses this class to create file
+ * security checks directly and via a special execution of DownloadManager.
+ * The main method of this class can be used to create a
+ * new set of security codes and updated properties for a given JRE path
+ * and set of bundle names (CWD assume to contain bundle files as <name>.zip).
+ *
+ * This is a Sun internal class defined by the Sun implementation and
+ * intended for JRE/JDK release deployment.
+ *
+ * @see sun.jkernel.DownloadManager
+ * @see sun.jkernel.Bundle
+ * @see sun.jkernel.StandaloneSHA
+ * @see sun.jkernel.ByteArrayToFromHexDigits
+ * See also deploy/src/kernel/share/classes/sun/kernel/SplitJRE.java
+ */
+
+package sun.jkernel;
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+
+public class BundleCheck {
+
+    /* File buffer size */
+
+    private static final int DIGEST_STREAM_BUFFER_SIZE = 2048;
+
+    /* The bundle filename suffix */
+
+    private static final String BUNDLE_SUFFIX = ".zip";
+
+    /* Mutable static state. */
+
+    /* Properties (Bundle name/check hex String pairs) for a set of Bundles.
+       Guarded by this class' object. */
+
+    private static volatile Properties properties;
+
+    /* Mutable instance state. */
+
+    /**
+     * The bytes of the check value. Guarded by the bundle Mutex (in
+     * sun.jkernel.DownloadManager) or the fact that sun.kernel.SplitJRE
+     * and/or DownloadManager with "-download all" runs a single thread.
+     */
+
+    private byte[] checkBytes;
+
+    /* Prevent instantiation by default constructor */
+
+    private BundleCheck(){}
+
+    /**
+     * Store the bundle check values as properties to the path specified.
+     * Only invoked by SplitJRE.
+     */
+
+    public static void storeProperties(String fullPath)  {
+
+        try {
+            File f = new File(fullPath);
+            f.getParentFile().mkdirs();
+            OutputStream out = new FileOutputStream(f);
+            properties.store(out, null);
+            out.close();
+        } catch (Exception e) {
+            throw new RuntimeException(
+                "BundleCheck: storing properties threw: " + e);
+        }
+    }
+
+    /**
+     * Fetch the check value properties as a DownloadManager resource.
+     */
+
+    private static void loadProperties()  {
+        properties = new Properties();
+        try {
+            InputStream in = new BufferedInputStream(
+                DownloadManager.class.getResourceAsStream(
+                DownloadManager.CHECK_VALUES_FILE));
+            if (in == null)
+                throw new RuntimeException("BundleCheck: unable to locate " +
+                    DownloadManager.CHECK_VALUES_FILE + " as resource");
+            properties.load(in);
+            in.close();
+        } catch (Exception e) {
+            throw new RuntimeException("BundleCheck: loadProperties threw " +
+                e);
+        }
+    }
+
+    /* Get the check value Properties object */
+
+    private synchronized static Properties getProperties() {
+        if (properties == null) {
+            // If this fails it means addProperty has been used inappropriately
+            loadProperties();
+        }
+        return properties;
+    }
+
+    /* Reset the properties with an empty Properties object */
+
+    public static void resetProperties() {
+        properties = null;
+    }
+
+    /* The BundleCheck expressed as a String */
+
+    public String toString() {
+        return ByteArrayToFromHexDigits.bytesToHexString(checkBytes);
+    }
+
+    /* Add the given BundleCheck as a property to bundleCheckvalueProperties */
+
+    private void addProperty(String name) {
+        // When first called by SplitJRE just start with empty object
+        // rather than allowing a load to happen, as it does at install time.
+        if (properties == null) {
+           properties = new Properties();
+        }
+        getProperties().put(name, toString());
+    }
+
+    /* private ctor for creating/initializing a BundleCheck */
+
+    private BundleCheck(byte[] checkBytes) {
+        this.checkBytes = checkBytes;
+    }
+
+    /* private ctor for creating a BundleCheck with a given name and known
+       Property value. */
+
+    private BundleCheck(String name) {
+        String hexString = getProperties().getProperty(name);
+        if  (hexString == null) {
+            throw new RuntimeException(
+                "BundleCheck: no check property for bundle: " + name);
+        }
+        this.checkBytes = ByteArrayToFromHexDigits.hexStringToBytes(hexString);
+    }
+
+    /* Make a BundleCheck from the contents of the given file or a Bundle
+       name. Save the new object's value as a property if saveProperty is
+       true. Behavior is only defined for name or file being null, but not
+       both, and for saveProperty to be true only when both name and file
+       are not null.
+       Any IO or other exception implies an unexpected and fatal internal
+       error and results in a RuntimeException.  */
+
+    private static BundleCheck getInstance(String name,
+        File file, boolean saveProperty) {
+        if (file == null ) {
+            return new BundleCheck(name);
+
+        } else {
+            StandaloneMessageDigest checkDigest = null;
+            try {
+                FileInputStream checkFileStream = new FileInputStream(file);
+                checkDigest = StandaloneMessageDigest.getInstance("SHA-1");
+
+                // Compute a check code across all of the file bytes.
+                // NOTE that every time a bundle is created, even from
+                // the "same bits", it may be different wrt to the security
+                // code because of slight variations build to build. For
+                // example, the JVM build normally contains an
+                // auto-incrementing build number, built archives might have
+                // timestamps, etc.
+
+                int readCount;
+                byte[] messageStreamBuff =
+                    new byte[DIGEST_STREAM_BUFFER_SIZE];
+                do {
+                    readCount = checkFileStream.read(messageStreamBuff);
+                    if (readCount > 0) {
+                        checkDigest.update(messageStreamBuff,0,readCount);
+                    }
+                } while (readCount != -1);
+                checkFileStream.close();
+
+            } catch (Exception e) {
+                throw new RuntimeException(
+                    "BundleCheck.addProperty() caught: " + e);
+            }
+            BundleCheck bc = new BundleCheck(checkDigest.digest());
+            if (saveProperty) {
+                bc.addProperty(name);
+            }
+            return bc;
+        }
+    }
+
+    /* Create a BundleCheck from the given file */
+
+    public static BundleCheck getInstance(File file) {
+        return getInstance(null, file, false);
+    }
+
+    /* Create a BundleCheck from the given bundle name */
+
+    static BundleCheck getInstance(String name) {
+        return getInstance(name, null, false);
+    }
+
+    /* Create a BundleCheck from the given bundle name and file and
+       use it to make and save a security check Property value. */
+
+    public static void addProperty(String name,  File file) {
+        getInstance(name, file, true);
+    }
+
+    /* Create a bundlecheck from the given bundle name and file and
+       add a Property value for it. */
+
+    static void add(String name, File file) {
+        getInstance(name, file, true).addProperty(name);
+    }
+
+    /* Compare two BundkCheck instances for equal check values */
+
+    boolean equals(BundleCheck b) {
+        if ((checkBytes == null) || (b.checkBytes == null)) {
+            return false;
+        }
+        if (checkBytes.length != b.checkBytes.length) {
+            return false;
+        }
+        for (int i = 0; i < checkBytes.length; i++) {
+            if (checkBytes[i] != b.checkBytes[i]) {
+                if (DownloadManager.debug) {
+                    System.out.println(
+                        "BundleCheck.equals mismatch between this: " +
+                        toString() + " and param: " + b.toString());
+                }
+                return false;
+            }
+         }
+         return true;
+    }
+
+    /* After SplitJRE is used to restructure the JRE into a "core JRE" and
+       a set of Java Kernel "bundles", if extra compression is available
+       the bundles are extracted and rearchived with zero compression by
+       deploy build make steps. The newly compressed bundle names are then
+       passed to this main with the path of the kernel core JRE to have new
+       bundle security check values computed and the corresponding properties
+       updated in rt.jar. If extra compression isn't available then this main is
+       never used and the default jar/zip bundle compression and security
+       codes created by SplitJRE are left in place and ready to use. */
+
+    public static void main(String[] args) {
+        if (args.length < 2) {
+            System.err.println("Usage: java BundleCheck <jre path> " +
+                "<bundle 1 name> ... <bundle N name>");
+            return;
+        }
+
+        // Make a security check code for each bundle file
+        for (int arg = 1; arg < args.length; arg++) {
+            BundleCheck.addProperty(args[arg],
+                new File(args[arg] + BUNDLE_SUFFIX));
+        }
+
+        // Store the new check code properties below the current directory
+        BundleCheck.storeProperties(DownloadManager.CHECK_VALUES_DIR);
+
+        // Now swap the new properties file into the core rt.jar
+        try {
+            int status = Runtime.getRuntime().exec(
+                "jar uf " + args[0] + "\\lib\\rt.jar " +
+                DownloadManager.CHECK_VALUES_DIR).waitFor();
+            if (status != 0) {
+                System.err.println(
+                    "BundleCheck: exec of jar uf gave nonzero status");
+                return;
+            }
+        } catch (Exception e) {
+            System.err.println("BundleCheck: exec of jar uf threw: " + e);
+            return;
+        }
+    } // main
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/ByteArrayToFromHexDigits.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package sun.jkernel;
+
+/**
+ * TODO: The JRE and deploy build code (SplitJRE) can be made a bit smarter
+ * then cryto hashcode byte arrays can be used directly, eliminating the need
+ * for this class altogether. So just leave this alone until it can be removed.
+ * TODO: Change "Digits" to "String" for uniformity and more intuitive names.
+ * A lightweight class to provide convert between hex digits and
+ * <code>byte[]</code>.
+ *<p>
+ * TODO: Try to get this built without the -source 1.3 -target -1.3 options,
+ * which prevent use of java.text.Format, assuming this wouldn't bloat the
+ * JK rt.jar. Also, there still might be equivalent code hiding in the JDK
+ * already, but preliminary searches havn't found it.
+ */
+
+public final class ByteArrayToFromHexDigits {
+
+    private static final char [] chars = new char[]
+        {'0','1','2','3','4','5','6','7','8','9', 'A','B','C','D','E','F'};
+
+    private static final boolean debug = false;
+
+    /**
+     * Converts the <code>byte[] b</code> into a <code>String</code> of
+     * hex digits representing the integer values of all the bytes.
+     *
+     * @param b byte array to be converted
+     * @return String representing <code>b</code> in hexadecimal
+     * @throws IllegalArgumentException if <code>b</code> is null or zero length
+     */
+    public static String bytesToHexString(byte[] b) {
+        if (debug ) {
+            System.out.print("I: ");
+            for(int i=0;i<b.length;i++) {
+                System.out.format("%02X",b[i]);
+            }
+            System.out.println();
+        }
+        if ((b == null) || (b.length == 0)) {
+            throw new IllegalArgumentException("argument null or zero length");
+        }
+        StringBuffer buff = new StringBuffer(b.length * 2);
+        for (int i = 0; i < b.length; i++ ) {
+            buff.insert(i*2,chars[(b[i] >> 4) & 0xf]);
+            buff.insert(i*2+1,chars[b[i] & 0xf]);
+        }
+        if (debug ) {
+            System.out.println("O: " + buff.toString());
+        }
+        return buff.toString();
+    }
+
+    // Convert one hex character to a 4 bit byte value
+
+    private static byte hexCharToByte(char c) throws IllegalArgumentException {
+        if ((c < '0') ||
+            ( ((c < 'A') && (c > 'F')) && ((c < 'a') && (c > 'f'))) ) {
+
+            throw new IllegalArgumentException("not a hex digit");
+        }
+
+        if (c > '9') {
+            if (c > 'F') {
+                return (byte) ((c - 'a' + 10) & 0xf);
+            } else {
+                return (byte) ((c - 'A' + 10) & 0xf);
+            }
+        } else {
+            return (byte) ((c - '0') & 0xf);
+        }
+
+    }
+
+    /**
+     * Converts the <code>String d</code> assumed to contain a sequence
+     * of hexadecimal digit characters into a <code>byte[]</code>.
+     *
+     * @param d String to be converted
+     * @return  byte array representing the hex string
+     * @throws IllegalArgumentException if <code>d</code> is odd length,
+     *     contains a character outside the ranges of 0-9, a-f, and A-F,
+     *     or is zero length or null
+     */
+
+    public static byte[] hexStringToBytes(String d) throws IllegalArgumentException {
+        if (d == null) {
+            throw new IllegalArgumentException(
+                "parameter cannot be null");
+        }
+
+        if (d.length() == 0) {
+            throw new IllegalArgumentException(
+                "parameter cannot be zero length");
+        }
+
+        if ((d.length() & 1) != 0) {
+            throw new IllegalArgumentException(
+                "odd length string");
+        }
+
+        byte[] b = new byte[d.length() / 2];
+
+        // TODO Might be code in the JK initial bundle to do this better (i.e.
+        // method that tests for a hex char?)
+
+        for (int i=0;i<d.length();i+=2) {
+            b[i/2] =  (byte) (( (byte) (hexCharToByte(d.charAt(i))) << 4) +
+                (byte) hexCharToByte(d.charAt(i+1)));
+        }
+        return b;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/DigestOutputStream.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,255 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+package sun.jkernel;
+
+import java.io.FilterOutputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import sun.jkernel.StandaloneMessageDigest;
+
+
+/*
+ * This class provides the main functionality of <code>FilterOutputStream</code>,
+ * and accumulates a check value as bytes are written to
+ * it. The check value is available by method <code>getCheckValue</code>.
+ *<p>
+ * Operations on the public <code>out</code> field of this class should be
+ * avoided to prevent an invalid check code being generated.
+ *
+ * TODO: The javadoc HTML hasn't been generated and eyeballed for yet.
+ * TODO: There is a javadoc trick to cause the parent class javadoc to be
+ *       automagically used: try to take advantage of this.
+ * TODO: Add javadoc links instead of <code>API</code> where it would be useful.
+ * TODO: Go visit the Docs style guide again and get the periods right and
+ *       consistent for all sun.* classes.
+ * @author Pete Soper
+ * @see java.lang.FilterOutputStream
+ * @see getCheckValue
+ */
+
+public class DigestOutputStream extends FilterOutputStream {
+    private static final String DEFAULT_ALGORITHM = "SHA-1";
+
+    private final boolean debug = false;
+
+    private StandaloneMessageDigest smd = null;
+
+    private void initDigest(String algorithm) throws NoSuchAlgorithmException {
+        smd = StandaloneMessageDigest.getInstance(algorithm);
+    }
+
+    // The underlying stream.
+
+    protected volatile OutputStream out;
+
+    /**
+     * Creates a <code>DigestOutputStream</code> with stream <code>s</code>
+     * to be checked with using <code>algorithm</code>.
+     * <p>
+     * If <code>algorithm</code> is not supported then
+     * <code>NoSuchAlgorithm</code> is thrown.
+     * <p>
+     * See {linkplain sun.security.provider.StandaloneMessageDigest} for an
+     * implementation-specific list of supported algorithms.
+     *
+     * @throws NoSuchAlgorithm if <code>algorithm</code> is not supported
+     * @see sun.security.provider.StandaloneMessageDigest
+     */
+
+    /**
+     * Creates an output stream filter built on top of
+     * underlying output stream <code>out</code> for checking with
+     * algorithm <code>algorithm</code>.
+     * <p>
+     * If <code>algorithm</code> is not supported then
+     * <code>NoSuchAlgorithm</code> is thrown.
+     * <p>
+     * See {linkplain sun.security.provider.StandaloneMessageDigest} for an
+     * implementation-specific list of supported algorithms.
+     *
+     * @param out the underlying output stream to be assigned to
+     *     the field <tt>this.out</tt> for later use, or
+     *     <code>null</code> if this instance is to be
+     *     created without an underlying stream.
+     * @param algorithm the check algorithm to use.
+     * @throws NoSuchAlgorithm if <code>algorithm</code> is not supported
+     * @see sun.security.provider.StandaloneMessageDigest
+     * @see DigestInputStream(InputStream, String)
+     */
+
+    public DigestOutputStream(OutputStream out, String algorithm) throws NoSuchAlgorithmException {
+        super(out);
+        initDigest(algorithm);
+        this.out = out;
+    }
+
+    /**
+     * Creates an output stream filter built on top of
+     * underlying output stream <code>out</code> for the default checking
+     * algorithm.
+     * <p>
+     * This implemention provides "SHA-1" as the default checking algorithm.
+     *
+     * @param out the underlying output stream to be assigned to
+     *     the field <tt>this.out</tt> for later use, or
+     *     <code>null</code> if this instance is to be
+     *     created without an underlying stream.
+     * @see DigestInputStream(InputStream)
+     */
+
+    public DigestOutputStream(OutputStream out) {
+        super(out);
+        try {
+            initDigest(DEFAULT_ALGORITHM);
+        } catch (NoSuchAlgorithmException e) {
+            // Impossible to get here, but stranger things have happened...
+            throw new RuntimeException("DigestOutputStream() unknown algorithm");
+        }
+        // superstition from a test failure this.out = out;
+    }
+
+    /**
+     * Writes a byte specified by <code>v</code> to this stream
+     * and updates the check information.
+     *
+     *
+     * @param v the byte to be written.
+     * @throws IOException if an I/O error occurs.
+     */
+    public void write(int v) throws IOException {
+        super.write(v);
+        // TODO Could create this array once
+        byte[] b = new byte[] {(byte) (v & 0xff)};
+        smd.update(b,0,1);
+    }
+
+    /**
+     * Writes the bytes in array <code>data</code>
+     * to this stream and updates the check information.
+     *
+     * @param data the data.
+     * @throws IOException  if an I/O error occurs.
+     * @throws NullPointerException  if <code>data</code> is <code>null</code>
+     */
+    public void write(byte[] data) throws IOException {
+        write(data,0,data.length);
+    }
+
+    /**
+     * Writes a sub array as a sequence of bytes to this output stream and
+     * updates the check information.
+     * @param data the data to be written
+     * @param ofs the start offset in the data
+     * @param len the number of bytes that are written
+     * @throws IOException If an I/O error has occurred.
+     * @throws NullPointerException  if <code>data</code> is <code>null</code>
+     * @throws IndexOutOfBoundsException If <code>ofs</code> is negative,
+     *     <code>len</code> is negative, or <code>len</code> is greater than
+     *     <code>b.length - ofs</code>
+     */
+    public void write(byte[] data, int ofs, int len) throws IOException {
+        if (debug) {
+            System.out.print("DigestOutputStream.write: ");
+            for (int i=ofs; i<(len - ofs); i++) {
+                System.out.format("%02X",data[i]);
+            }
+            System.out.println();
+        }
+        if (data == null) {
+            throw new NullPointerException("null array in DigestOutputStream.write");
+        } else if (ofs < 0 || len < 0 || len > data.length - ofs) {
+            throw new IndexOutOfBoundsException();
+        }
+        //super.write(data,ofs,len);
+        // WATCH OUT: FilterOutputStream does a byte at a time write(byte)
+        // TODO: Will this work all the time, or is there another caveat
+        // to publish
+        out.write(data,ofs,len);
+        if (debug) {
+            System.out.println("DigestOutputStream.write before");
+        }
+        smd.update(data,ofs,len);
+        if (debug) {
+            System.out.println("DigestOutputStream.write after");
+        }
+    }
+
+    /**
+     * Closes this file output stream and releases any system resources
+     * associated with this stream and makes the check value for the stream
+     * available via <code>getCheckValue</code>. This file output stream may
+     * no longer be used for writing bytes.
+     *
+     * @throws  IOException  if an I/O error occurs.
+     * @see getCheckValue
+     */
+    public void close() throws IOException {
+        super.close();
+    }
+
+    /**
+     * Return the check value computed for the stream and reset the state of
+     * check value generation.
+     *
+     * @return the check value bytes
+     */
+    public byte[] getCheckValue() {
+        byte[] b = smd.digest();
+        if (debug) {
+            System.out.print("DigestOutputStream.getCheckValue: ");
+            for (int i=0; i<b.length; i++) {
+                System.out.format("%02X",b[i]);
+            }
+            System.out.println();
+        }
+        smd.reset();
+        return b;
+    }
+
+    /**
+     * Flushes this output stream.
+     *
+     * @throws IOException if an I/O error occurs.
+     * @see java.io.FilterOutputStream#flush()
+     */
+    public void flush() throws IOException {
+        super.flush();
+    }
+
+    /**
+     * Compares two digests for equality. Does a simple byte compare.
+     *
+     * @param digesta one of the digests to compare.
+     *
+     * @param digestb the other digest to compare.
+     *
+     * @return true if the digests are equal, false otherwise.
+     */
+//    public static boolean isEqual(byte digesta[], byte digestb[]) {
+//        return StandaloneMessageDigest.isEqual(digesta, digestb);
+//    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/DownloadManager.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,1676 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+package sun.jkernel;
+
+import java.io.*;
+import java.security.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.jar.*;
+import java.util.zip.*;
+import sun.misc.Launcher;
+
+/**
+ * Handles the downloading of additional JRE components.  The bootstrap class
+ * loader automatically invokes DownloadManager when it comes across a resource
+ * that can't be located.
+ *
+ *@author Ethan Nicholas
+ */
+public class DownloadManager {
+    public static final String KERNEL_DOWNLOAD_URL_PROPERTY =
+            "kernel.download.url";
+    public static final String KERNEL_DOWNLOAD_ENABLED_PROPERTY =
+            "kernel.download.enabled";
+
+    public static final String KERNEL_DOWNLOAD_DIALOG_PROPERTY =
+            "kernel.download.dialog";
+
+    public static final String KERNEL_DEBUG_PROPERTY = "kernel.debug";
+    // disables JRE completion when set to true, used as part of the build
+    // process
+    public static final String KERNEL_NOMERGE_PROPERTY = "kernel.nomerge";
+
+    public static final String KERNEL_SIMULTANEOUS_DOWNLOADS_PROPERTY =
+            "kernel.simultaneous.downloads";
+
+    // used to bypass some problems with JAR entry modtimes not matching.
+    // originally was set to zero, but apparently the epochs are different
+    // for zip and pack so the pack/unpack cycle was causing the modtimes
+    // to change.  With some recent changes to the reconstruction, I'm
+    // not sure if this is actually necessary anymore.
+    public static final int KERNEL_STATIC_MODTIME = 10000000;
+
+    // indicates that bundles should be grabbed using getResource(), rather
+    // than downloaded from a network path -- this is used during the build
+    // process
+    public static final String RESOURCE_URL = "internal-resource/";
+    public static final String REQUESTED_BUNDLES_PATH = "lib" + File.separator +
+            "bundles" + File.separator + "requested.list";
+
+    private static final boolean disableDownloadDialog = "false".equals(
+            System.getProperty(KERNEL_DOWNLOAD_DIALOG_PROPERTY));
+
+    static boolean debug = "true".equals(
+            System.getProperty(KERNEL_DEBUG_PROPERTY));
+    // points to stderr in case we need to println before System.err is
+    // initialized
+    private static OutputStream errorStream;
+    private static OutputStream logStream;
+
+    static String MUTEX_PREFIX;
+
+    static boolean complete;
+
+    // 1 if jbroker started; 0 otherwise
+    private static int _isJBrokerStarted = -1;
+
+    // maps bundle names to URL strings
+    private static Properties bundleURLs;
+
+    public static final String JAVA_HOME = System.getProperty("java.home");
+    public static final String USER_HOME = System.getProperty("user.home");
+    public static final String JAVA_VERSION =
+            System.getProperty("java.version");
+    static final int BUFFER_SIZE = 2048;
+
+    static volatile boolean jkernelLibLoaded = false;
+
+    public static String DEFAULT_DOWNLOAD_URL =
+        "http://javadl.sun.com/webapps/download/GetList/"
+        +  System.getProperty("java.runtime.version") + "-kernel/windows-i586/";
+
+    private static final String CUSTOM_PREFIX = "custom";
+    private static final String KERNEL_PATH_SUFFIX = "-kernel";
+
+    public static final String JAR_PATH_PROPERTY = "jarpath";
+    public static final String SIZE_PROPERTY = "size";
+    public static final String DEPENDENCIES_PROPERTY = "dependencies";
+    public static final String INSTALL_PROPERTY = "install";
+
+    private static boolean reportErrors = true;
+
+    static final int ERROR_UNSPECIFIED = 0;
+    static final int ERROR_DISK_FULL   = 1;
+    static final int ERROR_MALFORMED_BUNDLE_PROPERTIES = 2;
+    static final int ERROR_DOWNLOADING_BUNDLE_PROPERTIES = 3;
+    static final int ERROR_MALFORMED_URL = 4;
+    static final int ERROR_RETRY_CANCELLED = 5;
+    static final int ERROR_NO_SUCH_BUNDLE = 6;
+
+
+    // tracks whether the current thread is downloading.  A count of zero means
+    // not currently downloading, >0 means the current thread is downloading or
+    // installing a bundle.
+    static ThreadLocal<Integer> downloading = new ThreadLocal<Integer>() {
+        protected Integer initialValue() {
+            return 0;
+        }
+    };
+
+    private static File[] additionalBootStrapPaths = { };
+
+    private static String[] bundleNames;
+    private static String[] criticalBundleNames;
+
+    private static String downloadURL;
+
+    private static boolean visitorIdDetermined;
+    private static String visitorId;
+
+    /**
+     * File and path where the Check value properties are gotten from
+     */
+    public static String CHECK_VALUES_FILE = "check_value.properties";
+    static String CHECK_VALUES_DIR = "sun/jkernel/";
+    static String CHECK_VALUES_PATH = CHECK_VALUES_DIR + CHECK_VALUES_FILE;
+
+    /**
+     * The contents of the bundle.properties file, which contains various
+     * information about individual bundles.
+     */
+    private static Map<String, Map<String, String>> bundleProperties;
+
+
+    /**
+     * The contents of the resource_map file, which maps resources
+     * to their respective bundles.
+     */
+    private static Map<String, String> resourceMap;
+
+
+    /**
+     * The contents of the file_map file, which maps files
+     * to their respective bundles.
+     */
+    private static Map<String, String> fileMap;
+
+    private static boolean extDirDetermined;
+    private static boolean extDirIncluded;
+
+    static {
+        AccessController.doPrivileged(new PrivilegedAction() {
+            public Object run() {
+                if (debug)
+                    println("DownloadManager startup");
+
+                 // this mutex is global and will apply to all different
+                // version of java kernel installed on the local machine
+                MUTEX_PREFIX = "jkernel";
+                boolean downloadEnabled = !"false".equals(
+                        System.getProperty(KERNEL_DOWNLOAD_ENABLED_PROPERTY));
+                complete = !getBundlePath().exists() ||
+                        !downloadEnabled;
+
+                // only load jkernel.dll if we are not "complete".
+                // DownloadManager will be loaded during build time, before
+                // jkernel.dll is built.  We only need to load jkernel.dll
+                // when DownloadManager needs to download something, which is
+                // not necessary during build time
+                if (!complete) {
+                    loadJKernelLibrary();
+                    log("Log opened");
+
+                    if (isWindowsVista()) {
+                        getLocalLowTempBundlePath().mkdirs();
+                    }
+
+                    new Thread() {
+                        public void run() {
+                            startBackgroundDownloads();
+                        }
+                    }.start();
+
+                    try {
+                        String dummyPath;
+                        if (isWindowsVista()) {
+                            dummyPath = USER_HOME +
+                                    "\\appdata\\locallow\\dummy.kernel";
+                        } else {
+                            dummyPath = USER_HOME + "\\dummy.kernel";
+                        }
+
+                        File f = new File(dummyPath);
+                        FileOutputStream out = new FileOutputStream(f, true);
+                        out.close();
+                        f.deleteOnExit();
+
+                    } catch (IOException e) {
+                        log(e);
+                    }
+                    // end of warm up code
+
+                    new Thread("BundleDownloader") {
+                        public void run() {
+                            downloadRequestedBundles();
+                        }
+                    }.start();
+                }
+                return null;
+            }
+        });
+    }
+
+
+    static synchronized void loadJKernelLibrary() {
+        if (!jkernelLibLoaded) {
+            try {
+                System.loadLibrary("jkernel");
+                jkernelLibLoaded = true;
+                debug = getDebugProperty();
+            } catch (Exception e) {
+                throw new Error(e);
+            }
+        }
+    }
+
+    static String appendTransactionId(String url) {
+        StringBuilder result = new StringBuilder(url);
+        String visitorId = DownloadManager.getVisitorId();
+        if (visitorId != null) {
+            if (url.indexOf("?") == -1)
+                result.append('?');
+            else
+                result.append('&');
+            result.append("transactionId=");
+            result.append(DownloadManager.getVisitorId());
+        }
+        return result.toString();
+    }
+
+
+    /**
+     * Returns the URL for the directory from which bundles should be
+     * downloaded.
+     */
+    static synchronized String getBaseDownloadURL() {
+        if (downloadURL == null) {
+            log("Determining download URL...");
+            loadJKernelLibrary();
+
+            /*
+             * First check if system property has been set - system
+             * property should take over registry key setting.
+             */
+            downloadURL = System.getProperty(
+                          DownloadManager.KERNEL_DOWNLOAD_URL_PROPERTY);
+            log("System property kernel.download.url = " + downloadURL);
+
+            /*
+             * Now check if registry key has been set
+             */
+            if (downloadURL == null){
+                downloadURL = getUrlFromRegistry();
+                log("getUrlFromRegistry = " + downloadURL);
+            }
+
+            /*
+             * Use default download url
+             */
+            if (downloadURL == null)
+                downloadURL = DEFAULT_DOWNLOAD_URL;
+            log("Final download URL: " + downloadURL);
+        }
+        return downloadURL;
+    }
+
+
+    /**
+     * Loads a file representing a node tree.  The format is described in
+     * SplitJRE.writeTreeMap().  The node paths (such as
+     * core/java/lang/Object.class) are interpreted with the root node as the
+     * value and the remaining nodes as
+     * the key, so the mapping for this entry would be java/lang/Object.class =
+     * core.
+     */
+    static Map<String, String> readTreeMap(InputStream rawIn)
+            throws IOException {
+        // "token level" refers to the 0-31 byte that occurs prior to every
+        // token in the stream, and would be e.g. <0> core <1> java <2> lang
+        // <3> Object.class <3> String.class, which gives us two mappings:
+        // java/lang/Object.class = core, and java/lang/String.class = core.
+        // See the format description in SplitJRE.writeTreeMap for more details.
+        Map<String, String> result = new HashMap<String, String>();
+        InputStream in = new BufferedInputStream(rawIn);
+        // holds the current token sequence,
+        // e.g. {"core", "java", "lang", "Object.class"}
+        List<String> tokens = new ArrayList<String>();
+        StringBuilder currentToken = new StringBuilder();
+        for (;;) {
+            int c = in.read();
+            if (c  == -1) // eof
+                break;
+            if (c < 32) { // new token level
+                if (tokens.size() > 0) {
+                    // replace the null at the end of the list with the token
+                    // we just finished reading
+                    tokens.set(tokens.size() - 1, currentToken.toString());
+                }
+
+                currentToken.setLength(0);
+
+                if (c > tokens.size()) {
+                    // can't increase by more than one token level at a step
+                    throw new InternalError("current token level is " +
+                            (tokens.size() - 1) + " but encountered token " +
+                            "level " + c);
+                }
+                else if (c == tokens.size()) {
+                    // token level increased by 1; this means we are still
+                    // adding tokens for the current mapping -- e.g. we have
+                    // read "core", "java", "lang" and are just about to read
+                    // "Object.class"
+                    // add a placeholder for the new token
+                    tokens.add(null);
+                }
+                else {
+                    // we just stayed at the same level or backed up one or more
+                    // token levels; this means that the current sequence is
+                    // complete and needs to be added to the result map
+                    StringBuilder key = new StringBuilder();
+                    // combine all tokens except the first into a single string
+                    for (int i = 1; i < tokens.size(); i++) {
+                        if (i > 1)
+                            key.append('/');
+                        key.append(tokens.get(i));
+                    }
+                    // map the combined string to the first token, e.g.
+                    // java/lang/Object.class = core
+                    result.put(key.toString(), tokens.get(0));
+                    // strip off tokens until we get back to the current token
+                    // level
+                    while (c < tokens.size())
+                        tokens.remove(c);
+                    // placeholder for upcoming token
+                    tokens.add(null);
+                }
+            }
+            else if (c < 254) // character
+                currentToken.append((char) c);
+            else if (c == 255)
+                currentToken.append(".class");
+            else { // out-of-band value
+                throw new InternalError("internal error processing " +
+                        "resource_map (can't-happen error)");
+            }
+        }
+        if (tokens.size() > 0) // add token we just finished reading
+            tokens.set(tokens.size() - 1, currentToken.toString());
+        StringBuilder key = new StringBuilder();
+        // add the last entry to the map
+        for (int i = 1; i < tokens.size(); i++) {
+            if (i > 1)
+                key.append('/');
+            key.append(tokens.get(i));
+        }
+        if (!tokens.isEmpty())
+            result.put(key.toString(), tokens.get(0));
+        in.close();
+        return Collections.unmodifiableMap(result);
+    }
+
+
+    /**
+     * Returns the contents of the resource_map file, which maps
+     * resources names to their respective bundles.
+     */
+    public static Map<String, String> getResourceMap() throws IOException {
+        if (resourceMap == null) {
+            InputStream in = DownloadManager.class.getResourceAsStream("resource_map");
+            if (in != null) {
+                in = new BufferedInputStream(in);
+                try {
+                    resourceMap = readTreeMap(in);
+                    in.close();
+                }
+                catch (IOException e) {
+                    // turns out we can be returned a broken stream instead of
+                    // just null
+                    resourceMap = new HashMap<String, String>();
+                    complete = true;
+                    log("Can't find resource_map, forcing complete to true");
+                }
+                in.close();
+            }
+            else {
+                resourceMap = new HashMap<String, String>();
+                complete = true;
+                log("Can't find resource_map, forcing complete to true");
+            }
+
+            for (int i = 1; ; i++) { // run through the numbered custom bundles
+                String name = CUSTOM_PREFIX + i;
+                File customPath = new File(getBundlePath(), name + ".jar");
+                if (customPath.exists()) {
+                    JarFile custom = new JarFile(customPath);
+                    Enumeration entries = custom.entries();
+                    while (entries.hasMoreElements()) {
+                        JarEntry entry = (JarEntry) entries.nextElement();
+                        if (!entry.isDirectory())
+                            resourceMap.put(entry.getName(), name);
+                    }
+                }
+                else
+                    break;
+            }
+        }
+        return resourceMap;
+    }
+
+
+    /**
+     * Returns the contents of the file_map file, which maps
+     * file names to their respective bundles.
+     */
+    public static Map<String, String> getFileMap() throws IOException {
+        if (fileMap == null) {
+            InputStream in = DownloadManager.class.getResourceAsStream("file_map");
+            if (in != null) {
+                in = new BufferedInputStream(in);
+                try {
+                    fileMap = readTreeMap(in);
+                    in.close();
+                }
+                catch (IOException e) {
+                    // turns out we can be returned a broken stream instead of
+                    // just null
+                    fileMap = new HashMap<String, String>();
+                    complete = true;
+                    log("Can't find file_map, forcing complete to true");
+                }
+                in.close();
+            }
+            else {
+                fileMap = new HashMap<String, String>();
+                complete = true;
+                log("Can't find file_map, forcing complete to true");
+            }
+        }
+        return fileMap;
+    }
+
+
+    /**
+     * Returns the contents of the bundle.properties file, which maps
+     * bundle names to a pipe-separated list of their properties.  Properties
+     * include:
+     * jarpath - By default, the JAR files (unpacked from classes.pack in the
+     *           bundle) are stored under lib/bundles.  The jarpath property
+     *           overrides this default setting, causing the JAR to be unpacked
+     *           at the specified location.  This is used to preserve the
+     *           identity of JRE JAR files such as lib/deploy.jar.
+     * size    - The size of the download in bytes.
+     */
+    private static synchronized Map<String, Map<String, String>> getBundleProperties()
+            throws IOException {
+        if (bundleProperties == null) {
+            InputStream in = DownloadManager.class.getResourceAsStream("bundle.properties");
+            if (in == null) {
+                complete = true;
+                log("Can't find bundle.properties, forcing complete to true");
+                return null;
+            }
+            in = new BufferedInputStream(in);
+            Properties tmp = new Properties();
+            tmp.load(in);
+            bundleProperties = new HashMap<String, Map<String, String>>();
+            for (Map.Entry e : tmp.entrySet()) {
+                String key = (String) e.getKey();
+                String[] properties = ((String) e.getValue()).split("\\|");
+                Map<String, String> map = new HashMap<String, String>();
+                for (String entry : properties) {
+                    int equals = entry.indexOf("=");
+                    if (equals == -1)
+                        throw new InternalError("error parsing bundle.properties: " +
+                            entry);
+                    map.put(entry.substring(0, equals).trim(),
+                        entry.substring(equals + 1).trim());
+                }
+                bundleProperties.put(key, map);
+            }
+            in.close();
+        }
+        return bundleProperties;
+    }
+
+
+    /**
+     * Returns a single bundle property value loaded from the bundle.properties
+     * file.
+     */
+    static String getBundleProperty(String bundleName, String property) {
+        try {
+            Map<String, Map<String, String>> props = getBundleProperties();
+            Map/*<String, String>*/ map = props != null ? props.get(bundleName) : null;
+            return map != null ? (String) map.get(property) : null;
+        }
+        catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    /** Returns an array of all supported bundle names. */
+    static String[] getBundleNames() throws IOException {
+        if (bundleNames == null) {
+            Set<String> result = new HashSet<String>();
+            Map<String, String> resourceMap = getResourceMap();
+            if (resourceMap != null)
+                result.addAll(resourceMap.values());
+            Map<String, String> fileMap = getFileMap();
+            if (fileMap != null)
+                result.addAll(fileMap.values());
+            bundleNames = result.toArray(new String[result.size()]);
+        }
+        return bundleNames;
+    }
+
+
+    /**
+     * Returns an array of all "critical" (must be downloaded prior to
+     * completion) bundle names.
+     */
+    private static String[] getCriticalBundleNames() throws IOException {
+        if (criticalBundleNames == null) {
+            Set<String> result = new HashSet<String>();
+            Map<String, String> fileMap = getFileMap();
+            if (fileMap != null)
+                result.addAll(fileMap.values());
+            criticalBundleNames = result.toArray(new String[result.size()]);
+        }
+        return criticalBundleNames;
+    }
+
+
+    public static void send(InputStream in, OutputStream out)
+            throws IOException {
+        byte[] buffer = new byte[BUFFER_SIZE];
+        int c;
+        while ((c = in.read(buffer)) > 0)
+            out.write(buffer, 0, c);
+    }
+
+
+    /**
+     * Determine whether all bundles have been downloaded, and if so create
+     * the merged jars that will eventually replace rt.jar and resoures.jar.
+     * IMPORTANT: this method should only be called from the background
+     * download process.
+     */
+    static void performCompletionIfNeeded() {
+        if (debug)
+            log("DownloadManager.performCompletionIfNeeded: checking (" +
+                    complete + ", " + System.getProperty(KERNEL_NOMERGE_PROPERTY)
+                    + ")");
+        if (complete ||
+                "true".equals(System.getProperty(KERNEL_NOMERGE_PROPERTY)))
+            return;
+        Bundle.loadReceipts();
+        try {
+            if (debug) {
+                List critical = new ArrayList(Arrays.asList(getCriticalBundleNames()));
+                critical.removeAll(Bundle.receipts);
+                log("DownloadManager.performCompletionIfNeeded: still need " +
+                        critical.size() + " bundles (" + critical + ")");
+            }
+            if (Bundle.receipts.containsAll(Arrays.asList(getCriticalBundleNames()))) {
+                log("DownloadManager.performCompletionIfNeeded: running");
+                // all done!
+                new Thread("JarMerger") {
+                    public void run() {
+                        createMergedJars();
+                    }
+                }.start();
+            }
+        }
+        catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+    /**
+     * Returns the bundle corresponding to a given resource path (e.g.
+     * "java/lang/Object.class").  If the resource does not appear in a bundle,
+     * null is returned.
+     */
+    public static Bundle getBundleForResource(String resource)
+            throws IOException {
+        String bundleName = getResourceMap().get(resource);
+        return bundleName != null ? Bundle.getBundle(bundleName) : null;
+    }
+
+
+    /**
+     * Returns the bundle corresponding to a given JRE file path (e.g.
+     * "bin/awt.dll").  If the file does not appear in a bundle, null is
+     * returned.
+     */
+    private static Bundle getBundleForFile(String file) throws IOException {
+        String bundleName = getFileMap().get(file);
+        return bundleName != null ? Bundle.getBundle(bundleName) : null;
+    }
+
+
+    /**
+     * Returns the path to the lib/bundles directory.
+     */
+    static File getBundlePath() {
+        return new File(JAVA_HOME, "lib" + File.separatorChar + "bundles");
+    }
+
+    private static String getAppDataLocalLow() {
+        return USER_HOME + "\\appdata\\locallow\\";
+    }
+
+    public static String getKernelJREDir() {
+        return "kerneljre" + JAVA_VERSION;
+    }
+
+    static File getLocalLowTempBundlePath() {
+        return new File(getLocalLowKernelJava() + "-bundles");
+    }
+
+    static String getLocalLowKernelJava() {
+        return getAppDataLocalLow() + getKernelJREDir();
+    }
+
+    /**
+     * Returns an array of JAR files which have been added to the boot strap
+     * class path since the JVM was first booted.
+     */
+    public static synchronized File[] getAdditionalBootStrapPaths() {
+        return additionalBootStrapPaths != null ? additionalBootStrapPaths :
+                new File[0];
+    }
+
+
+    private static void addEntryToBootClassPath(File path) {
+        // Must acquire these locks in this order
+        synchronized(Launcher.class) {
+           synchronized(DownloadManager.class) {
+                File[] newBootStrapPaths = new File[
+                    additionalBootStrapPaths.length + 1];
+                System.arraycopy(additionalBootStrapPaths, 0, newBootStrapPaths,
+                        0, additionalBootStrapPaths.length);
+                newBootStrapPaths[newBootStrapPaths.length - 1] = path;
+                additionalBootStrapPaths = newBootStrapPaths;
+                Launcher.flushBootstrapClassPath();
+           }
+       }
+    }
+
+
+    /**
+     * Scan through java.ext.dirs to see if the lib/ext directory is included.
+     * If not, we shouldn't be "finding" lib/ext jars for download.
+     */
+    private static synchronized boolean extDirIsIncluded() {
+        if (!extDirDetermined) {
+            extDirDetermined = true;
+            String raw = System.getProperty("java.ext.dirs");
+            String ext = JAVA_HOME + File.separator + "lib" + File.separator + "ext";
+            int index = 0;
+            while (index < raw.length()) {
+                int newIndex = raw.indexOf(File.pathSeparator, index);
+                if (newIndex == -1)
+                    newIndex = raw.length();
+                String path = raw.substring(index, newIndex);
+                if (path.equals(ext)) {
+                    extDirIncluded = true;
+                    break;
+                }
+                index = newIndex + 1;
+            }
+        }
+        return extDirIncluded;
+    }
+
+
+    private static String doGetBootClassPathEntryForResource(
+            String resourceName) {
+        boolean retry = false;
+        do {
+            Bundle bundle = null;
+            try {
+                bundle = getBundleForResource(resourceName);
+                if (bundle != null) {
+                    File path = bundle.getJarPath();
+                    boolean isExt = path.getParentFile().getName().equals("ext");
+                    if (isExt && !extDirIsIncluded()) // this is a lib/ext jar, but
+                        return null;                  // lib/ext isn't in the path
+                    if (getBundleProperty(bundle.getName(), JAR_PATH_PROPERTY) == null) {
+                        // if the bundle doesn't have its own JAR path, that means it's
+                        // going to be merged into rt.jar.  If we already have the
+                        // merged rt.jar, we can simply point to that.
+                        Bundle merged = Bundle.getBundle("merged");
+                        if (merged != null && merged.isInstalled()) {
+                            File jar;
+                            if (resourceName.endsWith(".class"))
+                                jar = merged.getJarPath();
+                            else
+                                jar = new File(merged.getJarPath().getPath().replaceAll("merged-rt.jar",
+                                        "merged-resources.jar"));
+                            addEntryToBootClassPath(jar);
+                            return jar.getPath();
+                        }
+                    }
+                    if (!bundle.isInstalled()) {
+                        bundle.queueDependencies(true);
+                        log("On-demand downloading " +
+                                bundle.getName() + " for resource " +
+                                resourceName + "...");
+                        bundle.install();
+                        log(bundle + " install finished.");
+                    }
+                    log("Double-checking " + bundle + " state...");
+                    if (!bundle.isInstalled()) {
+                        throw new IllegalStateException("Expected state of " +
+                                bundle + " to be INSTALLED");
+                    }
+                    if (isExt) {
+                        // don't add lib/ext entries to the boot class path, add
+                        // them to the extension classloader instead
+                        Launcher.addURLToExtClassLoader(path.toURL());
+                        return null;
+                    }
+
+                    if ("javaws".equals(bundle.getName())) {
+                        Launcher.addURLToAppClassLoader(path.toURL());
+                        log("Returning null for javaws");
+                        return null;
+                    }
+
+                    if ("core".equals(bundle.getName()))
+                        return null;
+
+                    // else add to boot class path
+                    addEntryToBootClassPath(path);
+
+                    return path.getPath();
+                }
+                return null; // not one of the JRE's classes
+            }
+            catch (Throwable e) {
+                retry = handleException(e);
+                log("Error downloading bundle for " +
+                        resourceName + ":");
+                log(e);
+                if (e instanceof IOException) {
+                    // bundle did not get installed correctly, remove incomplete
+                    // bundle files
+                    if (bundle != null) {
+                        if (bundle.getJarPath() != null) {
+                            File packTmp = new File(bundle.getJarPath() + ".pack");
+                            packTmp.delete();
+                            bundle.getJarPath().delete();
+                        }
+                        if (bundle.getLocalPath() != null) {
+                            bundle.getLocalPath().delete();
+                        }
+                        bundle.setState(Bundle.NOT_DOWNLOADED);
+                    }
+                }
+            }
+        } while (retry);
+        sendErrorPing(ERROR_RETRY_CANCELLED); // bundle failed to install, user cancelled
+
+        return null; // failed, user chose not to retry
+    }
+
+    static synchronized void sendErrorPing(int code) {
+        try {
+            File bundlePath;
+            if (isWindowsVista()) {
+                bundlePath = getLocalLowTempBundlePath();
+            } else {
+                bundlePath = getBundlePath();
+            }
+            File tmp = new File(bundlePath, "tmp");
+            File errors = new File(tmp, "errors");
+            String errorString = String.valueOf(code);
+            if (errors.exists()) {
+                BufferedReader in = new BufferedReader(new FileReader(errors));
+                String line = in.readLine();
+                while (line != null) {
+                    if (line.equals(errorString))
+                        return; // we have already pinged this error
+                    line = in.readLine();
+                }
+            }
+            tmp.mkdirs();
+            Writer out = new FileWriter(errors, true);
+            out.write(errorString + System.getProperty("line.separator"));
+            out.close();
+            postDownloadError(code);
+        }
+        catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+
+    /**
+     * Displays an error dialog and prompts the user to retry or cancel.
+     * Returns true if the user chose to retry, false if he chose to cancel.
+     */
+    static boolean handleException(Throwable e) {
+        if (e instanceof IOException) {
+            // I don't know of a better method to determine the root cause of
+            // the exception, unfortunately...
+            int code = ERROR_UNSPECIFIED;
+            if (e.getMessage().indexOf("not enough space") != -1)
+                code = ERROR_DISK_FULL;
+            return askUserToRetryDownloadOrQuit(code);
+        }
+        else
+            return false;
+    }
+
+
+    static synchronized void flushBundleURLs() {
+        bundleURLs = null;
+    }
+
+
+    static synchronized Properties getBundleURLs(boolean showUI)
+            throws IOException {
+        if (bundleURLs == null) {
+            log("Entering DownloadManager.getBundleURLs");
+            String base = getBaseDownloadURL();
+            String url = appendTransactionId(base);
+            // use PID instead of createTempFile or other random filename so as
+            // to avoid dependencies on the random number generator libraries
+            File bundlePath = null;
+            // write temp file to locallow directory on vista
+            if (isWindowsVista()) {
+                bundlePath = getLocalLowTempBundlePath();
+            } else {
+                bundlePath = getBundlePath();
+            }
+            File tmp = new File(bundlePath, "urls." + getCurrentProcessId() +
+                    ".properties");
+            try {
+                log("Downloading from " + url + " to " + tmp);
+                downloadFromURL(url, tmp, "", showUI);
+                bundleURLs = new Properties();
+                if (tmp.exists()) {
+                    addToTotalDownloadSize((int) tmp.length()); // better late than never
+                    InputStream in = new FileInputStream(tmp);
+                    in = new BufferedInputStream(in);
+                    bundleURLs.load(in);
+                    in.close();
+                    if (bundleURLs.isEmpty()) {
+                        fatalError(ERROR_MALFORMED_BUNDLE_PROPERTIES);
+                    }
+                } else {
+                    fatalError(ERROR_DOWNLOADING_BUNDLE_PROPERTIES);
+                }
+            } finally {
+                // delete the temp file
+                if (!debug)
+                    tmp.delete();
+            }
+            log("Leaving DownloadManager.getBundleURLs");
+            // else an error occurred and user chose not to retry; leave
+            // bundleURLs empty so we don't continually try to re-download it
+        }
+        return bundleURLs;
+    }
+
+    /**
+     * Checks to see if the specified resource is part of a bundle, and if so
+     * downloads it.  Returns either a string which should be added to the boot
+     * class path (the newly-downloaded JAR's location), or null to indicate
+     * that it isn't one of the JRE's resources or could not be downloaded.
+     */
+    public static String getBootClassPathEntryForResource(
+            final String resourceName) {
+        if (debug)
+            log("Entering getBootClassPathEntryForResource(" + resourceName + ")");
+        if (isJREComplete() || downloading == null ||
+                resourceName.startsWith("sun/jkernel")) {
+            if (debug)
+                log("Bailing: " + isJREComplete() + ", " + (downloading == null));
+            return null;
+        }
+        incrementDownloadCount();
+        try {
+            String result = (String) AccessController.doPrivileged(
+                new PrivilegedAction() {
+                    public Object run() {
+                        return (String) doGetBootClassPathEntryForResource(
+                                resourceName);
+                    }
+                }
+            );
+            log("getBootClassPathEntryForResource(" + resourceName + ") == " + result);
+            return result;
+        }
+        finally {
+            decrementDownloadCount();
+        }
+    }
+
+
+    /**
+     * Called by the boot class loader when it encounters a class it can't find.
+     * This method will check to see if the class is part of a bundle, and if so
+     * download it.  Returns either a string which should be added to the boot
+     * class path (the newly-downloaded JAR's location), or null to indicate
+     * that it isn't one of the JRE's classes or could not be downloaded.
+     */
+    public static String getBootClassPathEntryForClass(final String className) {
+        return getBootClassPathEntryForResource(className.replace('.', '/') +
+                ".class");
+    }
+
+
+    private static boolean doDownloadFile(String relativePath)
+            throws IOException {
+        Bundle bundle = getBundleForFile(relativePath);
+        if (bundle != null) {
+            bundle.queueDependencies(true);
+            log("On-demand downloading " + bundle.getName() +
+                    " for file " + relativePath + "...");
+            bundle.install();
+            return true;
+        }
+        return false;
+    }
+
+
+    /**
+     * Locates the bundle for the specified JRE file (e.g. "bin/awt.dll") and
+     * installs it.  Returns true if the file is indeed part of the JRE and has
+     * now been installed, false if the file is not part of the JRE, and throws
+     * an IOException if the file is part of the JRE but could not be
+     * downloaded.
+     */
+    public static boolean downloadFile(final String relativePath)
+            throws IOException {
+        if (isJREComplete() || downloading == null)
+            return false;
+
+        incrementDownloadCount();
+        try {
+            Object result =
+                    AccessController.doPrivileged(new PrivilegedAction() {
+                public Object run() {
+                    File path = new File(JAVA_HOME,
+                            relativePath.replace('/', File.separatorChar));
+                    if (path.exists())
+                        return true;
+                    try {
+                        return new Boolean(doDownloadFile(relativePath));
+                    }
+                    catch (IOException e) {
+                        return e;
+                    }
+                }
+            });
+            if (result instanceof Boolean)
+                return ((Boolean) result).booleanValue();
+            else
+                throw (IOException) result;
+        }
+        finally {
+            decrementDownloadCount();
+        }
+    }
+
+
+    // increments the counter that tracks whether the current thread is involved
+    // in any download-related activities.  A non-zero count indicates that the
+    // thread is currently downloading or installing a bundle.
+    static void incrementDownloadCount() {
+        downloading.set(downloading.get() + 1);
+    }
+
+
+    // increments the counter that tracks whether the current thread is involved
+    // in any download-related activities.  A non-zero count indicates that the
+    // thread is currently downloading or installing a bundle.
+    static void decrementDownloadCount() {
+        // will generate an exception if incrementDownloadCount() hasn't been
+        // called first, this is intentional
+        downloading.set(downloading.get() - 1);
+    }
+
+
+    /**
+     * Returns <code>true</code> if the current thread is in the process of
+     * downloading a bundle.  This is called by ClassLoader.loadLibrary(), so
+     * that when we run into a library required by the download process itself,
+     * we don't call back into DownloadManager in an attempt to download it
+     * (which would lead to infinite recursion).
+     *
+     * All classes and libraries required to download classes must by
+     * definition already be present.  So if this method returns true, we are
+     * currently in the middle of performing a download, and the class or
+     * library load must be happening due to the download itself.  We can
+     * immediately abort such requests -- the class or library should already
+     * be present.  If it isn't, we're not going to be able to download it,
+     * since we have just established that it is required to perform a
+     * download, and we might as well just let the NoClassDefFoundError /
+     * UnsatisfiedLinkError occur.
+     */
+    public static boolean isCurrentThreadDownloading() {
+        return downloading != null ? downloading.get() > 0 : false;
+    }
+
+
+    /**
+     * Returns true if everything is downloaded and the JRE has been
+     * reconstructed.  Also returns true if kernel functionality is disabled
+     * for any other reason.
+     */
+    public static boolean isJREComplete() {
+        return complete;
+    }
+
+
+    // called by BackgroundDownloader
+    static void doBackgroundDownloads(boolean showProgress) {
+        if (!complete) {
+            if (!showProgress && !debug)
+                reportErrors = false;
+            try {
+                // install swing first for ergonomic reasons
+                Bundle swing = Bundle.getBundle("javax_swing_core");
+                if (!swing.isInstalled())
+                    swing.install(showProgress, false, false);
+                // install remaining bundles
+                for (String name : getCriticalBundleNames()) {
+                    Bundle bundle = Bundle.getBundle(name);
+                    if (!bundle.isInstalled()) {
+                        bundle.install(showProgress, false, true);
+                    }
+                }
+                shutdown();
+            }
+            catch (IOException e) {
+                log(e);
+            }
+        }
+    }
+
+    // copy receipt file to destination path specified
+    static void copyReceiptFile(File from, File to) throws IOException {
+        DataInputStream in = new DataInputStream(
+                new BufferedInputStream(new FileInputStream(from)));
+        OutputStream out = new FileOutputStream(to);
+        String line = in.readLine();
+        while (line != null) {
+            out.write((line + '\n').getBytes("utf-8"));
+            line = in.readLine();
+        }
+        in.close();
+        out.close();
+    }
+
+
+    private static void downloadRequestedBundles() {
+        log("Checking for requested bundles...");
+        try {
+            File list = new File(JAVA_HOME, REQUESTED_BUNDLES_PATH);
+            if (list.exists()) {
+                FileInputStream in = new FileInputStream(list);
+                ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+                send(in, buffer);
+                in.close();
+
+                // split string manually to avoid relying on regexes or
+                // StringTokenizer
+                String raw = new String(buffer.toByteArray(), "utf-8");
+                List/*<String>*/ bundles = new ArrayList/*<String>*/();
+                StringBuilder token = new StringBuilder();
+                for (int i = 0; i < raw.length(); i++) {
+                    char c = raw.charAt(i);
+                    if (c == ',' || Character.isWhitespace(c)) {
+                        if (token.length() > 0) {
+                            bundles.add(token.toString());
+                            token.setLength(0);
+                        }
+                    }
+                    else
+                        token.append(c);
+                }
+                if (token.length() > 0)
+                    bundles.add(token.toString());
+                log("Requested bundles: " + bundles);
+                for (int i = 0; i < bundles.size(); i++) {
+                    Bundle bundle = Bundle.getBundle((String) bundles.get(i));
+                    if (bundle != null && !bundle.isInstalled()) {
+                        log("Downloading " + bundle + " due to requested.list");
+                        bundle.install(true, false, false);
+                    }
+                }
+            }
+        }
+        catch (IOException e) {
+            log(e);
+        }
+    }
+
+
+    static void fatalError(int code) {
+        fatalError(code, null);
+    }
+
+
+    /**
+     * Called to cleanly shut down the VM when a fatal download error has
+     * occurred.  Calls System.exit() if outside of the Java Plug-In, otherwise
+     * throws an error.
+     */
+    static void fatalError(int code, String arg) {
+        sendErrorPing(code);
+
+        for (int i = 0; i < Bundle.THREADS; i++)
+            bundleInstallComplete();
+        if (reportErrors)
+            displayError(code, arg);
+        // inPlugIn check isn't 100% reliable but should be close enough.
+        // headless is for the browser side of things in the out-of-process
+        // plug-in
+        boolean inPlugIn = (Boolean.getBoolean("java.awt.headless") ||
+           System.getProperty("javaplugin.version") != null);
+        KernelError error = new KernelError("Java Kernel bundle download failed");
+        if (inPlugIn)
+            throw error;
+        else {
+            log(error);
+            System.exit(1);
+        }
+    }
+
+
+    // start the background download process using the jbroker broker process
+    // the method will first launch the broker process, if it is not already
+    // running
+    // it will then send the command necessary to start the background download
+    // process to the broker process
+    private static void startBackgroundDownloadWithBroker() {
+
+        if (!BackgroundDownloader.getBackgroundDownloadProperty()) {
+            // If getBackgroundDownloadProperty() returns false
+            // we're doing the downloads from this VM; we don't want to
+            // spawn another one
+            return;
+        }
+
+        // launch broker process if necessary
+        if (!launchBrokerProcess()) {
+            return;
+        }
+
+
+        String kernelDownloadURLProperty = getBaseDownloadURL();
+
+        String kernelDownloadURL;
+
+        // only set KERNEL_DOWNLOAD_URL_PROPERTY if we override
+        // the default download url
+        if (kernelDownloadURLProperty == null ||
+                kernelDownloadURLProperty.equals(DEFAULT_DOWNLOAD_URL)) {
+            kernelDownloadURL = " ";
+        } else {
+            kernelDownloadURL = kernelDownloadURLProperty;
+        }
+
+        startBackgroundDownloadWithBrokerImpl(kernelDownloadURLProperty);
+    }
+
+    private static void startBackgroundDownloads() {
+        if (!complete) {
+            if (BackgroundDownloader.getBackgroundMutex().acquire(0)) {
+                // we don't actually need to hold the mutex -- it was just a
+                // quick check to see if there is any point in even attempting
+                // to start the background downloader
+                BackgroundDownloader.getBackgroundMutex().release();
+                if (isWindowsVista()) {
+                    // use broker process to start background download
+                    // at high integrity
+                    startBackgroundDownloadWithBroker();
+                } else {
+                    BackgroundDownloader.startBackgroundDownloads();
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Increases the total download size displayed in the download progress
+     * dialog.
+     */
+    static native void addToTotalDownloadSize(int size);
+
+
+    /**
+     * Displays a progress dialog while downloading from the specified URL.
+     *
+     *@param url the URL string from which to download
+     *@param file the destination path
+     *@param name the user-visible name of the component we are downloading
+     */
+    static void downloadFromURL(String url, File file, String name,
+            boolean showProgress) {
+        // do not show download dialog if kernel.download.dialog is false
+        downloadFromURLImpl(url, file, name,
+                disableDownloadDialog ? false : showProgress);
+    }
+
+    private static native void downloadFromURLImpl(String url, File file,
+            String name, boolean showProgress);
+
+    // This is for testing purposes only - allows to specify URL
+    // to download kernel bundles from through the registry key.
+    static native String getUrlFromRegistry();
+
+    static native String getVisitorId0();
+
+    static native void postDownloadComplete();
+
+    static native void postDownloadError(int code);
+
+    // Returns the visitor ID set by the installer, will be sent to the server
+    // during bundle downloads for logging purposes.
+    static synchronized String getVisitorId() {
+        if (!visitorIdDetermined) {
+            visitorIdDetermined = true;
+            visitorId = getVisitorId0();
+        }
+        return visitorId;
+    }
+
+    // display an error message using a native dialog
+    public static native void displayError(int code, String arg);
+
+    // prompt user whether to retry download, or quit
+    // returns true if the user chose to retry
+    public static native boolean askUserToRetryDownloadOrQuit(int code);
+
+    // returns true if we are running Windows Vista; false otherwise
+    static native boolean isWindowsVista();
+
+    private static native void startBackgroundDownloadWithBrokerImpl(
+            String command);
+
+    private static int isJBrokerStarted() {
+        if (_isJBrokerStarted == -1) {
+            // initialize state of jbroker
+            _isJBrokerStarted = isJBrokerRunning() ? 1 : 0;
+        }
+        return _isJBrokerStarted;
+    }
+
+    // returns true if broker process (jbroker) is running; false otherwise
+    private static native boolean isJBrokerRunning();
+
+    // returns true if we are running in IE protected mode; false otherwise
+    private static native boolean isIEProtectedMode();
+
+    private static native boolean launchJBroker(String jbrokerPath);
+
+    static native void bundleInstallStart();
+
+    static native void bundleInstallComplete();
+
+    private static native boolean moveFileWithBrokerImpl(String fromPath,
+            String userHome);
+
+    private static native boolean moveDirWithBrokerImpl(String fromPath,
+            String userHome);
+
+    static boolean moveFileWithBroker(String fromPath) {
+        // launch jbroker if necessary
+        if (!launchBrokerProcess()) {
+            return false;
+        }
+
+        return moveFileWithBrokerImpl(fromPath, USER_HOME);
+    }
+
+    static boolean moveDirWithBroker(String fromPath) {
+        // launch jbroker if necessary
+        if (!launchBrokerProcess()) {
+            return false;
+        }
+
+        return moveDirWithBrokerImpl(fromPath, USER_HOME);
+    }
+
+    private static synchronized boolean launchBrokerProcess() {
+        // launch jbroker if necessary
+        if (isJBrokerStarted() == 0) {
+            // launch jbroker if needed
+            boolean ret = launchJBroker(JAVA_HOME);
+            // set state of jbroker
+            _isJBrokerStarted = ret ? 1 : 0;
+            return ret;
+        }
+        return true;
+    }
+
+    private static class StreamMonitor implements Runnable {
+        private InputStream istream;
+        public StreamMonitor(InputStream stream) {
+            istream = new BufferedInputStream(stream);
+            new Thread(this).start();
+        }
+        public void run() {
+            byte[] buffer = new byte[4096];
+            try {
+                int ret = istream.read(buffer);
+                while (ret != -1) {
+                    ret = istream.read(buffer);
+                }
+            } catch (IOException e) {
+                try {
+                    istream.close();
+                } catch (IOException e2) {
+                } // Should allow clean exit when process shuts down
+            }
+        }
+    }
+
+
+    /** Copy a file tree, excluding certain named files. */
+    private static void copyAll(File src, File dest, Set/*<String>*/ excludes)
+                            throws IOException {
+        if (!excludes.contains(src.getName())) {
+            if (src.isDirectory()) {
+                File[] children = src.listFiles();
+                if (children != null) {
+                    for (int i = 0; i < children.length; i++)
+                        copyAll(children[i],
+                                new File(dest, children[i].getName()),
+                                excludes);
+                }
+            }
+            else {
+                dest.getParentFile().mkdirs();
+                FileInputStream in = new FileInputStream(src);
+                FileOutputStream out = new FileOutputStream(dest);
+                send(in, out);
+                in.close();
+                out.close();
+            }
+        }
+    }
+
+
+    public static void dumpOutput(final Process p) {
+        Thread outputReader = new Thread("outputReader") {
+            public void run() {
+                try {
+                    InputStream in = p.getInputStream();
+                    DownloadManager.send(in, System.out);
+                } catch (IOException e) {
+                    log(e);
+                }
+            }
+        };
+        outputReader.start();
+        Thread errorReader = new Thread("errorReader") {
+            public void run() {
+                try {
+                    InputStream in = p.getErrorStream();
+                    DownloadManager.send(in, System.err);
+                } catch (IOException e) {
+                    log(e);
+                }
+            }
+        };
+        errorReader.start();
+    }
+
+
+    /**
+     * Creates the merged rt.jar and resources.jar files.
+     */
+    private static void createMergedJars() {
+        log("DownloadManager.createMergedJars");
+        File bundlePath;
+        if (isWindowsVista()) {
+            bundlePath = getLocalLowTempBundlePath();
+        } else {
+            bundlePath = getBundlePath();
+        }
+        File tmp = new File(bundlePath, "tmp");
+        // explicitly check the final location, not the (potentially) local-low
+        // location -- a local-low finished isn't good enough to call it done
+        if (new File(getBundlePath(), "tmp" + File.separator + "finished").exists())
+            return; // already done
+        log("DownloadManager.createMergedJars: running");
+        tmp.mkdirs();
+        boolean retry = false;
+        do {
+            try {
+                Bundle.getBundle("merged").install(false, false, true);
+                postDownloadComplete();
+                // done, write an empty "finished" file to flag completion
+                File finished = new File(tmp, "finished");
+                new FileOutputStream(finished).close();
+                if (isWindowsVista()) {
+                    if (!moveFileWithBroker(getKernelJREDir() +
+                            "-bundles\\tmp\\finished")) {
+                        throw new IOException("unable to create 'finished' file");
+                    }
+                }
+                log("DownloadManager.createMergedJars: created " + finished);
+                // next JRE startup will move these files into their final
+                // locations, as long as no other JREs are running
+
+                // clean up the local low bundle directory on vista
+                if (isWindowsVista()) {
+                    File tmpDir = getLocalLowTempBundlePath();
+                    File[] list = tmpDir.listFiles();
+                    if (list != null) {
+                        for (int i = 0; i < list.length; i++) {
+                            list[i].delete();
+                        }
+                    }
+                    tmpDir.delete();
+                    log("Finished cleanup, " + tmpDir + ".exists(): " + tmpDir.exists());
+                }
+            }
+            catch (IOException e) {
+                log(e);
+            }
+        }
+        while (retry);
+        log("DownloadManager.createMergedJars: finished");
+    }
+
+
+    private static void shutdown() {
+        try {
+            ExecutorService e = Bundle.getThreadPool();
+            e.shutdown();
+            e.awaitTermination(60 * 60 * 24, TimeUnit.SECONDS);
+        }
+        catch (InterruptedException e) {
+        }
+    }
+
+
+    // returns the registry key for kernel.debug
+    static native boolean getDebugKey();
+
+
+    // returns the final value for the kernel debug property
+    public static boolean getDebugProperty(){
+         /*
+          * Check registry key value
+          */
+         boolean debugEnabled = getDebugKey();
+
+         /*
+          * Check system property - it should override the registry
+          * key value.
+          */
+         if (System.getProperty(KERNEL_DEBUG_PROPERTY) != null) {
+             debugEnabled = Boolean.valueOf(
+                      System.getProperty(KERNEL_DEBUG_PROPERTY));
+         }
+         return debugEnabled;
+
+    }
+
+
+    /**
+     * Outputs to the error stream even when System.err has not yet been
+     * initialized.
+     */
+    static void println(String msg) {
+        if (System.err != null)
+            System.err.println(msg);
+        else {
+            try {
+                if (errorStream == null)
+                    errorStream = new FileOutputStream(FileDescriptor.err);
+                errorStream.write((msg +
+                        System.getProperty("line.separator")).getBytes("utf-8"));
+            }
+            catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+
+    static void log(String msg) {
+        if (debug) {
+            println(msg);
+            try {
+                if (logStream == null) {
+                    loadJKernelLibrary();
+                    File path = isWindowsVista() ? getLocalLowTempBundlePath() :
+                            getBundlePath();
+                    path = new File(path, "kernel." + getCurrentProcessId() + ".log");
+                    logStream = new FileOutputStream(path);
+                }
+                logStream.write((msg +
+                        System.getProperty("line.separator")).getBytes("utf-8"));
+                logStream.flush();
+            }
+            catch (IOException e) {
+                // ignore
+            }
+        }
+    }
+
+
+    static void log(Throwable e) {
+        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        PrintStream p = new PrintStream(buffer);
+        e.printStackTrace(p);
+        p.close();
+        log(buffer.toString(0));
+    }
+
+
+    /** Dump the contents of a map to System.out. */
+    private static void printMap(Map/*<String, String>*/ map) {
+        int size = 0;
+        Set<Integer> identityHashes = new HashSet<Integer>();
+        Iterator/*<Map.Entry<String, String>>*/ i = map.entrySet().iterator();
+        while (i.hasNext()) {
+            Map.Entry/*<String, String>*/ e = (Map.Entry) i.next();
+            String key = (String) e.getKey();
+            String value = (String) e.getValue();
+            System.out.println(key + ": " + value);
+            Integer keyHash = Integer.valueOf(System.identityHashCode(key));
+            if (!identityHashes.contains(keyHash)) {
+                identityHashes.add(keyHash);
+                size += key.length();
+            }
+            Integer valueHash = Integer.valueOf(System.identityHashCode(value));
+            if (!identityHashes.contains(valueHash)) {
+                identityHashes.add(valueHash);
+                size += value.length();
+            }
+        }
+        System.out.println(size + " bytes");
+    }
+
+
+    /** Process the "-dumpmaps" command-line argument. */
+    private static void dumpMaps() throws IOException {
+        System.out.println("Resources:");
+        System.out.println("----------");
+        printMap(getResourceMap());
+        System.out.println();
+        System.out.println("Files:");
+        System.out.println("----------");
+        printMap(getFileMap());
+    }
+
+
+    /** Process the "-download" command-line argument. */
+    private static void processDownload(String bundleName) throws IOException {
+        if (bundleName.equals("all")) {
+            debug = true;
+            doBackgroundDownloads(true);
+            performCompletionIfNeeded();
+        }
+        else {
+            Bundle bundle = Bundle.getBundle(bundleName);
+            if (bundle == null) {
+                println("Unknown bundle: " + bundleName);
+                System.exit(1);
+            }
+            else
+                bundle.install();
+        }
+    }
+
+
+    static native int getCurrentProcessId();
+
+
+    public static void main(String[] arg) throws Exception {
+        AccessController.checkPermission(new AllPermission());
+
+        boolean valid = false;
+        if (arg.length == 2 && arg[0].equals("-install")) {
+            valid = true;
+            Bundle bundle = new Bundle() {
+                protected void updateState() {
+                    // the bundle path was provided on the command line, so we
+                    // just claim it has already been "downloaded" to the local
+                    // filesystem
+                    state = DOWNLOADED;
+                }
+            };
+
+            File jarPath;
+            int index = 0;
+            do {
+                index++;
+                jarPath = new File(getBundlePath(),
+                        CUSTOM_PREFIX + index + ".jar");
+            }
+            while (jarPath.exists());
+            bundle.setName(CUSTOM_PREFIX + index);
+            bundle.setLocalPath(new File(arg[1]));
+            bundle.setJarPath(jarPath);
+            bundle.setDeleteOnInstall(false);
+            bundle.install();
+        }
+        else if (arg.length == 2 && arg[0].equals("-download")) {
+            valid = true;
+            processDownload(arg[1]);
+        }
+        else if (arg.length == 1 && arg[0].equals("-dumpmaps")) {
+            valid = true;
+            dumpMaps();
+        }
+        else if (arg.length == 2 && arg[0].equals("-sha1")) {
+            valid = true;
+            System.out.println(BundleCheck.getInstance(new File(arg[1])));
+        }
+        else if (arg.length == 1 && arg[0].equals("-downloadtest")) {
+            valid = true;
+            File file = File.createTempFile("download", ".test");
+            for (;;) {
+                file.delete();
+                downloadFromURL(getBaseDownloadURL(), file, "URLS", true);
+                System.out.println("Downloaded " + file.length() + " bytes");
+            }
+        }
+        if (!valid) {
+            System.out.println("usage: DownloadManager -install <path>.zip |");
+            System.out.println("       DownloadManager -download " +
+                    "<bundle_name> |");
+            System.out.println("       DownloadManager -dumpmaps");
+            System.exit(1);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/KernelError.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+package sun.jkernel;
+
+/**
+ * Thrown to indicate that Java Kernel is unable to install a required bundle
+ * and the JRE is therefore not adhering to specifications.
+ */
+public class KernelError extends VirtualMachineError {
+    /**
+     * Constructs a <code>KernelError</code> with no detail message.
+     */
+    public KernelError() {
+        super();
+    }
+
+    /**
+     * Constructs a <code>KernelError</code> with the specified
+     * detail message.
+     *
+     * @param   s   the detail message.
+     */
+    public KernelError(String s) {
+        super(s);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/Mutex.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+package sun.jkernel;
+
+/**
+ * A mutex which works even between different processes.  Currently implemented
+ * only on Win32.
+ *
+ *@author Ethan Nicholas
+ */
+public class Mutex {
+    static {
+        try {
+            System.loadLibrary("jkernel");
+        }
+        catch (Exception e) {
+            throw new Error(e);
+        }
+    }
+
+    private String uniqueId;
+    private long handle;
+
+    public static Mutex create(String uniqueId) {
+        return new Mutex(uniqueId);
+    }
+
+
+    private Mutex(String uniqueId) {
+        this.uniqueId = uniqueId;
+        this.handle = createNativeMutex(uniqueId);
+    }
+
+
+    private static native long createNativeMutex(String uniqueId);
+
+
+    public native void acquire();
+
+
+    public native boolean acquire(int timeout);
+
+
+    public native void release();
+
+
+    public native void destroyNativeMutex();
+
+
+    public void dispose() {
+        destroyNativeMutex();
+        handle = 0;
+    }
+
+
+    public void finalize() {
+        dispose();
+    }
+
+
+    public String toString() {
+        return "Mutex[" + uniqueId + "]";
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/StandaloneByteArrayAccess.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/*
+ * This is a pure subset of package-private class
+ * sun.security.provider.ByteArrayAccess. The subset consists of only the simple
+ * shift and boolean operations needed for the one current client of this
+ * class (sun.jkernel.StandaloneSHA) and omits optimization code and comments
+ * not relevant to the subset.  No semantic changes have been made.
+ * A few long lines were broken to conform to JDK coding style.
+ * Pete Soper, August, 2007.
+ */
+
+package sun.jkernel;
+
+/**
+ * Methods for converting between byte[] and int[]/long[].
+ *
+ * @since   1.6
+ * @version 1.1, 05/26/06
+ * @author  Andreas Sterbenz
+ */
+final class StandaloneByteArrayAccess {
+
+    private StandaloneByteArrayAccess() {
+        // empty
+    }
+
+    /**
+     * byte[] to int[] conversion, little endian byte order.
+     */
+    static void b2iLittle(byte[] in, int inOfs, int[] out, int outOfs,
+        int len) {
+        len += inOfs;
+        while (inOfs < len) {
+            out[outOfs++] = ((in[inOfs    ] & 0xff)      )
+                          | ((in[inOfs + 1] & 0xff) <<  8)
+                          | ((in[inOfs + 2] & 0xff) << 16)
+                          | ((in[inOfs + 3]       ) << 24);
+            inOfs += 4;
+        }
+    }
+
+    /**
+     * int[] to byte[] conversion, little endian byte order.
+     */
+    static void i2bLittle(int[] in, int inOfs, byte[] out, int outOfs,
+        int len) {
+        len += outOfs;
+        while (outOfs < len) {
+            int i = in[inOfs++];
+            out[outOfs++] = (byte)(i      );
+            out[outOfs++] = (byte)(i >>  8);
+            out[outOfs++] = (byte)(i >> 16);
+            out[outOfs++] = (byte)(i >> 24);
+        }
+    }
+
+    /**
+     * byte[] to int[] conversion, big endian byte order.
+     */
+    static void b2iBig(byte[] in, int inOfs, int[] out, int outOfs, int len) {
+        len += inOfs;
+        while (inOfs < len) {
+            out[outOfs++] = ((in[inOfs + 3] & 0xff)      )
+                          | ((in[inOfs + 2] & 0xff) <<  8)
+                          | ((in[inOfs + 1] & 0xff) << 16)
+                          | ((in[inOfs    ]       ) << 24);
+            inOfs += 4;
+        }
+    }
+
+    /**
+     * int[] to byte[] conversion, big endian byte order.
+     */
+    static void i2bBig(int[] in, int inOfs, byte[] out, int outOfs, int len) {
+        len += outOfs;
+        while (outOfs < len) {
+            int i = in[inOfs++];
+            out[outOfs++] = (byte)(i >> 24);
+            out[outOfs++] = (byte)(i >> 16);
+            out[outOfs++] = (byte)(i >>  8);
+            out[outOfs++] = (byte)(i      );
+        }
+    }
+
+    // Store one 32-bit value into out[outOfs..outOfs+3] in big endian order.
+    static void i2bBig4(int val, byte[] out, int outOfs) {
+        out[outOfs    ] = (byte)(val >> 24);
+        out[outOfs + 1] = (byte)(val >> 16);
+        out[outOfs + 2] = (byte)(val >>  8);
+        out[outOfs + 3] = (byte)(val      );
+    }
+
+    /**
+     * byte[] to long[] conversion, big endian byte order.
+     */
+    static void b2lBig(byte[] in, int inOfs, long[] out, int outOfs, int len) {
+        len += inOfs;
+        while (inOfs < len) {
+            int i1 = ((in[inOfs + 3] & 0xff)      )
+                   | ((in[inOfs + 2] & 0xff) <<  8)
+                   | ((in[inOfs + 1] & 0xff) << 16)
+                   | ((in[inOfs    ]       ) << 24);
+            inOfs += 4;
+            int i2 = ((in[inOfs + 3] & 0xff)      )
+                   | ((in[inOfs + 2] & 0xff) <<  8)
+                   | ((in[inOfs + 1] & 0xff) << 16)
+                   | ((in[inOfs    ]       ) << 24);
+            out[outOfs++] = ((long)i1 << 32) | (i2 & 0xffffffffL);
+            inOfs += 4;
+        }
+    }
+
+    /**
+     * long[] to byte[] conversion
+     */
+    static void l2bBig(long[] in, int inOfs, byte[] out, int outOfs, int len) {
+        len += outOfs;
+        while (outOfs < len) {
+            long i = in[inOfs++];
+            out[outOfs++] = (byte)(i >> 56);
+            out[outOfs++] = (byte)(i >> 48);
+            out[outOfs++] = (byte)(i >> 40);
+            out[outOfs++] = (byte)(i >> 32);
+            out[outOfs++] = (byte)(i >> 24);
+            out[outOfs++] = (byte)(i >> 16);
+            out[outOfs++] = (byte)(i >>  8);
+            out[outOfs++] = (byte)(i      );
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/StandaloneMessageDigest.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,395 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/*
+ * This is a combination and adaptation of subsets of
+ * <code>java.security.MessageDigest</code> and
+ * <code>sun.security.provider.DigestBase</code> to provide a class offering
+ * most of the same public methods of <code>MessageDigest</code> while not
+ * depending on the Java Security Framework.
+ * <p>
+ * One algorithm is currently supported: "SHA-1".
+ * <p>
+ * NOTE If <code>java.security.MessageDigest</code>,
+ * <code>sun.security.provider.DigestBase</code> or
+ * <code>sun.security.provider.SHA</code> are modified, review of those
+ * modifications should be done to determine any possible implications for this
+ * class and <code>StandaloneSHA</code>.
+ */
+
+package sun.jkernel;
+
+import java.security.DigestException;
+import java.security.ProviderException;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * (Adapted from the <code>sun.security.provider.DigestBase</code> doc).
+ * This is a simple subset of the Common base message digest implementation
+ * for the Sun provider.
+ * It implements most of the JCA methods as suitable for a Java message
+ * digest
+ * implementation of an algorithm based on a compression function (as all
+ * commonly used algorithms are). The individual digest subclasses only need to
+ * implement the following methods:
+ *
+ *  . abstract void implCompress(byte[] b, int ofs);
+ *  . abstract void implDigest(byte[] out, int ofs);
+ *  . abstract void implReset();
+ * <p>
+ * No support for a clone() method is provided.
+ * <p>
+ * See the inline documentation for details.
+ *
+ * @since   1.5
+ * @version 1.3, 08/08/07
+ * @author  Andreas Sterbenz (MessageDigest)
+ * @author  Pete Soper (this derived class)
+ */
+public abstract class StandaloneMessageDigest {
+
+     public static final boolean debug = false;
+
+    /*
+     * (Copied/adapted from <code>java.security.MessageDigest</code>
+     *
+     * This is a subset/simplification <code>java.security.MessageDigest</code>
+     * that supports a fixed set of hashcode mechanisms (currently just
+     * SHA-1) while preserving the following MessageDigest methods:
+     *
+     * public MessageDigest getInstance(String algorithm)
+     * public final int getDigestLength()
+     * public void reset()
+     * public byte[] digest()
+     * public void update(byte[] input, int offset, int len)
+     * public final String getAlgorithm()
+     * <p>
+     * NOTE that the clone() method is not provided.
+     */
+
+    /**
+     * Prevent direct instantiation except via the factory method.
+     */
+
+    private StandaloneMessageDigest() {
+        // Keep javac happy.
+        digestLength = 0;
+        blockSize = 0;
+        algorithm = null;
+        buffer = null;
+    }
+
+    private String algorithm;
+
+    // The state of this digest
+    private static final int INITIAL = 0;
+    private static final int IN_PROGRESS = 1;
+    private int state = INITIAL;
+
+    /**
+     * Returns a StandaloneMessageDigest object that implements the specified
+     * digest algorithm.
+     *
+     * <p> This method returns a new StandaloneMessageDigest for a single
+     * algorithm provider.
+     *
+     * @param algorithm the name of the algorithm requested.
+     *
+     * @return a standalone Message Digest object that implements the specified algorithm.
+     *
+     * @exception NoSuchAlgorithmException if algorithm not supported
+     *
+     */
+    public static StandaloneMessageDigest getInstance(String algorithm)
+        throws NoSuchAlgorithmException {
+        if (! algorithm.equals("SHA-1")) {
+            throw new NoSuchAlgorithmException(algorithm + " not found");
+        } else {
+            return new StandaloneSHA();
+        }
+    }
+
+    /**
+     * Updates the digest using the specified array of bytes, starting
+     * at the specified offset.
+     *
+     * @param input the array of bytes.
+     *
+     * @param offset the offset to start from in the array of bytes.
+     *
+     * @param len the number of bytes to use, starting at
+     * <code>offset</code>.
+     */
+    public void update(byte[] input, int offset, int len) {
+        if (debug) {
+            System.out.println("StandaloneMessageDigest.update");
+            (new Exception()).printStackTrace();
+        }
+        if (input == null) {
+            throw new IllegalArgumentException("No input buffer given");
+        }
+        if (input.length - offset < len) {
+            throw new IllegalArgumentException("Input buffer too short");
+        }
+        // No need to check for negative offset: engineUpdate does this
+
+        engineUpdate(input, offset, len);
+        state = IN_PROGRESS;
+    }
+
+    /**
+     * Completes the hash computation by performing final operations
+     * such as padding. The digest is reset after this call is made.
+     *
+     * @return the array of bytes for the resulting hash value.
+     */
+    public byte[] digest() {
+        if (debug) {
+            System.out.println("StandaloneMessageDigest.digest");
+        }
+        /* Resetting is the responsibility of implementors. */
+        byte[] result = engineDigest();
+        state = INITIAL;
+        return result;
+    }
+
+    /**
+     * Compares two digests for equality. Does a simple byte compare.
+     *
+     * @param digesta one of the digests to compare.
+     *
+     * @param digestb the other digest to compare.
+     *
+     * @return true if the digests are equal, false otherwise.
+     */
+    public static boolean isEqual(byte digesta[], byte digestb[]) {
+        if (digesta.length != digestb.length)
+            return false;
+
+        for (int i = 0; i < digesta.length; i++) {
+            if (digesta[i] != digestb[i]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Resets the digest for further use.
+     */
+    public void reset() {
+        if (debug) {
+            System.out.println("StandaloneMessageDigest.reset");
+        }
+        engineReset();
+        state = INITIAL;
+    }
+
+    /**
+     * Returns a string that identifies the algorithm, independent of
+     * implementation details. The name should be a standard
+     * Java Security name (such as "SHA", "MD5", and so on).
+     * See Appendix A in the <a href=
+     * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
+     * Java Cryptography Architecture API Specification &amp; Reference </a>
+     * for information about standard algorithm names.
+     *
+     * @return the name of the algorithm
+     */
+    public final String getAlgorithm() {
+        return this.algorithm;
+    }
+
+    /**
+     * Returns the length of the digest in bytes.
+     *
+     * @return the digest length in bytes.
+     *
+     * @since 1.2
+     */
+    public final int getDigestLength() {
+        return engineGetDigestLength();
+    }
+
+    //* End of copied/adapted <code>java.security.MessageDigest</code>
+
+    // Start of copied/adapted <code>sun.security.provider.DigestBase</code>
+
+    // one element byte array, temporary storage for update(byte)
+    private byte[] oneByte;
+
+    // length of the message digest in bytes
+    private final int digestLength;
+
+    // size of the input to the compression function in bytes
+    private final int blockSize;
+    // buffer to store partial blocks, blockSize bytes large
+    // Subclasses should not access this array directly except possibly in their
+    // implDigest() method. See MD5.java as an example.
+    final byte[] buffer;
+    // offset into buffer
+    private int bufOfs;
+
+    // number of bytes processed so far. subclasses should not modify
+    // this value.
+    // also used as a flag to indicate reset status
+    // -1: need to call engineReset() before next call to update()
+    //  0: is already reset
+    long bytesProcessed;
+
+    /**
+     * Main constructor.
+     */
+    StandaloneMessageDigest(String algorithm, int digestLength, int blockSize) {
+        // super();
+        this.algorithm = algorithm;
+        this.digestLength = digestLength;
+        this.blockSize = blockSize;
+        buffer = new byte[blockSize];
+    }
+
+    // return digest length. See JCA doc.
+    protected final int engineGetDigestLength() {
+        return digestLength;
+    }
+
+    // single byte update. See JCA doc.
+    protected final void engineUpdate(byte b) {
+        if (oneByte == null) {
+            oneByte = new byte[1];
+        }
+        oneByte[0] = b;
+        engineUpdate(oneByte, 0, 1);
+    }
+
+    // array update. See JCA doc.
+    protected final void engineUpdate(byte[] b, int ofs, int len) {
+        if (len == 0) {
+            return;
+        }
+        if ((ofs < 0) || (len < 0) || (ofs > b.length - len)) {
+            throw new ArrayIndexOutOfBoundsException();
+        }
+        if (bytesProcessed < 0) {
+            engineReset();
+        }
+        bytesProcessed += len;
+        // if buffer is not empty, we need to fill it before proceeding
+        if (bufOfs != 0) {
+            int n = Math.min(len, blockSize - bufOfs);
+            System.arraycopy(b, ofs, buffer, bufOfs, n);
+            bufOfs += n;
+            ofs += n;
+            len -= n;
+            if (bufOfs >= blockSize) {
+                // compress completed block now
+                implCompress(buffer, 0);
+                bufOfs = 0;
+            }
+        }
+        // compress complete blocks
+        while (len >= blockSize) {
+            implCompress(b, ofs);
+            len -= blockSize;
+            ofs += blockSize;
+        }
+        // copy remainder to buffer
+        if (len > 0) {
+            System.arraycopy(b, ofs, buffer, 0, len);
+            bufOfs = len;
+        }
+    }
+
+    // reset this object. See JCA doc.
+    protected final void engineReset() {
+        if (bytesProcessed == 0) {
+            // already reset, ignore
+            return;
+        }
+        implReset();
+        bufOfs = 0;
+        bytesProcessed = 0;
+    }
+
+    // return the digest. See JCA doc.
+    protected final byte[] engineDigest() throws ProviderException {
+        byte[] b = new byte[digestLength];
+        try {
+            engineDigest(b, 0, b.length);
+        } catch (DigestException e) {
+            throw (ProviderException)
+                new ProviderException("Internal error").initCause(e);
+        }
+        return b;
+    }
+
+    // return the digest in the specified array. See JCA doc.
+    protected final int engineDigest(byte[] out, int ofs, int len)
+            throws DigestException {
+        if (len < digestLength) {
+            throw new DigestException("Length must be at least "
+                + digestLength + " for " + algorithm + "digests");
+        }
+        if ((ofs < 0) || (len < 0) || (ofs > out.length - len)) {
+            throw new DigestException("Buffer too short to store digest");
+        }
+        if (bytesProcessed < 0) {
+            engineReset();
+        }
+        implDigest(out, ofs);
+        bytesProcessed = -1;
+        return digestLength;
+    }
+
+    /**
+     * Core compression function. Processes blockSize bytes at a time
+     * and updates the state of this object.
+     */
+    abstract void implCompress(byte[] b, int ofs);
+
+    /**
+     * Return the digest. Subclasses do not need to reset() themselves,
+     * StandaloneMessageDigest calls implReset() when necessary.
+     */
+    abstract void implDigest(byte[] out, int ofs);
+
+    /**
+     * Reset subclass specific state to their initial values. StandaloneMessageDigest
+     * calls this method when necessary.
+     */
+    abstract void implReset();
+
+    // padding used for the MD5, and SHA-* message digests
+    static final byte[] padding;
+
+    static {
+        // we need 128 byte padding for SHA-384/512
+        // and an additional 8 bytes for the high 8 bytes of the 16
+        // byte bit counter in SHA-384/512
+        padding = new byte[136];
+        padding[0] = (byte)0x80;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/jkernel/StandaloneSHA.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,190 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package sun.jkernel;
+
+import static sun.jkernel.StandaloneByteArrayAccess.*;
+
+/**
+ * This is a slightly modified subset of the
+ * <code>sun.security.provider.SHA</code> class that
+ * is not dependent on the regular Java Security framework classes. It
+ * implements the Secure Hash Algorithm (SHA-1) developed by
+ * the National Institute of Standards and Technology along with the
+ * National Security Agency.  This is the updated version of SHA
+ * fip-180 as superseded by fip-180-1.
+ * <p>
+ * The <code>sun.security.provider.SHA.clonde()</code> method is not
+ * implemented and other, formerly public methods, are package private.
+ *
+ */
+final class StandaloneSHA extends StandaloneMessageDigest {
+
+    static final boolean debug = false;
+
+    // Buffer of int's and count of characters accumulated
+    // 64 bytes are included in each hash block so the low order
+    // bits of count are used to know how to pack the bytes into ints
+    // and to know when to compute the block and start the next one.
+    private final int[] W;
+
+    // state of this
+    private final int[] state;
+
+    /**
+     * Creates a new StandaloneSHA object.
+     */
+    StandaloneSHA() {
+        super("SHA-1", 20, 64);
+        state = new int[5];
+        W = new int[80];
+        implReset();
+    }
+
+    /**
+     * Resets the buffers and hash value to start a new hash.
+     */
+    void implReset() {
+        if (debug) {
+            System.out.print("StandaloneSHA.implR: " );
+        }
+        state[0] = 0x67452301;
+        state[1] = 0xefcdab89;
+        state[2] = 0x98badcfe;
+        state[3] = 0x10325476;
+        state[4] = 0xc3d2e1f0;
+    }
+
+    /**
+     * Computes the final hash and copies the 20 bytes to the output array.
+     */
+    void implDigest(byte[] out, int ofs) {
+        if (debug) {
+            System.out.print("StandaloneSHA.implD: " );
+        }
+        long bitsProcessed = bytesProcessed << 3;
+
+        int index = (int)bytesProcessed & 0x3f;
+        int padLen = (index < 56) ? (56 - index) : (120 - index);
+
+        engineUpdate(padding, 0, padLen);
+
+        // System.out.println("Inserting: " + bitsProcessed);
+        StandaloneByteArrayAccess.i2bBig4((int)(bitsProcessed >>> 32), buffer, 56);
+        StandaloneByteArrayAccess.i2bBig4((int)bitsProcessed, buffer, 60);
+        implCompress(buffer, 0);
+
+        StandaloneByteArrayAccess.i2bBig(state, 0, out, ofs, 20);
+    }
+
+    // Constants for each round
+    private final static int round1_kt = 0x5a827999;
+    private final static int round2_kt = 0x6ed9eba1;
+    private final static int round3_kt = 0x8f1bbcdc;
+    private final static int round4_kt = 0xca62c1d6;
+
+    /**
+     * Compute a the hash for the current block.
+     *
+     * This is in the same vein as Peter Gutmann's algorithm listed in
+     * the back of Applied Cryptography, Compact implementation of
+     * "old" NIST Secure Hash Algorithm.
+     */
+    void implCompress(byte[] buf, int ofs) {
+
+        if (debug) {
+            System.out.print("StandaloneSHA.implC: " );
+            for (int i=ofs; i<buf.length; i++) {
+                System.out.format("%02X",buf[i]);
+            }
+            System.out.println();
+        }
+
+        StandaloneByteArrayAccess.b2iBig(buf, ofs, W, 0, 64);
+
+        // The first 16 ints have the byte stream, compute the rest of
+        // the buffer
+        for (int t = 16; t <= 79; t++) {
+            int temp = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16];
+            W[t] = (temp << 1) | (temp >>> 31);
+        }
+
+        int a = state[0];
+        int b = state[1];
+        int c = state[2];
+        int d = state[3];
+        int e = state[4];
+
+        // Round 1
+        for (int i = 0; i < 20; i++) {
+            int temp = ((a<<5) | (a>>>(32-5))) +
+                ((b&c)|((~b)&d))+ e + W[i] + round1_kt;
+            e = d;
+            d = c;
+            c = ((b<<30) | (b>>>(32-30)));
+            b = a;
+            a = temp;
+        }
+
+        // Round 2
+        for (int i = 20; i < 40; i++) {
+            int temp = ((a<<5) | (a>>>(32-5))) +
+                (b ^ c ^ d) + e + W[i] + round2_kt;
+            e = d;
+            d = c;
+            c = ((b<<30) | (b>>>(32-30)));
+            b = a;
+            a = temp;
+        }
+
+        // Round 3
+        for (int i = 40; i < 60; i++) {
+            int temp = ((a<<5) | (a>>>(32-5))) +
+                ((b&c)|(b&d)|(c&d)) + e + W[i] + round3_kt;
+            e = d;
+            d = c;
+            c = ((b<<30) | (b>>>(32-30)));
+            b = a;
+            a = temp;
+        }
+
+        // Round 4
+        for (int i = 60; i < 80; i++) {
+            int temp = ((a<<5) | (a>>>(32-5))) +
+                (b ^ c ^ d) + e + W[i] + round4_kt;
+            e = d;
+            d = c;
+            c = ((b<<30) | (b>>>(32-30)));
+            b = a;
+            a = temp;
+        }
+        state[0] += a;
+        state[1] += b;
+        state[2] += c;
+        state[3] += d;
+        state[4] += e;
+    }
+
+}
--- a/jdk/src/share/classes/sun/management/OperatingSystemImpl.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/management/OperatingSystemImpl.java	Tue Jul 21 13:02:23 2009 -0700
@@ -78,4 +78,3 @@
     }
 
 }
-
--- a/jdk/src/share/classes/sun/management/ThreadImpl.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/management/ThreadImpl.java	Tue Jul 21 13:02:23 2009 -0700
@@ -419,4 +419,3 @@
     }
 
 }
-
--- a/jdk/src/share/classes/sun/misc/Launcher.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/misc/Launcher.java	Tue Jul 21 13:02:23 2009 -0700
@@ -38,6 +38,7 @@
 import java.util.Set;
 import java.util.Vector;
 import java.security.AccessController;
+import java.security.AllPermission;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.security.AccessControlContext;
@@ -49,7 +50,8 @@
 import sun.security.action.GetPropertyAction;
 import sun.security.util.SecurityConstants;
 import sun.net.www.ParseUtil;
-
+import sun.jkernel.Bundle;
+import sun.jkernel.DownloadManager;
 
 /**
  * This class is used by the system to launch the main application.
@@ -116,6 +118,18 @@
         return loader;
     }
 
+    public static void addURLToAppClassLoader(URL u) {
+        AccessController.checkPermission(new AllPermission());
+        ClassLoader loader = Launcher.getLauncher().getClassLoader();
+        ((Launcher.AppClassLoader) loader).addAppURL(u);
+    }
+
+    public static void addURLToExtClassLoader(URL u) {
+        AccessController.checkPermission(new AllPermission());
+        ClassLoader loader = Launcher.getLauncher().getClassLoader();
+        ((Launcher.ExtClassLoader) loader.getParent()).addExtURL(u);
+    }
+
     /*
      * The class loader used for loading installed extensions.
      */
@@ -233,6 +247,16 @@
             return null;
         }
 
+        protected Class findClass(String name) throws ClassNotFoundException {
+            if (VM.isBootedKernelVM()) {
+                // Check for download before we look for it.  If
+                // DownloadManager ends up downloading it, it will add it to
+                // our search path before we proceed to the findClass().
+                DownloadManager.getBootClassPathEntryForClass(name);
+            }
+            return super.findClass(name);
+        }
+
         private static AccessControlContext getContext(File[] dirs)
             throws IOException
         {
@@ -297,6 +321,9 @@
         public Class loadClass(String name, boolean resolve)
             throws ClassNotFoundException
         {
+            if (VM.isBootedKernelVM()) {
+                DownloadManager.getBootClassPathEntryForClass(name);
+            }
             int i = name.lastIndexOf('.');
             if (i != -1) {
                 SecurityManager sm = System.getSecurityManager();
@@ -353,39 +380,66 @@
 
             return acc;
         }
+
+        void addAppURL(URL url) {
+            super.addURL(url);
+        }
     }
 
-    public static URLClassPath getBootstrapClassPath() {
-        String prop = AccessController.doPrivileged(
-            new GetPropertyAction("sun.boot.class.path"));
-        URL[] urls;
-        if (prop != null) {
-            final String path = prop;
-            urls = AccessController.doPrivileged(
-                new PrivilegedAction<URL[]>() {
-                    public URL[] run() {
-                        File[] classPath = getClassPath(path);
-                        int len = classPath.length;
-                        Set<File> seenDirs = new HashSet<File>();
-                        for (int i = 0; i < len; i++) {
-                            File curEntry = classPath[i];
-                            // Negative test used to properly handle
-                            // nonexistent jars on boot class path
-                            if (!curEntry.isDirectory()) {
-                                curEntry = curEntry.getParentFile();
+    private static URLClassPath bootstrapClassPath;
+
+    public static synchronized URLClassPath getBootstrapClassPath() {
+        if (bootstrapClassPath == null) {
+            String prop = AccessController.doPrivileged(
+                new GetPropertyAction("sun.boot.class.path"));
+            URL[] urls;
+            if (prop != null) {
+                final String path = prop;
+                urls = AccessController.doPrivileged(
+                    new PrivilegedAction<URL[]>() {
+                        public URL[] run() {
+                            File[] classPath = getClassPath(path);
+                            int len = classPath.length;
+                            Set<File> seenDirs = new HashSet<File>();
+                            for (int i = 0; i < len; i++) {
+                                File curEntry = classPath[i];
+                                // Negative test used to properly handle
+                                // nonexistent jars on boot class path
+                                if (!curEntry.isDirectory()) {
+                                    curEntry = curEntry.getParentFile();
+                                }
+                                if (curEntry != null && seenDirs.add(curEntry)) {
+                                    MetaIndex.registerDirectory(curEntry);
+                                }
                             }
-                            if (curEntry != null && seenDirs.add(curEntry)) {
-                                MetaIndex.registerDirectory(curEntry);
-                            }
+                            return pathToURLs(classPath);
                         }
-                        return pathToURLs(classPath);
                     }
-                }
-            );
-        } else {
-            urls = new URL[0];
+                );
+            } else {
+                urls = new URL[0];
+            }
+
+            bootstrapClassPath = new URLClassPath(urls, factory);
+            if (VM.isBootedKernelVM()) {
+                final File[] additionalBootStrapPaths =
+                    DownloadManager.getAdditionalBootStrapPaths();
+                AccessController.doPrivileged(new PrivilegedAction() {
+                    public Object run() {
+                        for (int i=0; i<additionalBootStrapPaths.length; i++) {
+                            bootstrapClassPath.addURL(
+                                getFileURL(additionalBootStrapPaths[i]));
+                        }
+                        return null;
+                    }
+                });
+            }
         }
-        return new URLClassPath(urls, factory);
+        return bootstrapClassPath;
+    }
+
+    public static synchronized void flushBootstrapClassPath() {
+        bootstrapClassPath = null;
     }
 
     private static URL[] pathToURLs(File[] path) {
--- a/jdk/src/share/classes/sun/misc/PerformanceLogger.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/misc/PerformanceLogger.java	Tue Jul 21 13:02:23 2009 -0700
@@ -81,6 +81,7 @@
     private static Vector<TimeData> times;
     private static String logFileName = null;
     private static Writer logWriter = null;
+    private static long baseTime;
 
     static {
         String perfLoggingProp =
@@ -188,6 +189,16 @@
     }
 
     /**
+     * Sets the base time, output can then
+     * be displayed as offsets from the base time;.
+     */
+    public static void setBaseTime(long time) {
+        if (loggingEnabled()) {
+            baseTime = time;
+        }
+    }
+
+    /**
      * Sets the start time.
      * This version of the method is
      * given the time to log, instead of expecting this method to
@@ -281,7 +292,8 @@
                         TimeData td = times.get(i);
                         if (td != null) {
                             writer.write(i + " " + td.getMessage() + ": " +
-                                         td.getTime() + "\n");
+                                         (td.getTime() - baseTime) + "\n");
+
                         }
                     }
                 }
--- a/jdk/src/share/classes/sun/misc/VM.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/misc/VM.java	Tue Jul 21 13:02:23 2009 -0700
@@ -346,6 +346,11 @@
     private native static void getThreadStateValues(int[][] vmThreadStateValues,
                                                     String[][] vmThreadStateNames);
 
+    private static boolean kernelVM;
+    public static boolean isBootedKernelVM() {
+        return booted && kernelVM;
+    }
+
     static {
         initialize();
     }
--- a/jdk/src/share/classes/sun/security/provider/certpath/CertPathHelper.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/security/provider/certpath/CertPathHelper.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2002-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
@@ -25,9 +25,11 @@
 
 package sun.security.provider.certpath;
 
+import java.util.Date;
 import java.util.Set;
 
 import java.security.cert.X509CertSelector;
+import java.security.cert.X509CRLSelector;
 
 import sun.security.x509.GeneralNameInterface;
 
@@ -55,8 +57,14 @@
     protected abstract void implSetPathToNames(X509CertSelector sel,
             Set<GeneralNameInterface> names);
 
+    protected abstract void implSetDateAndTime(X509CRLSelector sel, Date date, long skew);
+
     static void setPathToNames(X509CertSelector sel,
             Set<GeneralNameInterface> names) {
         instance.implSetPathToNames(sel, names);
     }
+
+    static void setDateAndTime(X509CRLSelector sel, Date date, long skew) {
+        instance.implSetDateAndTime(sel, date, skew);
+    }
 }
--- a/jdk/src/share/classes/sun/security/provider/certpath/CrlRevocationChecker.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/security/provider/certpath/CrlRevocationChecker.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-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
@@ -81,6 +81,10 @@
     private static final boolean[] ALL_REASONS =
         {true, true, true, true, true, true, true, true, true};
 
+    // Maximum clock skew in milliseconds (15 minutes) allowed when checking
+    // validity of CRLs
+    private static final long MAX_CLOCK_SKEW = 900000;
+
     /**
      * Creates a <code>CrlRevocationChecker</code>.
      *
@@ -281,7 +285,7 @@
         try {
             X509CRLSelector sel = new X509CRLSelector();
             sel.setCertificateChecking(currCert);
-            sel.setDateAndTime(mCurrentTime);
+            CertPathHelper.setDateAndTime(sel, mCurrentTime, MAX_CLOCK_SKEW);
 
             for (CertStore mStore : mStores) {
                 for (java.security.cert.CRL crl : mStore.getCRLs(sel)) {
--- a/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java	Tue Jul 21 13:02:23 2009 -0700
@@ -149,9 +149,9 @@
 
     private SingleResponse singleResponse;
 
-    // Maximum clock skew in milliseconds (10 minutes) allowed when checking
+    // Maximum clock skew in milliseconds (15 minutes) allowed when checking
     // validity of OCSP responses
-    private static final long MAX_CLOCK_SKEW = 600000;
+    private static final long MAX_CLOCK_SKEW = 900000;
 
     // an array of all of the CRLReasons (used in SingleResponse)
     private static CRLReason[] values = CRLReason.values();
--- a/jdk/src/share/classes/sun/swing/AccessibleMethod.java	Wed Jul 15 10:46:42 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/*
- * Copyright 2005-2008 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.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun 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 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.
- */
-package sun.swing;
-
-import java.security.*;
-import java.lang.reflect.*;
-
-/**
- * A utility for accessing and invoking methods, via reflection,
- * that would otherwise be unaccessible.
- *
- * @author Shannon Hickey
- */
-public class AccessibleMethod {
-
-    private final Method method;
-
-    /**
-     * Construct an instance for the given params.
-     *
-     * @param klass the class to which the method belongs
-     * @param methodName the name of the method
-     * @param paramTypes the paramater type array
-     * @throws NullPointerException if <code>klass</code>
-     *         or <code>name</code> is <code>null</code>
-     * @throws NoSuchMethodException if the method can't be found
-     */
-    public AccessibleMethod(Class klass,
-                            String methodName,
-                            Class ... paramTypes) throws NoSuchMethodException {
-        try {
-            method = AccessController.doPrivileged(
-                new AccessMethodAction(klass, methodName, paramTypes));
-        } catch (PrivilegedActionException e) {
-            throw (NoSuchMethodException)e.getCause();
-        }
-    }
-
-    /**
-     * Invoke the method that this object represents.
-     * Has the same behavior and throws the same exceptions as
-     * <code>java.lang.reflect.Method.invoke</code> with one
-     * exception: This method does not throw
-     * <code>IllegalAccessException</code> since the target
-     * method has already been made accessible.
-     *
-     * @param obj the object the underlying method is invoked from
-     * @param args the arguments used for the method call
-     * @return the result of dispatching the method represented by
-     *         this object on <code>obj</code> with parameters
-     *         <code>args</code>
-     * @see java.lang.reflect.Method#invoke
-     */
-    public Object invoke(Object obj, Object ... args)
-            throws IllegalArgumentException, InvocationTargetException {
-
-        try {
-            return method.invoke(obj, args);
-        } catch (IllegalAccessException e) {
-            // should never happen since we've made it accessible
-            throw new AssertionError("accessible method inaccessible");
-        }
-    }
-
-    /**
-     * Invoke the method that this object represents, with the
-     * expectation that the method being called throws no
-     * checked exceptions.
-     * <p>
-     * Simply calls <code>this.invoke(obj, args)</code>
-     * but catches any <code>InvocationTargetException</code>
-     * and returns the cause wrapped in a runtime exception.
-     *
-     * @param obj the object the underlying method is invoked from
-     * @param args the arguments used for the method call
-     * @return the result of dispatching the method represented by
-     *         this object on <code>obj</code> with parameters
-     *         <code>args</code>
-     * @see #invoke
-     */
-    public Object invokeNoChecked(Object obj, Object ... args) {
-        try {
-            return invoke(obj, args);
-        } catch (InvocationTargetException ex) {
-            if (ex.getCause() instanceof RuntimeException) {
-                throw (RuntimeException)ex.getCause();
-            } else {
-                throw new RuntimeException(ex.getCause());
-            }
-        }
-    }
-
-    /** The action used to fetch the method and make it accessible */
-    private static class AccessMethodAction implements PrivilegedExceptionAction<Method> {
-        private final Class<?> klass;
-        private final String methodName;
-        private final Class[] paramTypes;
-
-        public AccessMethodAction(Class klass,
-                                  String methodName,
-                                  Class ... paramTypes) {
-
-            this.klass = klass;
-            this.methodName = methodName;
-            this.paramTypes = paramTypes;
-        }
-
-        public Method run() throws NoSuchMethodException {
-            Method method = klass.getDeclaredMethod(methodName, paramTypes);
-            method.setAccessible(true);
-            return method;
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/swing/SwingAccessor.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,96 @@
+/*
+ * 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package sun.swing;
+
+import sun.misc.Unsafe;
+
+import java.awt.Point;
+
+import javax.swing.text.JTextComponent;
+import javax.swing.TransferHandler;
+
+/**
+ * The SwingAccessor utility class.
+ * The main purpose of this class is to enable accessing
+ * private and package-private fields of classes from
+ * different classes/packages. See sun.misc.SharedSecretes
+ * for another example.
+ */
+public final class SwingAccessor {
+    private static final Unsafe unsafe = Unsafe.getUnsafe();
+
+    /**
+     * We don't need any objects of this class.
+     * It's rather a collection of static methods
+     * and interfaces.
+     */
+    private SwingAccessor() {
+    }
+
+    /**
+     * An accessor for the JTextComponent class.
+     * Note that we intentionally introduce the JTextComponentAccessor,
+     * and not the JComponentAccessor because the needed methods
+     * aren't override methods.
+     */
+    public interface JTextComponentAccessor {
+
+        /**
+         * Calculates a custom drop location for the text component,
+         * representing where a drop at the given point should insert data.
+         */
+        TransferHandler.DropLocation dropLocationForPoint(JTextComponent textComp, Point p);
+
+        /**
+         * Called to set or clear the drop location during a DnD operation.
+         */
+        Object setDropLocation(JTextComponent textComp, TransferHandler.DropLocation location,
+                               Object state, boolean forDrop);
+    }
+
+    /**
+     * The javax.swing.text.JTextComponent class accessor object.
+     */
+    private static JTextComponentAccessor jtextComponentAccessor;
+
+    /**
+     * Set an accessor object for the javax.swing.text.JTextComponent class.
+     */
+    public static void setJTextComponentAccessor(JTextComponentAccessor jtca) {
+         jtextComponentAccessor = jtca;
+    }
+
+    /**
+     * Retrieve the accessor object for the javax.swing.text.JTextComponent class.
+     */
+    public static JTextComponentAccessor getJTextComponentAccessor() {
+        if (jtextComponentAccessor == null) {
+            unsafe.ensureClassInitialized(JTextComponent.class);
+        }
+
+        return jtextComponentAccessor;
+    }
+}
--- a/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1598,15 +1598,34 @@
      * @param options   the optional features to be enabled.
      */
     public static String normalize(String str, Normalizer.Form form, int options) {
+        int len = str.length();
+        boolean asciiOnly = true;
+        if (len < 80) {
+            for (int i = 0; i < len; i++) {
+                if (str.charAt(i) > 127) {
+                    asciiOnly = false;
+                    break;
+                }
+            }
+        } else {
+            char[] a = str.toCharArray();
+            for (int i = 0; i < len; i++) {
+                if (a[i] > 127) {
+                    asciiOnly = false;
+                    break;
+                }
+            }
+        }
+
         switch (form) {
         case NFC :
-            return NFC.normalize(str, options);
+            return asciiOnly ? str : NFC.normalize(str, options);
         case NFD :
-            return NFD.normalize(str, options);
+            return asciiOnly ? str : NFD.normalize(str, options);
         case NFKC :
-            return NFKC.normalize(str, options);
+            return asciiOnly ? str : NFKC.normalize(str, options);
         case NFKD :
-            return NFKD.normalize(str, options);
+            return asciiOnly ? str : NFKD.normalize(str, options);
         }
 
         throw new IllegalArgumentException("Unexpected normalization form: " +
--- a/jdk/src/share/demo/jfc/Font2DTest/RangeMenu.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/demo/jfc/Font2DTest/RangeMenu.java	Tue Jul 21 13:02:23 2009 -0700
@@ -53,7 +53,7 @@
 public final class RangeMenu extends JComboBox implements ActionListener {
 
     /// Painfully extracted from java.lang.Character.UnicodeBlock.  Arrrgh!
-    /// Unicode 3.0 data.
+    /// Unicode 5.1.0 data.
 
     private final int[][] UNICODE_RANGES = {
         { 0x000000, 0x00007f }, /// BASIC_LATIN
@@ -63,14 +63,16 @@
         { 0x000250, 0x0002af }, /// IPA_EXTENSIONS
         { 0x0002b0, 0x0002ff }, /// SPACING_MODIFIER_LETTERS
         { 0x000300, 0x00036f }, /// COMBINING_DIACRITICAL_MARKS
-        { 0x000370, 0x0003ff }, /// GREEK
+        { 0x000370, 0x0003ff }, /// GREEK_AND_COPTIC
         { 0x000400, 0x0004ff }, /// CYRILLIC
         { 0x000500, 0x00052f }, /// CYRILLIC_SUPPLEMENTARY
         { 0x000530, 0x00058f }, /// ARMENIAN
         { 0x000590, 0x0005ff }, /// HEBREW
         { 0x000600, 0x0006ff }, /// ARABIC
         { 0x000700, 0x00074f }, /// SYRIAC
+        { 0x000750, 0x00077f }, /// ARABIC_SUPPLEMENT
         { 0x000780, 0x0007bf }, /// THAANA
+        { 0x0007c0, 0x0007ff }, /// NKO
         { 0x000900, 0x00097f }, /// DEVANAGARI
         { 0x000980, 0x0009ff }, /// BENGALI
         { 0x000a00, 0x000a7f }, /// GURMUKHI
@@ -88,6 +90,7 @@
         { 0x0010a0, 0x0010ff }, /// GEORGIAN
         { 0x001100, 0x0011ff }, /// HANGUL_JAMO
         { 0x001200, 0x00137f }, /// ETHIOPIC
+        { 0x001380, 0x00139f }, /// ETHIOPIC_SUPPLEMENT
         { 0x0013a0, 0x0013ff }, /// CHEROKEE
         { 0x001400, 0x00167f }, /// UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS
         { 0x001680, 0x00169f }, /// OGHAM
@@ -100,8 +103,16 @@
         { 0x001800, 0x0018af }, /// MONGOLIAN
         { 0x001900, 0x00194f }, /// LIMBU
         { 0x001950, 0x00197f }, /// TAI_LE
+        { 0x001980, 0x0019df }, /// NEW_TAI_LE
         { 0x0019e0, 0x0019ff }, /// KHMER_SYMBOLS
+        { 0x001a00, 0x001a1f }, /// BUGINESE
+        { 0x001b00, 0x001b7f }, /// BALINESE
+        { 0x001b80, 0x001bbf }, /// SUNDANESE
+        { 0x001c00, 0x001c4f }, /// LEPCHA
+        { 0x001c50, 0x001c7f }, /// OL_CHIKI
         { 0x001d00, 0x001d7f }, /// PHONETIC_EXTENSIONS
+        { 0x001d80, 0x001dbf }, /// PHONEITC EXTENSIONS SUPPLEMENT
+        { 0x001dc0, 0x001dff }, /// COMBINING_DIACRITICAL_MAKRS_SUPPLEMENT
         { 0x001e00, 0x001eff }, /// LATIN_EXTENDED_ADDITIONAL
         { 0x001f00, 0x001fff }, /// GREEK_EXTENDED
         { 0x002000, 0x00206f }, /// GENERAL_PUNCTUATION
@@ -128,6 +139,14 @@
         { 0x002980, 0x0029ff }, /// MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B
         { 0x002a00, 0x002aff }, /// SUPPLEMENTAL_MATHEMATICAL_OPERATORS
         { 0x002b00, 0x002bff }, /// MISCELLANEOUS_SYMBOLS_AND_ARROWS
+        { 0x002c00, 0x002c5f }, /// GLAGOLITIC
+        { 0x002c60, 0x002c7f }, /// LATIN_EXTENDED-C
+        { 0x002c80, 0x002cff }, /// COPTIC
+        { 0x002d00, 0x002d2f }, /// GEORGIAN_SUPPLEMENT
+        { 0x002d30, 0x002d7f }, /// TIFINAGH
+        { 0x002d80, 0x002ddf }, /// ETHIOPIC_EXTENDED
+        { 0x002de0, 0x002dff }, /// CYRILLIC_EXTENDED-A
+        { 0x002e00, 0x002e7f }, /// SUPPLEMENTAL_PUNCTUATION
         { 0x002e80, 0x002eff }, /// CJK_RADICALS_SUPPLEMENT
         { 0x002f00, 0x002fdf }, /// KANGXI_RADICALS
         { 0x002ff0, 0x002fff }, /// IDEOGRAPHIC_DESCRIPTION_CHARACTERS
@@ -138,6 +157,7 @@
         { 0x003130, 0x00318f }, /// HANGUL_COMPATIBILITY_JAMO
         { 0x003190, 0x00319f }, /// KANBUN
         { 0x0031a0, 0x0031bf }, /// BOPOMOFO_EXTENDED
+        { 0x0031c0, 0x0031ef }, /// CJK_STROKES
         { 0x0031f0, 0x0031ff }, /// KATAKANA_PHONETIC_EXTENSIONS
         { 0x003200, 0x0032ff }, /// ENCLOSED_CJK_LETTERS_AND_MONTHS
         { 0x003300, 0x0033ff }, /// CJK_COMPATIBILITY
@@ -146,13 +166,26 @@
         { 0x004e00, 0x009fff }, /// CJK_UNIFIED_IDEOGRAPHS
         { 0x00a000, 0x00a48f }, /// YI_SYLLABLES
         { 0x00a490, 0x00a4cf }, /// YI_RADICALS
+        { 0x00a500, 0x00a63f }, /// YAI
+        { 0x00a640, 0x00a69f }, /// CYRILLIC_EXTENDED-B
+        { 0x00a700, 0x00a71f }, /// MODIFIER_TONE_LETTERS
+        { 0x00a720, 0x00a7ff }, /// LATIN_EXTENDED-D
+        { 0x00a800, 0x00a82f }, /// SYLOTI_NAGRI
+        { 0x00a840, 0x00a87f }, /// PHAGS-PA
+        { 0x00a880, 0x00a8df }, /// SAURASHTRA
+        { 0x00a900, 0x00a92f }, /// KAYAH_LI
+        { 0x00a930, 0x00a95f }, /// REJANG
+        { 0x00aa00, 0x00aa5f }, /// CHAM
         { 0x00ac00, 0x00d7af }, /// HANGUL_SYLLABLES
-        { 0x00d800, 0x00dfff }, /// SURROGATES_AREA
+        { 0x00d800, 0x00db7f }, /// HIGH_SURROGATES_AREA
+        { 0x00db80, 0x00dbff }, /// HIGH_PRIVATE_USE_SURROGATES_AREA
+        { 0x00dc00, 0x00dfff }, /// LOW_SURROGATES_AREA
         { 0x00e000, 0x00f8ff }, /// PRIVATE_USE_AREA
         { 0x00f900, 0x00faff }, /// CJK_COMPATIBILITY_IDEOGRAPHS
         { 0x00fb00, 0x00fb4f }, /// ALPHABETIC_PRESENTATION_FORMS
         { 0x00fb50, 0x00fdff }, /// ARABIC_PRESENTATION_FORMS_A
         { 0x00fe00, 0x00fe0f }, /// VARIATION_SELECTORS
+        { 0x00fe10, 0x00fe1f }, /// VERTICAL_FORMS
         { 0x00fe20, 0x00fe2f }, /// COMBINING_HALF_MARKS
         { 0x00fe30, 0x00fe4f }, /// CJK_COMPATIBILITY_FORMS
         { 0x00fe50, 0x00fe6f }, /// SMALL_FORM_VARIANTS
@@ -162,17 +195,32 @@
         { 0x010000, 0x01007f }, /// LINEAR_B_SYLLABARY
         { 0x010080, 0x0100ff }, /// LINEAR_B_IDEOGRAMS
         { 0x010100, 0x01013f }, /// AEGEAN_NUMBERS
+        { 0x010140, 0x01018f }, /// ANCIENT_GREEK_NUMBERS
+        { 0x010190, 0x0101cf }, /// ANCIENT_SYMBOLS
+        { 0x0101d0, 0x0101ff }, /// PHAISTOS_DISC
+        { 0x010280, 0x01029f }, /// LYCIAN
+        { 0x0102a0, 0x0102df }, /// CARIAN
         { 0x010300, 0x01032f }, /// OLD_ITALIC
         { 0x010330, 0x01034f }, /// GOTHIC
         { 0x010380, 0x01039f }, /// UGARITIC
+        { 0x0103a0, 0x0103df }, /// OLD_PERSIAN
         { 0x010400, 0x01044f }, /// DESERET
         { 0x010450, 0x01047f }, /// SHAVIAN
         { 0x010480, 0x0104af }, /// OSMANYA
         { 0x010800, 0x01083f }, /// CYPRIOT_SYLLABARY
+        { 0x010900, 0x01091f }, /// PHOENICIAN
+        { 0x010920, 0x01093f }, /// LYDIAN
+        { 0x010a00, 0x010a5f }, /// KHAROSHTHI
+        { 0x012000, 0x0123ff }, /// CUNEIFORM
+        { 0x012400, 0x01247f }, /// CUNEIFORM_NUMBERS_AND_PUNCTUATION
         { 0x01d000, 0x01d0ff }, /// BYZANTINE_MUSICAL_SYMBOLS
         { 0x01d100, 0x01d1ff }, /// MUSICAL_SYMBOLS
+        { 0x01d200, 0x01d24f }, /// ANCIENT_GREEK_MUSICAL_NOTATION
         { 0x01d300, 0x01d35f }, /// TAI_XUAN_JING_SYMBOLS
+        { 0x01d360, 0x01d37f }, /// COUNTING_ROD_NUMERALS
         { 0x01d400, 0x01d7ff }, /// MATHEMATICAL_ALPHANUMERIC_SYMBOLS
+        { 0x01f000, 0x01f02f }, /// MAHJONG_TILES
+        { 0x01f030, 0x01f09f }, /// DOMINO_TILES
         { 0x020000, 0x02a6df }, /// CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
         { 0x02f800, 0x02fa1f }, /// CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT
         { 0x0e0000, 0x0e007f }, /// TAGS
@@ -190,14 +238,16 @@
         "IPA Extensions",
         "Spacing Modifier Letters",
         "Combining Diacritical Marks",
-        "Greek",
+        "Greek and Coptic",
         "Cyrillic",
         "Cyrillic Supplement",
         "Armenian",
         "Hebrew",
         "Arabic",
         "Syriac",
+        "Arabic Supplement",
         "Thaana",
+        "NKo",
         "Devanagari",
         "Bengali",
         "Gurmukhi",
@@ -215,6 +265,7 @@
         "Georgian",
         "Hangul Jamo",
         "Ethiopic",
+        "Ethiopic Supplement",
         "Cherokee",
         "Unified Canadian Aboriginal Syllabics",
         "Ogham",
@@ -227,14 +278,22 @@
         "Mongolian",
         "Limbu",
         "Tai Le",
+        "New Tai Lue",
         "Khmer Symbols",
+        "Buginese",
+        "Balinese",
+        "Sundanese",
+        "Lepcha",
+        "Ol Chiki",
         "Phonetic Extensions",
+        "Phonetic Extensions Supplement",
+        "Combining Diacritical Marks Supplement",
         "Latin Extended Additional",
         "Greek Extended",
         "General Punctuation",
         "Superscripts and Subscripts",
         "Currency Symbols",
-        "Combining Marks for Symbols",
+        "Combining Diacritical Marks for Symbols",
         "Letterlike Symbols",
         "Number Forms",
         "Arrows",
@@ -255,6 +314,14 @@
         "Miscellaneous Mathematical Symbols-B",
         "Supplemental Mathematical Operators",
         "Miscellaneous Symbols and Arrows",
+        "Glagolitic",
+        "Latin Extended-C",
+        "Coptic",
+        "Georgian Supplement",
+        "Tifinagh",
+        "Ethiopic Extended",
+        "Cyrillic Extended-A",
+        "Supplemental Punctuation",
         "CJK Radicals Supplement",
         "Kangxi Radicals",
         "Ideographic Description Characters",
@@ -265,6 +332,7 @@
         "Hangul Compatibility Jamo",
         "Kanbun",
         "Bopomofo Extended",
+        "CJK Strokes",
         "Katakana Phonetic Extensions",
         "Enclosed CJK Letters and Months",
         "CJK Compatibility",
@@ -273,13 +341,26 @@
         "CJK Unified Ideographs",
         "Yi Syllables",
         "Yi Radicals",
+        "Vai",
+        "Cyrillic Extended-B",
+        "Modifier Tone Letters",
+        "Latin Extended-D",
+        "Syloti Nagri",
+        "Phags-pa",
+        "Saurashtra",
+        "Kayah Li",
+        "Rejang",
+        "Cham",
         "Hangul Syllables",
-        "Surrogates Area", // High Surrogates, High Private Use Surrogates, Low Surrogates
+        "High Surrogates",
+        "High Private Use Surrogates",
+        "Low Surrogates",
         "Private Use Area",
         "CJK Compatibility Ideographs",
         "Alphabetic Presentation Forms",
         "Arabic Presentation Forms-A",
         "Variation Selectors",
+        "Vertical Forms",
         "Combining Half Marks",
         "CJK Compatibility Forms",
         "Small Form Variants",
@@ -289,17 +370,32 @@
         "Linear B Syllabary",
         "Linear B Ideograms",
         "Aegean Numbers",
+        "Ancient Greek Numbers",
+        "Ancient Symbols",
+        "Phaistos Disc",
+        "Lycian",
+        "Carian",
         "Old Italic",
         "Gothic",
         "Ugaritic",
+        "Old Persian",
         "Deseret",
         "Shavian",
         "Osmanya",
         "Cypriot Syllabary",
+        "Phoenician",
+        "Lydian",
+        "Kharoshthi",
+        "Cuneiform",
+        "Cuneiform Numbers and Punctuation",
         "Byzantine Musical Symbols",
         "Musical Symbols",
+        "Ancient Greek Musical Notation",
         "Tai Xuan Jing Symbols",
+        "Counting Rod Numerals",
         "Mathematical Alphanumeric Symbols",
+        "Mahjong Tiles",
+        "Domino Tiles",
         "CJK Unified Ideographs Extension B",
         "CJK Compatibility Ideographs Supplement",
         "Tags",
--- a/jdk/src/share/native/common/jni_util.c	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/native/common/jni_util.c	Tue Jul 21 13:02:23 2009 -0700
@@ -607,14 +607,6 @@
     return result;
 }
 
-enum {
-    NO_ENCODING_YET = 0,        /* "sun.jnu.encoding" not yet set */
-    NO_FAST_ENCODING,           /* Platform encoding is not fast */
-    FAST_8859_1,                /* ISO-8859-1 */
-    FAST_CP1252,                /* MS-DOS Cp1252 */
-    FAST_646_US                 /* US-ASCII : ISO646-US */
-};
-
 static int fastEncoding = NO_ENCODING_YET;
 static jstring jnuEncoding = NULL;
 
@@ -622,10 +614,14 @@
 static jmethodID String_init_ID;        /* String(byte[], enc) */
 static jmethodID String_getBytes_ID;    /* String.getBytes(enc) */
 
+int getFastEncoding() {
+    return fastEncoding;
+}
+
 /* Initialize the fast encoding.  If the "sun.jnu.encoding" property
  * has not yet been set, we leave fastEncoding == NO_ENCODING_YET.
  */
-static void
+void
 initializeEncoding(JNIEnv *env)
 {
     jstring propname = 0;
@@ -719,44 +715,47 @@
 JNU_NewStringPlatform(JNIEnv *env, const char *str)
 {
     jstring result;
-    jbyteArray hab = 0;
-    int len;
+    result = nativeNewStringPlatform(env, str);
+    if (result == NULL) {
+        jbyteArray hab = 0;
+        int len;
 
-    if (fastEncoding == NO_ENCODING_YET)
-        initializeEncoding(env);
+        if (fastEncoding == NO_ENCODING_YET)
+            initializeEncoding(env);
 
-    if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET))
-        return newString8859_1(env, str);
-    if (fastEncoding == FAST_646_US)
-        return newString646_US(env, str);
-    if (fastEncoding == FAST_CP1252)
-        return newStringCp1252(env, str);
+        if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET))
+            return newString8859_1(env, str);
+        if (fastEncoding == FAST_646_US)
+            return newString646_US(env, str);
+        if (fastEncoding == FAST_CP1252)
+            return newStringCp1252(env, str);
 
-    if ((*env)->EnsureLocalCapacity(env, 2) < 0)
-        return 0;
+        if ((*env)->EnsureLocalCapacity(env, 2) < 0)
+            return NULL;
 
-    len = (int)strlen(str);
-    hab = (*env)->NewByteArray(env, len);
-    if (hab != 0) {
-        (*env)->SetByteArrayRegion(env, hab, 0, len, (jbyte *)str);
-        if (jnuEncodingSupported(env)) {
-            result = (*env)->NewObject(env, JNU_ClassString(env),
-                                       String_init_ID, hab, jnuEncoding);
-        } else {
-            /*If the encoding specified in sun.jnu.encoding is not endorsed
-              by "Charset.isSupported" we have to fall back to use String(byte[])
-              explicitly here without specifying the encoding name, in which the
-              StringCoding class will pickup the iso-8859-1 as the fallback
-              converter for us.
-             */
-            jmethodID mid = (*env)->GetMethodID(env, JNU_ClassString(env),
-                                 "<init>", "([B)V");
-            result = (*env)->NewObject(env, JNU_ClassString(env), mid, hab);
+        len = (int)strlen(str);
+        hab = (*env)->NewByteArray(env, len);
+        if (hab != 0) {
+            (*env)->SetByteArrayRegion(env, hab, 0, len, (jbyte *)str);
+            if (jnuEncodingSupported(env)) {
+                result = (*env)->NewObject(env, JNU_ClassString(env),
+                                           String_init_ID, hab, jnuEncoding);
+            } else {
+                /*If the encoding specified in sun.jnu.encoding is not endorsed
+                  by "Charset.isSupported" we have to fall back to use String(byte[])
+                  explicitly here without specifying the encoding name, in which the
+                  StringCoding class will pickup the iso-8859-1 as the fallback
+                  converter for us.
+                 */
+                jmethodID mid = (*env)->GetMethodID(env, JNU_ClassString(env),
+                                                    "<init>", "([B)V");
+                result = (*env)->NewObject(env, JNU_ClassString(env), mid, hab);
+            }
+            (*env)->DeleteLocalRef(env, hab);
+            return result;
         }
-        (*env)->DeleteLocalRef(env, hab);
-        return result;
     }
-    return 0;
+    return NULL;
 }
 
 JNIEXPORT const char *
@@ -768,46 +767,49 @@
 JNIEXPORT const char * JNICALL
 JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy)
 {
-    jbyteArray hab = 0;
-    char *result = 0;
+    char *result = nativeGetStringPlatformChars(env, jstr, isCopy);
+    if (result == NULL) {
 
-    if (isCopy)
-        *isCopy = JNI_TRUE;
+        jbyteArray hab = 0;
 
-    if (fastEncoding == NO_ENCODING_YET)
-        initializeEncoding(env);
+        if (isCopy)
+            *isCopy = JNI_TRUE;
 
-    if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET))
-        return getString8859_1Chars(env, jstr);
-    if (fastEncoding == FAST_646_US)
-        return getString646_USChars(env, jstr);
-    if (fastEncoding == FAST_CP1252)
-        return getStringCp1252Chars(env, jstr);
+        if (fastEncoding == NO_ENCODING_YET)
+            initializeEncoding(env);
 
-    if ((*env)->EnsureLocalCapacity(env, 2) < 0)
-        return 0;
+        if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET))
+            return getString8859_1Chars(env, jstr);
+        if (fastEncoding == FAST_646_US)
+            return getString646_USChars(env, jstr);
+        if (fastEncoding == FAST_CP1252)
+            return getStringCp1252Chars(env, jstr);
+
+        if ((*env)->EnsureLocalCapacity(env, 2) < 0)
+            return 0;
 
-    if (jnuEncodingSupported(env)) {
-        hab = (*env)->CallObjectMethod(env, jstr, String_getBytes_ID, jnuEncoding);
-    } else {
-        jmethodID mid = (*env)->GetMethodID(env, JNU_ClassString(env),
-                                            "getBytes", "()[B");
-        hab = (*env)->CallObjectMethod(env, jstr, mid);
-    }
+        if (jnuEncodingSupported(env)) {
+            hab = (*env)->CallObjectMethod(env, jstr, String_getBytes_ID, jnuEncoding);
+        } else {
+            jmethodID mid = (*env)->GetMethodID(env, JNU_ClassString(env),
+                                                "getBytes", "()[B");
+            hab = (*env)->CallObjectMethod(env, jstr, mid);
+        }
 
-    if (!(*env)->ExceptionCheck(env)) {
-        jint len = (*env)->GetArrayLength(env, hab);
-        result = MALLOC_MIN4(len);
-        if (result == 0) {
-            JNU_ThrowOutOfMemoryError(env, 0);
-            (*env)->DeleteLocalRef(env, hab);
-            return 0;
+        if (!(*env)->ExceptionCheck(env)) {
+            jint len = (*env)->GetArrayLength(env, hab);
+            result = MALLOC_MIN4(len);
+            if (result == 0) {
+                JNU_ThrowOutOfMemoryError(env, 0);
+                (*env)->DeleteLocalRef(env, hab);
+                return 0;
+            }
+            (*env)->GetByteArrayRegion(env, hab, 0, len, (jbyte *)result);
+            result[len] = 0; /* NULL-terminate */
         }
-        (*env)->GetByteArrayRegion(env, hab, 0, len, (jbyte *)result);
-        result[len] = 0; /* NULL-terminate */
+
+        (*env)->DeleteLocalRef(env, hab);
     }
-
-    (*env)->DeleteLocalRef(env, hab);
     return result;
 }
 
--- a/jdk/src/share/native/common/jni_util.h	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/native/common/jni_util.h	Tue Jul 21 13:02:23 2009 -0700
@@ -320,6 +320,26 @@
 #define JNU_SetLongFieldFromPtr(env,obj,id,val) \
     (*(env))->SetLongField((env),(obj),(id),ptr_to_jlong(val))
 
+/*
+ * Internal use only.
+ */
+enum {
+    NO_ENCODING_YET = 0,        /* "sun.jnu.encoding" not yet set */
+    NO_FAST_ENCODING,           /* Platform encoding is not fast */
+    FAST_8859_1,                /* ISO-8859-1 */
+    FAST_CP1252,                /* MS-DOS Cp1252 */
+    FAST_646_US                 /* US-ASCII : ISO646-US */
+};
+
+jstring nativeNewStringPlatform(JNIEnv *env, const char *str);
+
+char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy);
+
+int getFastEncoding();
+
+void initializeEncoding();
+
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif /* __cplusplus */
--- a/jdk/src/share/native/sun/misc/VM.c	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/share/native/sun/misc/VM.c	Tue Jul 21 13:02:23 2009 -0700
@@ -109,11 +109,39 @@
     get_thread_state_info(env, JAVA_THREAD_STATE_TERMINATED, values, names);
 }
 
+typedef void (JNICALL *GetJvmVersionInfo_fp)(JNIEnv*, jvm_version_info*, size_t);
+
 JNIEXPORT void JNICALL
 Java_sun_misc_VM_initialize(JNIEnv *env, jclass cls) {
     char errmsg[128];
+    GetJvmVersionInfo_fp func_p;
 
     if (!JDK_InitJvmHandle()) {
         JNU_ThrowInternalError(env, "Handle for JVM not found for symbol lookup");
+        return;
+    }
+
+    func_p = (GetJvmVersionInfo_fp) JDK_FindJvmEntry("JVM_GetVersionInfo");
+     if (func_p != NULL) {
+        char errmsg[100];
+        jfieldID fid;
+        jvm_version_info info;
+
+        memset(&info, 0, sizeof(info));
+
+        /* obtain the JVM version info */
+        (*func_p)(env, &info, sizeof(info));
+
+        if (info.is_kernel_jvm == 1) {
+            /* set the static field VM.kernelVM to true for kernel VM */
+            fid = (*env)->GetStaticFieldID(env, cls, "kernelVM", "Z");
+            if (fid != 0) {
+                (*env)->SetStaticBooleanField(env, cls, fid, info.is_kernel_jvm);
+            } else {
+                sprintf(errmsg, "Static kernelVM boolean field not found");
+                JNU_ThrowInternalError(env, errmsg);
+            }
+        }
     }
 }
+
--- a/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XKeysym.java	Tue Jul 21 13:02:23 2009 -0700
@@ -145,7 +145,7 @@
     {
         // Xsun without XKB uses keysymarray[2] keysym to determine if it is KP event.
         // Otherwise, it is [1].
-        int ndx = XToolkit.isXsunServer() &&
+        int ndx = XToolkit.isXsunKPBehavior() &&
                   ! XToolkit.isXKBenabled() ? 2 : 1;
         // Even if XKB is enabled, we have another problem: some symbol tables (e.g. cz) force
         // a regular comma instead of KP_comma for a decimal separator. Result is,
@@ -193,7 +193,7 @@
     private static long getKeypadKeysym( XKeyEvent ev ) {
         int ndx = 0;
         long keysym = XConstants.NoSymbol;
-        if( XToolkit.isXsunServer() &&
+        if( XToolkit.isXsunKPBehavior() &&
             ! XToolkit.isXKBenabled() ) {
             if( (ev.get_state() & XConstants.ShiftMask) != 0 ) { // shift modifier is on
                 ndx = 3;
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1177,6 +1177,7 @@
         awtLock();
         try {
             XlibWrapper.XBell(getDisplay(), 0);
+            XlibWrapper.XFlush(getDisplay());
         } finally {
             awtUnlock();
         }
@@ -1435,9 +1436,14 @@
         return timeStamp;
     }
     protected void initializeDesktopProperties() {
-        desktopProperties.put("DnD.Autoscroll.initialDelay",     Integer.valueOf(50));
-        desktopProperties.put("DnD.Autoscroll.interval",         Integer.valueOf(50));
-        desktopProperties.put("DnD.Autoscroll.cursorHysteresis", Integer.valueOf(5));
+        desktopProperties.put("DnD.Autoscroll.initialDelay",
+                              Integer.valueOf(50));
+        desktopProperties.put("DnD.Autoscroll.interval",
+                              Integer.valueOf(50));
+        desktopProperties.put("DnD.Autoscroll.cursorHysteresis",
+                              Integer.valueOf(5));
+        desktopProperties.put("Shell.shellFolderManager",
+                              "sun.awt.shell.ShellFolderManager");
         // Don't want to call getMultiClickTime() if we are headless
         if (!GraphicsEnvironment.isHeadless()) {
             desktopProperties.put("awt.multiClickInterval",
@@ -2124,39 +2130,33 @@
      */
     private static int backingStoreType;
 
-    static boolean awt_ServerInquired = false;
-    static boolean awt_IsXsunServer    = false;
+    static final int XSUN_KP_BEHAVIOR = 1;
+    static final int XORG_KP_BEHAVIOR = 2;
+
+    static int     awt_IsXsunKPBehavior = 0;
     static boolean awt_UseXKB         = false;
     static boolean awt_UseXKB_Calls   = false;
     static int     awt_XKBBaseEventCode = 0;
     static int     awt_XKBEffectiveGroup = 0; // so far, I don't use it leaving all calculations
                                               // to XkbTranslateKeyCode
     static long    awt_XKBDescPtr     = 0;
+
     /**
-       Try to understand if it is Xsun server.
-       By now (2005) Sun is vendor of Xsun and Xorg servers; we only return true if Xsun is running.
-    */
-    static boolean isXsunServer() {
+     * Check for Xsun convention regarding numpad keys.
+     * Xsun and some other servers (i.e. derived from Xsun)
+     * under certain conditions process numpad keys unlike Xorg.
+     */
+    static boolean isXsunKPBehavior() {
         awtLock();
         try {
-            if( awt_ServerInquired ) {
-                return awt_IsXsunServer;
-            }
-            if( ! XlibWrapper.ServerVendor(getDisplay()).startsWith("Sun Microsystems") ) {
-                awt_ServerInquired = true;
-                awt_IsXsunServer = false;
-                return false;
+            if( awt_IsXsunKPBehavior == 0 ) {
+                if( XlibWrapper.IsXsunKPBehavior(getDisplay()) ) {
+                    awt_IsXsunKPBehavior = XSUN_KP_BEHAVIOR;
+                }else{
+                    awt_IsXsunKPBehavior = XORG_KP_BEHAVIOR;
+                }
             }
-            // Now, it's Sun. It still may be Xorg though, eg on Solaris 10, x86.
-            // Today (2005), VendorRelease of Xorg is a Big Number unlike Xsun.
-            if( XlibWrapper.VendorRelease(getDisplay()) > 10000 ) {
-                awt_ServerInquired = true;
-                awt_IsXsunServer = false;
-                return false;
-            }
-            awt_ServerInquired = true;
-            awt_IsXsunServer = true;
-            return true;
+            return awt_IsXsunKPBehavior == XSUN_KP_BEHAVIOR ? true : false;
         } finally {
             awtUnlock();
         }
--- a/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XlibWrapper.java	Tue Jul 21 13:02:23 2009 -0700
@@ -352,6 +352,7 @@
     static native int XIconifyWindow(long display, long window, long screenNumber);
     static native String ServerVendor(long display);
     static native int VendorRelease(long display);
+    static native boolean IsXsunKPBehavior(long display);
 
     static native void XBell(long display, int percent);
 
--- a/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/keysym2ucs.h	Tue Jul 21 13:02:23 2009 -0700
@@ -183,7 +183,7 @@
 tojava     {
 tojava         // Xsun without XKB uses keysymarray[2] keysym to determine if it is KP event.
 tojava         // Otherwise, it is [1].
-tojava         int ndx = XToolkit.isXsunServer() &&
+tojava         int ndx = XToolkit.isXsunKPBehavior() &&
 tojava                   ! XToolkit.isXKBenabled() ? 2 : 1;
 tojava         // Even if XKB is enabled, we have another problem: some symbol tables (e.g. cz) force
 tojava         // a regular comma instead of KP_comma for a decimal separator. Result is,
@@ -231,7 +231,7 @@
 tojava     private static long getKeypadKeysym( XKeyEvent ev ) {
 tojava         int ndx = 0;
 tojava         long keysym = XConstants.NoSymbol;
-tojava         if( XToolkit.isXsunServer() &&
+tojava         if( XToolkit.isXsunKPBehavior() &&
 tojava             ! XToolkit.isXKBenabled() ) {
 tojava             if( (ev.get_state() & XConstants.ShiftMask) != 0 ) { // shift modifier is on
 tojava                 ndx = 3;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/common/jni_util_md.c	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+#include "jni.h"
+#include "jni_util.h"
+
+jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
+    return NULL;
+}
+
+char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) {
+    return NULL;
+}
--- a/jdk/src/solaris/native/sun/xawt/XlibWrapper.c	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/solaris/native/sun/xawt/XlibWrapper.c	Tue Jul 21 13:02:23 2009 -0700
@@ -1181,6 +1181,38 @@
     AWT_CHECK_HAVE_LOCK();
     return VendorRelease((Display*)jlong_to_ptr(display));
 }
+/*
+ * Class:     sun_awt_X11_XlibWrapper
+ * Method:    IsXsunKPBehavior
+ * Signature: (J)Z;
+ */
+JNIEXPORT jboolean JNICALL Java_sun_awt_X11_XlibWrapper_IsXsunKPBehavior
+(JNIEnv *env, jclass clazz, jlong display)
+{
+    // Xsun without XKB uses keysymarray[2] keysym to determine if it is KP event.
+    // Otherwise, it is [1] or sometimes [0].
+    // This sniffer first tries to determine what is a keycode for XK_KP_7
+    // using XKeysymToKeycode;
+    // second, in which place in the keysymarray is XK_KP_7
+    // using XKeycodeToKeysym.
+    int kc7;
+    AWT_CHECK_HAVE_LOCK();
+    kc7 = XKeysymToKeycode((Display*)jlong_to_ptr(display), XK_KP_7);
+    if( !kc7 ) {
+        // keycode is not defined. Why, it's a reduced keyboard perhaps:
+        // report arbitrarily false.
+        return JNI_FALSE;
+    } else {
+        long ks2 = XKeycodeToKeysym((Display*)jlong_to_ptr(display), kc7, 2);
+        if( ks2 == XK_KP_7 ) {
+            //XXX If some Xorg server would put XK_KP_7 in keysymarray[2] as well,
+            //XXX for yet unknown to me reason, the sniffer would lie.
+            return JNI_TRUE;
+        }else{
+            return JNI_FALSE;
+        }
+    }
+}
 
 JavaVM* jvm = NULL;
 static int ToolkitErrorHandler(Display * dpy, XErrorEvent * event) {
--- a/jdk/src/windows/bin/java_md.c	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/bin/java_md.c	Tue Jul 21 13:02:23 2009 -0700
@@ -49,6 +49,7 @@
 static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
                            char *jvmpath, jint jvmpathsize);
 static jboolean GetJREPath(char *path, jint pathsize);
+static void EnsureJreInstallation(const char *jrepath);
 
 static jboolean _isjavaw = JNI_FALSE;
 
@@ -108,6 +109,9 @@
         exit(1);
     }
 
+    /* Do this before we read jvm.cfg */
+    EnsureJreInstallation(jrepath);
+
     /* Find out where the JRE is that we will be using. */
     if (!GetJREPath(jrepath, so_jrepath)) {
         JLI_ReportErrorMessage(JRE_ERROR1);
@@ -130,6 +134,103 @@
 
 }
 
+
+static jboolean
+LoadMSVCRT()
+{
+    // Only do this once
+    static int loaded = 0;
+    char crtpath[MAXPATHLEN];
+
+    if (!loaded) {
+        /*
+         * The Microsoft C Runtime Library needs to be loaded first.  A copy is
+         * assumed to be present in the "JRE path" directory.  If it is not found
+         * there (or "JRE path" fails to resolve), skip the explicit load and let
+         * nature take its course, which is likely to be a failure to execute.
+         */
+#ifdef _MSC_VER
+#if _MSC_VER < 1400
+#define CRT_DLL "msvcr71.dll"
+#endif
+#ifdef CRT_DLL
+        if (GetJREPath(crtpath, MAXPATHLEN)) {
+            (void)JLI_StrCat(crtpath, "\\bin\\" CRT_DLL);   /* Add crt dll */
+            JLI_TraceLauncher("CRT path is %s\n", crtpath);
+            if (_access(crtpath, 0) == 0) {
+                if (LoadLibrary(crtpath) == 0) {
+                    JLI_ReportErrorMessage(DLL_ERROR4, crtpath);
+                    return JNI_FALSE;
+                }
+            }
+        }
+#endif /* CRT_DLL */
+#endif /* _MSC_VER */
+        loaded = 1;
+    }
+    return JNI_TRUE;
+}
+
+/*
+ * The preJVMStart is a function in the jkernel.dll, which
+ * performs the final step of synthesizing back the decomposed
+ * modules  (partial install) to the full JRE. Any tool which
+ * uses the  JRE must peform this step to ensure the complete synthesis.
+ * The EnsureJreInstallation function calls preJVMStart based on
+ * the conditions outlined below, noting that the operation
+ * will fail silently if any of conditions are not met.
+ * NOTE: this call must be made before jvm.dll is loaded, or jvm.cfg
+ * is read, since jvm.cfg will be modified by the preJVMStart.
+ * 1. Are we on a supported platform.
+ * 2. Find the location of the JRE or the Kernel JRE.
+ * 3. check existence of JREHOME/lib/bundles
+ * 4. check jkernel.dll and invoke the entry-point
+ */
+typedef VOID (WINAPI *PREJVMSTART)();
+
+static void
+EnsureJreInstallation(const char* jrepath)
+{
+    HINSTANCE handle;
+    char tmpbuf[MAXPATHLEN];
+    PREJVMSTART PreJVMStart;
+    struct stat s;
+
+    /* 32 bit windows only please */
+    if (strcmp(GetArch(), "i386") != 0 ) {
+        return;
+    }
+    /* Does our bundle directory exist ? */
+    strcpy(tmpbuf, jrepath);
+    strcat(tmpbuf, "\\lib\\bundles");
+    if (stat(tmpbuf, &s) != 0) {
+        return;
+    }
+    /* Does our jkernel dll exist ? */
+    strcpy(tmpbuf, jrepath);
+    strcat(tmpbuf, "\\bin\\jkernel.dll");
+    if (stat(tmpbuf, &s) != 0) {
+        return;
+    }
+    /* The Microsoft C Runtime Library needs to be loaded first. */
+    if (!LoadMSVCRT()) {
+        return;
+    }
+    /* Load the jkernel.dll */
+    if ((handle = LoadLibrary(tmpbuf)) == 0) {
+        return;
+    }
+    /* Get the function address */
+    PreJVMStart = (PREJVMSTART)GetProcAddress(handle, "preJVMStart");
+    if (PreJVMStart == NULL) {
+        FreeLibrary(handle);
+        return;
+    }
+    PreJVMStart();
+    FreeLibrary(handle);
+    return;
+}
+
 /*
  * Find path to JRE based on .exe's location or registry settings.
  */
@@ -196,7 +297,6 @@
 LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn)
 {
     HINSTANCE handle;
-    char crtpath[MAXPATHLEN];
 
     JLI_TraceLauncher("JVM path is %s\n", jvmpath);
 
@@ -206,26 +306,8 @@
      * there (or "JRE path" fails to resolve), skip the explicit load and let
      * nature take its course, which is likely to be a failure to execute.
      *
-     * (NOTE: the above statement is only true for Visual Studio 2003 and
-     *  msvcr71.dll.)
      */
-#ifdef _MSC_VER
-#if _MSC_VER < 1400
-#define CRT_DLL "msvcr71.dll"
-#endif
-#ifdef CRT_DLL
-    if (GetJREPath(crtpath, MAXPATHLEN)) {
-        (void)JLI_StrCat(crtpath, "\\bin\\" CRT_DLL);   /* Add crt dll */
-        JLI_TraceLauncher("CRT path is %s\n", crtpath);
-        if (_access(crtpath, 0) == 0) {
-            if (LoadLibrary(crtpath) == 0) {
-                JLI_ReportErrorMessage(DLL_ERROR4, crtpath);
-                return JNI_FALSE;
-            }
-        }
-    }
-#endif /* CRT_DLL */
-#endif /* _MSC_VER */
+    LoadMSVCRT();
 
     /* Load the Java VM DLL */
     if ((handle = LoadLibrary(jvmpath)) == 0) {
--- a/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WComponentPeer.java	Tue Jul 21 13:02:23 2009 -0700
@@ -417,6 +417,15 @@
         replaceSurfaceData(this.numBackBuffers, this.backBufferCaps);
     }
 
+    public void createScreenSurface(boolean isResize)
+    {
+        Win32GraphicsConfig gc = (Win32GraphicsConfig)getGraphicsConfiguration();
+        ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
+
+        surfaceData = mgr.createScreenSurface(gc, this, numBackBuffers, isResize);
+    }
+
+
     /**
      * Multi-buffer version of replaceSurfaceData.  This version is called
      * by createBuffers(), which needs to acquire the same locks in the same
@@ -434,13 +443,10 @@
                     return;
                 }
                 numBackBuffers = newNumBackBuffers;
-                Win32GraphicsConfig gc =
-                        (Win32GraphicsConfig)getGraphicsConfiguration();
                 ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
                 oldData = surfaceData;
                 mgr.dropScreenSurface(oldData);
-                surfaceData =
-                    mgr.createScreenSurface(gc, this, numBackBuffers, true);
+                createScreenSurface(true);
                 if (oldData != null) {
                     oldData.invalidate();
                 }
@@ -449,6 +455,8 @@
                 if (numBackBuffers > 0) {
                     // set the caps first, they're used when creating the bb
                     backBufferCaps = caps;
+                    Win32GraphicsConfig gc =
+                        (Win32GraphicsConfig)getGraphicsConfiguration();
                     backBuffer = gc.createBackBuffer(this);
                 } else if (backBuffer != null) {
                     backBufferCaps = null;
@@ -711,11 +719,8 @@
         create(parentPeer);
         // fix for 5088782: check if window object is created successfully
         checkCreation();
-        this.winGraphicsConfig =
-            (Win32GraphicsConfig)getGraphicsConfiguration();
-        ScreenUpdateManager mgr = ScreenUpdateManager.getInstance();
-        this.surfaceData = mgr.createScreenSurface(winGraphicsConfig, this,
-                                                   numBackBuffers, false);
+
+        createScreenSurface(false);
         initialize();
         start();  // Initialize enable/disable state, turn on callbacks
     }
--- a/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WEmbeddedFrame.java	Tue Jul 21 13:02:23 2009 -0700
@@ -211,9 +211,10 @@
      */
     public void notifyModalBlocked(Dialog blocker, boolean blocked) {
         try {
-            notifyModalBlockedImpl((WEmbeddedFramePeer)ComponentAccessor.getPeer(this),
-                                   (WWindowPeer)ComponentAccessor.getPeer(blocker),
-                                   blocked);
+            ComponentPeer thisPeer = (ComponentPeer)WToolkit.targetToPeer(this);
+            ComponentPeer blockerPeer = (ComponentPeer)WToolkit.targetToPeer(blocker);
+            notifyModalBlockedImpl((WEmbeddedFramePeer)thisPeer,
+                                   (WWindowPeer)blockerPeer, blocked);
         } catch (Exception z) {
             z.printStackTrace(System.err);
         }
--- a/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WFileDialogPeer.java	Tue Jul 21 13:02:23 2009 -0700
@@ -237,4 +237,11 @@
     public void setOpacity(float opacity) {}
     public void setOpaque(boolean isOpaque) {}
     public void updateWindow(java.awt.image.BufferedImage backBuffer) {}
+
+    // the file/print dialogs are native dialogs and
+    // the native system does their own rendering
+    @Override
+    public void createScreenSurface(boolean isResize) {}
+    @Override
+    public void replaceSurfaceData() {}
 }
--- a/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WPopupMenuPeer.java	Tue Jul 21 13:02:23 2009 -0700
@@ -29,33 +29,25 @@
 import java.lang.reflect.Field;
 
 import sun.awt.SunToolkit;
+import sun.awt.AWTAccessor;
 
 public class WPopupMenuPeer extends WMenuPeer implements PopupMenuPeer {
     // We can't use target.getParent() for TrayIcon popup
     // because this method should return null for the TrayIcon
     // popup regardless of that whether it has parent or not.
-    private static Field f_parent;
-    private static Field f_isTrayIconPopup;
-
-    static {
-        f_parent = SunToolkit.getField(MenuComponent.class, "parent");
-        f_isTrayIconPopup = SunToolkit.getField(PopupMenu.class, "isTrayIconPopup");
-    }
 
     public WPopupMenuPeer(PopupMenu target) {
         this.target = target;
         MenuContainer parent = null;
-        boolean isTrayIconPopup = false;
-        try {
-            isTrayIconPopup = ((Boolean)f_isTrayIconPopup.get(target)).booleanValue();
-            if (isTrayIconPopup) {
-                parent = (MenuContainer)f_parent.get(target);
-            } else {
-                parent = target.getParent();
-            }
-        } catch (IllegalAccessException iae) {
-            iae.printStackTrace();
-            return;
+
+        // We can't use target.getParent() for TrayIcon popup
+        // because this method should return null for the TrayIcon
+        // popup regardless of that whether it has parent or not.
+        boolean isTrayIconPopup = AWTAccessor.getPopupMenuAccessor().isTrayIconPopup(target);
+        if (isTrayIconPopup) {
+            parent = AWTAccessor.getMenuComponentAccessor().getParent(target);
+        } else {
+            parent = target.getParent();
         }
 
         if (parent instanceof Component) {
--- a/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/classes/sun/awt/windows/WPrintDialogPeer.java	Tue Jul 21 13:02:23 2009 -0700
@@ -150,4 +150,11 @@
     public void setOpacity(float opacity) {}
     public void setOpaque(boolean isOpaque) {}
     public void updateWindow(java.awt.image.BufferedImage backBuffer) {}
+
+    // the file/print dialogs are native dialogs and
+    // the native system does their own rendering
+    @Override
+    public void createScreenSurface(boolean isResize) {}
+    @Override
+    public void replaceSurfaceData() {}
 }
--- a/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java	Tue Jul 21 13:02:23 2009 -0700
@@ -38,8 +38,6 @@
 import sun.awt.Win32GraphicsConfig;
 import sun.awt.Win32GraphicsDevice;
 import sun.awt.windows.WComponentPeer;
-import sun.awt.windows.WFileDialogPeer;
-import sun.awt.windows.WPrintDialogPeer;
 import sun.java2d.ScreenUpdateManager;
 import sun.java2d.SunGraphics2D;
 import sun.java2d.SurfaceData;
@@ -264,17 +262,7 @@
         this.graphicsConfig =
             (Win32GraphicsConfig) peer.getGraphicsConfiguration();
         this.solidloops = graphicsConfig.getSolidLoops(sType);
-        if (peer instanceof WFileDialogPeer ||
-            peer instanceof WPrintDialogPeer )
-        {
-            // REMIND: Awful hack.  The right fix for this problem
-            // would be for these type of Peers to not even use a
-            // GDIWindowSurfaceData object since they never do any
-            // rendering.  Or they could actually implement the
-            // functionality needed in initOps.  But this seems
-            // to work for now.  See bug 4391928 for more info.
-            return;
-        }
+
         Win32GraphicsDevice gd =
             (Win32GraphicsDevice)graphicsConfig.getDevice();
         initOps(peer, depth, rMask, gMask, bMask, gd.getScreen());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/common/jni_util_md.c	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2004 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <windows.h>
+#include <locale.h>
+
+#include "jni.h"
+#include "jni_util.h"
+
+static void getParent(const TCHAR *path, TCHAR *dest) {
+    char* lastSlash = max(strrchr(path, '\\'), strrchr(path, '/'));
+    if (lastSlash == NULL) {
+        *dest = 0;
+        return;
+    }
+    if (path != dest)
+        strcpy(dest, path);
+    *lastSlash = 0;
+}
+
+BOOL useNativeConverter(JNIEnv *env) {
+    static BOOL initialized;
+    static BOOL useNative;
+    if (!initialized) {
+        HMODULE jvm = GetModuleHandle("jvm");
+        useNative = FALSE;
+        if (jvm != NULL) {
+            TCHAR *jvmPath = NULL;
+            int bufferSize = MAX_PATH;
+            while (jvmPath == NULL) {
+                DWORD result;
+                jvmPath = malloc(bufferSize);
+                if (jvmPath == NULL)
+                    return FALSE;
+                result = GetModuleFileName(jvm, jvmPath, bufferSize);
+                if (result == 0)
+                    return FALSE;
+                if (result == bufferSize) { // didn't fit
+                    bufferSize += MAX_PATH; // increase buffer size, try again
+                    free(jvmPath);
+                    jvmPath = NULL;
+                }
+            }
+
+            getParent(jvmPath, jvmPath);
+            useNative = (!strcmp("kernel", jvmPath + strlen(jvmPath) -
+                    strlen("kernel"))); // true if jvm.dll lives in "kernel"
+            if (useNative)
+                setlocale(LC_ALL, "");
+            free(jvmPath);
+        }
+        initialized = TRUE;
+    }
+    return useNative;
+}
+
+jstring nativeNewStringPlatform(JNIEnv *env, const char *str) {
+    static String_char_constructor = NULL;
+    if (useNativeConverter(env)) {
+        // use native Unicode conversion so Kernel isn't required during
+        // System.initProperties
+        jcharArray chars = 0;
+        wchar_t *utf16;
+        int len;
+        jstring result = NULL;
+
+        if (getFastEncoding() == NO_ENCODING_YET)
+            initializeEncoding(env);
+
+        len = mbstowcs(NULL, str, strlen(str));
+        if (len == -1)
+            return NULL;
+        utf16 = calloc(len + 1, 2);
+        if (mbstowcs(utf16, str, len) == -1)
+            return NULL;
+        chars = (*env)->NewCharArray(env, len);
+        if (chars == NULL)
+            return NULL;
+        (*env)->SetCharArrayRegion(env, chars, 0, len, utf16);
+        if (String_char_constructor == NULL)
+            String_char_constructor = (*env)->GetMethodID(env,
+                    JNU_ClassString(env), "<init>", "([C)V");
+        result = (*env)->NewObject(env, JNU_ClassString(env),
+                String_char_constructor, chars);
+        free(utf16);
+        return result;
+    }
+    else
+        return NULL;
+}
+
+
+char* nativeGetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) {
+    if (useNativeConverter(env)) {
+        // use native Unicode conversion so Kernel isn't required during
+        // System.initProperties
+        char *result = NULL;
+        size_t len;
+        const jchar* utf16 = (*env)->GetStringChars(env, jstr, NULL);
+        len = wcstombs(NULL, utf16, (*env)->GetStringLength(env, jstr) * 4) + 1;
+        if (len == -1)
+            return NULL;
+        result = (char*) malloc(len);
+        if (result != NULL) {
+            if (wcstombs(result, utf16, len) == -1)
+                return NULL;
+            (*env)->ReleaseStringChars(env, jstr, utf16);
+            if (isCopy)
+                *isCopy = JNI_TRUE;
+        }
+        return result;
+    }
+    else
+        return NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/DownloadDialog.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,891 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#define _ATL_APARTMENT_THREADED
+
+#include <atlbase.h>
+//You may derive a class from CComModule and use it if you want to override
+//something, but do not change the name of _Module
+extern CComModule _Module;
+#include <atlcom.h>
+#include <atlwin.h>
+
+#include <atlhost.h>
+#include <commdlg.h>
+#include <commctrl.h>
+#include <windowsx.h>
+#include <urlmon.h>
+#include <wininet.h>
+#include <shellapi.h>
+#include <time.h>
+#include <math.h>
+#include <stdio.h>
+#include <jni.h>
+
+#include "DownloadDialog.h"
+
+#define UPDATE_INTERVAL 500
+#define INITIAL_DELAY 2000
+#define POST_DELAY 1000
+
+/////////////////////////////////////////////////////////////////////////////
+// CDownloadDialog
+
+typedef BOOL (WINAPI * InitCommonControlsType)();
+
+CDownloadDialog::CDownloadDialog()
+{
+    m_numDownloadThreadsRunning = 0;
+
+    m_destroyWindowTimerStarted = FALSE;
+    m_pszFileName = NULL;
+    m_jvm = NULL;
+
+    m_ulProgress = 0;
+    m_ulProgressMax = 0;
+    m_iProgressFactor = 0;
+    m_iMaxProgressFactor = 1;
+
+
+    m_hCancelEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
+    m_hDownloadThreadExitEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
+    m_hDialogInitializedEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
+
+    // Load up commctrl.dll
+    // Loading dll dynamically we can use latest available version
+    // (i.e. latest native components and extended API)
+    HMODULE hModComCtl32 = ::LoadLibrary(TEXT("comctl32.dll"));
+    if (hModComCtl32 != NULL) {
+        /* Initialize controls to ensure proper appearance */
+        InitCommonControlsType fn_InitCommonControls = (InitCommonControlsType)
+            ::GetProcAddress(hModComCtl32, "InitCommonControls");
+        fn_InitCommonControls();
+
+        /* MessageBox replacement introduced in Vista */
+        taskDialogFn = (TaskDialogIndirectFn)
+            ::GetProcAddress(hModComCtl32, "TaskDialogIndirect");
+    }
+}
+
+
+CDownloadDialog::~CDownloadDialog()
+{
+    ::CloseHandle(m_hCancelEvent);
+    ::CloseHandle(m_hDownloadThreadExitEvent);
+    ::CloseHandle(m_hDialogInitializedEvent);
+}
+
+void CDownloadDialog::addToTotalContentLength(DWORD contentLength) {
+     __try
+    {
+        m_csDownload.Lock();
+        if (m_ulProgressMax == 0) {
+            // first download this session, initialize start time
+            time(&m_startTime);
+        }
+
+        m_ulProgressMax = m_ulProgressMax + contentLength;
+        logProgress();
+    }
+    __finally
+    {
+        m_csDownload.Unlock();
+    }
+}
+
+
+
+void CDownloadDialog::initDialogText(LPCTSTR downloadURL, LPCTSTR bundleName) {
+
+    // reset status text
+    HWND hStatusWnd = GetDlgItem(IDC_TIME_REMAINING);
+    ::SetWindowText(hStatusWnd, "");
+
+    // reset progress bar
+    HWND hProgressWnd = GetDlgItem(IDC_DOWNLOAD_PROGRESS);
+
+    ::PostMessage(hProgressWnd, PBM_SETPOS, (WPARAM) 0, NULL);
+
+    m_hMastheadFont = NULL;
+    m_hDialogFont = NULL;
+    m_hSixPointFont = NULL;
+
+    m_hMemDC = NULL;
+
+    TCHAR szDownloadText[BUFFER_SIZE];
+
+    HWND hWndDownloadText = GetDlgItem(IDC_DOWNLOAD_TEXT);
+    ::LoadString(_Module.GetModuleInstance(), IDS_DOWNLOAD_TEXT, szDownloadText, BUFFER_SIZE);
+    ::SetWindowText(hWndDownloadText, szDownloadText);
+
+    TCHAR szMasthead[BUFFER_SIZE];
+
+    HWND hWndMastheadText = GetDlgItem(IDC_MASTHEAD_TEXT);
+    ::LoadString(_Module.GetModuleInstance(), IDS_DOWNLOAD, szMasthead, BUFFER_SIZE);
+    ::SetWindowText(hWndMastheadText, szMasthead);
+
+
+}
+
+BOOL CDownloadDialog::isDownloading() {
+    return m_numDownloadThreadsRunning > 0;
+}
+
+
+void CDownloadDialog::bundleInstallStart() {
+    __try
+    {
+        m_csNumDownloadThreads.Lock();
+        m_numDownloadThreadsRunning++;
+        // another download request has came in, kill the destroyWindowTimer
+        KillTimer(destroyWindowTimerID);
+        m_destroyWindowTimerStarted = FALSE;
+    }
+    __finally
+    {
+        m_csNumDownloadThreads.Unlock();
+    }
+}
+
+void CDownloadDialog::bundleInstallComplete() {
+    __try
+    {
+        m_csNumDownloadThreads.Lock();
+        m_numDownloadThreadsRunning = max(m_numDownloadThreadsRunning - 1, 0);
+        if (m_numDownloadThreadsRunning == 0) {
+            m_ulProgress = m_ulProgressMax;
+            logProgress();
+        }
+        // Signal main thread
+        ::SetEvent(m_hDownloadThreadExitEvent);
+    }
+    __finally
+    {
+        m_csNumDownloadThreads.Unlock();
+    }
+}
+
+
+//=--------------------------------------------------------------------------=
+// CDownloadDialog::OnInitDialog
+//=--------------------------------------------------------------------------=
+// Message handler for WM_INITDIALOG
+//
+// Parameters:
+//      uMsg        Windows Message
+//      wParam      WPARAM
+//      lParam      LPARAM
+//      bHandled    FALSE if not handled
+//
+// Output:
+//      LRESULT
+//
+// Notes:
+//
+LRESULT CDownloadDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+     __try
+    {
+        m_csDownload.Lock();
+    }
+    __finally
+    {
+        m_csDownload.Unlock();
+    }
+    // Set timer
+    SetTimer(iTimerID, UPDATE_INTERVAL);
+
+    m_hMastheadFont = NULL;
+    m_hDialogFont = NULL;
+    m_hSixPointFont = NULL;
+    m_feedbackOnCancel = TRUE;
+
+    m_hMemDC = NULL;
+
+    TCHAR szDownloadText[BUFFER_SIZE];
+
+    HWND hWndDownloadText = GetDlgItem(IDC_DOWNLOAD_TEXT);
+    ::LoadString(_Module.GetModuleInstance(), IDS_DOWNLOAD_TEXT, szDownloadText, BUFFER_SIZE);
+    ::SetWindowText(hWndDownloadText, szDownloadText);
+
+    TCHAR szMasthead[BUFFER_SIZE];
+
+    HWND hWndMastheadText = GetDlgItem(IDC_MASTHEAD_TEXT);
+    ::LoadString(_Module.GetModuleInstance(), IDS_DOWNLOAD, szMasthead, BUFFER_SIZE);
+    ::SetWindowText(hWndMastheadText, szMasthead);
+
+    HICON javaCupIcon = ::LoadIcon(_Module.GetModuleInstance(), MAKEINTRESOURCE(IDI_JAVA));
+    SetIcon(javaCupIcon, FALSE);
+
+    ::SetEvent(m_hDialogInitializedEvent);
+
+    return 0;  // do not set initial focus to cancel button
+}
+
+
+//=--------------------------------------------------------------------------=
+// CDownloadDialog::OnOK
+//=--------------------------------------------------------------------------=
+// Message handler for WM_COMMAND with IDOK
+//
+// Parameters:
+//      wNotifyCode Notify Code
+//      wID         ID of control
+//      hWndCtl     HWND of control
+//      bHandled    FALSE if not handled
+//
+// Output:
+//      LRESULT
+//
+// Notes:
+//
+LRESULT CDownloadDialog::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+    // do nothing for now
+    return 0;
+}
+
+
+
+//=--------------------------------------------------------------------------=
+// CDownloadDialog::OnCancel
+//=--------------------------------------------------------------------------=
+// Message handler for WM_COMMAND with IDCANCEL
+//
+// Parameters:
+//      wNotifyCode Notify Code
+//      wID         ID of control
+//      hWndCtl     HWND of control
+//      bHandled    FALSE if not handled
+//
+// Output:
+//      LRESULT
+//
+// Notes:
+//
+LRESULT CDownloadDialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+{
+    // Disable window first to avoid any keyboard input
+    EnableWindow(FALSE);
+
+    if (m_feedbackOnCancel) {
+      int r = SafeMessageBox(IDS_DOWNLOAD_CANCEL_MESSAGE,
+                       IDS_DOWNLOAD_CANCEL_INSTRUCTION,
+                       IDS_DOWNLOAD_CANCEL_CAPTION,
+                       DIALOG_WARNING_CANCELOK,
+                       NULL, NULL);
+      if (!::IsWindow(hWndCtl)) {
+         /* It is possible that download was finished and download
+            window hidden by the time user close this message box.
+            If such case we should simply return. */
+         return 0;
+      }
+      if (r == IDCANCEL) {
+        EnableWindow(TRUE);
+        return 0;
+      }
+    }
+
+    __try
+    {
+        m_csDownload.Lock();
+        // if we are downloading, signal download thread to stop downloading
+        if (m_numDownloadThreadsRunning > 0) {
+            SetEvent(m_hCancelEvent);
+        }
+    }
+    __finally
+    {
+        m_csDownload.Unlock();
+    }
+
+    // Kill timer
+    KillTimer(iTimerID);
+    KillTimer(destroyWindowTimerID);
+
+    FreeGDIResources();
+
+    // Destroy dialog
+    EndDialog(wID);
+
+    return 0;
+}
+
+void CDownloadDialog::destroyDialog() {
+    m_feedbackOnCancel = FALSE;
+    ::PostMessage(m_hWnd, WM_COMMAND, IDCANCEL, NULL);
+}
+
+
+void CDownloadDialog::delayedDoModal() {
+     __try
+    {
+         __try
+        {
+            m_csMessageBox.Lock();
+            m_dialogUp = true;
+            Sleep(INITIAL_DELAY);
+        }
+        __finally
+        {
+            m_csMessageBox.Unlock();
+        }
+
+        if (isDownloading())
+            DoModal();
+    }
+    __finally
+    {
+        m_dialogUp = false;
+    }
+}
+
+
+//=--------------------------------------------------------------------------=
+// CDownloadDialog::SafeMessageBox
+//=--------------------------------------------------------------------------=
+// Helper method that uses best availble API to show native error/information
+// dialog. In particular, it uses TaskDialog if availble (Vista specific)
+// and MessageBox otherwise.
+//
+// It also ensures that the message box is always displayed on top of
+// the progress dialog instead of underneath
+//
+
+//helper structures to define XP vs Vista style differences
+static TASKDIALOG_COMMON_BUTTON_FLAGS vistaDialogButtons[] = {
+    TDCBF_RETRY_BUTTON | TDCBF_CANCEL_BUTTON,
+    TDCBF_OK_BUTTON | TDCBF_CANCEL_BUTTON
+};
+static PCWSTR vistaIcons[] = {
+    TD_ERROR_ICON,
+    TD_WARNING_ICON
+};
+
+static UINT xpStyle[] = {
+    MB_ICONERROR | MB_RETRYCANCEL,
+    MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON2
+};
+
+int CDownloadDialog::SafeMessageBox(UINT details, UINT mainInstruction, UINT caption, DialogType type, LPCWSTR instructionArg, LPCWSTR detailsArg) {
+    WCHAR textCaption[BUFFER_SIZE+1];
+    WCHAR textDetails[BUFFER_SIZE+1];
+    WCHAR textInstruction[BUFFER_SIZE+1];
+    WCHAR tmpBuffer[BUFFER_SIZE+1];
+
+    /* make sure buffers are terminated */
+    textCaption[BUFFER_SIZE] = textDetails[BUFFER_SIZE] = 0;
+    textInstruction[BUFFER_SIZE] = tmpBuffer[BUFFER_SIZE] = 0;
+
+    if (detailsArg != NULL) {
+        ::LoadStringW(_Module.GetResourceInstance(),
+                 details,
+                 tmpBuffer,
+                 BUFFER_SIZE);
+        _snwprintf(textDetails, BUFFER_SIZE, tmpBuffer, detailsArg);
+    } else {
+        ::LoadStringW(_Module.GetResourceInstance(),
+                 details,
+                 textDetails,
+                 BUFFER_SIZE);
+    }
+
+    if (instructionArg != NULL) {
+        ::LoadStringW(_Module.GetResourceInstance(),
+                 mainInstruction,
+                 tmpBuffer,
+                 BUFFER_SIZE);
+        _snwprintf(textInstruction, BUFFER_SIZE, tmpBuffer, instructionArg);
+     } else {
+        ::LoadStringW(_Module.GetResourceInstance(),
+                 mainInstruction,
+                 textInstruction,
+                 BUFFER_SIZE);
+     }
+
+    ::LoadStringW(_Module.GetResourceInstance(),
+                 caption,
+                 textCaption,
+                 BUFFER_SIZE);
+
+    __try
+    {
+        m_csMessageBox.Lock();
+        if (m_dialogUp) {
+            waitUntilInitialized();
+        }
+        /* If TaskDialog availble - use it! */
+        if (taskDialogFn != NULL) {
+              TASKDIALOGCONFIG tc = { 0 };
+              int nButton;
+
+              tc.cbSize = sizeof(tc);
+              tc.hwndParent = ::IsWindow(m_hWnd) ? m_hWnd : NULL;
+              tc.dwCommonButtons = vistaDialogButtons[type];
+              tc.pszWindowTitle = textCaption;
+              tc.pszMainInstruction = textInstruction;
+              tc.pszContent = textDetails;
+              tc.pszMainIcon = vistaIcons[type];
+              /* workaround: we need to make sure Cancel is default
+                             for this type of Dialog */
+              if (type == DIALOG_WARNING_CANCELOK) {
+                  tc.nDefaultButton = IDCANCEL;
+              }
+
+              taskDialogFn(&tc, &nButton, NULL, NULL);
+              return nButton;
+        } else { /* default: use MessageBox */
+            /* Note that MessageBox API expects content as single string
+               and therefore we need to concatenate instruction
+               and details as 2 paragraphs.
+
+               The only exception is empty instruction. */
+            if (wcslen(textInstruction) > 0) {
+                wcsncat(textInstruction, L"\n\n",
+                        BUFFER_SIZE - wcslen(textInstruction));
+            }
+            wcsncat(textInstruction, textDetails,
+                    BUFFER_SIZE - wcslen(textInstruction));
+
+            return ::MessageBoxW(::IsWindow(m_hWnd) ? m_hWnd : NULL,
+                textInstruction, textCaption, xpStyle[type]);
+        }
+    }
+    __finally
+    {
+        m_csMessageBox.Unlock();
+    }
+}
+
+
+//=--------------------------------------------------------------------------=
+// CDownloadDialog::OnTimer
+//=--------------------------------------------------------------------------=
+// Message handler for WM_TIMER
+//
+// Parameters:
+//      uMsg        Windows Message
+//      wParam      WPARAM
+//      lParam      LPARAM
+//      bHandled    FALSE if not handled
+//
+// Output:
+//      LRESULT
+//
+// Notes:
+//
+LRESULT CDownloadDialog::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    if (destroyWindowTimerID == (int)wParam) {
+        KillTimer(destroyWindowTimerID);
+        m_destroyWindowTimerStarted = FALSE;
+        m_ulProgressMax = max(0, m_ulProgressMax - m_ulProgress);
+        logProgress();
+        m_ulProgress = 0;
+        logProgress();
+        m_feedbackOnCancel = FALSE;
+        ::PostMessage(m_hWnd, WM_COMMAND, IDCANCEL, NULL);
+    }
+
+    if (iTimerID == (int)wParam)
+    {
+
+        __try
+        {
+            m_csDownload.Lock();
+
+            HWND hStatusWnd = GetDlgItem(IDC_TIME_REMAINING);
+            HWND hProgressWnd = GetDlgItem(IDC_DOWNLOAD_PROGRESS);
+
+            if (m_ulProgress && m_ulProgressMax)
+            {
+                ::PostMessage(hProgressWnd, PBM_SETPOS,
+                     (WPARAM) (m_ulProgress * 100
+                        / m_ulProgressMax), NULL);
+
+                time_t currentTime;
+                time(&currentTime);
+
+                double elapsed_time = difftime(currentTime, m_startTime);
+                double remain_time = (elapsed_time / m_ulProgress) *
+                                      (m_ulProgressMax - m_ulProgress);
+                int hr = 0, min = 0;
+
+                if (remain_time > 60 * 60)
+                {
+                    hr = int(remain_time / (60 * 60));
+                    remain_time = remain_time - hr * 60 * 60;
+                }
+
+                if (remain_time > 60)
+                {
+                    min = int(remain_time / 60);
+                    remain_time = remain_time - min * 60;
+                }
+
+                TCHAR szBuffer[BUFFER_SIZE];
+                TCHAR szTimeBuffer[BUFFER_SIZE];
+
+                if (hr > 0)
+                {
+                    if (hr > 1)
+                        LoadString(_Module.GetResourceInstance(), IDS_HOURSMINUTESECOND,
+                                   szTimeBuffer, BUFFER_SIZE);
+                    else
+                        LoadString(_Module.GetResourceInstance(), IDS_HOURMINUTESECOND,
+                                   szTimeBuffer, BUFFER_SIZE);
+
+                    sprintf(szBuffer, szTimeBuffer, hr, min, remain_time);
+                }
+                else
+                {
+                    if (min > 0)
+                    {
+                        LoadString(_Module.GetResourceInstance(), IDS_MINUTESECOND,
+                                   szTimeBuffer, BUFFER_SIZE);
+                        sprintf(szBuffer, szTimeBuffer, min, remain_time);
+
+                    }
+                    else
+                    {
+                        LoadString(_Module.GetResourceInstance(), IDS_SECOND,
+                                   szTimeBuffer, BUFFER_SIZE);
+                        sprintf(szBuffer, szTimeBuffer, remain_time);
+
+                    }
+                }
+
+                if (m_ulProgress == m_ulProgressMax) {
+                    // download is done, unpacking bundle now, and waiting
+                    // for another download to take place
+                    ::LoadString(_Module.GetResourceInstance(),
+                            IDS_DOWNLOAD_UNPACKING, szBuffer, BUFFER_SIZE);
+                    __try
+                    {
+                        m_csNumDownloadThreads.Lock();
+                        // both download and unpacking is done, start
+                        // timer to destroy the progress window in 500ms
+                        if (!m_destroyWindowTimerStarted &&
+                               m_numDownloadThreadsRunning == 0) {
+                            SetTimer(destroyWindowTimerID, POST_DELAY);
+                            m_destroyWindowTimerStarted = TRUE;
+                        }
+                    }
+                    __finally
+                    {
+                        m_csNumDownloadThreads.Unlock();
+                    }
+                }
+
+                // Update status message
+                ::SetWindowText(hStatusWnd, szBuffer);
+            }
+        }
+        __finally
+        {
+           m_csDownload.Unlock();
+        }
+    }
+
+    return 0;
+}
+
+// Message handler for WM_ONCTLCOLORSTATIC.
+// this message is sent each time a static control is drawn.
+// we get the Control ID and then set background color and font
+// as appropriate for that control.
+LRESULT CDownloadDialog::OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+{
+    HDC hdc = (HDC) wParam;
+    HWND hwnd = (HWND) lParam;
+
+    int DlgCtrlID = ::GetDlgCtrlID(hwnd);
+
+    if (DlgCtrlID == IDC_DOWNLOAD_TEXT )
+    {
+        if (m_hDialogFont == NULL)
+        {
+            m_hDialogFont = CreateDialogFont(hdc, TEXT("MS Shell Dlg"), 8);
+        }
+
+        ::SelectObject(hdc, m_hDialogFont);
+        return 0;
+    }
+    else if (DlgCtrlID == IDC_TIME_REMAINING)
+    {
+        if (m_hSixPointFont == NULL)
+        {
+            m_hSixPointFont = CreateDialogFont(hdc, TEXT("MS Shell Dlg"), 8);
+        }
+
+        ::SelectObject(hdc, m_hSixPointFont);
+        return 0;
+    }
+    else if (DlgCtrlID == IDC_MASTHEAD_TEXT)
+    {
+        if (m_hMastheadFont == NULL)
+        {
+            m_hMastheadFont = CreateDialogFont(hdc, TEXT("MS Shell Dlg"), 12, 1);
+        }
+
+        ::SelectObject(hdc, m_hMastheadFont);
+        return (LRESULT) GetStockObject(WHITE_BRUSH);
+    }
+    else if (DlgCtrlID == IDC_DOWNLOAD_MASTHEAD)
+    {
+        if (m_hMemDC == NULL)
+        {
+            m_hBitmap = LoadBitmap(_Module.GetModuleInstance(),
+                                   MAKEINTRESOURCE(IDI_MASTHEAD));
+            GetObject(m_hBitmap, sizeof(BITMAP), &m_bmMasthead);
+            m_hMemDC = CreateCompatibleDC(NULL);
+            SelectObject(m_hMemDC, m_hBitmap);
+        }
+
+        RECT rect;
+        ::GetClientRect(hwnd, &rect);
+
+        StretchBlt(hdc, rect.left, rect.top, (rect.right - rect.left), (rect.bottom - rect.top),
+                   m_hMemDC, 0, 0, m_bmMasthead.bmWidth, m_bmMasthead.bmHeight, SRCCOPY);
+
+        return (LRESULT) GetStockObject(NULL_BRUSH);
+    }
+
+
+    return 0;
+}
+
+
+//=--------------------------------------------------------------------------=
+// CDownloadDialog::OnStartBinding
+//=--------------------------------------------------------------------------=
+// Called when download is started
+//
+// Parameters:
+//
+// Output:
+//      HRESULT
+//
+// Notes:
+//
+STDMETHODIMP CDownloadDialog::OnStartBinding()
+{
+    __try
+    {
+        m_csDownload.Lock();
+        time(&m_startTime);
+    }
+    __finally
+    {
+        m_csDownload.Unlock();
+    }
+
+    return S_OK;
+}
+
+
+//=--------------------------------------------------------------------------=
+// CDownloadDialog::OnProgress
+//=--------------------------------------------------------------------------=
+// Called when download is in progress
+//
+// Parameters: ULONG ulProgress
+//
+// Output:
+//      HRESULT
+//
+// Notes:
+//
+STDMETHODIMP CDownloadDialog::OnProgress(ULONG ulProgress)
+{
+    __try
+    {
+        m_csDownload.Lock();
+        m_ulProgress = m_ulProgress + ulProgress;
+        logProgress();
+
+    }
+    __finally
+    {
+        m_csDownload.Unlock();
+    }
+
+    return S_OK;
+}
+
+void CDownloadDialog::decrementProgressMax(ULONG contentLength, ULONG readSoFar) {
+    __try
+    {
+        m_csDownload.Lock();
+        m_ulProgressMax = m_ulProgressMax - contentLength;
+        m_ulProgress = m_ulProgress - readSoFar;
+        logProgress();
+    }
+    __finally
+    {
+        m_csDownload.Unlock();
+    }
+
+}
+
+void CDownloadDialog::waitUntilInitialized() {
+    // wait until download progress dialog is initialized and ready to show
+    WaitForSingleObject(m_hDialogInitializedEvent, INFINITE);
+    ResetEvent(m_hDialogInitializedEvent);
+
+}
+
+// Check if download has been cancelled
+BOOL CDownloadDialog::isDownloadCancelled() {
+    if (WAIT_OBJECT_0 == WaitForSingleObject(m_hCancelEvent, 0)) {
+        return TRUE;
+    }
+    return FALSE;
+}
+
+
+
+// Create the fonts we need for the download and
+// install UE
+HFONT CDownloadDialog::CreateDialogFont(HDC hdc, LPCTSTR lpszFaceName, int ptSize, int isBold)
+{
+    POINT pt;
+    FLOAT cxDPI, cyDPI;
+    HFONT hFont;
+    LOGFONT lf;
+
+    int iDeciPtWidth = 0;
+    int iDeciPtHeight = 10 * ptSize;
+
+    int iSavedDC = SaveDC(hdc);
+
+    SetGraphicsMode (hdc, GM_ADVANCED);
+    ModifyWorldTransform(hdc, NULL, MWT_IDENTITY);
+    SetViewportOrgEx (hdc, 0,0, NULL);
+    SetWindowOrgEx (hdc, 0,0, NULL);
+
+    cxDPI = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSX);
+    cyDPI = (FLOAT) GetDeviceCaps(hdc, LOGPIXELSY);
+
+    pt.x = (int) (iDeciPtWidth * cxDPI / 72);
+    pt.y = (int) (iDeciPtHeight * cyDPI / 72);
+
+    DPtoLP(hdc, &pt, 1);
+
+    lf.lfHeight = - (int) (fabs ((double) pt.y) / 10.0 + 0.5);
+    lf.lfWidth = 0;
+    lf.lfEscapement = 0;
+    lf.lfOrientation = 0;
+    lf.lfWeight = (isBold > 0) ? FW_BOLD : 0;
+    lf.lfItalic = 0;
+    lf.lfUnderline = 0;
+    lf.lfStrikeOut = 0;
+    lf.lfCharSet = 0;
+    lf.lfOutPrecision = 0;
+    lf.lfClipPrecision = 0;
+    lf.lfQuality = 0;
+    lf.lfPitchAndFamily = 0;
+
+    TCHAR szLocaleData[BUFFER_SIZE];
+    GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SENGCOUNTRY,
+                  szLocaleData, BUFFER_SIZE);
+
+    if (strncmp(szLocaleData, "Japan", 5) == 0) {
+        // need special font for _ja locale
+        strcpy (lf.lfFaceName, TEXT("MS UI Gothic"));
+    } else {
+        strcpy (lf.lfFaceName, lpszFaceName);
+    }
+
+    hFont = CreateFontIndirect(&lf);
+
+    RestoreDC (hdc, iSavedDC);
+    return hFont;
+}
+
+void CDownloadDialog::FreeGDIResources ()
+{
+    ::DeleteObject(m_hMastheadFont);
+    m_hMastheadFont = NULL;
+
+    ::DeleteObject(m_hDialogFont);
+    m_hDialogFont = NULL;
+
+    ::DeleteObject(m_hSixPointFont);
+    m_hSixPointFont = NULL;
+
+    ::DeleteObject(m_hBitmap);
+    m_hBitmap = NULL;
+
+    ::DeleteDC(m_hMemDC);
+    m_hMemDC = NULL;
+}
+
+
+JNIEnv* CDownloadDialog::getJNIEnv() {
+    if (m_jvm == NULL)
+        return NULL;
+    JNIEnv *env;
+    m_jvm->AttachCurrentThread((void**) &env, NULL);
+    return env;
+}
+
+
+void CDownloadDialog::log(char *msg) {
+    JNIEnv *env = getJNIEnv();
+    if (env != NULL) {
+        jclass dm = env->FindClass("sun/jkernel/DownloadManager");
+        if (dm == NULL) {
+            printf("Cound not find class sun.jkernel.DownloadManager\n");
+            return;
+        }
+        jmethodID log = env->GetStaticMethodID(dm, "log", "(Ljava/lang/String;)V");
+        if (log == NULL) {
+            printf("Could not find method sun.jkernel.DownloadManager.log(String)\n");
+            return;
+        }
+        jstring string = env->NewStringUTF(msg);
+        if (string == NULL) {
+            printf("Error creating log string\n");
+            return;
+        }
+        env->CallStaticVoidMethod(dm, log, string);
+    }
+}
+
+
+void CDownloadDialog::logProgress() {
+    char msg[256];
+    sprintf(msg, "Progress: %d / %d", m_ulProgress, m_ulProgressMax);
+    log(msg);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/DownloadDialog.h	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,329 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+//
+// DownloadDialog.h : Declaration of the CDownloadDialog
+//
+
+#ifndef __DOWNLOADDIALOG_H_
+#define __DOWNLOADDIALOG_H_
+
+#include "resource.h"       // main symbols
+#include <time.h>
+#include "jni.h"
+
+#ifndef BUFFER_SIZE
+#define BUFFER_SIZE 2048
+#endif
+
+#define iTimerID    1000
+#define destroyWindowTimerID    2000
+
+#define E_JDHELPER_TIMEOUT               12002
+#define E_JDHELPER_NAME_NOT_RESOLVED     12007
+#define E_JDHELPER_CANNOT_CONNECT        12029
+
+/* Following lines were copied from the new version of commctrl.h
+   These definitions are not available in default version of
+   this header file in VS 2003 but they are needed to use
+   new Vista task dialog API.
+*/
+#ifndef TD_ERROR_ICON
+
+/* These modifiers have sense with new VS only,
+   reset them to get code to compile */
+#define __in
+#define __in_opt
+#define __out_opt
+
+#ifdef _WIN32
+#include <pshpack1.h>
+#endif
+
+
+typedef HRESULT (CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, __in UINT msg, __in WPARAM wParam, __in LPARAM lParam, __in LONG_PTR lpRefData);
+
+enum _TASKDIALOG_FLAGS
+{
+    TDF_ENABLE_HYPERLINKS               = 0x0001,
+    TDF_USE_HICON_MAIN                  = 0x0002,
+    TDF_USE_HICON_FOOTER                = 0x0004,
+    TDF_ALLOW_DIALOG_CANCELLATION       = 0x0008,
+    TDF_USE_COMMAND_LINKS               = 0x0010,
+    TDF_USE_COMMAND_LINKS_NO_ICON       = 0x0020,
+    TDF_EXPAND_FOOTER_AREA              = 0x0040,
+    TDF_EXPANDED_BY_DEFAULT             = 0x0080,
+    TDF_VERIFICATION_FLAG_CHECKED       = 0x0100,
+    TDF_SHOW_PROGRESS_BAR               = 0x0200,
+    TDF_SHOW_MARQUEE_PROGRESS_BAR       = 0x0400,
+    TDF_CALLBACK_TIMER                  = 0x0800,
+    TDF_POSITION_RELATIVE_TO_WINDOW     = 0x1000,
+    TDF_RTL_LAYOUT                      = 0x2000,
+    TDF_NO_DEFAULT_RADIO_BUTTON         = 0x4000,
+    TDF_CAN_BE_MINIMIZED                = 0x8000
+};
+typedef int TASKDIALOG_FLAGS;                         // Note: _TASKDIALOG_FLAGS is an int
+
+typedef enum _TASKDIALOG_MESSAGES
+{
+    TDM_NAVIGATE_PAGE                   = WM_USER+101,
+    TDM_CLICK_BUTTON                    = WM_USER+102, // wParam = Button ID
+    TDM_SET_MARQUEE_PROGRESS_BAR        = WM_USER+103, // wParam = 0 (nonMarque) wParam != 0 (Marquee)
+    TDM_SET_PROGRESS_BAR_STATE          = WM_USER+104, // wParam = new progress state
+    TDM_SET_PROGRESS_BAR_RANGE          = WM_USER+105, // lParam = MAKELPARAM(nMinRange, nMaxRange)
+    TDM_SET_PROGRESS_BAR_POS            = WM_USER+106, // wParam = new position
+    TDM_SET_PROGRESS_BAR_MARQUEE        = WM_USER+107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints)
+    TDM_SET_ELEMENT_TEXT                = WM_USER+108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
+    TDM_CLICK_RADIO_BUTTON              = WM_USER+110, // wParam = Radio Button ID
+    TDM_ENABLE_BUTTON                   = WM_USER+111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID
+    TDM_ENABLE_RADIO_BUTTON             = WM_USER+112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID
+    TDM_CLICK_VERIFICATION              = WM_USER+113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus)
+    TDM_UPDATE_ELEMENT_TEXT             = WM_USER+114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR)
+    TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER+115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required)
+    TDM_UPDATE_ICON                     = WM_USER+116  // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise)
+} TASKDIALOG_MESSAGES;
+
+typedef enum _TASKDIALOG_NOTIFICATIONS
+{
+    TDN_CREATED                         = 0,
+    TDN_NAVIGATED                       = 1,
+    TDN_BUTTON_CLICKED                  = 2,            // wParam = Button ID
+    TDN_HYPERLINK_CLICKED               = 3,            // lParam = (LPCWSTR)pszHREF
+    TDN_TIMER                           = 4,            // wParam = Milliseconds since dialog created or timer reset
+    TDN_DESTROYED                       = 5,
+    TDN_RADIO_BUTTON_CLICKED            = 6,            // wParam = Radio Button ID
+    TDN_DIALOG_CONSTRUCTED              = 7,
+    TDN_VERIFICATION_CLICKED            = 8,             // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0
+    TDN_HELP                            = 9,
+    TDN_EXPANDO_BUTTON_CLICKED          = 10            // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded)
+} TASKDIALOG_NOTIFICATIONS;
+
+typedef struct _TASKDIALOG_BUTTON
+{
+    int     nButtonID;
+    PCWSTR  pszButtonText;
+} TASKDIALOG_BUTTON;
+
+typedef enum _TASKDIALOG_ELEMENTS
+{
+    TDE_CONTENT,
+    TDE_EXPANDED_INFORMATION,
+    TDE_FOOTER,
+    TDE_MAIN_INSTRUCTION
+} TASKDIALOG_ELEMENTS;
+
+typedef enum _TASKDIALOG_ICON_ELEMENTS
+{
+    TDIE_ICON_MAIN,
+    TDIE_ICON_FOOTER
+} TASKDIALOG_ICON_ELEMENTS;
+
+#define TD_WARNING_ICON         MAKEINTRESOURCEW(-1)
+#define TD_ERROR_ICON           MAKEINTRESOURCEW(-2)
+#define TD_INFORMATION_ICON     MAKEINTRESOURCEW(-3)
+#define TD_SHIELD_ICON          MAKEINTRESOURCEW(-4)
+
+
+enum _TASKDIALOG_COMMON_BUTTON_FLAGS
+{
+    TDCBF_OK_BUTTON            = 0x0001, // selected control return value IDOK
+    TDCBF_YES_BUTTON           = 0x0002, // selected control return value IDYES
+    TDCBF_NO_BUTTON            = 0x0004, // selected control return value IDNO
+    TDCBF_CANCEL_BUTTON        = 0x0008, // selected control return value IDCANCEL
+    TDCBF_RETRY_BUTTON         = 0x0010, // selected control return value IDRETRY
+    TDCBF_CLOSE_BUTTON         = 0x0020  // selected control return value IDCLOSE
+};
+typedef int TASKDIALOG_COMMON_BUTTON_FLAGS;           // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int
+
+typedef struct _TASKDIALOGCONFIG
+{
+    UINT        cbSize;
+    HWND        hwndParent;
+    HINSTANCE   hInstance;                              // used for MAKEINTRESOURCE() strings
+    TASKDIALOG_FLAGS                dwFlags;            // TASKDIALOG_FLAGS (TDF_XXX) flags
+    TASKDIALOG_COMMON_BUTTON_FLAGS  dwCommonButtons;    // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags
+    PCWSTR      pszWindowTitle;                         // string or MAKEINTRESOURCE()
+    union
+    {
+        HICON   hMainIcon;
+        PCWSTR  pszMainIcon;
+    };
+    PCWSTR      pszMainInstruction;
+    PCWSTR      pszContent;
+    UINT        cButtons;
+    const TASKDIALOG_BUTTON  *pButtons;
+    int         nDefaultButton;
+    UINT        cRadioButtons;
+    const TASKDIALOG_BUTTON  *pRadioButtons;
+    int         nDefaultRadioButton;
+    PCWSTR      pszVerificationText;
+    PCWSTR      pszExpandedInformation;
+    PCWSTR      pszExpandedControlText;
+    PCWSTR      pszCollapsedControlText;
+    union
+    {
+        HICON   hFooterIcon;
+        PCWSTR  pszFooterIcon;
+    };
+    PCWSTR      pszFooter;
+    PFTASKDIALOGCALLBACK pfCallback;
+    LONG_PTR    lpCallbackData;
+    UINT        cxWidth;                                // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width.
+} TASKDIALOGCONFIG;
+
+WINCOMMCTRLAPI HRESULT WINAPI TaskDialogIndirect(const TASKDIALOGCONFIG *pTaskConfig, __out_opt int *pnButton, __out_opt int *pnRadioButton, __out_opt BOOL *pfVerificationFlagChecked);
+WINCOMMCTRLAPI HRESULT WINAPI TaskDialog(__in_opt HWND hwndParent, __in_opt HINSTANCE hInstance, __in_opt PCWSTR pszWindowTitle, __in_opt PCWSTR pszMainInstruction, __in_opt PCWSTR pszContent, TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons, __in_opt PCWSTR pszIcon, __out_opt int *pnButton);
+
+#ifdef _WIN32
+#include <poppack.h>
+#endif
+
+#endif /* end of copy from commctrl.h */
+
+typedef HRESULT (WINAPI *TaskDialogIndirectFn) (const TASKDIALOGCONFIG *pTaskConfig, __out_opt int *pnButton, __out_opt int *pnRadioButton, __out_opt BOOL *pfVerificationFlagChecked);
+
+typedef enum {
+    DIALOG_ERROR_RETRYCANCEL = 0,
+    DIALOG_WARNING_CANCELOK
+} DialogType;
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CDownloadDialog
+class CDownloadDialog :
+        public CAxDialogImpl<CDownloadDialog>
+{
+public:
+        CDownloadDialog();
+        ~CDownloadDialog();
+
+        enum { IDD = IDD_DOWNLOAD_DIALOG };
+
+BEGIN_MSG_MAP(CDownloadDialog)
+        MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+        MESSAGE_HANDLER(WM_TIMER, OnTimer)
+        MESSAGE_HANDLER(WM_CTLCOLORSTATIC, OnCtlColorStatic)
+        COMMAND_ID_HANDLER(IDOK, OnOK)
+        COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
+END_MSG_MAP()
+
+        LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+        LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+        LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+        LRESULT OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+        LRESULT OnCtlColorStatic(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+
+        STDMETHODIMP OnStartBinding();
+
+        STDMETHODIMP OnProgress(ULONG ulProgress);
+
+        void initDialogText(LPCTSTR pszDownloadURL, LPCTSTR pszBundleName);
+
+        BOOL isDownloading();
+        BOOL isDownloadCancelled();
+
+        void addToTotalContentLength(DWORD contentLength);
+
+        void decrementProgressMax(ULONG contentLength, ULONG readSoFar);
+
+        void bundleInstallStart();
+        void bundleInstallComplete();
+
+        void waitUntilInitialized();
+
+        void log(char *msg);
+        void logProgress();
+
+        void setFile(LPCTSTR pszFileName)
+        {
+            m_pszFileName = pszFileName;
+        }
+
+        void setURL(LPCTSTR pszURL)
+        {
+            m_pszURL = pszURL;
+        }
+
+        void setNameText(LPTSTR pszNameText)
+        {
+            m_pszNameText = pszNameText;
+        }
+
+
+        JNIEnv* getJNIEnv();
+
+
+        void setJavaVM(JavaVM *jvm)
+        {
+            m_jvm = jvm;
+        }
+
+
+        HRESULT DownloadConfiguration(LPTSTR pszConfigURL, LPTSTR pszConfigFile);
+
+        void delayedDoModal();
+
+        int SafeMessageBox(UINT details, UINT mainInstruction, UINT caption,
+                           DialogType type, LPCWSTR instructionArg = NULL,
+                           LPCWSTR detailsArg = NULL);
+
+        void destroyDialog();
+
+    private:
+
+        HFONT CreateDialogFont (HDC hdc, LPCTSTR lpszFaceName, int ptSize, int isBold = 0);
+        void  FreeGDIResources ();
+
+        BOOL                    m_feedbackOnCancel;
+        TaskDialogIndirectFn    taskDialogFn;
+        LPCTSTR                 m_pszFileName;
+        LPCTSTR                 m_pszURL;
+        time_t                  m_startTime;
+        ULONG                   m_ulProgress;
+        ULONG                   m_ulProgressMax;
+        int                     m_iProgressFactor;
+        int                     m_iMaxProgressFactor;
+        int                     m_numDownloadThreadsRunning;
+        BOOL            m_destroyWindowTimerStarted;
+        volatile BOOL           m_dialogUp;
+        CComAutoCriticalSection m_csDownload;
+        CComAutoCriticalSection m_csNumDownloadThreads;
+        HANDLE                  m_hCancelEvent;
+        HANDLE                  m_hDownloadThreadExitEvent;
+        HANDLE                  m_hDialogInitializedEvent;
+        HFONT                   m_hMastheadFont;
+        HFONT                   m_hDialogFont;
+        HFONT                   m_hSixPointFont;
+        LPTSTR                  m_pszNameText;
+        BITMAP                  m_bmMasthead;
+        HBITMAP                 m_hBitmap;
+        HDC                     m_hMemDC;
+        TCHAR                   m_szUrlPath[BUFFER_SIZE];
+        TCHAR                   m_szHostName[BUFFER_SIZE];
+        JavaVM*                 m_jvm;
+        CComAutoCriticalSection m_csMessageBox;
+};
+
+#endif //__DOWNLOADDIALOG_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/DownloadHelper.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,652 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#define _ATL_APARTMENT_THREADED
+
+
+#include <atlbase.h>
+//You may derive a class from CComModule and use it if you want to override
+//something, but do not change the name of _Module
+extern CComModule _Module;
+#include <atlcom.h>
+#include <atlwin.h>
+
+#include <atlhost.h>
+#include <commdlg.h>
+#include <commctrl.h>
+#include <windowsx.h>
+#include <urlmon.h>
+#include <wininet.h>
+#include <shellapi.h>
+#include <time.h>
+#include <math.h>
+#include <stdio.h>
+
+#include <jni.h>
+
+#include "resource.h"       // main symbols
+#include "DownloadHelper.h"
+
+DownloadHelper::DownloadHelper() {
+
+    m_showProgressDialog = TRUE;
+    m_pszURL = NULL;
+    m_pszFileName = NULL;
+    m_pszNameText = NULL;
+}
+
+DownloadHelper::~DownloadHelper() {
+
+}
+
+HRESULT DownloadHelper::doDownload() {
+    return DownloadFile(m_pszURL, m_pszFileName, FALSE, m_showProgressDialog);
+}
+
+HRESULT DownloadHelper::DownloadFile(const TCHAR* szURL,
+        const TCHAR* szLocalFile, BOOL bResumable, BOOL bUIFeedback) {
+    HINTERNET hOpen = NULL;
+    HINTERNET hConnect = NULL;
+    HINTERNET hRequest = NULL;
+    HANDLE hFile = INVALID_HANDLE_VALUE;
+    DWORD dwDownloadError = 0;
+    DWORD nContentLength = 0;
+
+    /* Some of error messages use drive letter.
+       Result is something like "(C:)".
+       NB: Parentheses are added here because in some other places
+           we same message but can not provide disk label info */
+    TCHAR drivePath[5];
+    /* assuming szLocalFile is not NULL */
+    _sntprintf(drivePath, 5, "(%c:)", szLocalFile[0]);
+    WCHAR* wName = CT2CW(drivePath);
+
+    __try {
+        m_csDownload.Lock();
+
+        time(&m_startTime);
+
+    }
+    __finally {
+        m_csDownload.Unlock();
+    }
+
+    __try {
+        // block potential security hole
+        if (strstr(szURL, TEXT("file://")) != NULL) {
+            dwDownloadError = 1;
+            __leave;
+        }
+
+        HWND hProgressInfo = NULL;
+        TCHAR szStatus[BUFFER_SIZE];
+
+        if (bUIFeedback) {
+            // init download dialg text
+            m_dlg->initDialogText(m_pszURL, m_pszNameText);
+        }
+
+        // Open Internet Call
+        hOpen = ::InternetOpen("deployHelper", INTERNET_OPEN_TYPE_PRECONFIG,
+                NULL, NULL, NULL);
+
+        if (hOpen == NULL) {
+            dwDownloadError = 1;
+            __leave;
+        }
+
+        // URL components
+        URL_COMPONENTS url_components;
+        ::ZeroMemory(&url_components, sizeof(URL_COMPONENTS));
+
+        TCHAR szHostName[BUFFER_SIZE], szUrlPath[BUFFER_SIZE],
+                szExtraInfo[BUFFER_SIZE];
+        url_components.dwStructSize = sizeof(URL_COMPONENTS);
+        url_components.lpszHostName = szHostName;
+        url_components.dwHostNameLength = BUFFER_SIZE;
+        url_components.nPort = NULL;
+        url_components.lpszUrlPath = szUrlPath;
+        url_components.dwUrlPathLength = BUFFER_SIZE;
+        url_components.lpszExtraInfo = szExtraInfo;
+        url_components.dwExtraInfoLength = BUFFER_SIZE;
+
+        // Crack the URL into pieces
+        ::InternetCrackUrl(szURL, lstrlen(szURL), NULL, &url_components);
+
+        // Open Internet Connection
+        hConnect = ::InternetConnect(hOpen, url_components.lpszHostName,
+                url_components.nPort, "", "", INTERNET_SERVICE_HTTP, NULL,
+                NULL);
+
+        if (hConnect == NULL) {
+            dwDownloadError = 1;
+            __leave;
+        }
+
+        // Determine the relative URL path by combining
+        // Path and ExtraInfo
+        char szURL[4096];
+
+        if (url_components.dwUrlPathLength !=  0)
+            lstrcpy(szURL, url_components.lpszUrlPath);
+        else
+            lstrcpy(szURL, "/");
+
+        if (url_components.dwExtraInfoLength != 0)
+            lstrcat(szURL, url_components.lpszExtraInfo);
+
+        BOOL bRetryHttpRequest = FALSE;
+        int numberOfRetry = 0;
+        long secondsToWait = 60;
+
+        do {
+            bRetryHttpRequest = FALSE;
+
+            // Make a HTTP GET request
+            hRequest = ::HttpOpenRequest(hConnect, "GET", szURL, "HTTP/1.1",
+                    "", NULL,
+                    INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_DONT_CACHE,
+                    0);
+
+            if (hRequest == NULL) {
+                dwDownloadError = 1;
+                __leave;
+            }
+
+            // Create or open existing destination file
+            hFile = ::CreateFile(szLocalFile, GENERIC_WRITE, 0, NULL,
+                    OPEN_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, NULL);
+
+            if (hFile == INVALID_HANDLE_VALUE) {
+                if (bUIFeedback) {
+                    if (IDRETRY == m_dlg->SafeMessageBox(
+                                            IDS_DISK_WRITE_ERROR,
+                                            IDS_DISK_WRITE_ERROR_CAPTION,
+                                            IDS_ERROR_CAPTION,
+                                            DIALOG_ERROR_RETRYCANCEL,
+                                            wName)) {
+                         bRetryHttpRequest = TRUE;
+                         continue;
+                    }
+                }
+                dwDownloadError = 1;
+                __leave;
+            }
+            DWORD fileSize = GetFileSize(hFile, NULL);
+
+            // Check if resumable download is enabled
+            if (bResumable == FALSE) {
+                // Start from scratch
+                fileSize = 0;
+            }
+
+            FILETIME tWrite;
+            BOOL rangereq = FALSE;
+            if ((fileSize != 0) && (fileSize != 0xFFFFFFFF) &&
+                    GetFileTime(hFile, NULL, NULL, &tWrite)) {
+                char szHead[100];
+                SYSTEMTIME tLocal;
+                char buf[INTERNET_RFC1123_BUFSIZE];
+
+                FileTimeToSystemTime(&tWrite, &tLocal);
+                InternetTimeFromSystemTime(&tLocal, INTERNET_RFC1123_FORMAT,
+                        buf, INTERNET_RFC1123_BUFSIZE);
+                sprintf(szHead, "Range: bytes=%d-\r\nIf-Range: %s\r\n",
+                        fileSize, buf);
+                HttpAddRequestHeaders(hRequest, szHead, lstrlen(szHead),
+                        HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE);
+                rangereq = TRUE;
+            }
+
+            // This is a loop to handle various potential error when the
+            // connection is made
+            BOOL bCont = TRUE;
+
+            while ((FALSE == ::HttpSendRequest(hRequest, NULL, NULL, NULL, NULL))
+            && bCont ) {
+                // We might have an invalid CA.
+                DWORD dwErrorCode = GetLastError();
+
+                switch(dwErrorCode) {
+                    case E_JDHELPER_TIMEOUT:
+                    case E_JDHELPER_NAME_NOT_RESOLVED:
+                    case E_JDHELPER_CANNOT_CONNECT: {
+                        bCont = FALSE;
+                        // Display the information dialog
+                        if (bUIFeedback) {
+                            // decrement download counter to prevent progress
+                            // dialog from popping up while the message box is
+                            // up
+                            m_dlg->bundleInstallComplete();
+                            if (dwErrorCode == E_JDHELPER_TIMEOUT) {
+                                bRetryHttpRequest =
+                                    (IDRETRY == m_dlg->SafeMessageBox(
+                                       IDS_HTTP_STATUS_REQUEST_TIMEOUT,
+                                       IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT,
+                                       IDS_ERROR_CAPTION,
+                                       DIALOG_ERROR_RETRYCANCEL));
+                            } else {
+                                bRetryHttpRequest =
+                                    (IDRETRY == m_dlg->SafeMessageBox(
+                                       IDS_HTTP_STATUS_SERVER_NOT_REACHABLE,
+                                       IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE,
+                                       IDS_ERROR_CAPTION,
+                                       DIALOG_ERROR_RETRYCANCEL));
+                            }
+                            // re-increment counter because it will be decremented
+                            // again upon return
+                            m_dlg->bundleInstallStart();
+                            bCont = bRetryHttpRequest;
+                        }
+                        break;
+                    }
+                    case ERROR_INTERNET_INVALID_CA:
+                    case ERROR_INTERNET_SEC_CERT_CN_INVALID:
+                    case ERROR_INTERNET_SEC_CERT_DATE_INVALID:
+                    case ERROR_INTERNET_HTTP_TO_HTTPS_ON_REDIR:
+                    case ERROR_INTERNET_INCORRECT_PASSWORD:
+                    case ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED:
+                    default: {
+                        // Unless the user agrees to continue, we just
+                        // abandon now !
+                        bCont = FALSE;
+
+                        // Make sure to test the return code from
+                        // InternetErrorDlg user may click OK or Cancel. In
+                        // case of Cancel, request should not be resubmitted
+                        if (bUIFeedback) {
+                            if (ERROR_SUCCESS == ::InternetErrorDlg(
+                                    NULL, hRequest,
+                                    dwErrorCode,
+                                    FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
+                                    FLAGS_ERROR_UI_FLAGS_GENERATE_DATA |
+                                    FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS,
+                                    NULL))
+                                bCont = TRUE;
+                        }
+                    }
+                }
+            }
+
+            if (bCont == FALSE) {
+                // User has denied the request
+                dwDownloadError = 1;
+                __leave;
+            }
+
+            //
+            // Read HTTP status code
+            //
+            DWORD dwErrorCode = GetLastError();
+            DWORD dwStatus=0;
+            DWORD dwStatusSize = sizeof(DWORD);
+
+            if (FALSE == ::HttpQueryInfo(hRequest, HTTP_QUERY_FLAG_NUMBER |
+                    HTTP_QUERY_STATUS_CODE, &dwStatus, &dwStatusSize, NULL)) {
+                dwErrorCode = GetLastError();
+            }
+
+            bCont = TRUE;
+            while ((dwStatus == HTTP_STATUS_PROXY_AUTH_REQ ||
+                    dwStatus == HTTP_STATUS_DENIED) &&
+                    bCont) {
+                int result = ::InternetErrorDlg(GetDesktopWindow(), hRequest, ERROR_INTERNET_INCORRECT_PASSWORD,
+                        FLAGS_ERROR_UI_FILTER_FOR_ERRORS |
+                        FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS |
+                        FLAGS_ERROR_UI_FLAGS_GENERATE_DATA,
+                        NULL);
+                if (ERROR_CANCELLED == result) {
+                    bCont = FALSE;
+                }
+                else {
+                    ::HttpSendRequest(hRequest, NULL, 0, NULL, 0);
+
+                    // Reset buffer length
+                    dwStatusSize = sizeof(DWORD);
+
+                    ::HttpQueryInfo(hRequest, HTTP_QUERY_FLAG_NUMBER |
+                            HTTP_QUERY_STATUS_CODE, &dwStatus, &dwStatusSize,
+                            NULL);
+                }
+            }
+
+            if (dwStatus == HTTP_STATUS_OK ||
+                    dwStatus == HTTP_STATUS_PARTIAL_CONTENT) {
+                // Determine content length, so we may show the progress bar
+                // meaningfully
+                //
+                nContentLength = 0;
+                DWORD nLengthSize = sizeof(DWORD);
+                ::HttpQueryInfo(hRequest,
+                        HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
+                        &nContentLength, &nLengthSize, NULL);
+
+                if (nContentLength <= 0) {
+                    // If can't estimate content length, estimate it
+                    // to be 6MB
+                    nContentLength = 15000000;
+                }
+                else if (rangereq && (fileSize != 0) &&
+                        (nContentLength == fileSize)) {
+                    // If the file is already downloaded completely and then
+                    // we send a range request, the whole file is sent instead
+                    // of nothing. So avoid downloading again.
+                    // Some times return value is 206, even when whole file
+                    // is sent. So check if "Content-range:" is present in the
+                    // reply
+                    char buffer[256];
+                    DWORD length = sizeof(buffer);
+                    if(!HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_RANGE,
+                            buffer, &length, NULL)) {
+                        if(HttpQueryInfo(hRequest, HTTP_QUERY_LAST_MODIFIED,
+                                buffer, &length, NULL)) {
+                            SYSTEMTIME systime;
+                            FILETIME filtime;
+                            InternetTimeToSystemTime(buffer, &systime, NULL);
+                            SystemTimeToFileTime(&systime, &filtime);
+                            if ((CompareFileTime(&tWrite, &filtime)) == 1) {
+                                // no need to download
+                                dwDownloadError = 0;
+                                __leave;
+                            }
+                        }
+                        else {
+                            ::SetFilePointer(hFile, 0, 0, FILE_BEGIN);
+                            ::SetEndOfFile(hFile); // truncate the file
+                        }
+                    }
+
+                }
+
+                TCHAR szBuffer[8096];
+                DWORD dwBufferSize = 8096;
+
+                // Read from HTTP connection and write into
+                // destination file
+                //
+                DWORD nRead = 0;
+                DWORD dwTotalRead = 0;
+                BOOL bCancel = FALSE;
+
+                if (dwStatus == HTTP_STATUS_PARTIAL_CONTENT) {
+                    // If we are using resumable download, fake
+                    // start time so it looks like we have begun
+                    // the download several minutes again.
+                    //
+                    m_startTime = m_startTime - 100;
+
+                    ::SetFilePointer(hFile, 0, 0, FILE_END); // seek to end
+                }
+                else {
+                    ::SetFilePointer(hFile, 0, 0, FILE_BEGIN);
+                    ::SetEndOfFile(hFile); // truncate the file
+                }
+
+                do {
+                    nRead=0;
+
+                    if (::InternetReadFile(hRequest, szBuffer, dwBufferSize,
+                            &nRead)) {
+                        if (nRead) {
+                            DWORD dwNumberOfBytesWritten = NULL;
+
+                            BOOL ret = WriteFile(hFile, szBuffer, nRead,
+                                    &dwNumberOfBytesWritten, NULL);
+
+                            if (!ret) {
+                                // WriteFile failed
+                                if (bUIFeedback) {
+                                    if (GetLastError() == ERROR_DISK_FULL) {
+                                       bRetryHttpRequest =
+                                            (IDRETRY == m_dlg->SafeMessageBox(
+                                            IDS_DISK_FULL_ERROR,
+                                            IDS_DISK_FULL_ERROR_CAPTION,
+                                            IDS_ERROR_CAPTION,
+                                            DIALOG_ERROR_RETRYCANCEL,
+                                            wName));
+                                    } else {
+                                        bRetryHttpRequest =
+                                            (IDRETRY == m_dlg->SafeMessageBox(
+                                            IDS_DISK_WRITE_ERROR,
+                                            IDS_DISK_WRITE_ERROR_CAPTION,
+                                            IDS_ERROR_CAPTION,
+                                            DIALOG_ERROR_RETRYCANCEL,
+                                            wName));
+                                    }
+                                    if (!bRetryHttpRequest) {
+                                        dwDownloadError = 1;
+                                        break;
+                                    }
+                                }
+                                continue;
+                            }
+                        }
+
+                        dwTotalRead += nRead;
+
+                        // update download progress dialog
+                        m_dlg->OnProgress(nRead);
+                        // Check if download has been cancelled
+                        if (m_dlg->isDownloadCancelled()) {
+                            m_dlg->decrementProgressMax(nContentLength,
+                                    dwTotalRead);
+                            bCancel = TRUE;
+                            break;
+                        }
+
+                    }
+                    else {
+                        bCancel = TRUE;
+                        break;
+                    }
+                }
+                while (nRead);
+
+
+                if (bCancel) {
+                    // User has cancelled the operation or InternetRead failed
+                    // don't do return here, we need to cleanup
+                    dwDownloadError = 1;
+                    __leave;
+                }
+            }
+            else if (dwStatus == 416 && (fileSize != 0) &&
+                    (fileSize != 0xFFFFFFFF)) {
+                // This error could be returned, When the full file exists
+                // and a range request is sent with range beyond filessize.
+                // The best way to fix this is in future is, to send HEAD
+                // request and get filelength before sending range request.
+                dwDownloadError = 0;
+                __leave;
+            }
+            else if (dwStatus == 403) { // Forbidden from Akamai means we need to get a new download token
+                JNIEnv *env = m_dlg->getJNIEnv();
+                jclass exceptionClass = env->FindClass("java/net/HttpRetryException");
+                if (exceptionClass == NULL) {
+                    /* Unable to find the exception class, give up. */
+                    __leave;
+                }
+                jmethodID constructor;
+                constructor = env->GetMethodID(exceptionClass,
+                               "<init>", "(Ljava/lang/String;I)V");
+                if (constructor != NULL) {
+                    jobject exception = env->NewObject(exceptionClass,
+                            constructor, env->NewStringUTF("Forbidden"),
+                            403);
+                    env->Throw((jthrowable) exception);
+                }
+                __leave;
+            }
+            else if(dwStatus >= 400 && dwStatus < 600) {
+                /* NB: Following case seems to be never used!
+
+                   HTTP_STATUS_FORBIDDEN is the same as 403 and
+                   403 was specially handled few lines above! */
+                if (dwStatus == HTTP_STATUS_FORBIDDEN) {
+                    if (bUIFeedback) {
+                        bRetryHttpRequest = (IDRETRY == m_dlg->SafeMessageBox(
+                                            IDS_HTTP_STATUS_FORBIDDEN,
+                                            IDS_HTTP_INSTRUCTION_FORBIDDEN,
+                                            IDS_ERROR_CAPTION,
+                                            DIALOG_ERROR_RETRYCANCEL,
+                                            L"403"));
+                    }
+                }
+                else if (dwStatus == HTTP_STATUS_SERVER_ERROR) {
+                    if (bUIFeedback) {
+                       bRetryHttpRequest = (IDRETRY == m_dlg->SafeMessageBox(
+                                            IDS_HTTP_STATUS_SERVER_ERROR,
+                                            IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR,
+                                            IDS_ERROR_CAPTION,
+                                            DIALOG_ERROR_RETRYCANCEL,
+                                            L"500"));
+                    }
+                }
+                else if (dwStatus == HTTP_STATUS_SERVICE_UNAVAIL) {
+                    if (numberOfRetry < 5) {
+                        // If the server is busy, automatically retry
+
+                        // We wait couple seconds before retry to avoid
+                        // congestion
+                        for (long i = (long) secondsToWait; i >= 0; i--) {
+                            // Update status
+                            if (bUIFeedback) {
+                                char szBuffer[BUFFER_SIZE];
+                                ::LoadString(_Module.GetResourceInstance(),
+                                        IDS_DOWNLOAD_STATUS_RETRY, szStatus,
+                                        BUFFER_SIZE);
+                                wsprintf(szBuffer, szStatus, i);
+
+                                ::SetWindowText(hProgressInfo, szBuffer);
+                            }
+
+                            // Sleep 1 second
+                            ::Sleep(1000);
+                        }
+
+                        // We use a semi-binary backoff algorithm to
+                        // determine seconds to wait
+                        numberOfRetry += 1;
+                        secondsToWait = secondsToWait + 30;
+                        bRetryHttpRequest = TRUE;
+
+                        continue;
+                    }
+                    else {
+                        if (bUIFeedback) {
+                            bRetryHttpRequest = (IDRETRY == m_dlg->SafeMessageBox(
+                                            IDS_HTTP_STATUS_SERVICE_UNAVAIL,
+                                            IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL,
+                                            IDS_ERROR_CAPTION,
+                                            DIALOG_ERROR_RETRYCANCEL,
+                                            L"503"));
+
+                            if (bRetryHttpRequest) {
+                                numberOfRetry = 0;
+                                secondsToWait = 60;
+                                continue;
+                            }
+                        }
+                    }
+                }
+                else {
+                    if (bUIFeedback) {
+                        WCHAR szBuffer[10];
+                        _snwprintf(szBuffer, 10, L"%d", dwStatus);
+                        bRetryHttpRequest = (IDRETRY == m_dlg->SafeMessageBox(
+                                            IDS_HTTP_STATUS_OTHER,
+                                            IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR,
+                                            IDS_ERROR_CAPTION,
+                                            DIALOG_ERROR_RETRYCANCEL,
+                                            szBuffer));
+                    }
+                }
+                if (!bRetryHttpRequest) {
+                    dwDownloadError = 1;
+                }
+            }
+            else {
+                if (bUIFeedback) {
+                    WCHAR szBuffer[10];
+                    _snwprintf(szBuffer, 10, L"%d", dwStatus);
+                    bRetryHttpRequest = (IDRETRY == m_dlg->SafeMessageBox(
+                                            IDS_HTTP_STATUS_OTHER,
+                                            IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR,
+                                            IDS_ERROR_CAPTION,
+                                            DIALOG_ERROR_RETRYCANCEL,
+                                            szBuffer));
+                }
+                if (!bRetryHttpRequest) {
+                    dwDownloadError = 1;
+                }
+            }
+
+
+
+            // Close HTTP request
+            //
+            // This is necessary if the HTTP request
+            // is retried
+            if (hRequest)
+                ::InternetCloseHandle(hRequest);
+            if (hFile != INVALID_HANDLE_VALUE) {
+                ::CloseHandle(hFile);
+                hFile = INVALID_HANDLE_VALUE;
+            }
+        }
+        while (bRetryHttpRequest);
+    }
+    __finally {
+        if (hRequest)
+            ::InternetCloseHandle(hRequest);
+
+        if (hConnect)
+            ::InternetCloseHandle(hConnect);
+
+        if (hOpen)
+            ::InternetCloseHandle(hOpen);
+
+        if (hFile != INVALID_HANDLE_VALUE)
+            ::CloseHandle(hFile);
+    }
+
+
+
+    // Exit dialog
+    if (dwDownloadError == 0) {
+        return S_OK;
+    } else {
+        DeleteFile(szLocalFile);
+        return E_FAIL;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/DownloadHelper.h	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+#ifndef BUFFER_SIZE
+#define BUFFER_SIZE 2048
+#endif
+
+#define E_JDHELPER_TIMEOUT               12002
+#define E_JDHELPER_NAME_NOT_RESOLVED     12007
+#define E_JDHELPER_CANNOT_CONNECT        12029
+
+#include <jni.h>
+#include "DownloadDialog.h"
+
+class DownloadHelper {
+public:
+    DownloadHelper();
+    ~DownloadHelper();
+
+    HRESULT doDownload();
+
+    void setFile(LPCTSTR pszFileName) {
+        m_pszFileName = pszFileName;
+    }
+
+    void setURL(LPCTSTR pszURL) {
+        m_pszURL = pszURL;
+    }
+
+    void setNameText(LPTSTR pszNameText) {
+        m_pszNameText = pszNameText;
+    }
+
+    void setShowProgressDialog(BOOL showProgress) {
+        m_showProgressDialog = showProgress;
+    }
+
+    void setDownloadDialog(CDownloadDialog* dialog) {
+        m_dlg = dialog;
+    }
+
+    void setJavaVM(JavaVM *jvm) {
+        m_jvm = jvm;
+    }
+
+private:
+    HRESULT DownloadFile(const TCHAR* szURL, const TCHAR* szLocalFile,
+            BOOL bResumable, BOOL bUIFeedback);
+
+    BOOL m_showProgressDialog;
+    LPCTSTR m_pszURL;
+    LPCTSTR m_pszFileName;
+    LPTSTR m_pszNameText;
+    time_t m_startTime;
+    CComAutoCriticalSection m_csDownload;
+    CDownloadDialog* m_dlg;
+    JavaVM* m_jvm;
+};
Binary file jdk/src/windows/native/sun/jkernel/graphics/bullet.bmp has changed
Binary file jdk/src/windows/native/sun/jkernel/graphics/cautionshield32.bmp has changed
Binary file jdk/src/windows/native/sun/jkernel/graphics/java-icon.ico has changed
Binary file jdk/src/windows/native/sun/jkernel/graphics/masthead.bmp has changed
Binary file jdk/src/windows/native/sun/jkernel/graphics/warningmasthead.bmp has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,1621 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+#define _WIN32_WINNT 0x0500
+#define WINVER 0x0500
+
+#include "stdafx.h"
+#include <shlobj.h>
+#include <atlbase.h>
+#include <locale.h>
+
+CComModule _Module;
+
+#include <atlwin.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "Windows.h"
+#include "WinNT.h"
+#include <shellapi.h>
+#include "DownloadDialog.h"
+#include "DownloadHelper.h"
+#include "kernel.h"
+#include "sun_jkernel_DownloadManager.h"
+#include "sun_jkernel_Bundle.h"
+#include "sun_jkernel_Mutex.h"
+#include "sun_jkernel_BackgroundDownloader.h"
+#include <stdio.h>
+#include <windows.h>
+#include <conio.h>
+#include <tchar.h>
+#include <tchar.h>
+#include <sddl.h>
+#include <Aclapi.h>
+#include <strsafe.h>
+
+BOOL IsPlatformWindowsVista();
+
+#define BUFSIZE 4096
+
+#define JBROKERPIPE           "\\\\.\\pipe\\jbrokerpipe"
+#define JREMAINKEY              "SOFTWARE\\JavaSoft\\Java Runtime Environment"
+#define JRE_VERSION_REGISTRY_KEY    JREMAINKEY "\\" VERSION
+#define ReleaseAndClose(mutex) \
+        if (mutex != NULL) { \
+            ReleaseMutex(mutex);  \
+            CloseHandle(mutex); \
+            mutex = NULL; \
+        }
+
+#define KERNEL_DEBUG false
+
+// used to inform kernel that we believe it is running in high integrity
+#define JBROKER_KEY "-Dkernel.spawned.from.jbroker=true -Dkernel.background.download=false"
+
+// this is only available on Vista SDK, hard code it here for now
+#define LABEL_SECURITY_INFORMATION (0x00000010L)
+
+// The LABEL_SECURITY_INFORMATION SDDL SACL to be set for low integrity
+LPCSTR LOW_INTEGRITY_SDDL_SACL = "S:(ML;;NW;;;LW)";
+
+CDownloadDialog dlg;
+BOOL createDialog = TRUE;
+
+CComAutoCriticalSection m_csCreateDialog;
+
+typedef BOOL (WINAPI *LPFNInitializeSecurityDescriptor)(
+        PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD dwRevision);
+typedef BOOL (WINAPI *LPFNSetSecurityDescriptorDacl)(
+        PSECURITY_DESCRIPTOR pSecurityDescriptor, BOOL bDaclPresent, PACL pDacl,
+        BOOL bDaclDefaulted);
+
+typedef BOOL (WINAPI *LPFNConvertStringSecurityDescriptorToSecurityDescriptorA)(
+        LPCSTR StringSecurityDescriptor, DWORD StringSDRevision,
+        PSECURITY_DESCRIPTOR* SecurityDescriptor,
+        PULONG SecurityDescriptorSize);
+
+typedef BOOL (WINAPI *LPFNGetSecurityDescriptorSacl)(
+        PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbSaclPresent,
+        PACL* pSacl, LPBOOL lpbSaclDefaulted);
+
+typedef DWORD (WINAPI *LPFNSetSecurityInfo)(HANDLE handle,
+        SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo,
+        PSID psidOwner, PSID psidGroup, PACL pDacl, PACL pSacl);
+
+BOOL APIENTRY DllMain( HANDLE hModule,
+                       DWORD  ul_reason_for_call,
+                       LPVOID lpReserved
+                     )
+{
+    return TRUE;
+}
+
+char* getStringPlatformChars(JNIEnv* env, jstring jstr) {
+    char *result = NULL;
+    size_t len;
+    const jchar* utf16 = env->GetStringChars(jstr, NULL);
+    len = wcstombs(NULL, utf16, env->GetStringLength(jstr) * 4) + 1;
+    if (len == -1)
+        return NULL;
+    result = (char*) malloc(len);
+    if (wcstombs(result, utf16, len) == -1)
+        return NULL;
+    env->ReleaseStringChars(jstr, utf16);
+    return result;
+}
+
+bool SetObjectToLowIntegrity ( HANDLE hObject,
+        SE_OBJECT_TYPE type = SE_KERNEL_OBJECT ) {
+
+    bool bRet = false;
+    DWORD dwErr = ERROR_SUCCESS;
+    PSECURITY_DESCRIPTOR pSD = NULL;
+    PACL pSacl = NULL;
+    BOOL fSaclPresent = FALSE;
+    BOOL fSaclDefaulted = FALSE;
+
+    // initialize function pointers
+    HMODULE hModule = LoadLibrary("Advapi32.dll");
+
+    // ConvertStringSecurityDescriptorToSecurityDescriptorA
+    LPFNConvertStringSecurityDescriptorToSecurityDescriptorA
+            lpfnConvertStringSecurityDescriptorToSecurityDescriptorA =
+            (LPFNConvertStringSecurityDescriptorToSecurityDescriptorA)GetProcAddress(
+            hModule,
+            "ConvertStringSecurityDescriptorToSecurityDescriptorA");
+
+    // GetSecurityDescriptorSacl
+    LPFNGetSecurityDescriptorSacl lpfnGetSecurityDescriptorSacl =
+            (LPFNGetSecurityDescriptorSacl)GetProcAddress(hModule,
+            "GetSecurityDescriptorSacl");
+
+    // SetSecurityInfo
+    LPFNSetSecurityInfo lpfnSetSecurityInfo =
+            (LPFNSetSecurityInfo)GetProcAddress(hModule,
+            "SetSecurityInfo");
+
+    if (lpfnConvertStringSecurityDescriptorToSecurityDescriptorA == NULL ||
+            lpfnGetSecurityDescriptorSacl == NULL ||
+            lpfnSetSecurityInfo == NULL) {
+        if (KERNEL_DEBUG) {
+            printf("Fail to initialize function pointer\n");
+        }
+        FreeLibrary(hModule);
+        return FALSE;
+    }
+
+    // Set object to lower integrity
+    if ( lpfnConvertStringSecurityDescriptorToSecurityDescriptorA(
+            LOW_INTEGRITY_SDDL_SACL, SDDL_REVISION_1, &pSD, NULL ) ) {
+        if ( lpfnGetSecurityDescriptorSacl(
+                pSD, &fSaclPresent, &pSacl, &fSaclDefaulted ) ) {
+            dwErr = lpfnSetSecurityInfo(
+                    hObject, type, LABEL_SECURITY_INFORMATION,
+                    NULL, NULL, NULL, pSacl );
+
+            bRet = (ERROR_SUCCESS == dwErr);
+        }
+
+        LocalFree( pSD );
+    }
+
+    FreeLibrary(hModule);
+    return bRet;
+}
+
+
+JNIEXPORT jlong JNICALL Java_sun_jkernel_Mutex_createNativeMutex
+                                (JNIEnv *env , jclass cls, jstring id) {
+    SECURITY_ATTRIBUTES sa;
+    PSECURITY_DESCRIPTOR pSD = NULL;
+    BOOL saInitialized = FALSE;
+
+    // initialize function pointers
+    HMODULE hModule = LoadLibrary("Advapi32.dll");
+
+    // InitializeSecurityDescriptor
+    LPFNInitializeSecurityDescriptor lpfnInitializeSecurityDescriptor =
+            (LPFNInitializeSecurityDescriptor)GetProcAddress(hModule,
+            "InitializeSecurityDescriptor");
+
+    // SetSecurityDescriptorDacl
+    LPFNSetSecurityDescriptorDacl lpfnSetSecurityDescriptorDacl =
+            (LPFNSetSecurityDescriptorDacl)GetProcAddress(hModule,
+            "SetSecurityDescriptorDacl");
+
+    if (lpfnInitializeSecurityDescriptor != NULL &&
+            lpfnSetSecurityDescriptorDacl != NULL) {
+
+        // Initialize a security descriptor.
+        pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
+                SECURITY_DESCRIPTOR_MIN_LENGTH);
+        if (NULL == pSD) {
+            if (KERNEL_DEBUG) {
+                printf("LocalAlloc Error %u\n", GetLastError());
+            }
+            FreeLibrary(hModule);
+            return NULL;
+        }
+
+        if (!lpfnInitializeSecurityDescriptor(pSD,
+                SECURITY_DESCRIPTOR_REVISION)) {
+            if (KERNEL_DEBUG) {
+                printf("InitializeSecurityDescriptor Error %u\n", GetLastError());
+            }
+            FreeLibrary(hModule);
+            return NULL;
+
+        }
+        // Add the ACL to the security descriptor.
+        if (!lpfnSetSecurityDescriptorDacl(pSD,
+                TRUE,     // bDaclPresent flag
+                NULL,     // NULL DACL is assigned to the security descriptor,
+                // which allows all access to the object.
+                // This is to allow the mutex to be accessbile by
+                // all users;  The background downloader launched
+                // by the installer will be running as SYSTEM user;
+                // while other java process started by the current
+                // user will be running as the current username.
+                FALSE))   // not a default DACL
+        {
+            if (KERNEL_DEBUG) {
+                printf("SetSecurityDescriptorDacl Error %u\n",
+                        GetLastError());
+            }
+            FreeLibrary(hModule);
+            return NULL;
+        }
+
+        // Initialize a security attributes structure.
+        sa.nLength = sizeof (SECURITY_ATTRIBUTES);
+        sa.lpSecurityDescriptor = pSD;
+        sa.bInheritHandle = FALSE;
+
+        saInitialized = TRUE;
+        FreeLibrary(hModule);
+    }
+
+    HANDLE m = CreateMutex(saInitialized ? &sa : NULL, FALSE,
+            (LPCSTR) getStringPlatformChars(env, id));
+    if (m == NULL) {
+        if (KERNEL_DEBUG) {
+            printf("CreateMutex Error %u\n", GetLastError());
+        }
+    }
+
+    // set the mutex object to low integrity on vista, so the mutex
+    // can be accessed by different integrity level
+    if (IsPlatformWindowsVista()) {
+        if (!SetObjectToLowIntegrity(m)) {
+            if (KERNEL_DEBUG) {
+                printf("Fail to set Mutex object to low integrity\n");
+            }
+        }
+    }
+    return (jlong)m ;
+}
+
+
+HANDLE getMutexHandle(JNIEnv *env, jobject mutex) {
+    jfieldID handle = env->GetFieldID(env->GetObjectClass(mutex), "handle", "J");
+    return (HANDLE) env->GetLongField(mutex, handle);
+}
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_Mutex_acquire__I
+                                (JNIEnv *env, jobject mutex, jint timeout) {
+    HANDLE hmutex = getMutexHandle(env, mutex);
+    if (hmutex != NULL) {
+        int result = WaitForSingleObject(hmutex, timeout);
+        if (result == WAIT_ABANDONED)
+            result = WaitForSingleObject(hmutex, timeout);
+        return (result == WAIT_OBJECT_0);
+    }
+    else
+        return false;
+}
+
+void ThrowByName(JNIEnv *env, const char *name, const char *msg) {
+    jclass cls = env->FindClass(name);
+    /* if cls is NULL, an exception has already been thrown */
+    if (cls != NULL) {
+        env->ThrowNew(cls, msg);
+    }
+    /* free the local ref */
+    env->DeleteLocalRef(cls);
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_Mutex_acquire__
+        (JNIEnv *env, jobject mutex) {
+    if (!Java_sun_jkernel_Mutex_acquire__I(env, mutex, INFINITE)) {
+        // failed to acquire mutex, most likely because it was already disposed
+        ThrowByName(env, "java/lang/IllegalStateException",
+                "error acquiring mutex");
+    }
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_Mutex_release
+                                (JNIEnv *env, jobject mutex) {
+    HANDLE hmutex = getMutexHandle(env, mutex);
+    if (hmutex != NULL)
+        ReleaseMutex(hmutex);
+    else
+        ThrowByName(env, "java/lang/IllegalStateException",
+                "releasing disposed mutex");
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_Mutex_destroyNativeMutex
+        (JNIEnv *env, jobject mutex) {
+    HANDLE hmutex = getMutexHandle(env, mutex);
+    if (hmutex != NULL) {
+        Java_sun_jkernel_Mutex_release(env, mutex);
+        CloseHandle(hmutex);
+    }
+}
+
+void createDownloadWindowProc(LPVOID lpParameter) {
+    CDownloadDialog* pDlg = (CDownloadDialog *) lpParameter;
+
+    pDlg->delayedDoModal();
+
+    // dialog destroyed, need to create a new one next time
+    createDialog = TRUE;
+}
+
+
+void createDownloadWindow(LPVOID lpParameter) {
+    // Create a new thread for download window
+    DWORD dwThreadId = NULL;
+    ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) createDownloadWindowProc, lpParameter, 0, &dwThreadId);
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_DownloadManager_bundleInstallComplete
+    (JNIEnv *env, jclass dm) {
+    dlg.bundleInstallComplete();
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_DownloadManager_bundleInstallStart
+    (JNIEnv *env, jclass dm) {
+
+    dlg.bundleInstallStart();
+}
+
+typedef HRESULT (WINAPI *LPFNIEIsProtectedModeProcess)(BOOL *pbResult);
+
+BOOL isRunningIEProtectedMode() {
+
+    HMODULE hModule = NULL;
+    LPFNIEIsProtectedModeProcess lpfnIEIsProtectedModeProcess;
+
+    __try {
+        hModule = LoadLibrary("ieframe.dll");
+        if (hModule != NULL) {
+
+            lpfnIEIsProtectedModeProcess = (LPFNIEIsProtectedModeProcess)
+                GetProcAddress(hModule, "IEIsProtectedModeProcess");
+
+            if (lpfnIEIsProtectedModeProcess != NULL) {
+                BOOL bProtectedMode = FALSE;
+                HRESULT hr = lpfnIEIsProtectedModeProcess(&bProtectedMode);
+                if ( SUCCEEDED(hr) && bProtectedMode ) {
+                    // IE is running in protected mode
+                    return TRUE;
+                } else {
+                    // IE isn't running in protected mode
+                    return FALSE;
+                }
+            }
+        }
+    } __finally {
+        if (hModule != NULL) {
+            FreeLibrary(hModule);
+        }
+    }
+    return FALSE;
+}
+
+/* Return TRUE if current running platform is Windows Vista, FALSE otherwise */
+BOOL IsPlatformWindowsVista() {
+    static BOOL initialized = FALSE;
+    static BOOL isVista = FALSE;
+    OSVERSIONINFO  osvi;
+
+    if (initialized) {
+        return isVista;
+    }
+
+    // Initialize the OSVERSIONINFO structure.
+    ZeroMemory( &osvi, sizeof( osvi ) );
+    osvi.dwOSVersionInfoSize = sizeof( osvi );
+
+    GetVersionEx( &osvi );  // Assume this function succeeds.
+
+    if ( osvi.dwPlatformId == VER_PLATFORM_WIN32_NT &&
+        osvi.dwMajorVersion == 6 ) {
+        isVista = TRUE;
+    } else {
+        isVista = FALSE;
+    }
+
+    initialized = TRUE;
+
+    return isVista;
+}
+
+JNIEXPORT jboolean  JNICALL Java_sun_jkernel_DownloadManager_isIEProtectedMode
+    (JNIEnv *env, jclass dm) {
+
+    if (isRunningIEProtectedMode()) {
+        return TRUE;
+    }
+    return FALSE;
+}
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_DownloadManager_isWindowsVista
+    (JNIEnv *env, jclass dm) {
+
+    if (IsPlatformWindowsVista()) {
+        return TRUE;
+    }
+    return FALSE;
+}
+
+int sendMessageToBroker(const char * message) {
+        char ackString[1024];
+        HANDLE hp = INVALID_HANDLE_VALUE;
+
+        while (hp == INVALID_HANDLE_VALUE) {
+            hp = CreateNamedPipe(_T(JBROKERPIPE),
+                    PIPE_ACCESS_DUPLEX | FILE_FLAG_FIRST_PIPE_INSTANCE ,
+                    PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
+                    1, // number of pipes that can exist
+                    1024, // output buffer
+                    1024, // input buffer
+                    0, // timeout
+                    NULL); // security attributes
+
+            if (hp == INVALID_HANDLE_VALUE) {
+                DWORD err = GetLastError();
+                // we only allow one instance of the pipe; if the instance
+                // already exists, we will get ERROR_ACCESS_DENIED, which means
+                // some other process is using the pipe, so let's try again
+                if (err != ERROR_ACCESS_DENIED && err != ERROR_PIPE_BUSY) {
+                    // create pipe failed
+                    return 0;
+                }
+                // pipe instance might be in use, keep trying
+            }
+        }
+
+        // Wait for the client to connect; if it succeeds,
+        // the function returns a nonzero value. If the function
+        // returns zero, GetLastError returns ERROR_PIPE_CONNECTED.
+        BOOL fConnected = ConnectNamedPipe(hp, NULL) ?
+                TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
+
+        if (fConnected)
+        {
+                // Send message to the pipe server.
+                DWORD cbWritten;
+
+                BOOL fSuccess = WriteFile(
+                        hp,                  // pipe handle
+                        message,             // message
+                        (strlen(message)+1)*sizeof(char), // message length
+                        &cbWritten,             // bytes written
+                        NULL);                  // not overlapped
+
+                if (!fSuccess)
+                {
+                        // WriteFile failed
+                        CloseHandle(hp);
+                        return 0;
+                }
+
+                // wait for ack from server
+                DWORD cbRead;
+                TCHAR chBuf[BUFSIZE];
+
+                do
+                {
+                        // Read from the pipe.
+                        fSuccess = ReadFile(
+                                hp,    // pipe handle
+                                chBuf,    // buffer to receive reply
+                                BUFSIZE*sizeof(TCHAR),  // size of buffer
+                                &cbRead,  // number of bytes read
+                                NULL);    // not overlapped
+
+                        if (! fSuccess && GetLastError() != ERROR_MORE_DATA)
+                                break;
+
+                        sprintf(ackString, "%s", chBuf);
+
+
+                } while (!fSuccess);  // repeat loop if ERROR_MORE_DATA
+        }
+
+        CloseHandle(hp);
+
+        if (strcmp(ackString, "SUCCESS") == 0) {
+                // server completed move command successfully
+                return 1;
+        }
+
+        return 0;
+}
+
+int sendMoveMessageToBroker(const char * fromPath, const char * userHome) {
+    // Send move message
+    char * movecmd = "MOVEFILE";
+
+    char * msg = (char*)malloc((strlen(fromPath) + strlen(movecmd) +
+            strlen(userHome) + 3) * sizeof(char));
+
+    sprintf(msg, "%s*%s*%s", movecmd, fromPath, userHome);
+
+    return sendMessageToBroker(msg);
+}
+
+int sendMoveDirMessageToBroker(const char * fromPath, const char * userHome) {
+        // Send move dir message
+    char * movecmd = "MOVEDIR";
+
+    char * msg = (char*)malloc((strlen(fromPath) + strlen(movecmd) +
+            strlen(userHome) + 3) * sizeof(char));
+
+    sprintf(msg, "%s*%s*%s", movecmd, fromPath, userHome);
+
+    return sendMessageToBroker(msg);
+}
+
+
+int sendKillMessageToBroker() {
+        // Send move message
+        char * killcmd = "KILLBROKER";
+        return sendMessageToBroker(killcmd);
+}
+
+
+int sendPerformCompletionMessageToBroker(const char *javaHome) {
+    const char *cmd = "PERFORMCOMPLETION";
+
+    int result = sendMessageToBroker(cmd);
+
+    if (result)
+        sendKillMessageToBroker();
+    return result;
+}
+
+int getConstantInt(JNIEnv *env, jclass cls, const char *name) {
+    jfieldID handle = env->GetStaticFieldID(cls, name, "I");
+    return env->GetStaticIntField(cls, handle);
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_DownloadManager_displayError
+        (JNIEnv *env, jclass dm, jint code, jstring arg) {
+    int messageId = IDS_FATAL_ERROR;
+    int titleId = IDS_ERROR_CAPTION;
+    if (code == getConstantInt(env, dm, "ERROR_MALFORMED_BUNDLE_PROPERTIES"))
+        messageId = IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES;
+    else if (code == getConstantInt(env, dm, "ERROR_DOWNLOADING_BUNDLE_PROPERTIES"))
+        messageId = IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES;
+    else if (code == getConstantInt(env, dm, "ERROR_MALFORMED_URL"))
+        messageId = IDS_ERROR_MALFORMED_URL;
+    char message[BUFFER_SIZE];
+    char rawMessage[BUFFER_SIZE];
+    char title[BUFFER_SIZE];
+    ::LoadString(_Module.GetModuleInstance(), titleId, title, BUFFER_SIZE);
+    ::LoadString(_Module.GetModuleInstance(), messageId, rawMessage, BUFFER_SIZE);
+    if (arg != NULL) {
+        char *chars = getStringPlatformChars(env, arg);
+        sprintf(message, rawMessage, chars);
+    }
+    else
+        strcpy(message, rawMessage);
+
+    MessageBox(NULL, message, title, MB_OK|MB_TASKMODAL);
+}
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_DownloadManager_askUserToRetryDownloadOrQuit
+        (JNIEnv *env, jclass dm, jint code) {
+
+        int ret;
+        if (code == getConstantInt(env, dm, "ERROR_DISK_FULL")) {
+           ret = dlg.SafeMessageBox(IDS_DISK_FULL_ERROR,
+                                    IDS_DISK_FULL_ERROR_CAPTION,
+                                    IDS_ERROR_CAPTION,
+                                    DIALOG_ERROR_RETRYCANCEL);
+        } else {
+           ret = dlg.SafeMessageBox(IDS_DOWNLOAD_RETRY_TEXT,
+                                    IDS_DOWNLOAD_RETRY,
+                                    IDS_ERROR_CAPTION,
+                                    DIALOG_ERROR_RETRYCANCEL);
+        }
+        if (ret != IDRETRY) {
+                // user choose to exit, return 0
+                return JNI_FALSE;
+        }
+
+        // return 1 (retry the download)
+        return JNI_TRUE;
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_DownloadManager_startBackgroundDownloadWithBrokerImpl
+(JNIEnv *env, jclass dm, jstring command) {
+
+        char* szCommand = getStringPlatformChars(env, command);
+
+        // Send createprocess message
+        char * createproccmd = "STARTBACKGROUNDDOWNLOAD";
+
+        char * msg = (char*)malloc((strlen(createproccmd) + strlen(szCommand) + 2) * sizeof(char));
+
+        sprintf(msg, "%s*%s", createproccmd, szCommand);
+
+        sendMessageToBroker(msg);
+
+        free(szCommand);
+}
+
+
+void getParent(const TCHAR *path, TCHAR *dest) {
+    char* lastSlash = max(strrchr(path, '\\'), strrchr(path, '/'));
+    if (lastSlash == NULL) {
+        *dest = NULL;
+        return;
+    }
+    if (path != dest)
+        strcpy(dest, path);
+    *lastSlash = NULL;
+}
+
+
+bool createProcess(const TCHAR *path, const TCHAR *args) {
+    SHELLEXECUTEINFOA shInfo;
+
+    shInfo.cbSize = sizeof(SHELLEXECUTEINFOA);
+    shInfo.fMask = 0;
+    shInfo.hwnd = NULL;
+    shInfo.lpVerb = "runas";
+    shInfo.lpFile = path;
+    shInfo.lpParameters = args;
+    shInfo.lpDirectory = NULL;
+    shInfo.nShow = SW_NORMAL;
+    shInfo.hInstApp = NULL;
+
+    int result = (int) ::ShellExecuteExA(&shInfo);
+    // ShellExecute is documented to return >32 on success, but I'm consistently
+    // getting a return of 1 despite obviously successful results.  1 is not a
+    // documented return code from ShellExecute, and this may have something to
+    // do with the fact that we're using an undocumented verb in the first place
+    // ("runas").
+    return result > 32 || result == 1;
+}
+
+
+bool launchJBroker(const char *szJavaHome) {
+        char szPath[2048];
+        wsprintf(szPath, "%s\\bin\\jbroker.exe", szJavaHome);
+    return createProcess(szPath, NULL);
+}
+
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_DownloadManager_launchJBroker
+(JNIEnv *env, jclass dm, jstring javaHomePath) {
+        char* szJavaHome = getStringPlatformChars(env, javaHomePath);
+    bool result = launchJBroker(szJavaHome);
+        free(szJavaHome);
+    return result ? TRUE : FALSE;
+}
+
+
+bool isJBrokerRunning() {
+        HANDLE hMutex = NULL;
+        DWORD ret = 0;
+
+        if (isRunningIEProtectedMode()) {
+
+                // check if jbroker process is running
+                // Use OpenMutex since we have limited access rights.
+                // CreateMutex function will fail with ERROR_ACCESS_DENIED in protected mode
+                hMutex = OpenMutex(SYNCHRONIZE, FALSE, "SunJavaBrokerMutex");
+
+                ret = ::GetLastError();
+
+                if (hMutex != NULL) {
+                        CloseHandle(hMutex);
+                }
+
+                if (ret == ERROR_FILE_NOT_FOUND)
+                {
+                        // jbroker not running yet, launch it
+                        return FALSE;
+                }
+
+                return TRUE;
+
+        } else {
+                hMutex = ::CreateMutex(NULL, TRUE, "SunJavaBrokerMutex");
+
+                if ( (hMutex == NULL) || (::GetLastError() == ERROR_ALREADY_EXISTS)) {
+                        // jbroker already running
+                        if (hMutex != NULL) ::CloseHandle(hMutex);
+                        return TRUE;
+                }
+
+                if (hMutex != NULL) ::CloseHandle(hMutex);
+
+                return FALSE;
+        }
+}
+
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_DownloadManager_isJBrokerRunning
+(JNIEnv *env, jclass dm) {
+    return isJBrokerRunning() ? TRUE : FALSE;
+}
+
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_DownloadManager_moveDirWithBrokerImpl
+    (JNIEnv *env, jclass dm, jstring fromPath, jstring userHome) {
+
+    char* fromPathChars = getStringPlatformChars(env, fromPath);
+
+    char* userHomeChars = getStringPlatformChars(env, userHome);
+
+    int ret = sendMoveDirMessageToBroker(fromPathChars, userHomeChars);
+
+    free(fromPathChars);
+
+    free(userHomeChars);
+
+    if (ret == 0) {
+        return FALSE;
+    }
+    return TRUE;
+}
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_DownloadManager_moveFileWithBrokerImpl
+    (JNIEnv *env, jclass dm, jstring fromPath, jstring userHome) {
+
+    char* fromPathChars = getStringPlatformChars(env, fromPath);
+
+    char* userHomeChars = getStringPlatformChars(env, userHome);
+
+    int ret = sendMoveMessageToBroker(fromPathChars, userHomeChars);
+
+    free(fromPathChars);
+
+    free(userHomeChars);
+
+    if (ret == 0) {
+        return FALSE;
+    }
+    return TRUE;
+}
+
+/**
+ * Throw an exception with the last Windows error code if available.
+ */
+
+void ThrowByNameWithLastError(JNIEnv *env, char *exception, char* msg) {
+    char fullMsg[1024] = {0};
+    if (StringCbPrintf(fullMsg, 1024, "%s. Windows error: %d\n",
+        msg, GetLastError()) != S_OK) {
+
+        // Formatting failed: fall back to msg w/o error code
+        ThrowByName(env, exception, msg);
+    } else {
+        ThrowByName(env, exception, fullMsg);
+    }
+}
+
+/**
+ * Common code for "extra" compression or uncompression. If extra code
+ * not available do nothing but return false. If available, return true
+ * after locating the extra compression library at ".." and the defined
+ * path relative to the native library containing this method's code.
+ * If enabled, compress or uncompress the srcPath file into destpath,
+ * throwing exceptions for errors (see JNI routine docs below for details).
+ */
+
+jboolean extraCommon(BOOL docompress,
+        JNIEnv *env, jclass dm, jstring srcPath, jstring destPath) {
+#ifdef EXTRA_COMP_INSTALL_PATH
+    const char *operation = (docompress == true) ? "e" : "d";
+
+    // This should be shared with the deploy tree and should be defined
+    // in an implementation like LzmaAlone.h. However the deploy build
+    // doesn't exit yet wrt to this function pointer type.
+
+    typedef int (*EXTRACOMPTRTYPE) (int, const char**);
+
+    // Function pointer for invoking the encoder/decoder (uncompressor)
+    static volatile EXTRACOMPTRTYPE mptr = NULL;
+    // Volatile boolean becomes true when mptr init is finished
+
+// Stringifier macros to get the relative library path
+
+#define K_STRING(x) #x
+#define K_GETSTRING(x) K_STRING(x)
+
+    char *srcPathChars = getStringPlatformChars(env, srcPath);
+
+    if (srcPathChars == NULL) {
+        // TODO (for all throw calls). If the class&method are *reliably*
+        // reported to the user these message prefixes are silly.
+        ThrowByName(env, "java/io/IOException",
+            "Bundle.uncompress: GetStringPlatformChars failed");
+        return true;
+    }
+
+    char *destPathChars = getStringPlatformChars(env, destPath);
+    if (destPathChars == NULL) {
+        free(srcPathChars);
+        ThrowByName(env, "java/io/IOException",
+            "Bundle.uncompress: GetStringPlatformChars failed");
+        return true;
+    }
+    if (KERNEL_DEBUG) {
+        printf("LZMA: %s %s to %s\n", operation, srcPathChars, destPathChars);
+    }
+
+
+    // This loop avoids a lot of repetitious code for exception handling.
+    // If any loops are put inside this one be careful to properly
+    // handle exceptions within the inner loops.
+
+    do {
+
+        if (mptr == NULL) {
+
+            // Need to locate and link to the extra compression lib, which
+            // has a pathname relative to the directory containing the library
+            // containing this code, which is assumed to be one directory
+            // "below" the JRE base path. That is, the JRE base path is
+            // assumed to be ".." from the path of this library and then
+            // EXTRA_COMP_INSTALL_PATH from the JRE base path is expected to
+            // be the compression lib path.
+            // But this code is defensive and tries not to fail if the
+            // currently executing library is in ".". It will fail in a
+            // case like this if the extra compression lib path isn't
+            // "./EXTRA_CMP_INSTALL_PATH" (or just "EXTRA_CMP_INSTALL_PATH").
+            // Use macro magic to get the path macro as a string value.
+
+            const char *libRelativePath = K_GETSTRING(EXTRA_COMP_INSTALL_PATH);
+
+            // The max length the base JRE path can be to safely concatenate
+            // libRelativePath, a (possible) separator, and a null terminator.
+            int jreMaxPathLength = MAX_PATH - sizeof(libRelativePath) - 2;
+
+            TCHAR extraLibPath[MAX_PATH] = {0};
+            HMODULE kernel = GetModuleHandle("jkernel");
+            if (kernel != NULL) {
+                DWORD result = GetModuleFileName(kernel, extraLibPath,
+                    MAX_PATH-1);
+                if (result > 0) {
+                    // remove the name of this library (and maybe a
+                    // separator)
+                    getParent(extraLibPath, extraLibPath);
+                    if (extraLibPath[0] != NULL) {
+                        // There was a directory containing the library
+                        // (probably "<something or nothing\\>bin"), so
+                        // remove that to go up to the assumed JRE base path
+                        getParent(extraLibPath, extraLibPath);
+                    } else {
+                        ThrowByName(env, "java/io/IOException",
+                            "bundle uncompression: expected lib path component not found");
+                        break;
+                    }
+                    // This is effectively an assertion that the concat
+                    // below cannot overflow
+                    if (extraLibPath[0] != NULL) {
+                        // Current dir is not ".", so add a separator
+                        strcat(extraLibPath, "\\");
+                    }
+                    if ((strlen(extraLibPath) + 1) > jreMaxPathLength) {
+                        ThrowByName(env, "java/io/IOException",
+                            "bundle uncompression: JRE base pathname too long");
+                        break;
+                    }
+                    strcat(extraLibPath, libRelativePath);
+                } else {
+                    ThrowByName(env, "java/io/IOException",
+                        "bundle uncompression: GetModuleFileName failed");
+                    break;
+                }
+            } else {
+                ThrowByNameWithLastError(env, "java/io/IOException",
+                   "bundle uncompression: GetModuleHandle failed");
+                break;
+            }
+
+            // Load the library and develop a pointer to the decoder routine
+
+            if (KERNEL_DEBUG) {
+                printf("bundle uncompression: extra library path %s\n",
+                    extraLibPath);
+            }
+
+            HMODULE handle = LoadLibrary(extraLibPath);
+            if (handle == NULL) {
+                ThrowByNameWithLastError(env, "java/io/IOException",
+                    "bundle uncompression: LoadLibrary failed");
+                break;
+            }
+
+            // find the extra uncompression routine
+
+            mptr = (EXTRACOMPTRTYPE) GetProcAddress(handle,
+                "ExtraCompressionMain");
+
+            if (mptr == NULL) {
+                ThrowByNameWithLastError(env, "java/io/IOException",
+                    "bundle uncompression: GetProcAddress failed");
+                break;
+            }
+        }
+
+        // Create the arguments for the decoder
+        // Decoder options must go *between* the "d" argument and the
+        // source path arguments and don't forget to keep the 1st arg to
+        // (*mptr) the same as the number of elements of args.
+        const char *args[] = {
+            "", // the shared lib makes no attempt access it's "command name"
+            operation,
+
+            // Special decoder/encoder switch strings would go here
+
+            // For example: "-d24", to set the dictionary size to 16MB
+
+            "-q", // Suppress banner msg output
+
+            // No special option switch strings after here
+
+            srcPathChars,
+            destPathChars
+        };
+        int argc = sizeof(args) / sizeof(const char *);
+        if ((*mptr)(argc, args) != 0) {
+            if (KERNEL_DEBUG) {
+                printf("uncompress lib call failed with args: ");
+                for (int i = 0; i < argc; i++) {
+                    printf("%s", args[i]);
+                }
+                printf("\n");
+            }
+            ThrowByName(env, "java/io/IOException",
+                "bundle uncompression: uncompression failed");
+            break;
+        }
+    } while (false);
+
+    free(srcPathChars);
+    free(destPathChars);
+    return TRUE;
+#else
+    if (KERNEL_DEBUG) {
+        printf("LZMA not compiled in!\n");
+    }
+
+    return FALSE;
+#endif // EXTRA_COMP_INSTALL_PATH
+}
+
+/**
+ * Compress file sourcePath with "extra" algorithm (e.g. 7-Zip LZMA)
+ * if available, put the compressed data into file destPath and
+ * return true. If extra compression is not available do nothing
+ * with destPath and return false;
+ * @param srcPath the path of the uncompressed file
+ * @param destPath the path of the compressed file, if used
+ * @return true if the extra algorithm was used and destPath created
+ *
+ * @throws IOException if the extra compression code should be available
+ *     but cannot be located or linked to, the destination file already
+ *     exists or cannot be opened for writing, or the compression fails
+ */
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_Bundle_extraCompress
+        (JNIEnv *env, jclass dm, jstring srcPath, jstring destPath) {
+    return extraCommon(true, env, dm, srcPath, destPath);
+}
+
+/**
+ * Uncompress file sourcePath with "extra" algorithm (e.g. 7-Zip LZMA)
+ * if available, put the uncompressed data into file destPath and
+ * return true. If if the extra algorithm is not available, leave the
+ * destination path unchanged and return false;
+ * @param srcPath the path of the file having extra compression
+ * @param destPath the path of the uncompressed file
+ * @return true if the extra algorithm was used
+ *
+ * @throws IOException if the extra uncompression code should be available
+ *     but cannot be located or linked to, the destination file already
+ *     exists or cannot be opened for writing, or the uncompression fails
+ */
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_Bundle_extraUncompress
+        (JNIEnv *env, jclass dm, jstring srcPath, jstring destPath) {
+    return extraCommon(false, env, dm, srcPath, destPath);
+}
+
+
+JNIEXPORT void JNICALL Java_sun_jkernel_DownloadManager_addToTotalDownloadSize
+    (JNIEnv *env, jclass dm, jint size) {
+    dlg.addToTotalContentLength(size);
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_DownloadManager_downloadFromURLImpl
+    (JNIEnv *env, jclass dm, jstring url, jobject file, jstring name,
+        jboolean showProgress) {
+    jclass object = env->FindClass("java/lang/Object");
+    jmethodID toString = env->GetMethodID(object, "toString", "()Ljava/lang/String;");
+    jstring urlString = (jstring) env->CallObjectMethod(url, toString);
+    char* urlChars = getStringPlatformChars(env, urlString);
+    if (KERNEL_DEBUG) {
+        printf("Kernel downloadFromURL: %s\n", urlChars);
+    }
+    jstring fileString = (jstring) env->CallObjectMethod(file, toString);
+    char* fileChars = getStringPlatformChars(env, fileString);
+    char* nameChars = getStringPlatformChars(env, name);
+
+    JavaVM *jvm;
+    env->GetJavaVM(&jvm);
+
+    __try
+    {
+
+        m_csCreateDialog.Lock();
+        if (createDialog && showProgress) {
+            // create download progress dialog in a new thread
+            dlg.setJavaVM(jvm);
+            createDownloadWindow(&dlg);
+            createDialog = FALSE;
+        }
+
+    }
+    __finally
+    {
+        m_csCreateDialog.Unlock();
+    }
+
+    DownloadHelper dh;
+
+    dh.setJavaVM(jvm);
+    dh.setURL(urlChars);
+    dh.setFile(fileChars);
+    dh.setNameText((char*) nameChars);
+    dh.setShowProgressDialog(showProgress);
+    dh.setDownloadDialog(&dlg);
+
+    if (dh.doDownload() != S_OK) {
+        // remove incomplete file
+        int ret = DeleteFile(fileChars);
+    }
+
+    free(urlChars);
+    free(fileChars);
+    free(nameChars);
+}
+
+
+void error(char* msg) {
+    MessageBox(NULL, msg, "Java Error", MB_OK);
+}
+
+
+// Replace the dest file with the src file.  Returns zero on success, Windows
+// error code otherwise.
+int replace(TCHAR* fullDest, TCHAR* fullSrc) {
+    struct _stat stat;
+    int result = _stat(fullSrc, &stat);
+    if (result == 0) {
+        DeleteFile(fullDest);
+        if (MoveFile(fullSrc, fullDest))
+            return 0;
+        else
+            return GetLastError();
+    }
+    else
+        return ENOENT; // src file not found
+}
+
+
+// Replace the dest file with the src file, where both paths are relative to
+// the specified root.  Returns zero on success, Windows error code otherwise.
+int replaceRelative(TCHAR* root, TCHAR* dest, TCHAR* src) {
+    TCHAR fullDest[MAX_PATH];
+    TCHAR fullSrc[MAX_PATH];
+    strcpy(fullDest, root);
+    strcat(fullDest, dest);
+    strcpy(fullSrc, root);
+    strcat(fullSrc, src);
+    return replace(fullDest, fullSrc);
+}
+
+
+// Atomically deletes a file tree.  Returns zero on success, Windows
+// error code otherwise.
+int deleteAll(TCHAR* root) {
+    TCHAR tmp[MAX_PATH];
+    if (strlen(root) + 5 > MAX_PATH)
+        return ERROR_BUFFER_OVERFLOW;
+    strcpy(tmp, root);
+    strcat(tmp, ".tmp");
+    struct _stat stat;
+    int result = _stat(tmp, &stat);
+    if (result == 0) {
+        result = !deleteAll(tmp);
+        if (result)
+            return result;
+    }
+    if (!MoveFile(root, tmp))
+        return GetLastError();
+    struct _SHFILEOPSTRUCTA fileOp;
+    memset(&fileOp, NULL, sizeof(fileOp));
+    fileOp.wFunc = FO_DELETE;
+    TCHAR pFrom[MAX_PATH + 1];
+    strcpy(pFrom, tmp);
+    pFrom[strlen(pFrom) + 1] = NULL; // extra null to signify that there is only one file in the list
+    fileOp.pFrom = pFrom;
+    fileOp.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
+    return SHFileOperation(&fileOp);
+}
+
+
+// moves all file with "wait='true'" specified in bundles.xml into their final
+// locations.  These files are stored under lib/bundles/tmp, e.g. lib/meta-index
+// is stored at lib/bundles/tmp/lib/meta-index.
+// relativePath is the current relative path we are searching (e.g. "lib" for the
+// example above), which begins as the empty string.
+int moveDelayedFiles(TCHAR* javaHome, TCHAR* relativePath) {
+    TCHAR src[MAX_PATH];
+    TCHAR* tmp = "lib\\bundles\\tmp";
+    if (strlen(javaHome) + strlen(relativePath) + strlen(tmp) > MAX_PATH) {
+        error("Path too long.");
+        return ERROR_BUFFER_OVERFLOW;
+    }
+    strcpy(src, javaHome);
+    strcat(src, tmp);
+    if (relativePath[0] != NULL) {
+        strcat(src, "\\");
+        strcat(src, relativePath);
+    }
+
+    struct _stat stat;
+    int result = _stat(src, &stat);
+    if (result == 0) {
+        if (stat.st_mode & _S_IFDIR) { // is a directory, loop through contents
+            strcat(src, "\\*");
+            struct _WIN32_FIND_DATAA file;
+            HANDLE findHandle = FindFirstFile(src, &file);
+            if (findHandle != INVALID_HANDLE_VALUE) {
+                do {
+                    if (file.cFileName[0] != '.') {
+                        char child[MAX_PATH];
+                        strcpy(child, relativePath);
+                        strcat(child, "\\");
+                        strcat(child, file.cFileName);
+                        moveDelayedFiles(javaHome, child);
+                    }
+                }
+                while (FindNextFile(findHandle, &file) != 0);
+                FindClose(findHandle);
+            }
+        }
+        else { // normal file, move into place
+            if (strcmp(relativePath, "\\finished")) {
+                TCHAR dest[MAX_PATH];
+                strcpy(dest, javaHome);
+                strcat(dest, relativePath);
+
+                DeleteFile(dest); // just in case; ignore failures
+                if (MoveFile(src, dest))
+                    return 0;
+                else
+                    return GetLastError();
+            }
+        }
+    }
+    return result;
+}
+
+
+// activates Class Data Sharing
+void activateCDS(const char *javaHome) {
+    char java[MAX_PATH];
+    strcpy(java, javaHome);
+    strcat(java, "bin\\javaw.exe");
+
+    STARTUPINFO si;
+    PROCESS_INFORMATION pi;
+    ZeroMemory(&si, sizeof(si));
+    si.cb = sizeof(si);
+    ZeroMemory(&pi, sizeof(pi));
+    const char *args = " -Xshare:dump";
+    const int argLength = 13;
+    char commandLine[MAX_PATH + argLength + 2];
+    strcpy(commandLine, "\"");
+    strcat(commandLine, java);
+    strcat(commandLine, "\"");
+    strcat(commandLine, args);
+    if (KERNEL_DEBUG)
+        printf("Exec: %s\n", commandLine);
+    if (CreateProcess(java, commandLine, NULL, NULL, FALSE, 0,
+            NULL, NULL, &si, &pi)) {
+        CloseHandle(pi.hProcess);
+        CloseHandle(pi.hThread);
+    }
+    else
+        printf("Error initializing Class Data Sharing: %d", GetLastError());
+}
+
+typedef BOOL (*LPFNInstallJQS)();
+
+// activates the Java Quickstart Service
+void activateJQS(HMODULE hModule) {
+    LPFNInstallJQS lpfnInstallJQS;
+
+    if (hModule != NULL) {
+        lpfnInstallJQS = (LPFNInstallJQS)GetProcAddress(hModule, "InstallJQS");
+        if (lpfnInstallJQS != NULL) {
+            if ((lpfnInstallJQS)() == false && KERNEL_DEBUG) {
+                printf("InstallJQS returned FALSE\n");
+            }
+        }
+    }
+}
+
+// determines JAVA_HOME and stores it in the specified buffer.  Returns true on success.
+BOOL getJavaHome(char* buffer, int bufferSize) {
+    HMODULE kernel = GetModuleHandle("jkernel");
+    if (kernel != NULL) {
+        DWORD result = GetModuleFileName(kernel, buffer, bufferSize);
+        if (result > 0) {
+            getParent(buffer, buffer); // remove "jkernel.dll"
+            if (buffer[0] != NULL)
+                getParent(buffer, buffer); // remove "bin"
+            if (buffer[0] != NULL) {
+                strcat(buffer, "\\");
+                return TRUE;
+            }
+        }
+    }
+    return FALSE;
+}
+
+typedef unsigned int (WINAPI *LPFNPostPing)(LPVOID err);
+HANDLE PostPing(HMODULE hModule, char* fname, DWORD err)
+{
+    LPFNPostPing lpfnPostPing;
+    HANDLE hThread = NULL;
+    lpfnPostPing = (LPFNPostPing)GetProcAddress(hModule, fname);
+    if (lpfnPostPing != NULL) {
+        printf("############# ERROR CODE: %d\n", err);
+        hThread = (HANDLE)_beginthreadex(NULL, 0, lpfnPostPing,
+                                             (LPVOID)err, 0, NULL);
+        if (hThread == NULL)
+            lpfnPostPing((LPVOID)err);
+    }
+    return hThread;
+}
+
+void postPingAndWait(char* fname, DWORD err) {
+    TCHAR path[MAX_PATH];
+    if (getJavaHome(path, MAX_PATH)) {
+        strcat(path, "bin\\regutils.dll");
+        HANDLE hThread = NULL;
+        HMODULE hModule = LoadLibrary(path);
+        if (hModule != NULL) {
+            hThread = PostPing(hModule, fname, err);
+            if (hThread != NULL) {
+                DWORD dwRet = 0;
+                WaitForSingleObject(hThread, 60*1000);
+                GetExitCodeThread(hThread, &dwRet);
+                CloseHandle(hThread);
+            }
+        }
+    }
+    else
+        printf("error determining JAVA_HOME for ping\n");
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_DownloadManager_postDownloadError
+        (JNIEnv *env, jclass dm, jint error) {
+    postPingAndWait("PostKernelDLComp", error);
+}
+
+JNIEXPORT void JNICALL Java_sun_jkernel_DownloadManager_postDownloadComplete
+        (JNIEnv *env, jclass dm) {
+    Java_sun_jkernel_DownloadManager_postDownloadError(env, dm, ERROR_SUCCESS);
+}
+
+bool spawnedFromJBroker() {
+    return strstr(GetCommandLine(), JBROKER_KEY) != NULL;
+}
+
+
+// Determines if we have sufficient access to go ahead and perform completion.
+// This is true either if we are not on Vista (in which case we can't elevate
+// privileges anyway and have to hope for the best) or if we are on Vista and
+// running at High integrity level.
+bool highIntegrity() {
+    if (!IsPlatformWindowsVista())
+        return TRUE;
+    else {
+        // directly determining this would require access to Vista-specific
+        // APIs, which aren't supported by our current build configurations.
+        // Instead we look for the presence of a flag on the command line to
+        // indicate that we were launched by the jbroker process.  This is
+        // actually safer, as it prevents us from re-launching another JRE in
+        // the event that we somehow didn't end up with high integrity.
+        return spawnedFromJBroker();
+    }
+}
+
+JNIEXPORT jint JNICALL Java_sun_jkernel_DownloadManager_getCurrentProcessId
+        (JNIEnv *env, jclass dm) {
+    return (jint) GetCurrentProcessId();
+}
+
+JNIEXPORT jstring JNICALL Java_sun_jkernel_DownloadManager_getVisitorId0
+        (JNIEnv *env, jclass dm) {
+    CRegKey swKey, jsKey, juKey, pKey;
+    if (swKey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE", KEY_READ) != ERROR_SUCCESS){
+        return NULL;
+    }
+
+    if (jsKey.Open(swKey, "JavaSoft", KEY_READ) != ERROR_SUCCESS){
+        return NULL;
+    }
+
+    if (juKey.Open(jsKey, "Java Update", KEY_READ) != ERROR_SUCCESS){
+        return NULL;
+    }
+
+    if (pKey.Open(juKey, "Policy", KEY_READ) != ERROR_SUCCESS){
+        return NULL;
+    }
+
+    DWORD dwCount = BUFSIZE;
+    char* keyValue = new char[BUFSIZE];
+    if (pKey.QueryValue(keyValue, "VisitorId", &dwCount) != ERROR_SUCCESS){
+        return NULL;
+    }
+    jstring visitorId = env->NewStringUTF(keyValue);
+
+    return visitorId;
+}
+
+
+JNIEXPORT jstring JNICALL Java_sun_jkernel_DownloadManager_getUrlFromRegistry
+        (JNIEnv *env, jclass dm) {
+
+    CRegKey swKey, jsKey;
+    if (swKey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE", KEY_READ) != ERROR_SUCCESS){
+        return NULL;
+    }
+
+    if (jsKey.Open(swKey, "JavaSoft", KEY_READ) != ERROR_SUCCESS){
+        return NULL;
+    }
+
+    DWORD dwCount = BUFSIZE;
+        char * keyValue = new char[BUFSIZE];
+    if (jsKey.QueryValue(keyValue, "KernelDownloadUrl", &dwCount) != ERROR_SUCCESS){
+        return NULL;
+    }
+
+    jstring downloadKeyValue = env->NewStringUTF(keyValue);
+
+    return downloadKeyValue;
+}
+
+
+
+jboolean getBooleanRegistryKey(char *name, jboolean defaultValue) {
+    // Check DWORD registry key
+    // HKEY_LOCAL_MACHINE/Software/JavaSoft/<name>
+
+    CRegKey swKey, jsKey;
+    if (swKey.Open(HKEY_LOCAL_MACHINE, "SOFTWARE", KEY_READ) != ERROR_SUCCESS){
+        return NULL;
+    }
+
+    if (jsKey.Open(swKey, "JavaSoft", KEY_READ) != ERROR_SUCCESS){
+        return NULL;
+    }
+
+    DWORD dwValue = 0;
+    if (jsKey.QueryValue(dwValue, name) != ERROR_SUCCESS){
+
+        // Key does not exist, will return default value
+        return defaultValue;
+    }
+
+    return dwValue != 0;
+}
+
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_BackgroundDownloader_getBackgroundDownloadKey
+        (JNIEnv *env, jclass dm) {
+    return getBooleanRegistryKey("KernelBackgroundDownload", TRUE);
+}
+
+
+JNIEXPORT jboolean JNICALL Java_sun_jkernel_DownloadManager_getDebugKey
+        (JNIEnv *env, jclass dm) {
+    return getBooleanRegistryKey("KernelDebug", FALSE);
+}
+
+
+// Called by the launcher before the JVM starts.  If all kernel bundles have been
+// downloaded, this function performs various post-download cleanups such as
+// moving the merged rt.jar into place.  At the end of cleanup, the JRE should
+// be indistinguishable from the non-kernel JRE.
+void preJVMStart() {
+    char rawMsg[BUFFER_SIZE];
+    char msg[BUFFER_SIZE];
+    HMODULE kernel = GetModuleHandle("jkernel");
+    if (kernel != NULL) {
+        TCHAR javaHome[MAX_PATH];
+        DWORD result = GetModuleFileName(kernel, javaHome, MAX_PATH);
+        if (result > 0) {
+            getParent(javaHome, javaHome); // remove "jkernel.dll"
+            if (javaHome[0] != NULL)
+                getParent(javaHome, javaHome); // remove "bin"
+            if (javaHome[0] != NULL) {
+                // should now be pointing to correct java.home
+                strcat(javaHome, "\\");
+                bool jbroker = spawnedFromJBroker();
+                HANDLE file;
+                TCHAR rt[MAX_PATH];
+                strcpy(rt, javaHome);
+                strcat(rt, "lib\\rt.jar");
+                HANDLE startMutex = CreateMutex(NULL, FALSE, "jvmStart");
+                if (!jbroker) { // else mutex is already held by the pre-jbroker JVM
+                    if (KERNEL_DEBUG)
+                        printf("Locking startMutex\n");
+                    WaitForSingleObject(startMutex, INFINITE);
+                    if (KERNEL_DEBUG)
+                        printf("Locked startMutex\n");
+                    // open rt.jar for reading.  This prevents other JREs from being
+                    // able to acquire a write lock on rt.jar, which is used as a test
+                    // to ensure that no other JREs are running.
+                    // The failure to close the file handle is intentional -- if we
+                    // close it, there will be a brief window between the close and
+                    // when the JRE reopens it during which another jre could get
+                    // a write lock on it, hosing us.
+                    file = CreateFile(rt, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL);
+                    if (file == INVALID_HANDLE_VALUE) {
+                        ReleaseAndClose(startMutex);
+                        return;
+                    }
+                    if (KERNEL_DEBUG)
+                        printf("Opened rt.jar for reading\n");
+                }
+                TCHAR finished[MAX_PATH];
+                TCHAR* finishedPath = "lib\\bundles\\tmp\\finished";
+                if (strlen(javaHome) + strlen(finishedPath) < MAX_PATH) {
+                    strcpy(finished, javaHome);
+                    strcat(finished, finishedPath);
+                    struct _stat finishedStat;
+                    result = _stat(finished, &finishedStat);
+                    if (result == 0) { // JRE has been fully downloaded but not yet cleaned up
+                        if (KERNEL_DEBUG)
+                            printf("Beginning completion.\n");
+                        if (!jbroker)
+                            CloseHandle(file);
+                        if (highIntegrity()) {
+                            // attempt to open rt.jar for exclusive write access -- if this succeeds,
+                            // we know no other JREs are running
+                            file = CreateFile(rt, GENERIC_WRITE, NULL, NULL, OPEN_EXISTING, NULL, NULL);
+                            if (file == INVALID_HANDLE_VALUE) {
+                                // must be another JRE running...
+                                ReleaseAndClose(startMutex);
+                                return;
+                            }
+                            if (KERNEL_DEBUG)
+                                printf("Opened rt.jar for writing.\n");
+                            CloseHandle(file);
+                            if (KERNEL_DEBUG)
+                                printf("Closed rt.jar.\n");
+                            int result = replaceRelative(javaHome, "lib\\rt.jar",
+                                    "lib\\bundles\\tmp\\merged-rt.jar");
+                            if (result != 0 && result != ENOENT) {
+                                ::LoadString(_Module.GetModuleInstance(), IDS_FILE_UPDATE_ERROR, rawMsg, BUFFER_SIZE);
+                                wsprintf(msg, rawMsg, javaHome, "lib\\rt.jar");
+                                error(msg);
+                                ReleaseAndClose(startMutex);
+                                return;
+                            }
+                            result = replaceRelative(javaHome, "lib\\resources.jar",
+                                    "lib\\bundles\\tmp\\merged-resources.jar");
+                            if (result != 0 && result != ENOENT) {
+                                ::LoadString(_Module.GetModuleInstance(), IDS_FILE_UPDATE_ERROR, rawMsg, BUFFER_SIZE);
+                                wsprintf(msg, rawMsg, javaHome, "lib\\resources.jar");
+                                error(msg);
+                                ReleaseAndClose(startMutex);
+                                return;
+                            }
+
+                            TCHAR bundles[MAX_PATH];
+                            strcpy(bundles, javaHome);
+                            strcat(bundles, "lib\\bundles");
+                            if (moveDelayedFiles(javaHome, "")) {
+                                ::LoadString(_Module.GetModuleInstance(), IDS_FILE_UPDATE_ERROR, msg, BUFFER_SIZE);
+                                error(msg);
+                                ReleaseAndClose(startMutex);
+                                return;
+                            }
+
+                            TCHAR kernel[MAX_PATH];
+                            strcpy(kernel, javaHome);
+                            strcat(kernel, "bin\\kernel");
+                            result = deleteAll(kernel);
+                            if (result != 0 && result != ENOENT) {
+                                ::LoadString(_Module.GetModuleInstance(), IDS_FILE_DELETE_ERROR, rawMsg, BUFFER_SIZE);
+                                wsprintf(msg, rawMsg, kernel);
+                                error(msg);
+                                ReleaseAndClose(startMutex);
+                                return;
+                            }
+
+                            if (deleteAll(bundles)) {
+                                // fail silently, CR #6643218
+                                printf("deleteAll failed!\n");
+                                ReleaseAndClose(startMutex);
+                                return;
+                            }
+
+                            TCHAR kernelMap[MAX_PATH];
+                            strcpy(kernelMap, javaHome);
+                            strcat(kernelMap, "lib\\kernel.map");
+                            result = deleteAll(kernelMap);
+                            if (result != 0 && result != ENOENT) {
+                                ::LoadString(_Module.GetModuleInstance(), IDS_FILE_DELETE_ERROR, rawMsg, BUFFER_SIZE);
+                                wsprintf(msg, rawMsg, kernelMap);
+                                error(msg);
+                                ReleaseAndClose(startMutex);
+                                return;
+                            }
+
+                            strcpy(rt, javaHome);
+                            strcat(rt, "bin\\regutils.dll");
+                            HANDLE hThread = NULL;
+                            HMODULE hModule = LoadLibrary(rt);
+                            if (hModule != NULL)
+                                hThread = PostPing(hModule, "PostKernelComp", ERROR_SUCCESS);
+                            if (KERNEL_DEBUG)
+                                printf("Activating JQS.\n");
+                            activateJQS(hModule);
+
+                            if (KERNEL_DEBUG)
+                                printf("Activating CDS.\n");
+                            activateCDS(javaHome);
+
+                            if (hThread != NULL) {
+                                DWORD dwRet = 0;
+                                WaitForSingleObject(hThread, 60*1000);
+                                GetExitCodeThread(hThread, &dwRet);
+                                CloseHandle(hThread);
+                            }
+                            if (hModule != NULL)
+                                FreeLibrary(hModule);
+                        } else {
+                            bool jbroker = isJBrokerRunning();
+                            if (!jbroker) {
+                                // remove trailing slash
+                                javaHome[strlen(javaHome) - 1] = 0;
+                                jbroker = launchJBroker(javaHome);
+                                if (!jbroker) {
+                                    ::LoadString(_Module.GetModuleInstance(),
+                                                IDS_JBROKER_ERROR,
+                                                msg,
+                                                BUFFER_SIZE);
+                                    error(msg);
+                                }
+                            }
+                            if (jbroker)
+                                sendPerformCompletionMessageToBroker(javaHome);
+                        }
+                    }
+                }
+                if (KERNEL_DEBUG)
+                    printf("Releasing startMutex.\n");
+                ReleaseAndClose(startMutex);
+            } else {
+                ::LoadString(_Module.GetModuleInstance(), IDS_JAVA_HOME_ERROR, msg, BUFFER_SIZE);
+                error(msg);
+            }
+        } else {
+            ::LoadString(_Module.GetModuleInstance(), IDS_KERNEL_HOME_ERROR, msg, BUFFER_SIZE);
+            error(msg);
+        }
+    } else {
+        ::LoadString(_Module.GetModuleInstance(), IDS_KERNEL_HOME_ERROR, msg, BUFFER_SIZE);
+        error(msg);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel.def	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,28 @@
+;
+; Copyright 2008 - 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.  Sun designates this
+; particular file as subject to the "Classpath" exception as provided
+; by Sun 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 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.
+;
+
+LIBRARY jkernel
+EXPORTS
+   preJVMStart @1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel.h	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+void preJVMStart();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,198 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+#include "version.rc"
+
+#include "resource.h"
+#define APSTUDIO_READONLY_SYMBOLS
+#include "afxres.h"
+#undef APSTUDIO_READONLY_SYMBOLS
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+IDI_JAVA                ICON      DISCARDABLE     "graphics\\java-icon.ico"
+IDI_MASTHEAD            BITMAP    DISCARDABLE     "graphics\\masthead.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+// Include foreign resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Japanese resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
+#ifdef _WIN32
+LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
+#pragma code_page(932)
+#endif //_WIN32
+#include "kernel_ja.rc"
+#endif	  // Japanese resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Chinese (P.R.C.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS)
+#ifdef _WIN32
+LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
+#pragma code_page(936)
+#endif //_WIN32
+#include "kernel_zh.rc"
+#endif	  // Chinese (P.R.C.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Korean resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_KOR)
+#ifdef _WIN32
+LANGUAGE LANG_KOREAN, SUBLANG_DEFAULT
+#pragma code_page(949)
+#endif //_WIN32
+#include "kernel_ko.rc"
+#endif	  // Korean resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Chinese (Taiwan) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHT)
+#ifdef _WIN32
+LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
+#pragma code_page(950)
+#endif //_WIN32
+#include "kernel_zh_TW.rc"
+#endif	  // Chinese (Taiwan) resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+#include "kernel_de.rc"
+#endif	  // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Spanish (Castilian) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESP)
+#ifdef _WIN32
+LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+#include "kernel_es.rc"
+#endif	  // Spanish (Castilian) resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// French (France) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA)
+#ifdef _WIN32
+LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+#include "kernel_fr.rc"
+#endif	  // French (France) resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Italian (Italy) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
+#ifdef _WIN32
+LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+#include "kernel_it.rc"
+#endif	  // Italian (Italy) resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// Swedish resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_SVE)
+#ifdef _WIN32
+LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL
+#pragma code_page(1252)
+#endif //_WIN32
+#include "kernel_sv.rc"
+#endif	  // Swedish resources
+/////////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+#include "kernel_en.rc"
+#endif	  // English resources
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_de.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Zusätzliche Komponenten erforderlich"
+EXSTYLE WS_EX_APPWINDOW
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 4, 220, 30
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "Abbrechen",  2, 285, 100, 46, 14
+END
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "Wenn Sie die Installation zusätzlicher Komponenten, die für die Anwendung erforderlich sind, abbrechen, wird die Anwendung möglicherweise geschlossen.\n\nMöchten Sie die Installation zusätzlicher Komponenten wirklich abbrechen?"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "Abbrechen - Zusätzliche Komponenten"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "Verbindungszeitüberschreitung"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "Internetverbindung kann nicht hergestellt werden"
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "Serverfehler (Fehler %s)"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "Der Dienst nicht verfügbar (Fehler %s)"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "Zugriff verweigert oder verboten (Fehler %s)"
+    IDS_HTTP_STATUS_OTHER                     "Bei der Anfrage ist ein Fehler aufgetreten. Möchten Sie die Anfrage wiederholen?"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "Während der Server auf die Anforderung wartete, kam es zu einer Zeitüberschreitung."
+    IDS_HTTP_STATUS_FORBIDDEN		"Der Server hat die Anforderung verstanden, verweigert jedoch deren Ausführung."
+    IDS_HTTP_STATUS_SERVER_ERROR	"Der Server stieß auf eine unerwartete Bedingung, die das Ausführen der Anforderung verhinderte."
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"Der Dienst ist vorübergehend überlastet."
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"Server beschäftigt. Erneuter Versuch in %ld Sekunden ..."
+
+    IDS_ERROR_CAPTION               "Fehler - Java Kernel"
+    IDS_HOURSMINUTESECOND	    "Verbleibende Zeit (geschätzt): %d Stunden, %d Minuten und %.0f Sekunden"
+    IDS_HOURMINUTESECOND	    "Verbleibende Zeit (geschätzt): %d Stunde, %d Minuten und %.0f Sekunden"
+    IDS_MINUTESECOND 		    "Verbleibende Zeit (geschätzt): %d Minuten %.0f Sekunden"
+    IDS_SECOND                      "Verbleibende Zeit (geschätzt): %.0f Sekunden"
+    IDS_DISK_FULL_ERROR_CAPTION     "Festplatte voll"
+    IDS_DISK_FULL_ERROR             "Java Kernel konnte erforderliche Komponenten nicht herunterladen, da der Datenträger voll ist.  Noch einmal versuchen?"
+    IDS_DISK_WRITE_ERROR_CAPTION    "Fehler beim Schreiben auf Datenträger"
+    IDS_DISK_WRITE_ERROR            "Java Kernel hat beim Schreiben uf den Datenträger einen Fehler verursacht  Noch einmal versuchen?"
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "Java Kernel kann aufgrund der aktuellen Internetverbindungseinstellungen Ihres Systems nicht fortfahren.  Überprüfen Sie in der Windows-Systemsteuerung unter 'Internetoptionen -> Verbindungen' die Einstellungen und Proxy-Angaben."
+
+    IDS_DOWNLOAD_RETRY             "Downloadfehler"
+    IDS_DOWNLOAD_RETRY_TEXT        "Beim Herunterladen einiger benötigter Komponenten ist ein Fehler aufgetreten. Möchten Sie noch einmal versuchen, diese Komponenten herunterzuladen?"
+
+    IDS_DOWNLOAD                   "Zusätzliche Komponenten werden installiert."
+    IDS_DOWNLOAD_UNPACKING         "Entpacken des Pakets"
+    IDS_DOWNLOAD_TEXT              "Die Java-Anwendung wird starten, sobald zusätzliche Komponenten heruntergeladen und installiert sind."
+    
+    IDS_FILE_UPDATE_ERROR          "Beim Aktualisieren von %s%s ist ein Fehler aufgetreten."
+    IDS_FILE_DELETE_ERROR          "Beim Entfernen von %s ist ein Fehler aufgetreten."
+    IDS_JAVA_HOME_ERROR            "Java-Verzeichnis kann nicht ermittelt werden."
+    IDS_KERNEL_HOME_ERROR          "Pfad der jkernel.dll kann nicht ermittelt werden."
+    IDS_JBROKER_ERROR              "jbroker.exe kann nicht gestartet werden."
+    IDS_FATAL_ERROR                "Java konnte einige erforderliche Komponenten nicht herunterladen.  Das Programm wird geschlossen."
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "Java konnte keine Verbindung zum Downloadserver herstellen.  Das Programm wird geschlossen."
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "Bei der Verbindung mit dem Downloadserver ist ein Fehler aufgetreten.  Das Programm wird geschlossen."
+    IDS_ERROR_MALFORMED_URL "Java konnte von URL '%s' keinen Dowload ausführen.  Das Programm wird geschlossen."
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_en.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Additional Components Needed"
+EXSTYLE WS_EX_APPWINDOW
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 14, 200, 12
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "Cancel",  2, 285, 100, 46, 14
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "Canceling the installation of additional components which the application needs may cause the application to exit.\n\nAre you sure you want to cancel the installation of additional components?"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "Cancel - Additional Components"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "Connection Timed Out"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "Unable to connect to the Internet"
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "Server error (Error %s)"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "Service Unavailable (Error %s)"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "Access Denied or Forbidden (Error %s)"
+    IDS_HTTP_STATUS_OTHER                     "An error has occured during this request. Do you want to try the request again?"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "The server used to download the requested components is not responding and the connection has timed out. Do you want to try to connect again?"
+    IDS_HTTP_STATUS_FORBIDDEN		"You do not have permission to access the server to download the components requested by the application. Retry your access to the server?"
+    IDS_HTTP_STATUS_SERVER_ERROR	"An error occured on the server and it could not complete the request. Do you want to try the request again?"
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"The requested service is temporarily unavailable. Do you want to try the request again?"
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"Server is currently busy, retry in %ld seconds ..."
+  
+    IDS_ERROR_CAPTION               "Java Installer"
+    IDS_HOURSMINUTESECOND	    "Estimated time remaining: %d hours %d minutes %.0f seconds"
+    IDS_HOURMINUTESECOND	    "Estimated time remaining: %d hour %d minutes %.0f seconds"
+    IDS_MINUTESECOND 		    "Estimated time remaining: %d minutes %.0f seconds"
+    IDS_SECOND                      "Estimated time remaining: %.0f seconds"
+    IDS_DISK_FULL_ERROR_CAPTION     "Disk Full %s"
+    IDS_DISK_FULL_ERROR             "There is not enough space on the disk to download the requested components. Clear space on the disk and then Retry."
+    IDS_DISK_WRITE_ERROR_CAPTION    "Can't write to the disk %s"
+    IDS_DISK_WRITE_ERROR            "An error occurred during writing to the disk. Please check that the disk is not write protected."
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "Java cannot connect to the Internet. Please check that the Internet Connection settings are correct (these can be found in the Windows Control Panel under Internet Options > Connection) and that your firewall allows java.exe to access the Internet."
+
+    IDS_DOWNLOAD_RETRY             "Download error"
+    IDS_DOWNLOAD_RETRY_TEXT        "An error occurred during the download of some requested components. Do you want to try the download of these components again?"
+
+    IDS_DOWNLOAD                   "Installing Additional Components"
+    IDS_DOWNLOAD_UNPACKING         "Unpacking bundle"
+    IDS_DOWNLOAD_TEXT              "The Java application will start when additional components that it requires are downloaded and installed."
+    
+    IDS_FILE_UPDATE_ERROR          "An error occurred while updating %s%s."
+    IDS_FILE_DELETE_ERROR          "An error occurred while removing %s."
+    IDS_JAVA_HOME_ERROR            "Unable to determine Java home directory."
+    IDS_KERNEL_HOME_ERROR          "Unable to determine path to jkernel.dll."
+    IDS_JBROKER_ERROR              "Unable to launch jbroker.exe."
+    IDS_FATAL_ERROR                "Java was unable to download required components.  The program will now exit."
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "Java was unable to communicate with the download server.  The program will now exit."
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "Java encountered an error communicating with the download server.  The program will now exit."
+    IDS_ERROR_MALFORMED_URL "Java was unable to download from the URL '%s'.  The program will now exit."
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_es.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Componentes adicionales necesarios"
+EXSTYLE WS_EX_APPWINDOW
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 8, 225, 20
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "Cancelar",  2, 285, 100, 46, 14
+END
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "Cancelar la instalación de los componentes adicionales que necesita la aplicación puede hacer que se cierre la aplicación.\n\n¿Seguro que desea cancelar la instalación de componentes adicionales?"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "Cancelar - Componentes adicionales"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "Se ha agotado el tiempo de espera de la conexión"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "No es posible conectarse a Internet"
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "Ha habido un error en el servidor (error %s)"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "El servicio no está disponible (error %s)"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "El acceso se ha denegado o está prohibido (error %s)"
+    IDS_HTTP_STATUS_OTHER                     "Ha habido un error en el transcurso de esta solicitud. ¿Desea ejecutar de nuevo la solicitud?"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "El servidor ha agotado el tiempo de espera de la solicitud."
+    IDS_HTTP_STATUS_FORBIDDEN		"El servidor ha podido interpretar la solicitud, pero la rechaza."
+    IDS_HTTP_STATUS_SERVER_ERROR	"El servidor ha encontrado una condición inesperada que le ha impedido satisfacer la solicitud."
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"El servicio está temporalmente sobrecargado."
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"El servidor está ocupado en este momento, se volverá a intentar la conexión en %ld segundos..."
+
+    IDS_ERROR_CAPTION               "Error - Java Kernel"
+    IDS_HOURSMINUTESECOND	    "Tiempo restante estimado: %d horas %d minutos %.0f segundos"
+    IDS_HOURMINUTESECOND	    "Tiempo restante estimado: %d hora %d minutos %.0f segundos"
+    IDS_MINUTESECOND 		    "Tiempo restante estimado: %d minutos %.0f segundos"
+    IDS_SECOND                      "Tiempo restante estimado: %.0f segundos"
+    IDS_DISK_FULL_ERROR_CAPTION     "Disco lleno"
+    IDS_DISK_FULL_ERROR             "Java Kernel no puede descargar los componentes necesarios porque el disco está lleno.  ¿Desea volver a intentarlo?"
+    IDS_DISK_WRITE_ERROR_CAPTION    "Error de escritura en disco"
+    IDS_DISK_WRITE_ERROR            "Se ha producido un error cuando Java Kernel intentaba escribir en el disco.  ¿Desea volver a intentarlo?"
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "Java Kernel no puede continuar con la configuración actual de conexión a Internet del sistema.  En el Panel de control de Windows, compruebe Opciones de Internet -> Conexiones para verificar que la información de la configuración y de proxy sea la correcta."
+
+    IDS_DOWNLOAD_RETRY             "Error de descarga"
+    IDS_DOWNLOAD_RETRY_TEXT        "Se ha producido un error durante la descarga de algunos componentes solicitados. ¿Quiere volver a intentar descargar estos componentes?"
+
+    IDS_DOWNLOAD                   "Instalación de componentes adicionales"
+	IDS_DOWNLOAD_UNPACKING         "Desempaquetando paquete"
+    IDS_DOWNLOAD_TEXT              "La aplicación Java se iniciará cuando los componentes adicionales necesarios se hayan descargado e instalado."
+    
+    IDS_FILE_UPDATE_ERROR          "Se ha producido un error al actualizar %s%s."
+    IDS_FILE_DELETE_ERROR          "Se ha producido un error al eliminar %s."
+    IDS_JAVA_HOME_ERROR            "Imposible determinar el directorio de inicio Java."
+    IDS_KERNEL_HOME_ERROR          "Imposible determinar la ruta a jkernel.dll."
+    IDS_JBROKER_ERROR              "Imposible iniciar jbroker.exe."
+    IDS_FATAL_ERROR                "Java no ha podido descargar los componentes necesarios.  El programa se cerrará."
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "Java no ha podido comunicarse con el servidor de descarga.  El programa se cerrará."
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "Se ha producido un error en la comunicación entre Java y el servidor de descarga.  El programa se cerrará."
+    IDS_ERROR_MALFORMED_URL "Java no ha podido realizar la descarga desde el URL '%s'.  El programa se cerrará."
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_fr.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Composants supplémentaires requis"
+EXSTYLE WS_EX_APPWINDOW
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 4, 220, 30
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "Annuler",  2, 285, 100, 46, 14
+END
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "L'annulation de l'installation de composants supplémentaires nécessaires à l'application risque d'entraîner la fermeture de celle-ci.\n\nVoulez-vous vraiment annuler l'installation des composants supplémentaires ?"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "Annuler : composants supplémentaires"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "Délai de connexion dépassé"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "Connexion à Internet impossible"
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "Erreur de serveur (erreur %s)"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "Service non disponible (erreur %s)"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "Accès refusé ou interdit (erreur %s)"
+    IDS_HTTP_STATUS_OTHER                     "Une erreur s'est produite lors de cette demande. Voulez-vous effectuer à nouveau la demande ?"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "Temporisation du serveur lors de l'attente de la requête."
+    IDS_HTTP_STATUS_FORBIDDEN		"Le serveur a compris la requête mais refuse de la satisfaire."
+    IDS_HTTP_STATUS_SERVER_ERROR	"Le serveur a rencontré une condition inattendue l'empêchant de satisfaire la requête."
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"Le service est temporairement surchargé."
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"Le serveur est occupé ; veuillez réessayer dans %ld secondes..."
+
+    IDS_ERROR_CAPTION               "Erreur - Java Kernel"
+    IDS_HOURSMINUTESECOND	    "Temps restant prévu : %d heures %d minutes %.0f secondes"
+    IDS_HOURMINUTESECOND	    "Temps restant prévu : %d heure %d minutes %.0f secondes"
+    IDS_MINUTESECOND 		    "Temps restant prévu : %d minutes %.0f secondes"
+    IDS_SECOND                      "Temps restant prévu : %.0f secondes"
+    IDS_DISK_FULL_ERROR_CAPTION     "Disque saturé"
+    IDS_DISK_FULL_ERROR             "En raison de la saturation du disque, Java Kernel n'a pas été en mesure de télécharger les composants requis.  Voulez-vous réessayer ?"
+    IDS_DISK_WRITE_ERROR_CAPTION    "Erreur d'écriture sur le disque"
+    IDS_DISK_WRITE_ERROR            "Java Kernel a rencontré une erreur lors de l'écriture sur le disque.  Voulez-vous réessayer ?"
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "Java Kernel ne peut pas s'exécuter avec les paramètres de connexion Internet actuels de votre système.  Dans le Panneau de configuration de Windows, cliquez sur Options Internet -> Connexions pour vérifier les paramètres et informations de proxy."
+
+    IDS_DOWNLOAD_RETRY             "Erreur de téléchargement"
+    IDS_DOWNLOAD_RETRY_TEXT        "Une erreur s'est produite lors du téléchargement de certains composants requis. Souhaitez-vous réessayer de télécharger ces composants ?"
+
+    IDS_DOWNLOAD                   "Installation de composants supplémentaires"
+	IDS_DOWNLOAD_UNPACKING         "Décompression du bundle"
+    IDS_DOWNLOAD_TEXT              "L'application Java démarre lorsque des composants supplémentaires requis sont téléchargés et installés."
+    
+    IDS_FILE_UPDATE_ERROR          "Une erreur s'est produite lors de la mise à jour de %s%s."
+    IDS_FILE_DELETE_ERROR          "Une erreur s'est produite lors de la suppression de %s."
+    IDS_JAVA_HOME_ERROR            "Le répertoire d'accueil Java est introuvable."
+    IDS_KERNEL_HOME_ERROR          "Le chemin de jkernel.dll est introuvable."
+    IDS_JBROKER_ERROR              "Impossible de lancer jbroker.exe."
+    IDS_FATAL_ERROR                "Java n'a pas été en mesure de télécharger les composants requis.  Fermeture imminente du programme."
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "Java n'a pas été en mesure de communiquer avec le serveur de téléchargement.  Fermeture imminente du programme."
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "Java a rencontré une erreur lors de la communication avec le serveur de téléchargement.  Fermeture imminente du programme."
+    IDS_ERROR_MALFORMED_URL "Java n'a pas été en mesure de réaliser le téléchargement à partir de l'URL '%s'.  Fermeture imminente du programme."
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_it.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Componenti aggiuntivi richiesti"
+EXSTYLE WS_EX_APPWINDOW
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 4, 220, 30
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "Annulla",  2, 285, 100, 46, 14
+END
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "Se si annulla l'installazione di componenti aggiuntivi necessari per l'applicazione, quest'ultima potrebbe chiudersi.\n\nAnnullare l'installazione di componenti aggiuntivi?"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "Annulla - Componenti aggiuntivi"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "Timeout della connessione"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "Impossibile stabilire una connessione a Internet"
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "Errore del server (errore %s)"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "Servizio non disponibile (errore %s)"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "Accesso negato o vietato (errore %s)"
+    IDS_HTTP_STATUS_OTHER                     "Errore durante la richiesta. Provare a reinviare la richiesta?"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "Tempo scaduto del server in attesa della richiesta."
+    IDS_HTTP_STATUS_FORBIDDEN		"Il server ha ricevuto la richiesta ma non ne consente l'elaborazione."
+    IDS_HTTP_STATUS_SERVER_ERROR	"Il server ha rilevato una condizione imprevista che ha impedito di soddisfare la richiesta."
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"Il servizio è temporaneamente sovraccarico."
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"Server occupato, riprovare tra %ld secondi..."
+
+    IDS_ERROR_CAPTION               "Errore - Java Kernel"
+    IDS_HOURSMINUTESECOND	    "Tempo rimanente previsto: %d ore %d minuti %.0f secondi"
+    IDS_HOURMINUTESECOND	    "Tempo rimanente previsto: %d ora %d minuti %.0f secondi"
+    IDS_MINUTESECOND 		    "Tempo rimanente previsto: %d minuti %.0f secondi"
+    IDS_SECOND                      "Tempo rimanente previsto: %.0f secondi"
+    IDS_DISK_FULL_ERROR_CAPTION     "Disco pieno"
+    IDS_DISK_FULL_ERROR             "Java Kernel non ha effettuato il download dei componenti necessari perché il disco è pieno.  Riprovare?"
+    IDS_DISK_WRITE_ERROR_CAPTION    "Errore di scrittura sul disco"
+    IDS_DISK_WRITE_ERROR            "Java Kernel ha rilevato un errore durante la scrittura sul disco.  Riprovare?"
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "Non è possibile utilizzare Java Kernel con le impostazioni di connessione Internet attive nel sistema.  Nel Pannello di controllo di Windows, selezionare Opzioni Internet -> Connessioni per controllare che le impostazioni e le informazioni sul proxy siano corrette."
+
+    IDS_DOWNLOAD_RETRY             "Errore di download"
+    IDS_DOWNLOAD_RETRY_TEXT        "Si è verificato un errore durante il download di alcuni componenti richiesti. Ritentare il download di tali componenti?"
+
+    IDS_DOWNLOAD                   "Installazione di componenti aggiuntivi in corso"
+	IDS_DOWNLOAD_UNPACKING         "Decompressione del bundle in corso"
+    IDS_DOWNLOAD_TEXT              "L'applicazione Java verrà avviata dopo il download e l'installazione dei componenti richiesti."
+    
+    IDS_FILE_UPDATE_ERROR          "Errore durante l'aggiornamento di %s%s."
+    IDS_FILE_DELETE_ERROR          "Errore durante la rimozione di %s."
+    IDS_JAVA_HOME_ERROR            "Impossibile determinare la directory home di Java."
+    IDS_KERNEL_HOME_ERROR          "Impossibile determinare il percorso di jkernel.dll."
+    IDS_JBROKER_ERROR              "Impossibile avviare jbroker.exe."
+    IDS_FATAL_ERROR                "Java non è in grado di scaricare i componenti necessari. Il programma verrà terminato."
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "Java non è in grado di comunicare con il server di download. Il programma verrà terminato."
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "Java ha rilevato un errore durante la comunicazione con il server di download. Il programma verrà terminato."
+    IDS_ERROR_MALFORMED_URL "Java non è in grado di eseguire il download dall'URL '%s'. Il programma verrà terminato."
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_ja.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "’ljÁƒRƒ“ƒ|[ƒlƒ“ƒg‚ª•K—v"
+EXSTYLE WS_EX_APPWINDOW
+FONT 10, "MS UI Gothic"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 14, 200, 12
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "ŽæÁ‚µ",  2, 285, 100, 46, 14
+END
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ª•K—v‚Æ‚·‚é’ljÁƒRƒ“ƒ|[ƒlƒ“ƒg‚̃Cƒ“ƒXƒg[ƒ‹‚ðƒLƒƒƒ“ƒZƒ‹‚·‚é‚ÆAƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ªI—¹‚·‚é‰Â”\«‚ª‚ ‚è‚Ü‚·B\n\n’ljÁƒRƒ“ƒ|[ƒlƒ“ƒg‚̃Cƒ“ƒXƒg[ƒ‹‚ðƒLƒƒƒ“ƒZƒ‹‚µ‚Ä‚æ‚낵‚¢‚Å‚·‚©H"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "ƒLƒƒƒ“ƒZƒ‹ - ’ljÁƒRƒ“ƒ|[ƒlƒ“ƒg"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "Ú‘±‚ªƒ^ƒCƒ€ƒAƒEƒg‚µ‚Ü‚µ‚½"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "ƒCƒ“ƒ^[ƒlƒbƒg‚ÉÚ‘±‚Å‚«‚Ü‚¹‚ñ"
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "ƒT[ƒo[ƒGƒ‰[ (ƒGƒ‰[ %s)"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "ƒT[ƒrƒX—˜—p•s‰Â (ƒGƒ‰[ %s)"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "ƒAƒNƒZƒX‚ª‹‘”Û‚Ü‚½‚Í‹ÖŽ~‚³‚ê‚Ä‚¢‚Ü‚· (ƒGƒ‰[ %s)"
+    IDS_HTTP_STATUS_OTHER                     "‚±‚Ì—v‹‚̈—’†‚ɃGƒ‰[‚ª”­¶‚µ‚Ü‚µ‚½B—v‹‚ðÄŽŽs‚µ‚Ü‚·‚©?"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "—v‹‚ð‘Ò‹@’†‚ɃT[ƒo[‚ªƒ^ƒCƒ€ƒAƒEƒg‚µ‚Ü‚µ‚½B"
+    IDS_HTTP_STATUS_FORBIDDEN		"ƒT[ƒo[‚ÍA—v‹‚ð”FŽ¯‚µ‚Ä‚¢‚Ü‚·‚ªAŽÀs‚ð‹‘”Û‚µ‚Ä‚¢‚Ü‚·B"
+    IDS_HTTP_STATUS_SERVER_ERROR	"ƒT[ƒo[‚ÍA—v‹‚ÌŽÀs‚ð–W‚°‚é—\Šú‚µ‚È‚¢ó‹µ‚É‘˜‹ö‚µ‚Ü‚µ‚½B"
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"ƒT[ƒrƒX‚ªˆêŽž“I‚ɃI[ƒo[ƒ[ƒh‚µ‚Ä‚¢‚Ü‚·B"
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"ƒT[ƒo[‚ÍŒ»ÝƒrƒW[‚Å‚·B%ld •bŒã‚ÉÄŽŽs‚µ‚Ü‚· ..."
+
+    IDS_ERROR_CAPTION               "ƒGƒ‰[ - Java ƒJ[ƒlƒ‹"
+    IDS_HOURSMINUTESECOND	    "—\‘zŽc‚莞ŠÔ: %d ŽžŠÔ %d •ª %.0f •b"
+    IDS_HOURMINUTESECOND	    "—\‘zŽc‚莞ŠÔ: %d ŽžŠÔ %d •ª %.0f •b"
+    IDS_MINUTESECOND 		    "—\‘zŽc‚莞ŠÔ: %d •ª %.0f •b"
+    IDS_SECOND                      "—\‘zŽc‚莞ŠÔ: %.0f •b"
+    IDS_DISK_FULL_ERROR_CAPTION     "ƒfƒBƒXƒN‚ª‚¢‚Á‚Ï‚¢‚Å‚·"
+    IDS_DISK_FULL_ERROR             "ƒfƒBƒXƒN‚ª‚¢‚Á‚Ï‚¢‚Ì‚½‚ßAJava ƒJ[ƒlƒ‹‚ª•K—v‚ȃRƒ“ƒ|[ƒlƒ“ƒg‚ðƒ_ƒEƒ“ƒ[ƒh‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½B‚à‚¤ˆê“xŽŽ‚µ‚Ü‚·‚©?"
+    IDS_DISK_WRITE_ERROR_CAPTION    "ƒfƒBƒXƒN‘‚«ž‚݃Gƒ‰["
+    IDS_DISK_WRITE_ERROR            "Java ƒJ[ƒlƒ‹‚ªƒfƒBƒXƒN‚Ö‚Ì‘‚«ž‚ÝŽž‚ɃGƒ‰[‚ðŒŸo‚µ‚Ü‚µ‚½B‚à‚¤ˆê“xŽŽ‚µ‚Ü‚·‚©?"
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "Java ƒJ[ƒlƒ‹‚ÍA‚¨Žg‚¢‚̃VƒXƒeƒ€‚ÌŒ»Ý‚̃Cƒ“ƒ^[ƒlƒbƒgÚ‘±Ý’è‚Å‚Í“®ì‚µ‚Ü‚¹‚ñBWindows ‚̃Rƒ“ƒgƒ[ƒ‹ƒpƒlƒ‹‚ÅAuƒCƒ“ƒ^[ƒlƒbƒgƒIƒvƒVƒ‡ƒ“v -> uÚ‘±v‚ð‘I‘ð‚µ‚ÄAݒ肨‚æ‚уvƒƒLƒVî•ñ‚ª³‚µ‚¢‚±‚Æ‚ðŠm”F‚µ‚Ä‚­‚¾‚³‚¢B"
+
+    IDS_DOWNLOAD_RETRY             "ƒ_ƒEƒ“ƒ[ƒhƒGƒ‰["
+    IDS_DOWNLOAD_RETRY_TEXT        "—v‹‚³‚ꂽƒRƒ“ƒ|[ƒlƒ“ƒg‚̈ꕔ‚ðƒ_ƒEƒ“ƒ[ƒh’†‚ɃGƒ‰[‚ª”­¶‚µ‚Ü‚µ‚½B‚±‚ê‚ç‚̃Rƒ“ƒ|[ƒlƒ“ƒg‚̃_ƒEƒ“ƒ[ƒh‚ðÄ“xŽŽ‚Ý‚Ü‚·‚© ?"
+
+    IDS_DOWNLOAD                   "’ljÁƒRƒ“ƒ|[ƒlƒ“ƒg‚ðƒCƒ“ƒXƒg[ƒ‹‚µ‚Ä‚¢‚Ü‚·"
+	IDS_DOWNLOAD_UNPACKING         "ƒoƒ“ƒhƒ‹‚ð“WŠJ‚µ‚Ä‚¢‚Ü‚·"
+    IDS_DOWNLOAD_TEXT              "Java ƒAƒvƒŠƒP[ƒVƒ‡ƒ“‚ÍA•K{‚̒ljÁƒRƒ“ƒ|[ƒlƒ“ƒg‚̃_ƒEƒ“ƒ[ƒh‚¨‚æ‚уCƒ“ƒXƒg[ƒ‹Œã‚É‹N“®‚µ‚Ü‚·B"
+    
+    IDS_FILE_UPDATE_ERROR          "%s%s ‚ÌXV’†‚ɃGƒ‰[‚ª”­¶‚µ‚Ü‚µ‚½B"
+    IDS_FILE_DELETE_ERROR          "%s ‚Ì휒†‚ɃGƒ‰[‚ª”­¶‚µ‚Ü‚µ‚½B"
+    IDS_JAVA_HOME_ERROR            "Java ƒz[ƒ€ƒfƒBƒŒƒNƒgƒŠ‚ð”»’è‚Å‚«‚Ü‚¹‚ñB"
+    IDS_KERNEL_HOME_ERROR          "jkernel.dll ‚̃pƒX‚ð”»’è‚Å‚«‚Ü‚¹‚ñB"
+    IDS_JBROKER_ERROR              "jbroker.exe ‚ð‹N“®‚Å‚«‚Ü‚¹‚ñB"
+    IDS_FATAL_ERROR                "Java ‚ª•K—v‚ȃRƒ“ƒ|[ƒlƒ“ƒg‚ðƒ_ƒEƒ“ƒ[ƒh‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½BƒvƒƒOƒ‰ƒ€‚ÍI—¹‚µ‚Ü‚·B"
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "Java ‚ªƒ_ƒEƒ“ƒ[ƒhƒT[ƒo[‚Æ’ÊM‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½BƒvƒƒOƒ‰ƒ€‚ÍI—¹‚µ‚Ü‚·B"
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "Java ‚ªƒ_ƒEƒ“ƒ[ƒhƒT[ƒo[‚Æ‚Ì’ÊM’†‚ɃGƒ‰[‚ðŒŸo‚µ‚Ü‚µ‚½BƒvƒƒOƒ‰ƒ€‚ÍI—¹‚µ‚Ü‚·B"
+    IDS_ERROR_MALFORMED_URL "Java ‚ª URL '%s' ‚©‚çƒ_ƒEƒ“ƒ[ƒh‚Å‚«‚Ü‚¹‚ñ‚Å‚µ‚½BƒvƒƒOƒ‰ƒ€‚ÍI—¹‚µ‚Ü‚·B"
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_ko.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Ãß°¡ ±¸¼º ¿ä¼Ò ÇÊ¿ä"
+EXSTYLE WS_EX_APPWINDOW
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 14, 200, 12
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "Ãë¼Ò",  2, 285, 100, 46, 14
+END
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "ÀÀ¿ë ÇÁ·Î±×·¥¿¡¼­ ÇÊ¿äÇÑ Ãß°¡ ±¸¼º ¿ä¼ÒÀÇ ¼³Ä¡¸¦ Ãë¼ÒÇϸé ÀÀ¿ë ÇÁ·Î±×·¥ÀÌ Á¾·áµÉ ¼ö ÀÖ½À´Ï´Ù.\n\nÃß°¡ ±¸¼º ¿ä¼ÒÀÇ ¼³Ä¡¸¦ Ãë¼ÒÇϽðڽÀ´Ï±î?"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "Ãë¼Ò - Ãß°¡ ±¸¼º ¿ä¼Ò"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "¿¬°á ½Ã°£ ÃÊ°ú"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "ÀÎÅͳݿ¡ ¿¬°áÇÒ ¼ö ¾ø½À´Ï´Ù."
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "¼­¹ö ¿À·ù(¿À·ù %s)"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "¼­ºñ½º¸¦ »ç¿ëÇÒ ¼ö ¾øÀ½(¿À·ù %s)"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "¾×¼¼½º°¡ °ÅºÎµÇ¾ú°Å³ª ±ÝÁöµÊ(¿À·ù %s)"
+    IDS_HTTP_STATUS_OTHER                     "ÀÌ ¿äû µ¿¾È ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù. ¿äûÀ» ´Ù½Ã ½ÃµµÇϽðڽÀ´Ï±î?"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "¼­¹ö°¡ ¿äûÀ» ±â´Ù¸®´Â µ¿¾È ½Ã°£ÀÌ ÃÊ°úµÇ¾ú½À´Ï´Ù."
+    IDS_HTTP_STATUS_FORBIDDEN		"¼­¹ö°¡ ¿äûÀ» ÀÌÇØÇßÁö¸¸ ÀÌÇàÇϱ⸦ °ÅºÎÇÕ´Ï´Ù."
+    IDS_HTTP_STATUS_SERVER_ERROR	"¼­¹ö¿¡¼­ ¿äû ÀÌÇàÀ» ¹æÇØÇÏ´Â ¿¹»óÄ¡ ¸øÇÑ Á¶°ÇÀÌ ¹ß°ßµÇ¾ú½À´Ï´Ù."
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"¼­¹ö°¡ ÀϽÃÀûÀ¸·Î °úºÎÇϵǾú½À´Ï´Ù."
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"ÇöÀç ¼­¹ö°¡ »ç¿ë ÁßÀ̹ǷΠ%ldÃÊ ÈÄ¿¡ ´Ù½Ã ½ÃµµÇϽʽÿÀ."
+
+    IDS_ERROR_CAPTION               "¿À·ù - Java Ä¿³Î"
+    IDS_HOURSMINUTESECOND	    "¿¹»óµÈ ³²Àº ½Ã°£: %d½Ã°£ %dºÐ %.0fÃÊ"
+    IDS_HOURMINUTESECOND	    "¿¹»óµÈ ³²Àº ½Ã°£: %d½Ã°£ %dºÐ %.0fÃÊ"
+    IDS_MINUTESECOND 		    "¿¹»óµÈ ³²Àº ½Ã°£: %dºÐ %.0fÃÊ"
+    IDS_SECOND                      "¿¹»óµÈ ³²Àº ½Ã°£: %.0fÃÊ"
+    IDS_DISK_FULL_ERROR_CAPTION     "µð½ºÅ©°¡ °¡µæ Âü"
+    IDS_DISK_FULL_ERROR             "µð½ºÅ©°¡ °¡µæ Â÷¼­ Java Kernel¿¡¼­ ÇÊ¿äÇÑ ±¸¼º ¿ä¼Ò¸¦ ´Ù¿î·ÎµåÇÏÁö ¸øÇß½À´Ï´Ù. ´Ù½Ã ½ÃµµÇϽðڽÀ´Ï±î?"
+    IDS_DISK_WRITE_ERROR_CAPTION    "µð½ºÅ© ¾²±â ¿À·ù"
+    IDS_DISK_WRITE_ERROR            "µð½ºÅ©¿¡ ¾²´Â µ¿¾È Java Kernel¿¡¼­ ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù. ´Ù½Ã ½ÃµµÇϽðڽÀ´Ï±î?"
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "½Ã½ºÅÛÀÇ ÇöÀç ÀÎÅÍ³Ý ¿¬°á ¼³Á¤À¸·Î´Â Java KernelÀ» °è¼ÓÇÒ ¼ö ¾ø½À´Ï´Ù.  Windows Á¦¾îÆÇ¿¡¼­ ÀÎÅÍ³Ý ¿É¼Ç -> ¿¬°áÀ» ¼±ÅÃÇÏ¿© ¼³Á¤ ¹× ÇÁ·Ï½Ã Á¤º¸°¡ ¿Ã¹Ù¸¥Áö È®ÀÎÇϽʽÿÀ."
+
+    IDS_DOWNLOAD_RETRY             "´Ù¿î·Îµå ¿À·ù"
+    IDS_DOWNLOAD_RETRY_TEXT        "¿äûµÈ ±¸¼º ¿ä¼Ò¸¦ ´Ù¿î·ÎµåÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù. ÀÌ ±¸¼º ¿ä¼Ò¸¦ ´Ù½Ã ´Ù¿î·ÎµåÇϽðڽÀ´Ï±î?"
+
+    IDS_DOWNLOAD                   "Ãß°¡ ±¸¼º ¿ä¼Ò ¼³Ä¡"
+	IDS_DOWNLOAD_UNPACKING         "¹øµé ¾ÐÃà Ç®±â"
+    IDS_DOWNLOAD_TEXT              "ÇÊ¿äÇÑ Ãß°¡ ±¸¼º ¿ä¼Ò°¡ ´Ù¿î·ÎµåµÇ¾î ¼³Ä¡µÇ¸é Java ÀÀ¿ë ÇÁ·Î±×·¥ÀÌ ½ÃÀ۵˴ϴÙ."
+    
+    IDS_FILE_UPDATE_ERROR          "%s%sÀ»(¸¦) ¾÷µ¥ÀÌÆ®ÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù."
+    IDS_FILE_DELETE_ERROR          "%sÀ»(¸¦) Á¦°ÅÇÏ´Â µ¿¾È ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù."
+    IDS_JAVA_HOME_ERROR            "Java Ȩ µð·ºÅ丮¸¦ È®ÀÎÇÒ ¼ö ¾ø½À´Ï´Ù."
+    IDS_KERNEL_HOME_ERROR          "jkernel.dllÀÇ °æ·Î¸¦ È®ÀÎÇÒ ¼ö ¾ø½À´Ï´Ù."
+    IDS_JBROKER_ERROR              "jbroker.exe¸¦ ½ÃÀÛÇÒ ¼ö ¾ø½À´Ï´Ù."
+    IDS_FATAL_ERROR                "ÇÊ¿äÇÑ ±¸¼º ¿ä¼Ò¸¦ ´Ù¿î·ÎµåÇÏÁö ¸øÇß½À´Ï´Ù.  ÇÁ·Î±×·¥ÀÌ Á¾·áµË´Ï´Ù."
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "´Ù¿î·Îµå ¼­¹ö¿Í Åë½ÅÇÏÁö ¸øÇß½À´Ï´Ù.  ÇÁ·Î±×·¥ÀÌ Á¾·áµË´Ï´Ù."
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "´Ù¿î·Îµå ¼­¹ö¿ÍÀÇ Åë½Å ¿À·ù°¡ ¹ß»ýÇß½À´Ï´Ù.  ÇÁ·Î±×·¥ÀÌ Á¾·áµË´Ï´Ù."
+    IDS_ERROR_MALFORMED_URL "URL '%s'¿¡¼­ ´Ù¿î·ÎµåÇÏÁö ¸øÇß½À´Ï´Ù.  ÇÁ·Î±×·¥ÀÌ Á¾·áµË´Ï´Ù."
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_sv.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Ytterligare komponenter behövs"
+EXSTYLE WS_EX_APPWINDOW
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 14, 200, 12
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "Avbryt",  2, 285, 100, 46, 14
+END
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "Programmet kan avslutas om du avbryter installationen av ytterligare komponenter som är nödvändiga för programmet.\n\nVill du avbryta installationen av ytterligare komponenter?"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "Avbryt - Ytterligare komponenter"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "Anslutningen avbröts på grund av timeout"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "Det går inte att ansluta till Internet."
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "Serverfel (Fel %s)"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "Tjänsten är inte tillgänglig (Fel %s)"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "Åtkomst nekad eller förbjuden (Fel %s)"
+    IDS_HTTP_STATUS_OTHER                     "Ett fel inträffade i samband med begäran. Vill du försöka skicka begäran igen?"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "Ett tidsfel inträffade medan servern väntade på begäran."
+    IDS_HTTP_STATUS_FORBIDDEN		"Servern förstod begäran men vägrar uppfylla den."
+    IDS_HTTP_STATUS_SERVER_ERROR	"Ett oväntat tillstånd som innebär att begäran inte kan uppfyllas påträffades."
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"Tjänsten är tillfälligt överbelastad."
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"Servern är upptagen för närvarande. Försök igen om %ld sekund(er) ..."
+
+    IDS_ERROR_CAPTION               "Fel - Java Kernel"
+    IDS_HOURSMINUTESECOND	    "Återstående tid: %d timmar %d minuter %.0f sekunder"
+    IDS_HOURMINUTESECOND	    "Återstående tid: %d timme %d minuter %.0f sekunder"
+    IDS_MINUTESECOND 		    "Återstående tid: %d minuter %.0f sekunder"
+    IDS_SECOND                      "Återstående tid: %.0f sekunder"
+    IDS_DISK_FULL_ERROR_CAPTION     "Disken är full"
+    IDS_DISK_FULL_ERROR             "Java Kernel kunde inte ladda ned nödvändiga komponenter därför att disken är full.  Försöka igen?"
+    IDS_DISK_WRITE_ERROR_CAPTION    "Fel vid skrivning till disk"
+    IDS_DISK_WRITE_ERROR            "Java Kernel stötte på ett fel vid skrivning till disken.  Försöka igen?"
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "Java Kernel kan inte fortsätta med systemets aktuella inställningar för Internetanslutning.  Öppna Kontrollpanelen, Internet-alternativ > Anslutningar och kontrollera att inställningarna och proxyinformationen stämmer."
+
+    IDS_DOWNLOAD_RETRY             "Nedladdningsfel"
+    IDS_DOWNLOAD_RETRY_TEXT        "Ett fel uppstod under nedladdning av vissa begärda komponenter. Vill du försöka ladda ned dessa komponenter igen?"
+
+    IDS_DOWNLOAD                   "Ytterligare komponenter installeras"
+	IDS_DOWNLOAD_UNPACKING         "Uppackning av paket"
+    IDS_DOWNLOAD_TEXT              "Java-applikationen startar när ytterligare komponenter som krävs är nedladdade och installerade."
+    
+    IDS_FILE_UPDATE_ERROR          "Ett fel uppstod när %s%s uppdaterades."
+    IDS_FILE_DELETE_ERROR          "Ett fel uppstod när %s skulle tas bort."
+    IDS_JAVA_HOME_ERROR            "Det går inte att avgöra Javas hemkatalog"
+    IDS_KERNEL_HOME_ERROR          "Det går inte att avgöra sökvägen till jkernell.dll."
+    IDS_JBROKER_ERROR              "Det går inte att starta jbroker.exe."
+    IDS_FATAL_ERROR                "Det gick inte att ladda ned de nödvändiga komponenterna med Java.  Programmet avslutas."
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "Det gick inte att upprätta någon kommunikation mellan Java och nedladdningsservern.  Programmet avslutas."
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "Det uppstod ett fel i kommunikationen mellan Java och nedladdningsservern.  Programmet avslutas."
+    IDS_ERROR_MALFORMED_URL "Det gick inte att ladda ned från webbadressen '%s'.  Programmet avslutas."
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_zh.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "ËùÐèµÄÆäËû×é¼þ"
+EXSTYLE WS_EX_APPWINDOW
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 14, 200, 12
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "È¡Ïû",  2, 285, 100, 46, 14
+END
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "È¡Ïû°²×°Ó¦ÓóÌÐòËùÐèµÄ¶îÍâ×é¼þ¿ÉÄܻᵼÖ¸ÃÓ¦ÓóÌÐòÍ˳ö¡£\n\nÊÇ·ñÈ·¶¨ÒªÈ¡Ïû°²×°¶îÍâ×é¼þ£¿"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "È¡Ïû - ¶îÍâ×é¼þ"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "Á¬½ÓÒѳ¬Ê±"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "ÎÞ·¨Á¬½Óµ½ Internet"
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "·þÎñÆ÷´íÎ󣨴íÎó %s£©"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "·þÎñ²»¿ÉÓ㨴íÎó %s£©"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "¾Ü¾ø·ÃÎÊ»ò½ûÖ¹·ÃÎÊ£¨´íÎó %s£©"
+    IDS_HTTP_STATUS_OTHER                     "ÔÚ´ËÇëÇóÆÚ¼ä³öÏÖ´íÎó¡£ÄúÊÇ·ñÒªÖØÊÔÇëÇó£¿"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "·þÎñÆ÷µÈ´ýÇëÇóʱ³¬Ê±¡£"
+    IDS_HTTP_STATUS_FORBIDDEN		"·þÎñÆ÷ÒѽÓÊÜÇëÇ󣬵«¾Ü¾øÖ´ÐС£"
+    IDS_HTTP_STATUS_SERVER_ERROR	"·þÎñÆ÷Óöµ½ÒâÍâÇé¿ö£¬ÎÞ·¨Íê³ÉÇëÇó¡£"
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"·þÎñÔÝʱ¹ýÔØ¡£"
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"·þÎñÆ÷Õý棬ÇëÔÚ %ld ÃëºóÖØÊÔ..."
+
+    IDS_ERROR_CAPTION               "´íÎó - Java Kernel"
+    IDS_HOURSMINUTESECOND	    "¹À¼ÆÊ£Óàʱ¼ä:%d Сʱ %d ·ÖÖÓ %.0f Ãë"
+    IDS_HOURMINUTESECOND	    "¹À¼ÆÊ£Óàʱ¼ä:%d Сʱ  %d ·ÖÖÓ %.0f Ãë"
+    IDS_MINUTESECOND 		    "¹À¼ÆÊ£Óàʱ¼ä:%d ·ÖÖÓ %.0f Ãë"
+    IDS_SECOND                      "¹À¼ÆÊ£Óàʱ¼ä:%.0f Ãë"
+    IDS_DISK_FULL_ERROR_CAPTION     "´ÅÅÌÒÑÂú"
+    IDS_DISK_FULL_ERROR             "ÓÉÓÚ´ÅÅÌÒÑÂú£¬Java Kernel ÎÞ·¨ÏÂÔØËùÐèµÄ×é¼þ¡£ÊÇ·ñÖØÊÔ£¿"
+    IDS_DISK_WRITE_ERROR_CAPTION    "´ÅÅÌдÈë´íÎó"
+    IDS_DISK_WRITE_ERROR            "ÔÚÏò´ÅÅÌÖ´ÐÐдÈë²Ù×÷ʱ Java Kernel Óöµ½´íÎó¡£ÊÇ·ñÖØÊÔ£¿"
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "ÔÚʹÓÃϵͳµ±Ç°µÄ Internet Á¬½ÓÉèÖõÄÇé¿öÏ£¬Java Kernel ÎÞ·¨¼ÌÐøÖ´ÐС£ÔÚ Windows""¿ØÖÆÃæ°å""ÖУ¬Çë¼ì²é""Internet Ñ¡Ïî""->""Á¬½Ó""ÒÔÈ·±£ÉèÖúʹúÀíÐÅÏ¢ÕýÈ·¡£"
+
+    IDS_DOWNLOAD_RETRY             "ÏÂÔØ´íÎó"
+    IDS_DOWNLOAD_RETRY_TEXT        "ÔÚÏÂÔØijЩÇëÇóµÄ×é¼þÆڼ䷢Éú´íÎó¡£ÊÇ·ñÒªÔÙÊÔÒ»´ÎÏÂÔØÕâЩ×é¼þ£¿"
+
+    IDS_DOWNLOAD                   "°²×°ÆäËû×é¼þ"
+	IDS_DOWNLOAD_UNPACKING         "ÕýÔÚ½âѹËõ°ü"
+    IDS_DOWNLOAD_TEXT              "ÏÂÔز¢°²×° Java Ó¦ÓóÌÐòËùÐèµÄÆäËû×é¼þºó£¬¸ÃÓ¦ÓóÌÐò½«Æô¶¯¡£"
+    
+    IDS_FILE_UPDATE_ERROR          "¸üР%s%s ʱ·¢Éú´íÎó¡£"
+    IDS_FILE_DELETE_ERROR          "ɾ³ý %s ʱ·¢Éú´íÎó¡£"
+    IDS_JAVA_HOME_ERROR            "ÎÞ·¨È·¶¨ Java Ö÷Ŀ¼¡£"
+    IDS_KERNEL_HOME_ERROR          "ÎÞ·¨È·¶¨ jkernel.dll µÄ·¾¶¡£"
+    IDS_JBROKER_ERROR              "ÎÞ·¨Æô¶¯ jbroker.exe¡£"
+    IDS_FATAL_ERROR                "Java ÎÞ·¨ÏÂÔØËùÐèµÄ×é¼þ¡£ÏÖÔÚ³ÌÐò½«Í˳ö¡£"
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "Java ÎÞ·¨ÓëÏÂÔØ·þÎñÆ÷½øÐÐͨÐÅ¡£ÏÖÔÚ³ÌÐò½«Í˳ö¡£"
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "Java ÔÚÓëÏÂÔØ·þÎñÆ÷½øÐÐͨÐÅʱÓöµ½´íÎó¡£ÏÖÔÚ³ÌÐò½«Í˳ö¡£"
+    IDS_ERROR_MALFORMED_URL "Java ÎÞ·¨´Ó URL '%s' Ö´ÐÐÏÂÔØ¡£ÏÖÔÚ³ÌÐò½«Í˳ö¡£"
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/kernel_zh_TW.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 340, 120
+STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | 
+    WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "©Ò»Ýªº¨ä¥L¤¸¥ó"
+EXSTYLE WS_EX_APPWINDOW
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", IDC_DOWNLOAD_MASTHEAD, 0, 0, 340, 39
+    LTEXT           "", IDC_MASTHEAD_TEXT, 60, 14, 200, 12
+    CONTROL         "", IDC_STATIC,"Static", SS_BLACKFRAME | SS_SUNKEN,
+                    0, 39, 340, 1
+    LTEXT           "", IDC_DOWNLOAD_TEXT, 12, 60, 316, 20
+    LTEXT           "", IDC_TIME_REMAINING, 12, 90, 316, 10
+    CONTROL         "Progress1",1006,"msctls_progress32",PBS_SMOOTH,
+                    12, 100, 265, 14
+    PUSHBUTTON	    "¨ú®ø",  2, 285, 100, 46, 14
+END
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE 
+BEGIN
+    105, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 236
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 63
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE 
+BEGIN
+    IDS_DOWNLOAD_CANCEL_MESSAGE   "¨ú®ø¦w¸ËÀ³¥Îµ{¦¡©Ò»Ýªº¨ä¥L¤¸¥ó¡A¥i¯à·|¾É­PÀ³¥Îµ{¦¡µ²§ô¡C\n\n±z½T©w­n¨ú®ø¦w¸Ë¨ä¥L¤¸¥ó¡H"
+    IDS_DOWNLOAD_CANCEL_CAPTION   "¨ú®ø - ¨ä¥L¤¸¥ó"
+    IDS_DOWNLOAD_CANCEL_INSTRUCTION   ""
+    IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT      "³s½u¹O®É"
+    IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE "µLªk³s½u¦Üºô»Úºô¸ô"
+    IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR        "¦øªA¾¹¿ù»~ (¿ù»~ %s)"
+    IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL      "µLªk¨Ï¥ÎªA°È (¿ù»~ %s)"
+    IDS_HTTP_INSTRUCTION_FORBIDDEN            "©Úµ´©Î¸T¤î¦s¨ú (¿ù»~ %s)"
+    IDS_HTTP_STATUS_OTHER                     "¦b¦¹½Ð¨D´Á¶¡µo¥Í¿ù»~¡C¬O§_­n­«¸Õ½Ð¨D¡H"
+
+// HTTP status code
+    IDS_HTTP_STATUS_REQUEST_TIMEOUT "¦øªA¾¹µ¥«Ý½Ð¨D®É¥X²{¹O®É¡C"
+    IDS_HTTP_STATUS_FORBIDDEN		"¦øªA¾¹ÁA¸Ñ¸Ó½Ð¨D¡A¦ý¥¿¦b©Úµ´¹ê²{¥¦¡C"
+    IDS_HTTP_STATUS_SERVER_ERROR	"¦øªA¾¹¹J¨ìªý¤î¨ä¹ê²{½Ð¨Dªº¥¼¹w´Á±ø¥ó¡C"
+    IDS_HTTP_STATUS_SERVICE_UNAVAIL	"ªA°È¼È®É¶W¸ü¡C"
+
+
+    IDS_DOWNLOAD_STATUS_RETRY		"¦øªA¾¹¥Ø«e³B©ó¦£¸Lª¬ºA¡A½Ð¦b %ld ¬í«á­«¸Õ..."
+
+    IDS_ERROR_CAPTION               "¿ù»~ - Java Kernel"
+    IDS_HOURSMINUTESECOND	    "¹w¦ô³Ñ¾l®É¶¡¡G%d ¤p®É %d ¤À %.0f ¬í"
+    IDS_HOURMINUTESECOND	    "¹w¦ô³Ñ¾l®É¶¡¡G%d ¤p®É %d ¤À %.0f ¬í"
+    IDS_MINUTESECOND 		    "¹w¦ô³Ñ¾l®É¶¡¡G%d ¤À %.0f ¬í"
+    IDS_SECOND                      "¹w¦ô³Ñ¾l®É¶¡¡G%.0f ¬í"
+    IDS_DISK_FULL_ERROR_CAPTION     "ºÏºÐ¤wº¡"
+    IDS_DISK_FULL_ERROR             "¥Ñ©óºÏºÐ¤wº¡¡AJava Kernel µLªk¤U¸ü©Ò»Ýªº¤¸¥ó¡C¬O§_­n­«¸Õ¡H"
+    IDS_DISK_WRITE_ERROR_CAPTION    "ºÏºÐ¼g¤J¿ù»~"
+    IDS_DISK_WRITE_ERROR            "Java Kernel ¦b¼g¤J¦ÜºÏºÐ®É¹J¨ì¿ù»~¡C¬O§_­n­«¸Õ¡H"
+    IDS_HTTP_STATUS_SERVER_NOT_REACHABLE "¦b¨t²Î¥Ø«eªººô»Úºô¸ô³s½u³]©w¤U¡AJava Kernel µLªkÄ~Äò°õ¦æ¡C¦b Windows¡u±±¨î¥x¡v¤¤¡A½Ð®Ö¹ï¡uºô»Úºô¸ô¿ï¶µ¡v->¡u³s½u¡v¡A¥H½T©w³]©w©M¥N²z¦øªA¾¹¸ê°T¥¿½T¡C"
+
+    IDS_DOWNLOAD_RETRY             "¤U¸ü¿ù»~"
+    IDS_DOWNLOAD_RETRY_TEXT        "¤U¸ü¬Y¨Ç©Ò»Ý¤¸¥ó®Éµo¥Í¿ù»~¡C¬O§_­n­«¸Õ¤U¸ü³o¨Ç¤¸¥ó¡H"
+
+    IDS_DOWNLOAD                   "¥¿¦b¦w¸Ë¨ä¥L¤¸¥ó"
+	IDS_DOWNLOAD_UNPACKING         "¥¿¦b¸ÑÀ£ÁY§ô"
+    IDS_DOWNLOAD_TEXT              "¤U¸ü¨Ã¦w¸Ë¨ä¥L©Ò»Ý¤¸¥ó«á¡AJava À³¥Îµ{¦¡±N±Ò°Ê¡C"
+    
+    IDS_FILE_UPDATE_ERROR          "§ó·s %s%s ®Éµo¥Í¿ù»~¡C"
+    IDS_FILE_DELETE_ERROR          "²¾°£ %s ®Éµo¥Í¿ù»~¡C"
+    IDS_JAVA_HOME_ERROR            "µLªk½T©w Java ¥D¥Ø¿ý¡C"
+    IDS_KERNEL_HOME_ERROR          "µLªk½T©w jkernel.dll ªº¸ô®|¡C"
+    IDS_JBROKER_ERROR              "µLªk±Ò°Ê jbroker.exe¡C"
+    IDS_FATAL_ERROR                "Java µLªk¤U¸ü©Ò»Ýªº¤¸¥ó¡Cµ{¦¡±N¥ß§Yµ²§ô¡C"
+    IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES "Java µLªk»P¤U¸ü¦øªA¾¹¶i¦æ³q°T¡Cµ{¦¡±N¥ß§Yµ²§ô¡C"
+    IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES "Java ¦b»P¤U¸ü¦øªA¾¹¶i¦æ³q°T®É¹J¨ì¤F¤@­Ó¿ù»~¡Cµ{¦¡±N¥ß§Yµ²§ô¡C"
+    IDS_ERROR_MALFORMED_URL "Java µLªk±q URL¡u%s¡v¤U¸ü¡Cµ{¦¡±N¥ß§Yµ²§ô¡C"
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/resource.h	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+//
+//
+
+
+// HTTP status code
+#define IDS_HTTP_STATUS_FORBIDDEN           403
+#define IDS_HTTP_STATUS_REQUEST_TIMEOUT     408
+#define IDS_HTTP_STATUS_SERVER_ERROR        500
+#define IDS_HTTP_STATUS_SERVICE_UNAVAIL     503
+
+
+
+#define IDS_HTTP_INSTRUCTION_REQUEST_TIMEOUT           2408
+#define IDS_HTTP_INSTRUCTION_SERVICE_UNAVAIL           2503
+#define IDS_HTTP_INSTRUCTION_FORBIDDEN                 2403
+#define IDS_HTTP_INSTRUCTION_SERVER_NOT_REACHABLE      2035
+#define IDS_HTTP_INSTRUCTION_UNKNOWN_ERROR             2036
+#define IDS_HTTP_STATUS_OTHER                          2037
+
+#define IDS_DOWNLOAD_STATUS_RETRY           3004
+
+#define IDD_DOWNLOAD_DIALOG             105
+#define IDI_JAVA                        114
+#define IDI_MASTHEAD                    115
+#define IDC_DOWNLOAD_PROGRESS           1006
+#define IDC_DOWNLOAD_INFO               1007
+#define IDC_DOWNLOAD_STATUS             1008
+#define IDC_DOWNLOAD_ANIMATE            1009
+#define IDS_ERROR_CAPTION               2004
+#define IDS_HOURSMINUTESECOND           2007
+#define IDS_HOURMINUTESECOND            2008
+#define IDS_MINUTESECOND                2009
+#define IDS_SECOND                      2010
+#define IDS_DISK_FULL_ERROR             2023
+#define IDS_DISK_FULL_ERROR_CAPTION     2024
+#define IDS_DISK_WRITE_ERROR            2025
+#define IDS_DISK_WRITE_ERROR_CAPTION    2026
+#define IDS_HTTP_STATUS_SERVER_NOT_REACHABLE  2028
+#define IDS_FATAL_ERROR                 2029
+#define IDS_ERROR_DOWNLOADING_BUNDLE_PROPERTIES 2030
+#define IDS_ERROR_MALFORMED_BUNDLE_PROPERTIES 2031
+#define IDS_ERROR_MALFORMED_URL         2032
+
+#define IDS_DOWNLOAD_CANCEL_CAPTION            2038
+#define IDS_DOWNLOAD_CANCEL_INSTRUCTION        2039
+#define IDS_DOWNLOAD_CANCEL_MESSAGE            2040
+
+// codes for download and install dialog
+#define IDC_MASTHEAD_TEXT               116
+#define IDC_DOWNLOAD_MASTHEAD           121
+#define IDC_TIME_REMAINING              122
+#define IDC_DOWNLOAD_TEXT               123
+
+// codes for download retry dialog
+#define IDS_DOWNLOAD_RETRY              130
+#define IDS_DOWNLOAD_RETRY_TEXT         131
+
+#define IDS_DOWNLOAD_UNPACKING          3900
+#define IDS_DOWNLOAD                    4000
+#define IDS_DOWNLOAD_TEXT               4001
+
+// codes for completion cleanup
+#define IDS_FILE_UPDATE_ERROR           4101
+#define IDS_FILE_DELETE_ERROR           4103
+#define IDS_JAVA_HOME_ERROR             4104
+#define IDS_KERNEL_HOME_ERROR           4105
+#define IDS_JBROKER_ERROR               4106
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE        128
+#define _APS_NEXT_COMMAND_VALUE         40001
+#define _APS_NEXT_CONTROL_VALUE         1016
+#define _APS_NEXT_SYMED_VALUE           103
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/stdafx.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+// stdafx.cpp : source file that includes just the standard includes
+//  stdafx.pch will be the pre-compiled header
+//  stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+#ifdef _ATL_STATIC_REGISTRY
+#include <statreg.h>
+#include <statreg.cpp>
+#endif
+
+#include <atlimpl.cpp>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/stdafx.h	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+// stdafx.h : include file for standard system include files,
+//      or project specific include files that are used frequently,
+//      but are changed infrequently
+
+#if !defined(AFX_STDAFX_H__FBC6C744_18F8_11D6_9DF1_0001023B10AA__INCLUDED_)
+#define AFX_STDAFX_H__FBC6C744_18F8_11D6_9DF1_0001023B10AA__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#define _ATL_APARTMENT_THREADED
+
+#include <atlbase.h>
+//You may derive a class from CComModule and use it if you want to override
+//something, but do not change the name of _Module
+extern CComModule _Module;
+#include <atlcom.h>
+#include <atlwin.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__FBC6C744_18F8_11D6_9DF1_0001023B10AA__INCLUDED)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/native/sun/jkernel/version.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2008 - 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+#include "afxres.h"
+
+// Need 2 defines so macro argument to XSTR will get expanded before quoting.
+#define XSTR(x) STR(x)
+#define STR(x)  #x
+
+LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION    JDK_FVER
+ PRODUCTVERSION JDK_FVER
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ // FILEOS 0x4 is Win32, 0x40004 is Win32 NT only
+ FILEOS 0x4L
+ // FILETYPE should be 0x1 for .exe and 0x2 for .dll
+ FILETYPE JDK_FTYPE
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "000004b0"
+        BEGIN
+            VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
+            VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
+            VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
+            VALUE "Full Version",     XSTR(JDK_BUILD_ID)      "\0"
+	    VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
+            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
+            VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
+            VALUE "ProductName",      XSTR(JDK_NAME)          "\0"
+            VALUE "ProductVersion",   XSTR(JDK_VER)           "\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x0, 1200
+    END
+END
--- a/jdk/src/windows/native/sun/windows/awt.rc	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/native/sun/windows/awt.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -48,8 +48,8 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION    J2SE_FVER
- PRODUCTVERSION J2SE_FVER
+ FILEVERSION    JDK_FVER
+ PRODUCTVERSION JDK_FVER
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -59,22 +59,22 @@
  // FILEOS 0x4 is Win32, 0x40004 is Win32 NT only
  FILEOS 0x4L
  // FILETYPE should be 0x1 for .exe and 0x2 for .dll
- FILETYPE J2SE_FTYPE
+ FILETYPE JDK_FTYPE
  FILESUBTYPE 0x0L
 BEGIN
     BLOCK "StringFileInfo"
     BEGIN
         BLOCK "040904b0"
         BEGIN
-            VALUE "CompanyName",      XSTR(J2SE_COMPANY)       "\0"
-            VALUE "FileDescription",  XSTR(J2SE_COMPONENT)     "\0"
-            VALUE "FileVersion",      XSTR(J2SE_VER)           "\0"
-            VALUE "Full Version",     XSTR(J2SE_BUILD_ID)      "\0"
-	    VALUE "InternalName",     XSTR(J2SE_INTERNAL_NAME) "\0"
-            VALUE "LegalCopyright",   XSTR(J2SE_COPYRIGHT)     "\0"
-            VALUE "OriginalFilename", XSTR(J2SE_FNAME)         "\0"
-            VALUE "ProductName",      XSTR(J2SE_NAME)          "\0"
-            VALUE "ProductVersion",   XSTR(J2SE_VER)           "\0"
+            VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
+            VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
+            VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
+            VALUE "Full Version",     XSTR(JDK_BUILD_ID)      "\0"
+	    VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
+            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
+            VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
+            VALUE "ProductName",      XSTR(JDK_NAME)          "\0"
+            VALUE "ProductVersion",   XSTR(JDK_VER)           "\0"
         END
     END
     BLOCK "VarFileInfo"
--- a/jdk/src/windows/native/sun/windows/awt_Component.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Component.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -5975,17 +5975,7 @@
     env->DeleteGlobalRef(self);
 
     delete cpps;
-
-    if (result != NULL)
-    {
-        jintArray resultGlobalRef = (jintArray)env->NewGlobalRef(result);
-        env->DeleteLocalRef(result);
-        return resultGlobalRef;
-    }
-    else
-    {
-        return NULL;
-    }
+    return result; // this reference is global
 }
 
 jboolean AwtComponent::_IsObscured(void *param)
--- a/jdk/src/windows/native/sun/windows/awt_Frame.cpp	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.cpp	Tue Jul 21 13:02:23 2009 -0700
@@ -381,19 +381,29 @@
 
 void AwtFrame::CreateProxyFocusOwner()
 {
-    DASSERT(m_proxyFocusOwner == NULL);
-    DASSERT(AwtToolkit::MainThread() == ::GetCurrentThreadId());
+    if (AwtToolkit::IsMainThread()) {
+        AwtFrame::_CreateProxyFocusOwner((void *)this);
+    } else {
+        AwtToolkit::GetInstance().InvokeFunction(AwtFrame::_CreateProxyFocusOwner, (void *)this);
+    }
+}
+
+void AwtFrame::_CreateProxyFocusOwner(void *param)
+{
+    DASSERT(AwtToolkit::IsMainThread());
 
-    m_proxyFocusOwner = ::CreateWindow(TEXT("STATIC"),
-                                       TEXT("ProxyFocusOwner"),
-                                       WS_CHILD,
-                                       0, 0, 0, 0, GetHWnd(), NULL,
-                                       AwtToolkit::GetInstance().
-                                           GetModuleHandle(),
-                                       NULL);
+    AwtFrame *f = (AwtFrame *)param;
+    DASSERT(f->m_proxyFocusOwner == NULL);
 
-    m_proxyDefWindowProc = ComCtl32Util::GetInstance().SubclassHWND(m_proxyFocusOwner, ProxyWindowProc);
+    f->m_proxyFocusOwner = ::CreateWindow(TEXT("STATIC"),
+                                          TEXT("ProxyFocusOwner"),
+                                          WS_CHILD,
+                                          0, 0, 0, 0, f->GetHWnd(), NULL,
+                                          AwtToolkit::GetInstance().
+                                          GetModuleHandle(),
+                                          NULL);
 
+    f->m_proxyDefWindowProc = ComCtl32Util::GetInstance().SubclassHWND(f->m_proxyFocusOwner, ProxyWindowProc);
 }
 
 void AwtFrame::DestroyProxyFocusOwner()
--- a/jdk/src/windows/native/sun/windows/awt_Frame.h	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/native/sun/windows/awt_Frame.h	Tue Jul 21 13:02:23 2009 -0700
@@ -117,7 +117,6 @@
     INLINE BOOL IsUndecorated() { return m_isUndecorated; }
 
     INLINE HWND GetProxyFocusOwner() {
-        DASSERT(AwtToolkit::MainThread() == ::GetCurrentThreadId());
         if (m_proxyFocusOwner == NULL) {
             CreateProxyFocusOwner();
         }
@@ -165,6 +164,8 @@
     void CreateProxyFocusOwner();
     void DestroyProxyFocusOwner();
 
+    /* creates proxy focus owner, called on Toolkit thread */
+    static void _CreateProxyFocusOwner(void *param);
     /* destroys proxy focus owner, called on Toolkit thread */
     static void _DestroyProxyFocusOwner(void *param);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/resource/unpack200_proto.exe.manifest	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
+  <assemblyIdentity version="IMVERSION"
+     processorArchitecture="X86"
+     name="unpack200.exe"
+     type="win32"/> 
+
+  <description>Java(TM) SE Runtime Environment unpack200 Process.</description> 
+  <!-- Identify the application security requirements. -->
+  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
+    <security>
+      <requestedPrivileges>
+        <requestedExecutionLevel
+          level="asInvoker"
+          uiAccess="false"/>
+        </requestedPrivileges>
+       </security>
+  </trustInfo>
+</assembly>
--- a/jdk/src/windows/resource/version.rc	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/src/windows/resource/version.rc	Tue Jul 21 13:02:23 2009 -0700
@@ -37,8 +37,8 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION    J2SE_FVER
- PRODUCTVERSION J2SE_FVER
+ FILEVERSION    JDK_FVER
+ PRODUCTVERSION JDK_FVER
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -48,22 +48,22 @@
  // FILEOS 0x4 is Win32, 0x40004 is Win32 NT only
  FILEOS 0x4L
  // FILETYPE should be 0x1 for .exe and 0x2 for .dll
- FILETYPE J2SE_FTYPE
+ FILETYPE JDK_FTYPE
  FILESUBTYPE 0x0L
 BEGIN
     BLOCK "StringFileInfo"
     BEGIN
         BLOCK "000004b0"
         BEGIN
-            VALUE "CompanyName",      XSTR(J2SE_COMPANY)       "\0"
-            VALUE "FileDescription",  XSTR(J2SE_COMPONENT)     "\0"
-            VALUE "FileVersion",      XSTR(J2SE_VER)           "\0"
-            VALUE "Full Version",     XSTR(J2SE_BUILD_ID)      "\0"
-	    VALUE "InternalName",     XSTR(J2SE_INTERNAL_NAME) "\0"
-            VALUE "LegalCopyright",   XSTR(J2SE_COPYRIGHT)     "\0"
-            VALUE "OriginalFilename", XSTR(J2SE_FNAME)         "\0"
-            VALUE "ProductName",      XSTR(J2SE_NAME)          "\0"
-            VALUE "ProductVersion",   XSTR(J2SE_VER)           "\0"
+            VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
+            VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
+            VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
+            VALUE "Full Version",     XSTR(JDK_BUILD_ID)      "\0"
+	    VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
+            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
+            VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
+            VALUE "ProductName",      XSTR(JDK_NAME)          "\0"
+            VALUE "ProductVersion",   XSTR(JDK_VER)           "\0"
         END
     END
     BLOCK "VarFileInfo"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,52 @@
+/*
+ * 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 6736247
+  @summary Component.printAll Invalid local JNI handle
+  @author Dmitry Cherepanov: area=awt.component
+  @run  main/othervm -Xcheck:jni PrintAllXcheckJNI
+*/
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+
+public class PrintAllXcheckJNI
+{
+    public static void main(String []s)
+    {
+        Frame frame = new Frame();
+        frame.setVisible(true);
+
+        BufferedImage img = new BufferedImage(frame.getWidth(),
+                                              frame.getHeight(),
+                                              BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = img.createGraphics();
+
+        frame.printAll(g);
+
+        g.dispose();
+        img.flush();
+    }
+}
--- a/jdk/test/java/awt/Focus/FocusTraversalPolicy/DefaultFTPTest.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/java/awt/Focus/FocusTraversalPolicy/DefaultFTPTest.java	Tue Jul 21 13:02:23 2009 -0700
@@ -104,7 +104,7 @@
 */
 
 public class DefaultFTPTest {
-    final int TESTS_NUMBER = 10;
+    final int TESTS_NUMBER = 11;
 
     public static void main(String[] args) {
         DefaultFTPTest app = new DefaultFTPTest();
@@ -928,3 +928,63 @@
         }
     }
 }
+
+/*
+ * frame [ container(root) [...] comp ]
+ * - getDefaultComponent(<frame>) should implicitly down-cycle into the <container>.
+ * - getFirstComponent(<frame>) should implicitly down-cycle into the <container>.
+ */
+class PolicyTest11 extends AbstractPolicyTest {
+    protected Frame createFrame() {
+        Frame frame = (Frame) registerComponent("frame", new Frame("Test Frame"));
+        frame.setLayout(new FlowLayout());
+
+        Container cont = (Container)registerComponent("panel", new Panel());
+        cont.add(registerComponent("btn-1", new Button("button")));
+        cont.add(registerComponent("btn-2", new Button("button")));
+
+        frame.add(cont);
+        frame.add(registerComponent("btn-3", new Button("button")));
+
+        return frame;
+    }
+
+    protected void customizeHierarchy() {
+        ((Container)getComponent("frame")).setFocusTraversalPolicy(new DefaultFocusTraversalPolicy());
+        ((Container)getComponent("panel")).setFocusCycleRoot(true);
+    }
+
+    protected Map<String, String> getForwardOrder() {
+        Map<String, String> order = new HashMap<String, String>();
+        order.put("frame", "btn-1");
+        order.put("btn-1", "btn-2");
+        order.put("btn-2", "btn-1");
+        order.put("btn-3", "btn-1");
+        return order;
+    }
+
+    protected Map<String, String> getBackwardOrder() {
+        Map<String, String> order = new HashMap<String, String>();
+        order.put("btn-3", "btn-1");
+        order.put("btn-2", "btn-1");
+        order.put("btn-1", "btn-2");
+        order.put("frame", "btn-3");
+        return order;
+    }
+
+    protected String[] getContainersToTest() {
+        return new String[] {"frame"};
+    }
+
+    protected String getDefaultComp(String focusCycleRoot_id) {
+        return "btn-1";
+    }
+
+    protected String getFirstComp(String focusCycleRoot_id) {
+        return "btn-1";
+    }
+
+    protected String getLastComp(String focusCycleRoot_id) {
+        return "btn-3";
+    }
+}
--- a/jdk/test/java/awt/Focus/FocusTraversalPolicy/LayoutFTPTest.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/java/awt/Focus/FocusTraversalPolicy/LayoutFTPTest.java	Tue Jul 21 13:02:23 2009 -0700
@@ -105,7 +105,7 @@
 */
 
 public class LayoutFTPTest {
-    final int TESTS_NUMBER = 10;
+    final int TESTS_NUMBER = 11;
 
     public static void main(String[] args) {
         LayoutFTPTest app = new LayoutFTPTest();
@@ -929,3 +929,63 @@
         }
     }
 }
+
+/*
+ * frame [ container(root) [...] comp ]
+ * - getDefaultComponent(<frame>) should implicitly down-cycle into the <container>.
+ * - getFirstComponent(<frame>) should implicitly down-cycle into the <container>.
+ */
+class PolicyTest11 extends AbstractPolicyTest {
+    protected Frame createFrame() {
+        JFrame jframe = (JFrame) registerComponent("jframe", new JFrame("Test Frame"));
+        jframe.setLayout(new FlowLayout());
+
+        Container cont = (Container)registerComponent("jpanel", new JPanel());
+        cont.add(registerComponent("btn-1", new JButton("jbutton")));
+        cont.add(registerComponent("btn-2", new JButton("jbutton")));
+
+        jframe.add(cont);
+        jframe.add(registerComponent("btn-3", new JButton("jbutton")));
+
+        return jframe;
+    }
+
+    protected void customizeHierarchy() {
+        ((Container)getComponent("jframe")).setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
+        ((Container)getComponent("jpanel")).setFocusCycleRoot(true);
+    }
+
+    protected Map<String, String> getForwardOrder() {
+        Map<String, String> order = new HashMap<String, String>();
+        order.put("jframe", "btn-1");
+        order.put("btn-1", "btn-2");
+        order.put("btn-2", "btn-1");
+        order.put("btn-3", "btn-1");
+        return order;
+    }
+
+    protected Map<String, String> getBackwardOrder() {
+        Map<String, String> order = new HashMap<String, String>();
+        order.put("btn-3", "btn-1");
+        order.put("btn-2", "btn-1");
+        order.put("btn-1", "btn-2");
+        order.put("jframe", "btn-3");
+        return order;
+    }
+
+    protected String[] getContainersToTest() {
+        return new String[] {"jframe"};
+    }
+
+    protected String getDefaultComp(String focusCycleRoot_id) {
+        return "btn-1";
+    }
+
+    protected String getFirstComp(String focusCycleRoot_id) {
+        return "btn-1";
+    }
+
+    protected String getLastComp(String focusCycleRoot_id) {
+        return "btn-3";
+    }
+}
--- a/jdk/test/java/awt/Focus/NonFocusableWindowTest/NoEventsTest.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/java/awt/Focus/NonFocusableWindowTest/NoEventsTest.java	Tue Jul 21 13:02:23 2009 -0700
@@ -416,5 +416,3 @@
 //         }
     }
 }
-
-
--- a/jdk/test/java/awt/Focus/RestoreFocusOnDisabledComponentTest/RestoreFocusOnDisabledComponentTest.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/java/awt/Focus/RestoreFocusOnDisabledComponentTest/RestoreFocusOnDisabledComponentTest.java	Tue Jul 21 13:02:23 2009 -0700
@@ -105,4 +105,3 @@
         super("Test failed: " + msg);
     }
 }
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.html	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,43 @@
+<html>
+<!--  
+
+ 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 5004032
+  @summary GridBagConstraints.ipad(x|y) defined in a new way
+  @author dav@sparc.spb.su area= 
+  @run applet GridBagLayoutIpadXYTest.html
+  -->
+<head>
+<title>  </title>
+</head>
+<body>
+
+<h1>GridBagLayoutIpadXYTest<br>Bug ID: 5004032 </h1>
+
+<p> This is an AUTOMATIC test, simply wait for completion </p>
+
+<APPLET CODE="GridBagLayoutIpadXYTest.class" WIDTH=200 HEIGHT=200></APPLET>
+</body>
+</html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/GridBagLayout/GridBagLayoutIpadXYTest/GridBagLayoutIpadXYTest.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,89 @@
+/*
+ * 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 5004032
+  @summary GridBagConstraints.ipad(x|y) defined in a new way
+  @author dav@sparc.spb.su area=
+  @run applet GridBagLayoutIpadXYTest.html
+*/
+
+import java.applet.Applet;
+import java.awt.*;
+
+public class GridBagLayoutIpadXYTest extends Applet
+{
+    Frame frame = new Frame();
+    TextField jtf = null;
+    final int customIpadx = 300;
+    final int customIpady = 40;
+
+    public void init()
+    {
+        this.setLayout (new BorderLayout ());
+
+        String[] instructions =
+        {
+            "This is an AUTOMATIC test",
+            "simply wait until it is done"
+        };
+    }//End  init()
+
+    public void start ()
+    {
+        validate();
+        frame.setLayout(new GridBagLayout());
+        GridBagConstraints gc = new GridBagConstraints();
+        Insets fieldInsets = new Insets(0,5,5,0);
+
+        gc.anchor = gc.NORTH;
+        gc.fill = gc.HORIZONTAL;
+        gc.gridx = 1;
+        gc.gridy = 0;
+        gc.weightx = 1;
+        gc.ipadx = customIpadx;
+        gc.ipady = customIpady;
+        gc.insets = fieldInsets;
+        jtf = new TextField();
+        frame.add(jtf, gc);
+
+        frame.pack();
+        frame.setVisible(true);
+
+        ((sun.awt.SunToolkit)Toolkit.getDefaultToolkit()).realSync();
+
+        Dimension minSize = jtf.getMinimumSize();
+        if ( minSize.width + customIpadx != jtf.getSize().width ||
+             minSize.height + customIpady != jtf.getSize().height ){
+            System.out.println("TextField originally has min size = " + jtf.getMinimumSize());
+            System.out.println("TextField supplied with ipadx =  300, ipady =40");
+            System.out.println("Frame size: " + frame.getSize());
+            System.out.println(" Fields's size is "+jtf.getSize());
+
+            throw new RuntimeException("Test Failed. TextField has incorrect width. ");
+        }
+        System.out.println("Test Passed.");
+
+    }// start()
+}
--- a/jdk/test/java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/java/awt/GridLayout/LayoutExtraGaps/LayoutExtraGaps.java	Tue Jul 21 13:02:23 2009 -0700
@@ -24,7 +24,8 @@
 /*
    @test
    @bug 4370316
-   @summary GridLayout does not fill its Container
+   @summary GridLayout does not centre its component properly
+    (summary was GridLayout does not fill its Container)
    @library ../../regtesthelpers
    @build Util
    @author Andrei Dmitriev : area=awt.layout
@@ -90,25 +91,97 @@
         setVisible(true);
 
         Util.waitForIdle(Util.createRobot());
-        Rectangle r1 = yellowPanel.getComponent(0).getBounds();
-        Rectangle r2 = bluePanel.getComponent(0).getBounds();
-        Rectangle r3 = blackPanel.getComponent(0).getBounds();
-        Rectangle r4 = redPanel.getComponent(0).getBounds();
+
+        if (isComponentCentredLTR(yellowPanel) && isComponentCentredLTR(bluePanel)
+                && isComponentCentredLTR(blackPanel) && isComponentCentredRTL(redPanel))
+        {
+            System.out.println("Test passed.");
+        } else {
+            throw new RuntimeException("Test failed. GridLayout doesn't center component.");
+        }
+    }
+
+    /**
+     * Checks if the components under Panel p are properly centred (i.e.
+     * opposite borders between the Panel and component are equal). Panel p
+     * must not be affect by RTL orientation (RTL only affects horizontal
+     * positioning and components lay out from top right corner).
+     *
+     * @param      p the panel where the components exist and is not affected
+     *             by right to left orientation
+     * @return     true if components of panel p are properly centre, false
+     *             otherwise
+     */
+    public static boolean isComponentCentredLTR(Panel p) {
+        double borderLeft;
+        double borderRight;
+        double borderTop;
+        double borderBottom;
+
+        //The first component(rectangle) in panel p.
+        Rectangle firstRec = p.getComponent(0).getBounds();
+
+        //The last component(rectangle) in panel p.
+        Rectangle lastRec = p.getComponent(compCount - 1).getBounds();
+
+        System.out.println("bounds of the first rectangle in "+ p.getName() + " = " + firstRec);
+        System.out.println("bounds of the last rectangle in "+ p.getName() + " = " + lastRec);
+
+        borderLeft = firstRec.getX();
+        borderRight = p.getWidth() - lastRec.getWidth() - lastRec.getX();
+        borderTop = firstRec.getY();
+        borderBottom = p.getHeight() - lastRec.getHeight() - lastRec.getY();
+
+        return areBordersEqual(borderLeft, borderRight) &&
+                areBordersEqual(borderTop, borderBottom);
+    }
 
-        System.out.println("firstHorizLabel bounds  ="+r1);
-        System.out.println("firstVertLabel bounds ="+r2);
-        System.out.println("firstHorizLabel_RTL bounds ="+r3);
-        System.out.println("firstVertLabel_RTL bounds ="+r4);
-        if ((r1.getX() == 0 && r1.getY() == 0) ||
-            (r2.getX() == 0 && r2.getY() == 0) ||
-            (r3.getX() == 0 && r3.getY() == 0) ||
-            // RTL only affects horizontal positioning and components lays out from top right corner
-            (r4.getX() == blackPanel.getWidth() && r4.getY() == 0))
-        {
-            throw new RuntimeException("Test failed. GridLayout doesn't center component.");
-        } else {
-            System.out.println("Test passed.");
-        }
+    /**
+     * Checks if the components under Panel p are properly centred (i.e.
+     * opposite borders between the Panel and component are equal). Panel p
+     * must be affect by RTL orientation (RTL only affects horizontal positioning
+     * and components lay out from top right corner).
+     *
+     * @param      p the panel where the components exist and is affected by
+     *             right to left orientation
+     * @return     true if components of panel p are properly centre, false
+     *             otherwise
+     */
+    public static boolean isComponentCentredRTL(Panel p) {
+        double borderLeft;
+        double borderRight;
+        double borderTop;
+        double borderBottom;
+
+        //The first component(rectangle) in panel p.
+        Rectangle firstRec = p.getComponent(0).getBounds();
+
+        //The last component(rectangle) in panel p.
+        Rectangle lastRec = p.getComponent(compCount - 1).getBounds();
+
+        System.out.println("bounds of the first rectangle in "+ p.getName() + " = " + firstRec);
+        System.out.println("bounds of the last rectangle in "+ p.getName() + " = " + lastRec);
+
+        borderLeft = lastRec.getX();
+        borderRight = p.getWidth() - firstRec.getWidth() - firstRec.getX();
+        borderTop = lastRec.getY();
+        borderBottom = p.getHeight() - firstRec.getHeight() - firstRec.getY();
+
+        return areBordersEqual(borderLeft, borderRight) &&
+                areBordersEqual(borderTop, borderBottom);
+    }
+
+    /**
+     * Given two borders border1 and border2 check if they are equal.
+     *
+     * @param      border1 one of the borders being compared
+     * @param      border2 the other border being compared
+     * @return     true if border1 and border2 are equal to each other (i.e.
+     *             their width/height difference is at most 1, assuming the
+     *             smallest pixel is of size 1), false otherwise
+     */
+    public static boolean areBordersEqual(double border1, double border2) {
+        return Math.abs(border1 - border2) <= 1;
     }
 
     public static void main(String[] args) {
--- a/jdk/test/java/awt/font/Rotate/TranslatedOutlineTest.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/java/awt/font/Rotate/TranslatedOutlineTest.java	Tue Jul 21 13:02:23 2009 -0700
@@ -66,4 +66,3 @@
         throw new RuntimeException("Outline was not detected");
     }
 }
-
--- a/jdk/test/java/awt/font/Threads/FontThread.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/java/awt/font/Threads/FontThread.java	Tue Jul 21 13:02:23 2009 -0700
@@ -85,5 +85,3 @@
         }
     }
 }
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/Test6852574.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,58 @@
+/*
+ * 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 6852574
+ * @summary Tests Enum subclass encoding
+ * @author Sergey Malenkov
+ */
+
+public final class Test6852574 extends AbstractTest {
+    public static void main(String[] args) {
+        new Test6852574().test(true);
+    }
+
+    protected Object getObject() {
+        return Data.FIRST;
+    }
+
+    protected Object getAnotherObject() {
+        return Data.SECOND;
+    }
+
+    public enum Data {
+        FIRST {
+            @Override
+            public String toString() {
+                return "1";
+            }
+        },
+        SECOND {
+            @Override
+            public String toString() {
+                return "2";
+            }
+        }
+    }
+}
--- a/jdk/test/java/security/AccessControlContext/FailureDebugOption.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/java/security/AccessControlContext/FailureDebugOption.java	Tue Jul 21 13:02:23 2009 -0700
@@ -47,4 +47,3 @@
         }
    }
 }
-
--- a/jdk/test/java/text/Bidi/Bug6850113.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/java/text/Bidi/Bug6850113.java	Tue Jul 21 13:02:23 2009 -0700
@@ -24,6 +24,7 @@
  * @test
  * @bug 6850113
  * @summary Verify the return value of digit() for some digits.
+ * @compile -XDignore.symbol.file=true Bug6850113.java
  */
 
 import sun.text.normalizer.UCharacter;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/text/Format/DateFormat/Bug6609750.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,81 @@
+/*
+ * 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 6609750
+ * @summary Make sure that SimpleDateFormat.format() formats years correctly.
+ */
+import java.text.*;
+import java.util.*;
+
+public class Bug6609750 {
+
+    public static void main(String[] args) {
+        boolean error = false;
+
+        Locale defaultLocale = Locale.getDefault();
+        Locale.setDefault(Locale.US);
+
+        Date[] dates = {
+            new Date(9-1900,     Calendar.JUNE, 12),
+            new Date(99-1900,    Calendar.JUNE, 12),
+            new Date(999-1900,   Calendar.JUNE, 12),
+            new Date(2009-1900,  Calendar.JUNE, 12),
+            new Date(30009-1900, Calendar.JUNE, 12),
+        };
+
+        String[] patterns = {
+           "y", "yy", "yyy", "yyyy", "yyyyy", "yyyyyy"
+        };
+        String[][] expectedResults = {
+           {"9",     "09", "009",   "0009",  "00009", "000009"},
+           {"99",    "99", "099",   "0099",  "00099", "000099"},
+           {"999",   "99", "999",   "0999",  "00999", "000999"},
+           {"2009",  "09", "2009",  "2009",  "02009", "002009"},
+           {"30009", "09", "30009", "30009", "30009", "030009"},
+        };
+
+        SimpleDateFormat sdf = new SimpleDateFormat();
+        for (int dateNo = 0; dateNo < dates.length; dateNo++) {
+            Date date = dates[dateNo];
+            for (int patternNo = 0; patternNo < patterns.length; patternNo++) {
+                sdf.applyPattern(patterns[patternNo]);
+                String got = sdf.format(date);
+                if (!expectedResults[dateNo][patternNo].equals(got)) {
+                    error = true;
+                    System.err.println("Failed: Unexpected format result: " +
+                        "Expected: \"" + expectedResults[dateNo][patternNo] +
+                        "\", Got: \"" + got + "\" for date " + date +
+                        " with pattern \"" + patterns[patternNo] + "\"");
+                }
+            }
+        }
+
+        Locale.setDefault(defaultLocale);
+        if (error) {
+            throw new RuntimeException("SimpleDateFormat.format() error.");
+        };
+    }
+
+}
--- a/jdk/test/javax/swing/JPopupMenu/6691503/bug6691503.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/javax/swing/JPopupMenu/6691503/bug6691503.java	Tue Jul 21 13:02:23 2009 -0700
@@ -109,5 +109,3 @@
         });
     }
 }
-
-
--- a/jdk/test/javax/swing/border/Test4856008.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/javax/swing/border/Test4856008.java	Tue Jul 21 13:02:23 2009 -0700
@@ -35,6 +35,7 @@
 import java.awt.Font;
 import java.awt.Insets;
 
+import javax.swing.ActionMap;
 import javax.swing.JComponent;
 import javax.swing.JFileChooser;
 import javax.swing.JLabel;
@@ -51,6 +52,7 @@
 import javax.swing.border.MatteBorder;
 import javax.swing.border.SoftBevelBorder;
 import javax.swing.border.TitledBorder;
+import javax.swing.plaf.ActionMapUIResource;
 import javax.swing.plaf.BorderUIResource;
 import javax.swing.plaf.synth.SynthLookAndFeel;
 import javax.swing.plaf.basic.BasicBorders;
@@ -59,7 +61,6 @@
 import javax.swing.plaf.metal.MetalComboBoxEditor;
 
 import sun.swing.plaf.synth.SynthFileChooserUI;
-import sun.tools.jconsole.BorderedComponent;
 
 public class Test4856008 {
     private static final JLabel LABEL = new JLabel();
@@ -133,11 +134,6 @@
 
             //+ SynthFileChooserUI.UIBorder:
             new SynthFileChooser().getUIBorder(),
-
-            //+ BorderedComponent.FocusBorder:
-            getBorder(false),
-            //+ BorderedComponent.LabeledBorder:
-            getBorder(true),
     };
 
     public static void main(String[] args) {
@@ -182,15 +178,6 @@
         return LABEL;
     }
 
-    // This method is used to get the border from BorderedComponent
-    private static Border getBorder(boolean labeled) {
-        JComponent component = new BorderedComponent("4856008", null, true);
-        CompoundBorder border = (CompoundBorder) component.getBorder();
-        return labeled
-                ? border.getInsideBorder()
-                : border.getOutsideBorder();
-    }
-
     // This class is used to get the instance of BasicBorders.RolloverMarginBorder
     private static class ToolBar extends BasicToolBarUI {
         private Border getRolloverMarginBorder() {
@@ -224,6 +211,11 @@
         }
 
         @Override
+        protected ActionMap createActionMap() {
+            return new ActionMapUIResource();
+        }
+
+        @Override
         public String getFileName() {
             return this.name;
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/nimbus/Test6849805.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2008 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 6849805
+   @summary Tests NimbusLookAndFeel.deriveColor()
+   @author Peter Zhelezniakov
+   @run main Test6849805
+*/
+
+import java.awt.Color;
+
+
+public class Test6849805 {
+
+    static boolean pass = true;
+
+    static class Minimbus extends javax.swing.plaf.nimbus.NimbusLookAndFeel {
+
+        public void test(Color c1, Color c2, float f) {
+            Color r = getDerivedColor(c1, c2, f);
+            Color test = (f > 0 ? c2 : c1);
+            System.out.printf("Got %s, need %s ", r, test);
+
+            if (r.getRGB() == test.getRGB() &&
+                r.getAlpha() == test.getAlpha()) {
+
+                System.out.println("Ok");
+            } else {
+                System.out.println("FAIL");
+                pass = false;
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        Minimbus laf = new Minimbus();
+        laf.test(Color.WHITE, Color.BLACK, 0f);
+        laf.test(Color.WHITE, Color.BLACK, 1f);
+        laf.test(Color.BLACK, Color.WHITE, 0f);
+        laf.test(Color.BLACK, Color.WHITE, 1f);
+        laf.test(Color.RED, Color.GREEN, 0f);
+        laf.test(Color.RED, Color.GREEN, 1f);
+        laf.test(new Color(127, 127, 127), new Color(51, 151, 212), 0f);
+        laf.test(new Color(127, 127, 127), new Color(51, 151, 212), 1f);
+        laf.test(new Color(221, 63, 189), new Color(112, 200, 89), 0f);
+        laf.test(new Color(221, 63, 189), new Color(112, 200, 89), 1f);
+
+        if (! pass) {
+            throw new RuntimeException("Some testcases failed, see above");
+        }
+    }
+}
--- a/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/sun/security/pkcs11/Cipher/TestRSACipherWrap.java	Tue Jul 21 13:02:23 2009 -0700
@@ -106,4 +106,3 @@
         main(new TestRSACipherWrap());
     }
 }
-
--- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java	Tue Jul 21 13:02:23 2009 -0700
@@ -113,4 +113,3 @@
     }
 
 }
-
--- a/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/CloseKeepAliveCached.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/jdk/test/sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/CloseKeepAliveCached.java	Tue Jul 21 13:02:23 2009 -0700
@@ -305,4 +305,3 @@
         }
     }
 }
-
--- a/langtools/.hgtags	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/.hgtags	Tue Jul 21 13:02:23 2009 -0700
@@ -37,3 +37,5 @@
 5cdce469ea2ad90d308c9abe420fd0643c0a6b9e jdk7-b60
 522520757dd34321b27a7145ecbd24ac4fb64f34 jdk7-b61
 6855e5aa3348f185fe5b443ee43a1b00ec5d390e jdk7-b62
+5c2c8112055565b4980b6756e001e45eb7b88d6e jdk7-b63
+d8f23a81d46f47a4186f1044dd9e44841bbeab84 jdk7-b64
--- a/langtools/src/share/bin/launcher.sh-template	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/bin/launcher.sh-template	Tue Jul 21 13:02:23 2009 -0700
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright 2006-2007 Sun Microsystems, Inc.  All Rights Reserved.
+# Copyright 2006-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
@@ -44,7 +44,26 @@
    bcp="$mylib/#PROGRAM#.jar":$cp 
 fi
 
-# javac currently assumes that assertions are enabled in the launcher
+# tools currently assumes that assertions are enabled in the launcher
 ea=-ea:com.sun.tools
 
-"#TARGET_JAVA#" ${bcp:+-Xbootclasspath/p:"$bcp"} ${ea} -jar "${mydir}"/../lib/#PROGRAM#.jar "$@"
+# Any parameters starting with -J are passed to the JVM.
+# All other parameters become parameters of #PROGRAM#.
+
+# Separate out -J* options for the JVM
+# Unset IFS and use newline as arg separator to preserve spaces in args
+DUALCASE=1  # for MKS: make case statement case-sensitive (6709498)
+saveIFS="$IFS"
+nl='
+'
+for i in "$@" ; do
+   IFS=
+   case $i in
+   -J* )       javaOpts=$javaOpts$nl`echo $i | sed -e 's/^-J//'` ;;
+   *   )       toolOpts=$toolOpts$nl$i ;;
+   esac
+   IFS="$saveIFS"
+done
+unset DUALCASE
+
+eval "#TARGET_JAVA#" "${bcp:+-Xbootclasspath/p:"$bcp"}" ${ea} ${javaOpts} -jar "${mydir}"/../lib/#PROGRAM#.jar ${toolOpts}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/tree/AnnotatedTypeTree.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2008-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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package com.sun.source.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for an annotated type
+ *
+ * For example:
+ * <pre>
+ *    {@code @}<em>annotationType String</em>
+ *    {@code @}<em>annotationType</em> ( <em>arguments</em> ) <em>Date</em>
+ * </pre>
+ *
+ * @see "JSR 308: Annotations on Java Types"
+ *
+ * @author Mahmood Ali
+ * @since 1.7
+ */
+public interface AnnotatedTypeTree extends ExpressionTree {
+    List<? extends AnnotationTree> getAnnotations();
+    ExpressionTree getUnderlyingType();
+}
--- a/langtools/src/share/classes/com/sun/source/tree/MethodTree.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/source/tree/MethodTree.java	Tue Jul 21 13:02:23 2009 -0700
@@ -53,6 +53,7 @@
     Tree getReturnType();
     List<? extends TypeParameterTree> getTypeParameters();
     List<? extends VariableTree> getParameters();
+    List<? extends AnnotationTree> getReceiverAnnotations();
     List<? extends ExpressionTree> getThrows();
     BlockTree getBody();
     Tree getDefaultValue(); // for annotation types
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java	Tue Jul 21 13:02:23 2009 -0700
@@ -45,6 +45,9 @@
      * Enumerates all kinds of trees.
      */
     public enum Kind {
+
+        ANNOTATED_TYPE(AnnotatedTypeTree.class),
+
         /**
          * Used for instances of {@link AnnotationTree}.
          */
--- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java	Tue Jul 21 13:02:23 2009 -0700
@@ -57,6 +57,7 @@
  * @since 1.6
  */
 public interface TreeVisitor<R,P> {
+    R visitAnnotatedType(AnnotatedTypeTree node, P p);
     R visitAnnotation(AnnotationTree node, P p);
     R visitMethodInvocation(MethodInvocationTree node, P p);
     R visitAssert(AssertTree node, P p);
--- a/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/source/tree/TypeParameterTree.java	Tue Jul 21 13:02:23 2009 -0700
@@ -47,4 +47,5 @@
 public interface TypeParameterTree extends Tree {
     Name getName();
     List<? extends Tree> getBounds();
+    List<? extends AnnotationTree> getAnnotations();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/util/AbstractTypeProcessor.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,245 @@
+/*
+ * 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package com.sun.source.util;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.annotation.processing.*;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.ElementFilter;
+
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+
+import com.sun.source.tree.ClassTree;
+
+/**
+ * This class is an abstract annotation processor designed to be a
+ * convenient superclass for concrete "type processors", processors that
+ * require the type information in the processed source.
+ *
+ * <p>Type processing occurs in one round after the tool (e.g. java compiler)
+ * analyzes the source (all sources taken as input to the tool and sources
+ * generated by other annotation processors).
+ *
+ * <p>The tool infrastructure will interact with classes extending this abstract
+ * class as follows:
+ *
+ * <ol>
+ * [1-3: Identical to {@link Processor} life cycle]
+ *
+ * <li>If an existing {@code Processor} object is not being used, to
+ * create an instance of a processor the tool calls the no-arg
+ * constructor of the processor class.
+ *
+ * <li>Next, the tool calls the {@link #init init} method with
+ * an appropriate {@code ProcessingEnvironment}.
+ *
+ * <li>Afterwards, the tool calls {@link #getSupportedAnnotationTypes
+ * getSupportedAnnotationTypes}, {@link #getSupportedOptions
+ * getSupportedOptions}, and {@link #getSupportedSourceVersion
+ * getSupportedSourceVersion}.  These methods are only called once per
+ * run, not on each round.
+ *
+ * [4-5Unique to {@code AbstractTypeProcessor} subclasses]
+ *
+ * <li>For each class containing a supported annotation, the tool calls
+ * {@link #typeProcess(TypeElement, TreePath) typeProcess} method on the
+ * {@code Processor}.  The class is guaranteed to be type-checked Java code
+ * and all the tree type and symbol information is resolved.
+ *
+ * <li>Finally, the tools calls the
+ * {@link #typeProcessingOver() typeProcessingOver} method
+ * on the {@code Processor}.
+ *
+ * </ol>
+ *
+ * <p>The tool is permitted to ask type processors to process a class once
+ * it is analyzed before the rest of classes are analyzed.  The tool is also
+ * permitted to stop type processing immediately if any errors are raised,
+ * without invoking {@code typeProcessingOver}
+ *
+ * <p>A subclass may override any of the methods in this class, as long as the
+ * general {@link javax.annotation.processing.Processor Processor}
+ * contract is obeyed, with one notable exception.
+ * {@link #process(Set, RoundEnvironment)} may not be overridden, as it
+ * is called during the regular annotation phase before classes are analyzed.
+ *
+ * @author Mahmood Ali
+ * @since 1.7
+ */
+public abstract class AbstractTypeProcessor extends AbstractProcessor {
+    private final Set<Name> elements = new HashSet<Name>();
+    private boolean hasInvokedTypeProcessingOver = false;
+    private JavacProcessingEnvironment env;
+    private final AttributionTaskListener listener = new AttributionTaskListener();
+
+    /**
+     * Constructor for subclasses to call.
+     */
+    protected AbstractTypeProcessor() { }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void init(ProcessingEnvironment env) {
+        super.init(env);
+        this.env = (JavacProcessingEnvironment)env;
+        prepareContext(this.env.getContext());
+    }
+
+    /**
+     * The use of this method is obsolete in type processors.  The method is
+     * called during regular annotation processing phase only.
+     */
+    @Override
+    public final boolean process(Set<? extends TypeElement> annotations,
+            RoundEnvironment roundEnv) {
+        for (TypeElement elem : ElementFilter.typesIn(roundEnv.getRootElements())) {
+            elements.add(elem.getQualifiedName());
+        }
+        return false;
+    }
+
+    /**
+     * Processes a fully analyzed class that contains a supported annotation
+     * (look {@link #getSupportedAnnotationTypes()}).
+     *
+     * <p>The passed class is always a valid type-checked Java code.
+     *
+     * @param element       element of the analyzed class
+     * @param tree  the tree path to the element, with the leaf being a
+     *              {@link ClassTree}
+     */
+    public abstract void typeProcess(TypeElement element, TreePath tree);
+
+    /**
+     * A method to be called once all the classes are processed and no error
+     * is reported.
+     *
+     * <p>Subclasses may override this method to do any aggregate analysis
+     * (e.g. generate report, persistence) or resource deallocation.
+     *
+     * <p>If an error (a Java error or a processor error) is reported, this
+     * method is not guaranteed to be invoked.
+     */
+    public void typeProcessingOver() { }
+
+    /**
+     * adds a listener for attribution.
+     */
+    private void prepareContext(Context context) {
+        TaskListener otherListener = context.get(TaskListener.class);
+        if (otherListener == null) {
+            context.put(TaskListener.class, listener);
+        } else {
+            // handle cases of multiple listeners
+            context.put(TaskListener.class, (TaskListener)null);
+            TaskListeners listeners = new TaskListeners();
+            listeners.add(otherListener);
+            listeners.add(listener);
+            context.put(TaskListener.class, listeners);
+        }
+    }
+
+    /**
+     * A task listener that invokes the processor whenever a class is fully
+     * analyzed.
+     */
+    private final class AttributionTaskListener implements TaskListener {
+
+        @Override
+        public void finished(TaskEvent e) {
+            Log log = Log.instance(env.getContext());
+
+            if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) {
+                typeProcessingOver();
+                hasInvokedTypeProcessingOver = true;
+            }
+
+            if (e.getKind() != TaskEvent.Kind.ANALYZE)
+                return;
+
+            if (e.getTypeElement() == null)
+                throw new AssertionError("event task without a type element");
+            if (e.getCompilationUnit() == null)
+                throw new AssertionError("even task without compilation unit");
+
+            if (!elements.remove(e.getTypeElement().getQualifiedName()))
+                return;
+
+            if (log.nerrors != 0)
+                return;
+
+            TypeElement elem = e.getTypeElement();
+            TreePath p = Trees.instance(env).getPath(elem);
+
+            typeProcess(elem, p);
+
+            if (!hasInvokedTypeProcessingOver && elements.isEmpty() && log.nerrors == 0) {
+                typeProcessingOver();
+                hasInvokedTypeProcessingOver = true;
+            }
+        }
+
+        @Override
+        public void started(TaskEvent e) { }
+
+    }
+
+    /**
+     * A task listener multiplexer.
+     */
+    private static class TaskListeners implements TaskListener {
+        private final List<TaskListener> listeners = new ArrayList<TaskListener>();
+
+        public void add(TaskListener listener) {
+            listeners.add(listener);
+        }
+
+        public void remove(TaskListener listener) {
+            listeners.remove(listener);
+        }
+
+        @Override
+        public void finished(TaskEvent e) {
+            for (TaskListener listener : listeners)
+                listener.finished(e);
+        }
+
+        @Override
+        public void started(TaskEvent e) {
+            for (TaskListener listener : listeners)
+                listener.started(e);
+        }
+    }
+}
--- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java	Tue Jul 21 13:02:23 2009 -0700
@@ -244,6 +244,10 @@
         return defaultAction(node, p);
     }
 
+    public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
+        return defaultAction(node, p);
+    }
+
     public R visitErroneous(ErroneousTree node, P p) {
         return defaultAction(node, p);
     }
--- a/langtools/src/share/classes/com/sun/source/util/TreePath.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/source/util/TreePath.java	Tue Jul 21 13:02:23 2009 -0700
@@ -120,19 +120,20 @@
     public Iterator<Tree> iterator() {
         return new Iterator<Tree>() {
             public boolean hasNext() {
-                return curr.parent != null;
+                return next != null;
             }
 
             public Tree next() {
-                curr = curr.parent;
-                return curr.leaf;
+                Tree t = next.leaf;
+                next = next.parent;
+                return t;
             }
 
             public void remove() {
                 throw new UnsupportedOperationException();
             }
 
-            private TreePath curr;
+            private TreePath next = TreePath.this;
         };
     }
 
--- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java	Tue Jul 21 13:02:23 2009 -0700
@@ -138,6 +138,7 @@
         r = scanAndReduce(node.getReturnType(), p, r);
         r = scanAndReduce(node.getTypeParameters(), p, r);
         r = scanAndReduce(node.getParameters(), p, r);
+        r = scanAndReduce(node.getReceiverAnnotations(), p, r);
         r = scanAndReduce(node.getThrows(), p, r);
         r = scanAndReduce(node.getBody(), p, r);
         return r;
@@ -354,7 +355,9 @@
     }
 
     public R visitTypeParameter(TypeParameterTree node, P p) {
-        return scan(node.getBounds(), p);
+        R r = scan(node.getAnnotations(), p);
+        r = scanAndReduce(node.getBounds(), p, r);
+        return r;
     }
 
     public R visitWildcard(WildcardTree node, P p) {
@@ -371,6 +374,12 @@
         return r;
     }
 
+   public R visitAnnotatedType(AnnotatedTypeTree node, P p) {
+       R r = scan(node.getAnnotations(), p);
+       r = scanAndReduce(node.getUnderlyingType(), p, r);
+       return r;
+   }
+
     public R visitOther(Tree node, P p) {
         return null;
     }
--- a/langtools/src/share/classes/com/sun/source/util/Trees.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/source/util/Trees.java	Tue Jul 21 13:02:23 2009 -0700
@@ -35,6 +35,7 @@
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.type.ErrorType;
 import javax.lang.model.type.TypeMirror;
+import javax.tools.Diagnostic;
 import javax.tools.JavaCompiler.CompilationTask;
 
 import com.sun.source.tree.ClassTree;
@@ -182,7 +183,20 @@
     /**
       * Gets the original type from the ErrorType object.
       * @param errorType The errorType for which we want to get the original type.
-      * @returns javax.lang.model.type.TypeMirror corresponding to the original type, replaced by the ErrorType.
+      * @return javax.lang.model.type.TypeMirror corresponding to the original type, replaced by the ErrorType.
       */
     public abstract TypeMirror getOriginalType(ErrorType errorType);
+
+    /**
+     * Prints a message of the specified kind at the location of the
+     * tree within the provided compilation unit
+     *
+     * @param kind the kind of message
+     * @param msg  the message, or an empty string if none
+     * @param t    the tree to use as a position hint
+     * @param root the compilation unit that contains tree
+     */
+    public abstract void printMessage(Diagnostic.Kind kind, CharSequence msg,
+            com.sun.source.tree.Tree t,
+            com.sun.source.tree.CompilationUnitTree root);
 }
--- a/langtools/src/share/classes/com/sun/tools/classfile/AccessFlags.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/classfile/AccessFlags.java	Tue Jul 21 13:02:23 2009 -0700
@@ -58,7 +58,7 @@
     public static final int ACC_ENUM          = 0x4000; // class, inner, field
     public static final int ACC_MODULE        = 0x8000; // class, inner, field, method
 
-    private static enum Type { Class, InnerClass, Field, Method};
+    public static enum Kind { Class, InnerClass, Field, Method};
 
     AccessFlags(ClassReader cr) throws IOException {
         this(cr.readUnsignedShort());
@@ -87,11 +87,11 @@
 
     public Set<String> getClassModifiers() {
         int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags);
-        return getModifiers(f, classModifiers, Type.Class);
+        return getModifiers(f, classModifiers, Kind.Class);
     }
 
     public Set<String> getClassFlags() {
-        return getFlags(classFlags, Type.Class);
+        return getFlags(classFlags, Kind.Class);
     }
 
     private static final int[] innerClassModifiers = {
@@ -106,11 +106,11 @@
 
     public Set<String> getInnerClassModifiers() {
         int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags);
-        return getModifiers(f, innerClassModifiers, Type.InnerClass);
+        return getModifiers(f, innerClassModifiers, Kind.InnerClass);
     }
 
     public Set<String> getInnerClassFlags() {
-        return getFlags(innerClassFlags, Type.InnerClass);
+        return getFlags(innerClassFlags, Kind.InnerClass);
     }
 
     private static final int[] fieldModifiers = {
@@ -124,11 +124,11 @@
     };
 
     public Set<String> getFieldModifiers() {
-        return getModifiers(fieldModifiers, Type.Field);
+        return getModifiers(fieldModifiers, Kind.Field);
     }
 
     public Set<String> getFieldFlags() {
-        return getFlags(fieldFlags, Type.Field);
+        return getFlags(fieldFlags, Kind.Field);
     }
 
     private static final int[] methodModifiers = {
@@ -143,18 +143,18 @@
     };
 
     public Set<String> getMethodModifiers() {
-        return getModifiers(methodModifiers, Type.Method);
+        return getModifiers(methodModifiers, Kind.Method);
     }
 
     public Set<String> getMethodFlags() {
-        return getFlags(methodFlags, Type.Method);
+        return getFlags(methodFlags, Kind.Method);
     }
 
-    private Set<String> getModifiers(int[] modifierFlags, Type t) {
+    private Set<String> getModifiers(int[] modifierFlags, Kind t) {
         return getModifiers(flags, modifierFlags, t);
     }
 
-    private static Set<String> getModifiers(int flags, int[] modifierFlags, Type t) {
+    private static Set<String> getModifiers(int flags, int[] modifierFlags, Kind t) {
         Set<String> s = new LinkedHashSet<String>();
         for (int m: modifierFlags) {
             if ((flags & m) != 0)
@@ -163,7 +163,7 @@
         return s;
     }
 
-    private Set<String> getFlags(int[] expectedFlags, Type t) {
+    private Set<String> getFlags(int[] expectedFlags, Kind t) {
         Set<String> s = new LinkedHashSet<String>();
         int f = flags;
         for (int e: expectedFlags) {
@@ -180,7 +180,7 @@
         return s;
     }
 
-    private static String flagToModifier(int flag, Type t) {
+    private static String flagToModifier(int flag, Kind t) {
         switch (flag) {
             case ACC_PUBLIC:
                 return "public";
@@ -195,7 +195,7 @@
             case ACC_SYNCHRONIZED:
                 return "synchronized";
             case 0x80:
-                return (t == Type.Field ? "transient" : null);
+                return (t == Kind.Field ? "transient" : null);
             case ACC_VOLATILE:
                 return "volatile";
             case ACC_NATIVE:
@@ -211,7 +211,7 @@
         }
     }
 
-    private static String flagToName(int flag, Type t) {
+    private static String flagToName(int flag, Kind t) {
         switch (flag) {
         case ACC_PUBLIC:
             return "ACC_PUBLIC";
@@ -224,11 +224,11 @@
         case ACC_FINAL:
             return "ACC_FINAL";
         case 0x20:
-            return (t == Type.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED");
+            return (t == Kind.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED");
         case 0x40:
-            return (t == Type.Field ? "ACC_VOLATILE" : "ACC_BRIDGE");
+            return (t == Kind.Field ? "ACC_VOLATILE" : "ACC_BRIDGE");
         case 0x80:
-            return (t == Type.Field ? "ACC_TRANSIENT" : "ACC_VARARGS");
+            return (t == Kind.Field ? "ACC_TRANSIENT" : "ACC_VARARGS");
         case ACC_NATIVE:
             return "ACC_NATIVE";
         case ACC_INTERFACE:
@@ -250,5 +250,5 @@
         }
     }
 
-    final int flags;
+    public final int flags;
 }
--- a/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java	Tue Jul 21 13:02:23 2009 -0700
@@ -54,6 +54,8 @@
     public static final String RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations";
     public static final String RuntimeVisibleParameterAnnotations = "RuntimeVisibleParameterAnnotations";
     public static final String RuntimeInvisibleParameterAnnotations = "RuntimeInvisibleParameterAnnotations";
+    public static final String RuntimeVisibleTypeAnnotations = "RuntimeVisibleTypeAnnotations";
+    public static final String RuntimeInvisibleTypeAnnotations = "RuntimeInvisibleTypeAnnotations";
     public static final String Signature                = "Signature";
     public static final String SourceDebugExtension     = "SourceDebugExtension";
     public static final String SourceFile               = "SourceFile";
@@ -131,6 +133,8 @@
                 standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class);
                 standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class);
                 standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class);
+                standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class);
+                standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class);
                 standardAttributes.put(Signature,     Signature_attribute.class);
                 standardAttributes.put(SourceID, SourceID_attribute.class);
             }
@@ -184,6 +188,8 @@
         R visitRuntimeInvisibleAnnotations(RuntimeInvisibleAnnotations_attribute attr, P p);
         R visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, P p);
         R visitRuntimeInvisibleParameterAnnotations(RuntimeInvisibleParameterAnnotations_attribute attr, P p);
+        R visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, P p);
+        R visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, P p);
         R visitSignature(Signature_attribute attr, P p);
         R visitSourceDebugExtension(SourceDebugExtension_attribute attr, P p);
         R visitSourceFile(SourceFile_attribute attr, P p);
--- a/langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/classfile/ClassWriter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1,3 +1,4 @@
+
 /*
  * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -477,6 +478,16 @@
             return null;
         }
 
+        public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, ClassOutputStream out) {
+            annotationWriter.write(attr.annotations, out);
+            return null;
+        }
+
+        public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, ClassOutputStream out) {
+            annotationWriter.write(attr.annotations, out);
+            return null;
+        }
+
         public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, ClassOutputStream out) {
             out.writeByte(attr.parameter_annotations.length);
             for (Annotation[] annos: attr.parameter_annotations)
@@ -636,6 +647,12 @@
                 write(anno, out);
         }
 
+        public void write(ExtendedAnnotation[] annos, ClassOutputStream out) {
+            out.writeShort(annos.length);
+            for (ExtendedAnnotation anno: annos)
+                write(anno, out);
+        }
+
         public void write(Annotation anno, ClassOutputStream out) {
             out.writeShort(anno.type_index);
             out.writeShort(anno.element_value_pairs.length);
@@ -643,6 +660,11 @@
                 write(p, out);
         }
 
+        public void write(ExtendedAnnotation anno, ClassOutputStream out) {
+            write(anno.annotation, out);
+            write(anno.position, out);
+        }
+
         public void write(element_value_pair pair, ClassOutputStream out) {
             out.writeShort(pair.element_name_index);
             write(pair.value, out);
@@ -680,5 +702,95 @@
                 write(v, out);
             return null;
         }
+
+        private void write(ExtendedAnnotation.Position p, ClassOutputStream out) {
+            out.writeByte(p.type.targetTypeValue());
+            switch (p.type) {
+            // type case
+            case TYPECAST:
+            case TYPECAST_GENERIC_OR_ARRAY:
+            // object creation
+            case INSTANCEOF:
+            case INSTANCEOF_GENERIC_OR_ARRAY:
+            // new expression
+            case NEW:
+            case NEW_GENERIC_OR_ARRAY:
+            case NEW_TYPE_ARGUMENT:
+            case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+                out.writeShort(p.offset);
+                break;
+             // local variable
+            case LOCAL_VARIABLE:
+            case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
+                int table_length = p.lvarOffset.length;
+                out.writeShort(table_length);
+                for (int i = 0; i < table_length; ++i) {
+                    out.writeShort(1);  // for table length
+                    out.writeShort(p.lvarOffset[i]);
+                    out.writeShort(p.lvarLength[i]);
+                    out.writeShort(p.lvarIndex[i]);
+                }
+                break;
+             // method receiver
+            case METHOD_RECEIVER:
+                // Do nothing
+                break;
+            // type parameters
+            case CLASS_TYPE_PARAMETER:
+            case METHOD_TYPE_PARAMETER:
+                out.writeByte(p.parameter_index);
+                break;
+            // type parameters bounds
+            case CLASS_TYPE_PARAMETER_BOUND:
+            case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+            case METHOD_TYPE_PARAMETER_BOUND:
+            case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+                out.writeByte(p.parameter_index);
+                out.writeByte(p.bound_index);
+                break;
+             // wildcards
+            case WILDCARD_BOUND:
+            case WILDCARD_BOUND_GENERIC_OR_ARRAY:
+                write(p.wildcard_position, out);
+                break;
+            // Class extends and implements clauses
+            case CLASS_EXTENDS:
+            case CLASS_EXTENDS_GENERIC_OR_ARRAY:
+                out.writeByte(p.type_index);
+                break;
+            // throws
+            case THROWS:
+                out.writeByte(p.type_index);
+                break;
+            case CLASS_LITERAL:
+                out.writeShort(p.offset);
+                break;
+            // method parameter: not specified
+            case METHOD_PARAMETER_GENERIC_OR_ARRAY:
+                out.writeByte(p.parameter_index);
+                break;
+            // method type argument: wasn't specified
+            case METHOD_TYPE_ARGUMENT:
+            case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+                out.writeShort(p.offset);
+                out.writeByte(p.type_index);
+                break;
+            // We don't need to worry abut these
+            case METHOD_RETURN_GENERIC_OR_ARRAY:
+            case FIELD_GENERIC_OR_ARRAY:
+                break;
+            case UNKNOWN:
+                break;
+            default:
+                throw new AssertionError("unknown type: " + p);
+            }
+
+            // Append location data for generics/arrays.
+            if (p.type.hasLocation()) {
+                out.writeShort(p.location.size());
+                for (int i : p.location)
+                    out.writeByte((byte)i);
+            }
+        }
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/classfile/ConstantPool.java	Tue Jul 21 13:02:23 2009 -0700
@@ -573,6 +573,11 @@
             return visitor.visitNameAndType(this, data);
         }
 
+        @Override
+        public String toString() {
+            return "CONSTANT_NameAndType_info[name_index: " + name_index + ", type_index: " + type_index + "]";
+        }
+
         public final int name_index;
         public final int type_index;
     }
@@ -600,6 +605,11 @@
             return visitor.visitString(this, data);
         }
 
+        @Override
+        public String toString() {
+            return "CONSTANT_String_info[class_index: " + string_index + "]";
+        }
+
         public final int string_index;
     }
 
@@ -618,7 +628,19 @@
 
         @Override
         public String toString() {
-            return "CONSTANT_Utf8_info[value: " + value + "]";
+            if (value.length() < 32 && isPrintableAscii(value))
+                return "CONSTANT_Utf8_info[value: \"" + value + "\"]";
+            else
+                return "CONSTANT_Utf8_info[value: (" + value.length() + " chars)]";
+        }
+
+        static boolean isPrintableAscii(String s) {
+            for (int i = 0; i < s.length(); i++) {
+                char c = s.charAt(i);
+                if (c < 32 || c >= 127)
+                    return false;
+            }
+            return true;
         }
 
         public <R, D> R accept(Visitor<R, D> visitor, D data) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/classfile/ExtendedAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,614 @@
+/*
+ * 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package com.sun.tools.classfile;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+
+import static com.sun.tools.classfile.ExtendedAnnotation.TargetAttribute.*;
+
+/**
+ * See JSR 308 specification, section 4.1
+ *
+ *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
+ *  you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class ExtendedAnnotation {
+    ExtendedAnnotation(ClassReader cr) throws IOException, Annotation.InvalidAnnotation {
+        annotation = new Annotation(cr);
+        position = read_position(cr);
+    }
+
+    public ExtendedAnnotation(ConstantPool constant_pool,
+            Annotation annotation, Position position) {
+        this.annotation = annotation;
+        this.position = position;
+    }
+
+    public int length() {
+        int n = annotation.length();
+        n += position_length(position);
+        return n;
+    }
+
+    public final Annotation annotation;
+    public final Position position;
+
+    private static Position read_position(ClassReader cr) throws IOException, Annotation.InvalidAnnotation {
+        // Copied from ClassReader
+        int tag = (byte)cr.readUnsignedByte();  // cast to introduce signedness
+        if (!TargetType.isValidTargetTypeValue(tag))
+            throw new Annotation.InvalidAnnotation("invalid type annotation target type value: " + tag);
+
+        TargetType type = TargetType.fromTargetTypeValue(tag);
+
+        Position position = new Position();
+        position.type = type;
+
+        switch (type) {
+        // type case
+        case TYPECAST:
+        case TYPECAST_GENERIC_OR_ARRAY:
+        // object creation
+        case INSTANCEOF:
+        case INSTANCEOF_GENERIC_OR_ARRAY:
+        // new expression
+        case NEW:
+        case NEW_GENERIC_OR_ARRAY:
+            position.offset = cr.readUnsignedShort();
+            break;
+         // local variable
+        case LOCAL_VARIABLE:
+        case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
+            int table_length = cr.readUnsignedShort();
+            position.lvarOffset = new int[table_length];
+            position.lvarLength = new int[table_length];
+            position.lvarIndex = new int[table_length];
+            for (int i = 0; i < table_length; ++i) {
+                position.lvarOffset[i] = cr.readUnsignedShort();
+                position.lvarLength[i] = cr.readUnsignedShort();
+                position.lvarIndex[i] = cr.readUnsignedShort();
+            }
+            break;
+         // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+        // type parameters
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            position.parameter_index = cr.readUnsignedByte();
+            break;
+        // type parameter bounds
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+        case METHOD_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+            position.parameter_index = cr.readUnsignedByte();
+            position.bound_index = cr.readUnsignedByte();
+            break;
+         // wildcards
+        case WILDCARD_BOUND:
+        case WILDCARD_BOUND_GENERIC_OR_ARRAY:
+            position.wildcard_position = read_position(cr);
+            break;
+         // Class extends and implements clauses
+        case CLASS_EXTENDS:
+        case CLASS_EXTENDS_GENERIC_OR_ARRAY:
+            position.type_index = cr.readUnsignedByte();
+            break;
+        // throws
+        case THROWS:
+            position.type_index = cr.readUnsignedByte();
+            break;
+        case CLASS_LITERAL:
+        case CLASS_LITERAL_GENERIC_OR_ARRAY:
+            position.offset = cr.readUnsignedShort();
+            break;
+        // method parameter: not specified
+        case METHOD_PARAMETER_GENERIC_OR_ARRAY:
+            position.parameter_index = cr.readUnsignedByte();
+            break;
+        // method type argument: wasn't specified
+        case NEW_TYPE_ARGUMENT:
+        case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+        case METHOD_TYPE_ARGUMENT:
+        case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+            position.offset = cr.readUnsignedShort();
+            position.type_index = cr.readUnsignedByte();
+            break;
+        // We don't need to worry abut these
+        case METHOD_RETURN_GENERIC_OR_ARRAY:
+        case FIELD_GENERIC_OR_ARRAY:
+            break;
+        case UNKNOWN:
+            break;
+        default:
+            throw new AssertionError("Cannot be here");
+        }
+
+        if (type.hasLocation()) {
+            int len = cr.readUnsignedShort();
+            List<Integer> loc = new ArrayList<Integer>(len);
+            for (int i = 0; i < len; i++)
+                loc.add(cr.readUnsignedByte());
+            position.location = loc;
+        }
+        return position;
+    }
+
+    private static int position_length(Position pos) {
+        int n = 0;
+        n += 1; // target_type
+        switch (pos.type) {
+        // type case
+        case TYPECAST:
+        case TYPECAST_GENERIC_OR_ARRAY:
+        // object creation
+        case INSTANCEOF:
+        case INSTANCEOF_GENERIC_OR_ARRAY:
+        // new expression
+        case NEW:
+        case NEW_GENERIC_OR_ARRAY:
+            n += 2;
+            break;
+         // local variable
+        case LOCAL_VARIABLE:
+        case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
+            n += 2; // table_length;
+            int table_length = pos.lvarOffset.length;
+            n += 2 * table_length; // offset
+            n += 2 * table_length; // length;
+            n += 2 * table_length; // index
+            break;
+         // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+        // type parameters
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            n += 1; // parameter_index;
+            break;
+        // type parameter bounds
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+        case METHOD_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+            n += 1; // parameter_index
+            n += 1; // bound_index
+            break;
+        case WILDCARD_BOUND:
+        case WILDCARD_BOUND_GENERIC_OR_ARRAY:
+            n += position_length(pos.wildcard_position);
+            break;
+         // Class extends and implements clauses
+        case CLASS_EXTENDS:
+        case CLASS_EXTENDS_GENERIC_OR_ARRAY:
+            n += 1; // type_index
+            break;
+        // throws
+        case THROWS:
+            n += 1; // type_index
+            break;
+        case CLASS_LITERAL:
+        case CLASS_LITERAL_GENERIC_OR_ARRAY:
+            n += 1; // offset
+            break;
+        // method parameter: not specified
+        case METHOD_PARAMETER_GENERIC_OR_ARRAY:
+            n += 1; // parameter_index
+            break;
+        // method type argument: wasn't specified
+        case NEW_TYPE_ARGUMENT:
+        case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+        case METHOD_TYPE_ARGUMENT:
+        case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+            n += 2; // offset
+            n += 1; // type index
+            break;
+        // We don't need to worry abut these
+        case METHOD_RETURN_GENERIC_OR_ARRAY:
+        case FIELD_GENERIC_OR_ARRAY:
+            break;
+        case UNKNOWN:
+            break;
+        default:
+        }
+
+        if (pos.type.hasLocation()) {
+            n += 2; // length
+            n += 1 * pos.location.size(); // actual array size
+        }
+
+        return n;
+    }
+
+    // Code duplicated from com.sun.tools.javac.code.TypeAnnotations.Position
+    public static class Position {
+
+        public TargetType type = TargetType.UNKNOWN;
+
+        // For generic/array types.
+        public List<Integer> location = new ArrayList<Integer>();
+
+        // Tree position.
+        public int pos = -1;
+
+        // For typecasts, type tests, new (and locals, as start_pc).
+        public int offset = -1;
+
+        // For locals.
+        public int[] lvarOffset = new int[] { -1 };
+        public int[] lvarLength = new int[] { -1 };
+        public int[] lvarIndex = new int[] { -1 };
+
+        // For type parameter bound
+        public int bound_index = -1;
+
+        // For type parameter and method parameter
+        public int parameter_index = -1;
+
+        // For class extends, implements, and throws classes
+        public int type_index = -2;
+
+        // For wildcards
+        public Position wildcard_position = null;
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append('[');
+            sb.append(type);
+
+            switch (type) {
+            // type case
+            case TYPECAST:
+            case TYPECAST_GENERIC_OR_ARRAY:
+            // object creation
+            case INSTANCEOF:
+            case INSTANCEOF_GENERIC_OR_ARRAY:
+            // new expression
+            case NEW:
+            case NEW_GENERIC_OR_ARRAY:
+            case NEW_TYPE_ARGUMENT:
+            case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+                sb.append(", offset = ");
+                sb.append(offset);
+                break;
+             // local variable
+            case LOCAL_VARIABLE:
+            case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
+                sb.append(", {");
+                for (int i = 0; i < lvarOffset.length; ++i) {
+                    if (i != 0) sb.append("; ");
+                    sb.append(", start_pc = ");
+                    sb.append(lvarOffset[i]);
+                    sb.append(", length = ");
+                    sb.append(lvarLength[i]);
+                    sb.append(", index = ");
+                    sb.append(lvarIndex[i]);
+                }
+                sb.append("}");
+                break;
+             // method receiver
+            case METHOD_RECEIVER:
+                // Do nothing
+                break;
+            // type parameters
+            case CLASS_TYPE_PARAMETER:
+            case METHOD_TYPE_PARAMETER:
+                sb.append(", param_index = ");
+                sb.append(parameter_index);
+                break;
+            // type parameters bound
+            case CLASS_TYPE_PARAMETER_BOUND:
+            case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+            case METHOD_TYPE_PARAMETER_BOUND:
+            case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+                sb.append(", param_index = ");
+                sb.append(parameter_index);
+                sb.append(", bound_index = ");
+                sb.append(bound_index);
+                break;
+             // wildcard
+            case WILDCARD_BOUND:
+            case WILDCARD_BOUND_GENERIC_OR_ARRAY:
+                sb.append(", wild_card = ");
+                sb.append(wildcard_position);
+                break;
+             // Class extends and implements clauses
+            case CLASS_EXTENDS:
+            case CLASS_EXTENDS_GENERIC_OR_ARRAY:
+                sb.append(", type_index = ");
+                sb.append(type_index);
+                break;
+            // throws
+            case THROWS:
+                sb.append(", type_index = ");
+                sb.append(type_index);
+                break;
+            case CLASS_LITERAL:
+                sb.append(", offset = ");
+                sb.append(offset);
+                break;
+            // method parameter: not specified
+            case METHOD_PARAMETER_GENERIC_OR_ARRAY:
+                sb.append(", param_index = ");
+                sb.append(parameter_index);
+                break;
+            // method type argument: wasn't specified
+            case METHOD_TYPE_ARGUMENT:
+            case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+                sb.append(", offset = ");
+                sb.append(offset);
+                sb.append(", type_index = ");
+                sb.append(type_index);
+                break;
+            // We don't need to worry abut these
+            case METHOD_RETURN_GENERIC_OR_ARRAY:
+            case FIELD_GENERIC_OR_ARRAY:
+                break;
+            case UNKNOWN:
+                break;
+            default:
+                throw new AssertionError("unknown type: " + type);
+            }
+
+            // Append location data for generics/arrays.
+            if (type.hasLocation()) {
+                sb.append(", location = (");
+                sb.append(location);
+                sb.append(")");
+            }
+
+            sb.append(", pos = ");
+            sb.append(pos);
+
+            sb.append(']');
+            return sb.toString();
+        }
+    }
+
+    // Code duplicated from com.sun.tools.javac.comp.TargetType
+    public enum TargetType {
+
+        /** For annotations on typecasts. */
+        TYPECAST(0x00),
+
+        /** For annotations on a type argument or nested array of a typecast. */
+        TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation),
+
+        /** For annotations on type tests. */
+        INSTANCEOF(0x02),
+
+        /** For annotations on a type argument or nested array of a type test. */
+        INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation),
+
+        /** For annotations on object creation expressions. */
+        NEW(0x04),
+
+        /**
+         * For annotations on a type argument or nested array of an object creation
+         * expression.
+         */
+        NEW_GENERIC_OR_ARRAY(0x05, HasLocation),
+
+
+        /** For annotations on the method receiver. */
+        METHOD_RECEIVER(0x06),
+
+        // invalid location
+        // METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation),
+
+        /** For annotations on local variables. */
+        LOCAL_VARIABLE(0x08),
+
+        /** For annotations on a type argument or nested array of a local. */
+        LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation),
+
+        // already handled by regular annotations
+        // METHOD_RETURN(0x0A),
+
+        /**
+         * For annotations on a type argument or nested array of a method return
+         * type.
+         */
+        METHOD_RETURN_GENERIC_OR_ARRAY(0x0B, HasLocation),
+
+        // already handled by regular annotations
+        // METHOD_PARAMETER(0x0C),
+
+        /** For annotations on a type argument or nested array of a method parameter. */
+        METHOD_PARAMETER_GENERIC_OR_ARRAY(0x0D, HasLocation),
+
+        // already handled by regular annotations
+        // FIELD(0x0E),
+
+        /** For annotations on a type argument or nested array of a field. */
+        FIELD_GENERIC_OR_ARRAY(0x0F, HasLocation),
+
+        /** For annotations on a bound of a type parameter of a class. */
+        CLASS_TYPE_PARAMETER_BOUND(0x10, HasBound, HasParameter),
+
+        /**
+         * For annotations on a type argument or nested array of a bound of a type
+         * parameter of a class.
+         */
+        CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x11, HasBound, HasLocation, HasParameter),
+
+        /** For annotations on a bound of a type parameter of a method. */
+        METHOD_TYPE_PARAMETER_BOUND(0x12, HasBound, HasParameter),
+
+        /**
+         * For annotations on a type argument or nested array of a bound of a type
+         * parameter of a method.
+         */
+        METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x13, HasBound, HasLocation, HasParameter),
+
+        /** For annotations on the type of an "extends" or "implements" clause. */
+        CLASS_EXTENDS(0x14),
+
+        /** For annotations on the inner type of an "extends" or "implements" clause. */
+        CLASS_EXTENDS_GENERIC_OR_ARRAY(0x15, HasLocation),
+
+        /** For annotations on a throws clause in a method declaration. */
+        THROWS(0x16),
+
+        // invalid location
+        // THROWS_GENERIC_OR_ARRAY(0x17, HasLocation),
+
+        /** For annotations in type arguments of object creation expressions. */
+        NEW_TYPE_ARGUMENT(0x18),
+        NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation),
+
+        METHOD_TYPE_ARGUMENT(0x1A),
+        METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation),
+
+        WILDCARD_BOUND(0x1C, HasBound),
+        WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation),
+
+        CLASS_LITERAL(0x1E),
+        CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation),
+
+        METHOD_TYPE_PARAMETER(0x20, HasParameter),
+
+        // invalid location
+        // METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter),
+
+        CLASS_TYPE_PARAMETER(0x22, HasParameter),
+
+        // invalid location
+        // CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter),
+
+        /** For annotations with an unknown target. */
+        UNKNOWN(-1);
+
+        static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22;
+
+        private final int targetTypeValue;
+        private Set<TargetAttribute> flags;
+
+        TargetType(int targetTypeValue, TargetAttribute... attrs) {
+            if (targetTypeValue < Byte.MIN_VALUE
+                || targetTypeValue > Byte.MAX_VALUE)
+                throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue);
+            this.targetTypeValue = (byte)targetTypeValue;
+            this.flags = EnumSet.noneOf(TargetAttribute.class);
+            for (TargetAttribute attr : attrs)
+                this.flags.add(attr);
+        }
+
+        /**
+         * Returns whether or not this TargetType represents an annotation whose
+         * target is an inner type of a generic or array type.
+         *
+         * @return true if this TargetType represents an annotation on an inner
+         *         type, false otherwise
+         */
+        public boolean hasLocation() {
+            return flags.contains(HasLocation);
+        }
+
+        public TargetType getGenericComplement() {
+            if (hasLocation())
+                return this;
+            else
+                return fromTargetTypeValue(targetTypeValue() + 1);
+        }
+
+        /**
+         * Returns whether or not this TargetType represents an annotation whose
+         * target has a parameter index.
+         *
+         * @return true if this TargetType has a parameter index,
+         *         false otherwise
+         */
+        public boolean hasParameter() {
+            return flags.contains(HasParameter);
+        }
+
+        /**
+         * Returns whether or not this TargetType represents an annotation whose
+         * target is a type parameter bound.
+         *
+         * @return true if this TargetType represents an type parameter bound
+         *         annotation, false otherwise
+         */
+        public boolean hasBound() {
+            return flags.contains(HasBound);
+        }
+
+        public int targetTypeValue() {
+            return this.targetTypeValue;
+        }
+
+        private static TargetType[] targets = null;
+
+        private static TargetType[] buildTargets() {
+            TargetType[] targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
+            TargetType[] alltargets = values();
+            for (TargetType target : alltargets)
+                if (target.targetTypeValue >= 0)
+                    targets[target.targetTypeValue] = target;
+            for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i)
+                if (targets[i] == null)
+                    targets[i] = UNKNOWN;
+            return targets;
+        }
+
+        public static boolean isValidTargetTypeValue(int tag) {
+            if (targets == null)
+                targets = buildTargets();
+
+            if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
+                return true;
+
+            return (tag >= 0 && tag < targets.length);
+        }
+
+        public static TargetType fromTargetTypeValue(int tag) {
+            if (targets == null)
+                targets = buildTargets();
+
+            if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
+                return UNKNOWN;
+
+            if (tag < 0 || tag >= targets.length)
+                throw new IllegalArgumentException("Unknown TargetType: " + tag);
+            return targets[tag];
+        }
+    }
+
+    static enum TargetAttribute {
+        HasLocation, HasParameter, HasBound;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/classfile/RuntimeInvisibleTypeAnnotations_attribute.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2007-2008 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package com.sun.tools.classfile;
+
+import java.io.IOException;
+
+/**
+ * See JSR 308 specification, section 4.1
+ *
+ *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
+ *  you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class RuntimeInvisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute {
+    RuntimeInvisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length)
+            throws IOException, Annotation.InvalidAnnotation {
+        super(cr, name_index, length);
+    }
+
+    public RuntimeInvisibleTypeAnnotations_attribute(ConstantPool cp, ExtendedAnnotation[] annotations)
+            throws ConstantPoolException {
+        this(cp.getUTF8Index(Attribute.RuntimeInvisibleTypeAnnotations), annotations);
+    }
+
+    public RuntimeInvisibleTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) {
+        super(name_index, annotations);
+    }
+
+    public <R, P> R accept(Visitor<R, P> visitor, P p) {
+        return visitor.visitRuntimeInvisibleTypeAnnotations(this, p);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/classfile/RuntimeTypeAnnotations_attribute.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2007-2008 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package com.sun.tools.classfile;
+
+import java.io.IOException;
+
+/**
+ * See JSR 308 specification, section 4
+ *
+ *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
+ *  you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public abstract class RuntimeTypeAnnotations_attribute extends Attribute {
+    protected RuntimeTypeAnnotations_attribute(ClassReader cr, int name_index, int length)
+            throws IOException, Annotation.InvalidAnnotation {
+        super(name_index, length);
+        int num_annotations = cr.readUnsignedShort();
+        annotations = new ExtendedAnnotation[num_annotations];
+        for (int i = 0; i < annotations.length; i++)
+            annotations[i] = new ExtendedAnnotation(cr);
+    }
+
+    protected RuntimeTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) {
+        super(name_index, length(annotations));
+        this.annotations = annotations;
+    }
+
+    private static int length(ExtendedAnnotation[] annos) {
+        int n = 2;
+        for (ExtendedAnnotation anno: annos)
+            n += anno.length();
+        return n;
+    }
+
+    public final ExtendedAnnotation[] annotations;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/classfile/RuntimeVisibleTypeAnnotations_attribute.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2007-2008 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package com.sun.tools.classfile;
+
+import java.io.IOException;
+
+/**
+ * See JSR 308 specification, section 4.1
+ *
+ *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
+ *  you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class RuntimeVisibleTypeAnnotations_attribute extends RuntimeTypeAnnotations_attribute {
+    RuntimeVisibleTypeAnnotations_attribute(ClassReader cr, int name_index, int length)
+            throws IOException, Annotation.InvalidAnnotation {
+        super(cr, name_index, length);
+    }
+
+    public RuntimeVisibleTypeAnnotations_attribute(ConstantPool cp, ExtendedAnnotation[] annotations)
+            throws ConstantPoolException {
+        this(cp.getUTF8Index(Attribute.RuntimeVisibleTypeAnnotations), annotations);
+    }
+
+    public RuntimeVisibleTypeAnnotations_attribute(int name_index, ExtendedAnnotation[] annotations) {
+        super(name_index, annotations);
+    }
+
+    public <R, P> R accept(Visitor<R, P> visitor, P p) {
+        return visitor.visitRuntimeVisibleTypeAnnotations(this, p);
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Tue Jul 21 13:02:23 2009 -0700
@@ -133,6 +133,7 @@
     public Boolean call() {
         if (!used.getAndSet(true)) {
             beginContext();
+            notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
             try {
                 compilerMain.setFatalErrors(true);
                 result = compilerMain.compile(args, context, fileObjects, processors);
@@ -143,6 +144,7 @@
             args = null;
             context = null;
             fileObjects = null;
+            notYetEntered = null;
             return result == 0;
         } else {
             throw new IllegalStateException("multiple calls to method 'call'");
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Tue Jul 21 13:02:23 2009 -0700
@@ -35,6 +35,7 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.type.TypeMirror;
+import javax.tools.Diagnostic;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 
@@ -54,6 +55,7 @@
 import com.sun.tools.javac.comp.MemberEnter;
 import com.sun.tools.javac.comp.Resolve;
 import com.sun.tools.javac.model.JavacElements;
+import com.sun.tools.javac.processing.JavacMessager;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.tree.JCTree;
@@ -61,6 +63,7 @@
 import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.tree.TreeMaker;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.Pair;
@@ -336,4 +339,54 @@
 
         return com.sun.tools.javac.code.Type.noType;
     }
+
+    /**
+     * Prints a message of the specified kind at the location of the
+     * tree within the provided compilation unit
+     *
+     * @param kind the kind of message
+     * @param msg  the message, or an empty string if none
+     * @param t    the tree to use as a position hint
+     * @param root the compilation unit that contains tree
+     */
+    public void printMessage(Diagnostic.Kind kind, CharSequence msg,
+            com.sun.source.tree.Tree t,
+            com.sun.source.tree.CompilationUnitTree root) {
+        JavaFileObject oldSource = null;
+        JavaFileObject newSource = null;
+        JCDiagnostic.DiagnosticPosition pos = null;
+
+        newSource = root.getSourceFile();
+        if (newSource != null) {
+            oldSource = log.useSource(newSource);
+            pos = ((JCTree) t).pos();
+        }
+
+        try {
+            switch (kind) {
+            case ERROR:
+                boolean prev = log.multipleErrors;
+                try {
+                    log.error(pos, "proc.messager", msg.toString());
+                } finally {
+                    log.multipleErrors = prev;
+                }
+                break;
+
+            case WARNING:
+                log.warning(pos, "proc.messager", msg.toString());
+                break;
+
+            case MANDATORY_WARNING:
+                log.mandatoryWarning(pos, "proc.messager", msg.toString());
+                break;
+
+            default:
+                log.note(pos, "proc.messager", msg.toString());
+            }
+        } finally {
+            if (oldSource != null)
+                log.useSource(oldSource);
+        }
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Attribute.java	Tue Jul 21 13:02:23 2009 -0700
@@ -204,6 +204,21 @@
         }
     }
 
+    public static class TypeCompound extends Compound {
+        public TypeAnnotationPosition position;
+        public TypeCompound(Compound compound,
+                TypeAnnotationPosition position) {
+            this(compound.type, compound.values, position);
+        }
+        public TypeCompound(Type type,
+                List<Pair<MethodSymbol, Attribute>> values,
+                TypeAnnotationPosition position) {
+            super(type, values);
+            this.position = position;
+        }
+
+    }
+
     /** The value for an annotation element of an array type.
      */
     public static class Array extends Attribute {
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java	Tue Jul 21 13:02:23 2009 -0700
@@ -95,6 +95,7 @@
         ANNOTATION("kindname.interface"),
         CONSTRUCTOR("kindname.constructor"),
         INTERFACE("kindname.interface"),
+        ENUM("kindname.enum"),
         STATIC("kindname.static"),
         TYPEVAR("kindname.type.variable"),
         BOUND("kindname.type.variable.bound"),
@@ -145,11 +146,15 @@
             return KindName.PACKAGE;
 
         case ENUM:
+            return KindName.ENUM;
+
         case ANNOTATION_TYPE:
-        case INTERFACE:
         case CLASS:
             return KindName.CLASS;
 
+        case INTERFACE:
+            return KindName.INTERFACE;
+
         case TYPE_PARAMETER:
             return KindName.TYPEVAR;
 
@@ -160,8 +165,10 @@
         case EXCEPTION_PARAMETER:
             return KindName.VAR;
 
+        case CONSTRUCTOR:
+            return KindName.CONSTRUCTOR;
+
         case METHOD:
-        case CONSTRUCTOR:
         case STATIC_INIT:
         case INSTANCE_INIT:
             return KindName.METHOD;
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java	Tue Jul 21 13:02:23 2009 -0700
@@ -153,6 +153,9 @@
     public boolean enforceMandatoryWarnings() {
         return compareTo(JDK1_5) >= 0;
     }
+    public boolean allowTypeAnnotations() {
+        return compareTo(JDK1_7) >= 0;
+    }
     public static SourceVersion toSourceVersion(Source source) {
         switch(source) {
         case JDK1_2:
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Jul 21 13:02:23 2009 -0700
@@ -100,6 +100,17 @@
      */
     public Type type;
 
+    /** The type annotations targeted to a tree directly owned by this symbol
+     */
+    // type annotations are stored here for two purposes:
+    //  - convenient location to store annotations for generation after erasure
+    //  - a private interface for accessing type annotations parsed from
+    //    classfiles
+    //  the field is populated for the following declaration only
+    //  class, field, variable and type parameters
+    //
+    public List<Attribute.TypeCompound> typeAnnotations;
+
     /** The owner of this symbol.
      */
     public Symbol owner;
@@ -122,6 +133,7 @@
         this.completer = null;
         this.erasure_field = null;
         this.attributes_field = List.nil();
+        this.typeAnnotations = List.nil();
         this.name = name;
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TargetType.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,277 @@
+/*
+ * Copyright 2008-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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package com.sun.tools.javac.code;
+
+import static com.sun.tools.javac.code.TargetType.TargetAttribute.*;
+
+import java.util.EnumSet;
+import java.util.Set;
+
+/**
+ * Describes the type of program element an extended annotation (or extended
+ * compound attribute) targets.
+ *
+ * By comparison, a Tree.Kind has enum values for all elements in the AST, and
+ * it does not provide enough resolution for type arguments (i.e., whether an
+ * annotation targets a type argument in a local variable, method return type,
+ * or a typecast).
+ *
+ *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
+ *  you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public enum TargetType {
+
+    //
+    // Some target types are commented out, because Java doesn't permit such
+    // targets.  They are included here to confirm that their omission is
+    // intentional omission not an accidental omission.
+    //
+
+    /** For annotations on typecasts. */
+    TYPECAST(0x00, IsLocal),
+
+    /** For annotations on a type argument or nested array of a typecast. */
+    TYPECAST_GENERIC_OR_ARRAY(0x01, HasLocation, IsLocal),
+
+    /** For annotations on type tests. */
+    INSTANCEOF(0x02, IsLocal),
+
+    /** For annotations on a type argument or nested array of a type test. */
+    INSTANCEOF_GENERIC_OR_ARRAY(0x03, HasLocation, IsLocal),
+
+    /** For annotations on object creation expressions. */
+    NEW(0x04, IsLocal),
+
+    /**
+     * For annotations on a type argument or nested array of an object creation
+     * expression.
+     */
+    NEW_GENERIC_OR_ARRAY(0x05, HasLocation, IsLocal),
+
+
+    /** For annotations on the method receiver. */
+    METHOD_RECEIVER(0x06),
+
+    // invalid location
+    //@Deprecated METHOD_RECEIVER_GENERIC_OR_ARRAY(0x07, HasLocation),
+
+    /** For annotations on local variables. */
+    LOCAL_VARIABLE(0x08, IsLocal),
+
+    /** For annotations on a type argument or nested array of a local. */
+    LOCAL_VARIABLE_GENERIC_OR_ARRAY(0x09, HasLocation, IsLocal),
+
+    // handled by regular annotations
+    //@Deprecated METHOD_RETURN(0x0A),
+
+    /**
+     * For annotations on a type argument or nested array of a method return
+     * type.
+     */
+    METHOD_RETURN_GENERIC_OR_ARRAY(0x0B, HasLocation),
+
+    // handled by regular annotations
+    //@Deprecated METHOD_PARAMETER(0x0C),
+
+    /** For annotations on a type argument or nested array of a method parameter. */
+    METHOD_PARAMETER_GENERIC_OR_ARRAY(0x0D, HasLocation),
+
+    // handled by regular annotations
+    //@Deprecated FIELD(0x0E),
+
+    /** For annotations on a type argument or nested array of a field. */
+    FIELD_GENERIC_OR_ARRAY(0x0F, HasLocation),
+
+    /** For annotations on a bound of a type parameter of a class. */
+    CLASS_TYPE_PARAMETER_BOUND(0x10, HasBound, HasParameter),
+
+    /**
+     * For annotations on a type argument or nested array of a bound of a type
+     * parameter of a class.
+     */
+    CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x11, HasBound, HasLocation, HasParameter),
+
+    /** For annotations on a bound of a type parameter of a method. */
+    METHOD_TYPE_PARAMETER_BOUND(0x12, HasBound, HasParameter),
+
+    /**
+     * For annotations on a type argument or nested array of a bound of a type
+     * parameter of a method.
+     */
+    METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY(0x13, HasBound, HasLocation, HasParameter),
+
+    /** For annotations on the type of an "extends" or "implements" clause. */
+    CLASS_EXTENDS(0x14),
+
+    /** For annotations on the inner type of an "extends" or "implements" clause. */
+    CLASS_EXTENDS_GENERIC_OR_ARRAY(0x15, HasLocation),
+
+    /** For annotations on a throws clause in a method declaration. */
+    THROWS(0x16),
+
+    // invalid location
+    //@Deprecated THROWS_GENERIC_OR_ARRAY(0x17, HasLocation),
+
+    /** For annotations in type arguments of object creation expressions. */
+    NEW_TYPE_ARGUMENT(0x18, IsLocal),
+    NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x19, HasLocation, IsLocal),
+
+    METHOD_TYPE_ARGUMENT(0x1A, IsLocal),
+    METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY(0x1B, HasLocation, IsLocal),
+
+    WILDCARD_BOUND(0x1C, HasBound),
+    WILDCARD_BOUND_GENERIC_OR_ARRAY(0x1D, HasBound, HasLocation),
+
+    CLASS_LITERAL(0x1E, IsLocal),
+    CLASS_LITERAL_GENERIC_OR_ARRAY(0x1F, HasLocation, IsLocal),
+
+    METHOD_TYPE_PARAMETER(0x20, HasParameter),
+
+    // invalid location
+    //@Deprecated METHOD_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x21, HasLocation, HasParameter),
+
+    CLASS_TYPE_PARAMETER(0x22, HasParameter),
+
+    // invalid location
+    //@Deprecated CLASS_TYPE_PARAMETER_GENERIC_OR_ARRAY(0x23, HasLocation, HasParameter),
+
+    /** For annotations with an unknown target. */
+    UNKNOWN(-1);
+
+    static final int MAXIMUM_TARGET_TYPE_VALUE = 0x22;
+
+    private final int targetTypeValue;
+    private Set<TargetAttribute> flags;
+
+    TargetType(int targetTypeValue, TargetAttribute... attributes) {
+        if (targetTypeValue < Byte.MIN_VALUE
+                || targetTypeValue > Byte.MAX_VALUE)
+                throw new AssertionError("attribute type value needs to be a byte: " + targetTypeValue);
+        this.targetTypeValue = (byte)targetTypeValue;
+        flags = EnumSet.noneOf(TargetAttribute.class);
+        for (TargetAttribute attr : attributes)
+            flags.add(attr);
+    }
+
+    /**
+     * Returns whether or not this TargetType represents an annotation whose
+     * target is an inner type of a generic or array type.
+     *
+     * @return true if this TargetType represents an annotation on an inner
+     *         type, false otherwise
+     */
+    public boolean hasLocation() {
+        return flags.contains(HasLocation);
+    }
+
+    public TargetType getGenericComplement() {
+        if (hasLocation())
+            return this;
+        else
+            return fromTargetTypeValue(targetTypeValue() + 1);
+    }
+
+    /**
+     * Returns whether or not this TargetType represents an annotation whose
+     * target has a parameter index.
+     *
+     * @return true if this TargetType has a parameter index,
+     *         false otherwise
+     */
+    public boolean hasParameter() {
+        return flags.contains(HasParameter);
+    }
+
+    /**
+     * Returns whether or not this TargetType represents an annotation whose
+     * target is a type parameter bound.
+     *
+     * @return true if this TargetType represents an type parameter bound
+     *         annotation, false otherwise
+     */
+    public boolean hasBound() {
+        return flags.contains(HasBound);
+    }
+
+    /**
+     * Returns whether or not this TargetType represents an annotation whose
+     * target is exclusively a tree in a method body
+     *
+     * Note: wildcard bound targets could target a local tree and a class
+     * member declaration signature tree
+     */
+    public boolean isLocal() {
+        return flags.contains(IsLocal);
+    }
+
+    public int targetTypeValue() {
+        return this.targetTypeValue;
+    }
+
+    private static TargetType[] targets = null;
+
+    private static TargetType[] buildTargets() {
+        TargetType[] targets = new TargetType[MAXIMUM_TARGET_TYPE_VALUE + 1];
+        TargetType[] alltargets = values();
+        for (TargetType target : alltargets) {
+            if (target.targetTypeValue >= 0)
+                targets[target.targetTypeValue] = target;
+        }
+        for (int i = 0; i <= MAXIMUM_TARGET_TYPE_VALUE; ++i) {
+            if (targets[i] == null)
+                targets[i] = UNKNOWN;
+        }
+        return targets;
+    }
+
+    public static boolean isValidTargetTypeValue(int tag) {
+        if (targets == null)
+            targets = buildTargets();
+
+        if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
+            return true;
+
+        return (tag >= 0 && tag < targets.length);
+    }
+
+    public static TargetType fromTargetTypeValue(int tag) {
+        if (targets == null)
+            targets = buildTargets();
+
+        if (((byte)tag) == ((byte)UNKNOWN.targetTypeValue))
+            return UNKNOWN;
+
+        if (tag < 0 || tag >= targets.length)
+            throw new IllegalArgumentException("Unknown TargetType: " + tag);
+        return targets[tag];
+    }
+
+    static enum TargetAttribute {
+        HasLocation, HasParameter, HasBound, IsLocal;
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1066,6 +1066,21 @@
             return qtype.isErroneous();
         }
 
+        /**
+         * Replaces this ForAll's typevars with a set of concrete Java types
+         * and returns the instantiated generic type. Subclasses might override
+         * in order to check that the list of types is a valid instantiation
+         * of the ForAll's typevars.
+         *
+         * @param actuals list of actual types
+         * @param types types instance
+         * @return qtype where all occurrences of tvars are replaced
+         * by types in actuals
+         */
+        public Type inst(List<Type> actuals, Types types) {
+            return types.subst(qtype, tvars, actuals);
+        }
+
         public Type map(Mapping f) {
             return f.apply(qtype);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2003-2008 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.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 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.
+ */
+
+package com.sun.tools.javac.code;
+
+import com.sun.tools.javac.util.*;
+
+/** A type annotation position.
+*
+*  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
+*  you write code that depends on this, you do so at your own risk.
+*  This code and its internal interfaces are subject to change or
+*  deletion without notice.</b>
+*/
+public class TypeAnnotationPosition {
+
+    public TargetType type = TargetType.UNKNOWN;
+
+    // For generic/array types.
+    public List<Integer> location = List.nil();
+
+    // Tree position.
+    public int pos = -1;
+
+    // For typecasts, type tests, new (and locals, as start_pc).
+    public boolean isValidOffset = false;
+    public int offset = -1;
+
+    // For locals. arrays same length
+    public int[] lvarOffset = new int[] { -1 };
+    public int[] lvarLength = new int[] { -1 };
+    public int[] lvarIndex = new int[] { -1 };
+
+    // For type parameter bound
+    public int bound_index = -1;
+
+    // For type parameter and method parameter
+    public int parameter_index = -1;
+
+    // For class extends, implements, and throws classes
+    public int type_index = -2;
+
+    // For wildcards
+    public TypeAnnotationPosition wildcard_position = null;
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append('[');
+        sb.append(type);
+
+        switch (type) {
+        // type case
+        case TYPECAST:
+        case TYPECAST_GENERIC_OR_ARRAY:
+            // object creation
+        case INSTANCEOF:
+        case INSTANCEOF_GENERIC_OR_ARRAY:
+            // new expression
+        case NEW:
+        case NEW_GENERIC_OR_ARRAY:
+        case NEW_TYPE_ARGUMENT:
+        case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+            sb.append(", offset = ");
+            sb.append(offset);
+            break;
+            // local variable
+        case LOCAL_VARIABLE:
+        case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
+            sb.append(", {");
+            for (int i = 0; i < lvarOffset.length; ++i) {
+                if (i != 0) sb.append("; ");
+                sb.append(", start_pc = ");
+                sb.append(lvarOffset[i]);
+                sb.append(", length = ");
+                sb.append(lvarLength[i]);
+                sb.append(", index = ");
+                sb.append(lvarIndex[i]);
+            }
+            sb.append("}");
+            break;
+            // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+            // type parameters
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            sb.append(", param_index = ");
+            sb.append(parameter_index);
+            break;
+            // type parameters bound
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+        case METHOD_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+            sb.append(", param_index = ");
+            sb.append(parameter_index);
+            sb.append(", bound_index = ");
+            sb.append(bound_index);
+            break;
+            // wildcard
+        case WILDCARD_BOUND:
+        case WILDCARD_BOUND_GENERIC_OR_ARRAY:
+            sb.append(", wild_card = ");
+            sb.append(wildcard_position);
+            break;
+            // Class extends and implements clauses
+        case CLASS_EXTENDS:
+        case CLASS_EXTENDS_GENERIC_OR_ARRAY:
+            sb.append(", type_index = ");
+            sb.append(type_index);
+            break;
+            // throws
+        case THROWS:
+            sb.append(", type_index = ");
+            sb.append(type_index);
+            break;
+        case CLASS_LITERAL:
+            sb.append(", offset = ");
+            sb.append(offset);
+            break;
+            // method parameter: not specified
+        case METHOD_PARAMETER_GENERIC_OR_ARRAY:
+            sb.append(", param_index = ");
+            sb.append(parameter_index);
+            break;
+            // method type argument: wasn't specified
+        case METHOD_TYPE_ARGUMENT:
+        case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+            sb.append(", offset = ");
+            sb.append(offset);
+            sb.append(", type_index = ");
+            sb.append(type_index);
+            break;
+            // We don't need to worry abut these
+        case METHOD_RETURN_GENERIC_OR_ARRAY:
+        case FIELD_GENERIC_OR_ARRAY:
+            break;
+        case UNKNOWN:
+            break;
+        default:
+            //                throw new AssertionError("unknown type: " + type);
+        }
+
+        // Append location data for generics/arrays.
+        if (type.hasLocation()) {
+            sb.append(", location = (");
+            sb.append(location);
+            sb.append(")");
+        }
+
+        sb.append(", pos = ");
+        sb.append(pos);
+
+        sb.append(']');
+        return sb.toString();
+    }
+
+    /**
+     * Indicates whether the target tree of the annotation has been optimized
+     * away from classfile or not.
+     * @return true if the target has not been optimized away
+     */
+    public boolean emitToClassfile() {
+        if (type == TargetType.WILDCARD_BOUND
+            || type == TargetType.WILDCARD_BOUND_GENERIC_OR_ARRAY)
+            return wildcard_position.isValidOffset;
+        else
+            return !type.isLocal() || isValidOffset;
+    }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Jul 21 13:02:23 2009 -0700
@@ -343,6 +343,14 @@
         if (s.tag >= firstPartialTag)
             return isSuperType(s, t);
 
+        if (s.isCompound()) {
+            for (Type s2 : interfaces(s).prepend(supertype(s))) {
+                if (!isSubtype(t, s2, capture))
+                    return false;
+            }
+            return true;
+        }
+
         Type lower = lowerBound(s);
         if (s != lower)
             return isSubtype(capture ? capture(t) : t, lower, false);
@@ -2870,6 +2878,14 @@
     /**
      * Capture conversion as specified by JLS 3rd Ed.
      */
+
+    public List<Type> capture(List<Type> ts) {
+        List<Type> buf = List.nil();
+        for (Type t : ts) {
+            buf = buf.prepend(capture(t));
+        }
+        return buf.reverse();
+    }
     public Type capture(Type t) {
         if (t.tag != CLASS)
             return t;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Jul 21 13:02:23 2009 -0700
@@ -303,7 +303,7 @@
 
     public Env<AttrContext> attribExprToTree(JCTree expr, Env<AttrContext> env, JCTree tree) {
         breakTree = tree;
-        JavaFileObject prev = log.useSource(null);
+        JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
         try {
             attribExpr(expr, env);
         } catch (BreakAttr b) {
@@ -317,7 +317,7 @@
 
     public Env<AttrContext> attribStatToTree(JCTree stmt, Env<AttrContext> env, JCTree tree) {
         breakTree = tree;
-        JavaFileObject prev = log.useSource(null);
+        JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
         try {
             attribStat(stmt, env);
         } catch (BreakAttr b) {
@@ -700,7 +700,6 @@
             localEnv.info.scope.leave();
             result = tree.type = m.type;
             chk.validateAnnotations(tree.mods.annotations, m);
-
         }
         finally {
             chk.setLint(prevLint);
@@ -2516,10 +2515,11 @@
                 Type clazzOuter = clazztype.getEnclosingType();
                 if (clazzOuter.tag == CLASS) {
                     Type site;
-                    if (tree.clazz.getTag() == JCTree.IDENT) {
+                    JCExpression clazz = TreeInfo.typeIn(tree.clazz);
+                    if (clazz.getTag() == JCTree.IDENT) {
                         site = env.enclClass.sym.type;
-                    } else if (tree.clazz.getTag() == JCTree.SELECT) {
-                        site = ((JCFieldAccess) tree.clazz).selected.type;
+                    } else if (clazz.getTag() == JCTree.SELECT) {
+                        site = ((JCFieldAccess) clazz).selected.type;
                     } else throw new AssertionError(""+tree);
                     if (clazzOuter.tag == CLASS && site != clazzOuter) {
                         if (site.tag == CLASS)
@@ -2628,6 +2628,10 @@
         result = tree.type = syms.errType;
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        result = tree.type = attribType(tree.getUnderlyingType(), env);
+    }
+
     public void visitErroneous(JCErroneous tree) {
         if (tree.errs != null)
             for (JCTree err : tree.errs)
@@ -2816,6 +2820,9 @@
             (c.flags() & ABSTRACT) == 0) {
             checkSerialVersionUID(tree, c);
         }
+
+        // Check type annotations applicability rules
+        validateTypeAnnotations(tree);
     }
         // where
         /** check if a class is a subtype of Serializable, if that is available. */
@@ -2858,4 +2865,33 @@
     private Type capture(Type type) {
         return types.capture(type);
     }
+
+    private void validateTypeAnnotations(JCTree tree) {
+        tree.accept(typeAnnotationsValidator);
+    }
+    //where
+    private final JCTree.Visitor typeAnnotationsValidator =
+        new TreeScanner() {
+        public void visitAnnotation(JCAnnotation tree) {
+            if (tree instanceof JCTypeAnnotation) {
+                chk.validateTypeAnnotation((JCTypeAnnotation)tree, false);
+            }
+            super.visitAnnotation(tree);
+        }
+        public void visitTypeParameter(JCTypeParameter tree) {
+            chk.validateTypeAnnotations(tree.annotations, true);
+            // don't call super. skip type annotations
+            scan(tree.bounds);
+        }
+        public void visitMethodDef(JCMethodDecl tree) {
+            // need to check static methods
+            if ((tree.sym.flags() & Flags.STATIC) != 0) {
+                for (JCTypeAnnotation a : tree.receiverAnnotations) {
+                    if (chk.isTypeAnnotation(a, false))
+                        log.error(a.pos(), "annotation.type.not.applicable");
+                }
+            }
+            super.visitMethodDef(tree);
+        }
+    };
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue Jul 21 13:02:23 2009 -0700
@@ -391,6 +391,10 @@
                                      diags.fragment("incompatible.types" + (d!=null ? ".1" : ""), d),
                                      t, pt);
                 }
+            } catch (Infer.InvalidInstanceException ex) {
+                JCDiagnostic d = ex.getDiagnostic();
+                log.error(pos, "invalid.inferred.types", t.tvars, d);
+                return types.createErrorType(pt);
             }
         }
     }
@@ -912,6 +916,10 @@
             }
         }
 
+        public void visitAnnotatedType(JCAnnotatedType tree) {
+            tree.underlyingType.accept(this);
+        }
+
         /** Default visitor method: do nothing.
          */
         public void visitTree(JCTree tree) {
@@ -1802,6 +1810,14 @@
             validateAnnotation(a, s);
     }
 
+    /** Check the type annotations
+     */
+    public void validateTypeAnnotations(List<JCTypeAnnotation> annotations, boolean isTypeParameter) {
+        if (skipAnnotations) return;
+        for (JCTypeAnnotation a : annotations)
+            validateTypeAnnotation(a, isTypeParameter);
+    }
+
     /** Check an annotation of a symbol.
      */
     public void validateAnnotation(JCAnnotation a, Symbol s) {
@@ -1816,6 +1832,15 @@
         }
     }
 
+    public void validateTypeAnnotation(JCTypeAnnotation a, boolean isTypeParameter) {
+        if (a.type == null)
+            throw new AssertionError("annotation tree hasn't been attributed yet: " + a);
+        validateAnnotation(a);
+
+        if (!isTypeAnnotation(a, isTypeParameter))
+            log.error(a.pos(), "annotation.type.not.applicable");
+    }
+
     /** Is s a method symbol that overrides a method in a superclass? */
     boolean isOverrider(Symbol s) {
         if (s.kind != MTH || s.isStatic())
@@ -1834,6 +1859,25 @@
         return false;
     }
 
+    /** Is the annotation applicable to type annotations */
+    boolean isTypeAnnotation(JCTypeAnnotation a, boolean isTypeParameter) {
+        Attribute.Compound atTarget =
+            a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym);
+        if (atTarget == null) return true;
+        Attribute atValue = atTarget.member(names.value);
+        if (!(atValue instanceof Attribute.Array)) return true; // error recovery
+        Attribute.Array arr = (Attribute.Array) atValue;
+        for (Attribute app : arr.values) {
+            if (!(app instanceof Attribute.Enum)) return true; // recovery
+            Attribute.Enum e = (Attribute.Enum) app;
+            if (!isTypeParameter && e.value.name == names.TYPE_USE)
+                return true;
+            else if (isTypeParameter && e.value.name == names.TYPE_PARAMETER)
+                return true;
+        }
+        return false;
+    }
+
     /** Is the annotation applicable to the symbol? */
     boolean annotationApplicable(JCAnnotation a, Symbol s) {
         Attribute.Compound atTarget =
@@ -1870,6 +1914,13 @@
                 }
             else if (e.value.name == names.PACKAGE)
                 { if (s.kind == PCK) return true; }
+            else if (e.value.name == names.TYPE_USE)
+                { if (s.kind == TYP ||
+                      s.kind == VAR ||
+                      (s.kind == MTH && !s.isConstructor() &&
+                       s.type.getReturnType().tag != VOID))
+                    return true;
+                }
             else
                 return true; // recovery
         }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1245,6 +1245,11 @@
         }
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        // annotations don't get scanned
+        tree.underlyingType.accept(this);
+    }
+
     public void visitIdent(JCIdent tree) {
         if (tree.sym.kind == VAR)
             checkInit(tree.pos(), (VarSymbol)tree.sym);
@@ -1254,7 +1259,8 @@
         super.visitTypeCast(tree);
         if (!tree.type.isErroneous()
             && lint.isEnabled(Lint.LintCategory.CAST)
-            && types.isSameType(tree.expr.type, tree.clazz.type)) {
+            && types.isSameType(tree.expr.type, tree.clazz.type)
+            && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz))) {
             log.warning(tree.pos(), "redundant.cast", tree.expr.type);
         }
     }
@@ -1264,6 +1270,23 @@
     }
 
 /**************************************************************************
+ * utility methods for ignoring type-annotated casts lint checking
+ *************************************************************************/
+    private static final boolean ignoreAnnotatedCasts = true;
+    private static class AnnotationFinder extends TreeScanner {
+        public boolean foundTypeAnno = false;
+        public void visitAnnotation(JCAnnotation tree) {
+            foundTypeAnno = foundTypeAnno || (tree instanceof JCTypeAnnotation);
+        }
+    }
+
+    private boolean containsTypeAnnotation(JCTree e) {
+        AnnotationFinder finder = new AnnotationFinder();
+        finder.scan(e);
+        return finder.foundTypeAnno;
+    }
+
+/**************************************************************************
  * main method
  *************************************************************************/
 
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Jul 21 13:02:23 2009 -0700
@@ -29,6 +29,7 @@
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Type.*;
+import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.util.JCDiagnostic;
 
 import static com.sun.tools.javac.code.TypeTags.*;
@@ -49,6 +50,7 @@
 
     Symtab syms;
     Types types;
+    Resolve rs;
     JCDiagnostic.Factory diags;
 
     public static Infer instance(Context context) {
@@ -62,48 +64,60 @@
         context.put(inferKey, this);
         syms = Symtab.instance(context);
         types = Types.instance(context);
+        rs = Resolve.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
         ambiguousNoInstanceException =
             new NoInstanceException(true, diags);
         unambiguousNoInstanceException =
             new NoInstanceException(false, diags);
+        invalidInstanceException =
+            new InvalidInstanceException(diags);
+
     }
 
-    public static class NoInstanceException extends RuntimeException {
+    public static class InferenceException extends RuntimeException {
         private static final long serialVersionUID = 0;
 
-        boolean isAmbiguous; // exist several incomparable best instances?
-
         JCDiagnostic diagnostic;
         JCDiagnostic.Factory diags;
 
-        NoInstanceException(boolean isAmbiguous, JCDiagnostic.Factory diags) {
+        InferenceException(JCDiagnostic.Factory diags) {
             this.diagnostic = null;
-            this.isAmbiguous = isAmbiguous;
             this.diags = diags;
         }
-        NoInstanceException setMessage(String key) {
-            this.diagnostic = diags.fragment(key);
-            return this;
-        }
-        NoInstanceException setMessage(String key, Object arg1) {
-            this.diagnostic = diags.fragment(key, arg1);
+
+        InferenceException setMessage(String key, Object... args) {
+            this.diagnostic = diags.fragment(key, args);
             return this;
         }
-        NoInstanceException setMessage(String key, Object arg1, Object arg2) {
-            this.diagnostic = diags.fragment(key, arg1, arg2);
-            return this;
-        }
-        NoInstanceException setMessage(String key, Object arg1, Object arg2, Object arg3) {
-            this.diagnostic = diags.fragment(key, arg1, arg2, arg3);
-            return this;
-        }
+
         public JCDiagnostic getDiagnostic() {
-            return diagnostic;
+             return diagnostic;
+         }
+    }
+
+    public static class NoInstanceException extends InferenceException {
+        private static final long serialVersionUID = 1;
+
+        boolean isAmbiguous; // exist several incomparable best instances?
+
+        NoInstanceException(boolean isAmbiguous, JCDiagnostic.Factory diags) {
+            super(diags);
+            this.isAmbiguous = isAmbiguous;
         }
     }
+
+    public static class InvalidInstanceException extends InferenceException {
+        private static final long serialVersionUID = 2;
+
+        InvalidInstanceException(JCDiagnostic.Factory diags) {
+            super(diags);
+        }
+    }
+
     private final NoInstanceException ambiguousNoInstanceException;
     private final NoInstanceException unambiguousNoInstanceException;
+    private final InvalidInstanceException invalidInstanceException;
 
 /***************************************************************************
  * Auxiliary type values and classes
@@ -158,8 +172,7 @@
                 that.inst = types.glb(that.hibounds);
         }
         if (that.inst == null ||
-            that.inst.isErroneous() ||
-            !types.isSubtypeUnchecked(that.inst, that.hibounds, warn))
+            that.inst.isErroneous())
             throw ambiguousNoInstanceException
                 .setMessage("no.unique.maximal.instance.exists",
                             that.qtype, that.hibounds);
@@ -234,7 +247,7 @@
      */
     public Type instantiateExpr(ForAll that,
                                 Type to,
-                                Warner warn) throws NoInstanceException {
+                                Warner warn) throws InferenceException {
         List<Type> undetvars = Type.map(that.tvars, fromTypeVarFun);
         for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) {
             UndetVar v = (UndetVar) l.head;
@@ -260,8 +273,7 @@
         List<Type> targs = Type.map(undetvars, getInstFun);
         targs = types.subst(targs, that.tvars, targs);
         checkWithinBounds(that.tvars, targs, warn);
-
-        return getInstFun.apply(qtype1);
+        return that.inst(targs, types);
     }
 
     /** Instantiate method type `mt' by finding instantiations of
@@ -269,36 +281,42 @@
      */
     public Type instantiateMethod(List<Type> tvars,
                                   MethodType mt,
-                                  List<Type> argtypes,
-                                  boolean allowBoxing,
-                                  boolean useVarargs,
-                                  Warner warn) throws NoInstanceException {
+                                  final List<Type> argtypes,
+                                  final boolean allowBoxing,
+                                  final boolean useVarargs,
+                                  final Warner warn) throws InferenceException {
         //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
         List<Type> undetvars = Type.map(tvars, fromTypeVarFun);
         List<Type> formals = mt.argtypes;
-
+        //need to capture exactly once - otherwise subsequent
+        //applicability checks might fail
+        final List<Type> capturedArgs = types.capture(argtypes);
+        List<Type> actuals = capturedArgs;
+        List<Type> actualsNoCapture = argtypes;
         // instantiate all polymorphic argument types and
         // set up lower bounds constraints for undetvars
         Type varargsFormal = useVarargs ? formals.last() : null;
-        while (argtypes.nonEmpty() && formals.head != varargsFormal) {
-            Type ft = formals.head;
-            Type at = argtypes.head.baseType();
-            if (at.tag == FORALL)
-                at = instantiateArg((ForAll) at, ft, tvars, warn);
-            Type sft = types.subst(ft, tvars, undetvars);
+        while (actuals.nonEmpty() && formals.head != varargsFormal) {
+            Type formal = formals.head;
+            Type actual = actuals.head.baseType();
+            Type actualNoCapture = actualsNoCapture.head.baseType();
+            if (actual.tag == FORALL)
+                actual = instantiateArg((ForAll)actual, formal, tvars, warn);
+            Type undetFormal = types.subst(formal, tvars, undetvars);
             boolean works = allowBoxing
-                ? types.isConvertible(at, sft, warn)
-                : types.isSubtypeUnchecked(at, sft, warn);
+                ? types.isConvertible(actual, undetFormal, warn)
+                : types.isSubtypeUnchecked(actual, undetFormal, warn);
             if (!works) {
                 throw unambiguousNoInstanceException
                     .setMessage("no.conforming.assignment.exists",
-                                tvars, at, ft);
+                                tvars, actualNoCapture, formal);
             }
             formals = formals.tail;
-            argtypes = argtypes.tail;
+            actuals = actuals.tail;
+            actualsNoCapture = actualsNoCapture.tail;
         }
         if (formals.head != varargsFormal || // not enough args
-            !useVarargs && argtypes.nonEmpty()) { // too many args
+            !useVarargs && actuals.nonEmpty()) { // too many args
             // argument lists differ in length
             throw unambiguousNoInstanceException
                 .setMessage("arg.length.mismatch");
@@ -306,20 +324,21 @@
 
         // for varargs arguments as well
         if (useVarargs) {
-            Type elt = types.elemtype(varargsFormal);
-            Type sft = types.subst(elt, tvars, undetvars);
-            while (argtypes.nonEmpty()) {
-                Type ft = sft;
-                Type at = argtypes.head.baseType();
-                if (at.tag == FORALL)
-                    at = instantiateArg((ForAll) at, ft, tvars, warn);
-                boolean works = types.isConvertible(at, sft, warn);
+            Type elemType = types.elemtype(varargsFormal);
+            Type elemUndet = types.subst(elemType, tvars, undetvars);
+            while (actuals.nonEmpty()) {
+                Type actual = actuals.head.baseType();
+                Type actualNoCapture = actualsNoCapture.head.baseType();
+                if (actual.tag == FORALL)
+                    actual = instantiateArg((ForAll)actual, elemType, tvars, warn);
+                boolean works = types.isConvertible(actual, elemUndet, warn);
                 if (!works) {
                     throw unambiguousNoInstanceException
                         .setMessage("no.conforming.assignment.exists",
-                                    tvars, at, ft);
+                                    tvars, actualNoCapture, elemType);
                 }
-                argtypes = argtypes.tail;
+                actuals = actuals.tail;
+                actualsNoCapture = actualsNoCapture.tail;
             }
         }
 
@@ -350,16 +369,38 @@
         }
         checkWithinBounds(tvars, undettypes.toList(), warn);
 
+        mt = (MethodType)types.subst(mt, tvars, insttypes.toList());
+
         if (!restvars.isEmpty()) {
             // if there are uninstantiated variables,
             // quantify result type with them
-            mt = new MethodType(mt.argtypes,
-                                new ForAll(restvars.toList(), mt.restype),
-                                mt.thrown, syms.methodClass);
+            final List<Type> inferredTypes = insttypes.toList();
+            final List<Type> all_tvars = tvars; //this is the wrong tvars
+            final MethodType mt2 = new MethodType(mt.argtypes, null, mt.thrown, syms.methodClass);
+            mt2.restype = new ForAll(restvars.toList(), mt.restype) {
+                @Override
+                public Type inst(List<Type> inferred, Types types) throws NoInstanceException {
+                    List<Type> formals = types.subst(mt2.argtypes, tvars, inferred);
+                   if (!rs.argumentsAcceptable(capturedArgs, formals,
+                           allowBoxing, useVarargs, warn)) {
+                      // inferred method is not applicable
+                      throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", formals, argtypes);
+                   }
+                   // check that inferred bounds conform to their bounds
+                   checkWithinBounds(all_tvars,
+                           types.subst(inferredTypes, tvars, inferred), warn);
+                   return super.inst(inferred, types);
+            }};
+            return mt2;
         }
-
-        // return instantiated version of method type
-        return types.subst(mt, tvars, insttypes.toList());
+        else if (!rs.argumentsAcceptable(capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn)) {
+            // inferred method is not applicable
+            throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", mt.getParameterTypes(), argtypes);
+        }
+        else {
+            // return instantiated version of method type
+            return mt;
+        }
     }
     //where
 
@@ -371,7 +412,7 @@
         private Type instantiateArg(ForAll that,
                                     Type to,
                                     List<Type> tvars,
-                                    Warner warn) throws NoInstanceException {
+                                    Warner warn) throws InferenceException {
             List<Type> targs;
             try {
                 return instantiateExpr(that, to, warn);
@@ -388,16 +429,16 @@
     private void checkWithinBounds(List<Type> tvars,
                                    List<Type> arguments,
                                    Warner warn)
-        throws NoInstanceException {
+        throws InvalidInstanceException {
         for (List<Type> tvs = tvars, args = arguments;
              tvs.nonEmpty();
              tvs = tvs.tail, args = args.tail) {
             if (args.head instanceof UndetVar) continue;
             List<Type> bounds = types.subst(types.getBounds((TypeVar)tvs.head), tvars, arguments);
             if (!types.isSubtypeUnchecked(args.head, bounds, warn))
-                throw unambiguousNoInstanceException
+                throw invalidInstanceException
                     .setMessage("inferred.do.not.conform.to.bounds",
-                                arguments, tvars);
+                                args.head, bounds);
         }
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1979,7 +1979,6 @@
             c.members_field = new Scope(c);
             c.flags_field = flags;
             c.attributes_field = tree.packge.attributes_field;
-            tree.packge.attributes_field = List.nil();
             ClassType ctype = (ClassType) c.type;
             ctype.supertype_field = syms.objectType;
             ctype.interfaces_field = List.nil();
@@ -2369,6 +2368,11 @@
         result = tree;
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        tree.underlyingType = translate(tree.underlyingType);
+        result = tree.underlyingType;
+    }
+
     public void visitTypeCast(JCTypeCast tree) {
         tree.clazz = translate(tree.clazz);
         if (tree.type.isPrimitive() != tree.expr.type.isPrimitive())
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -99,8 +99,8 @@
         types = Types.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
         target = Target.instance(context);
-        skipAnnotations =
-            Options.instance(context).get("skipAnnotations") != null;
+        Options options = Options.instance(context);
+        skipAnnotations = options.get("skipAnnotations") != null;
     }
 
     /** A queue for classes whose members still need to be entered into the
@@ -906,6 +906,10 @@
             if (hasDeprecatedAnnotation(tree.mods.annotations))
                 c.flags_field |= DEPRECATED;
             annotateLater(tree.mods.annotations, baseEnv, c);
+            // class type parameters use baseEnv but everything uses env
+            for (JCTypeParameter tp : tree.typarams)
+                tp.accept(new TypeAnnotate(baseEnv));
+            tree.accept(new TypeAnnotate(env));
 
             chk.checkNonCyclic(tree.pos(), c.type);
 
@@ -988,6 +992,100 @@
         }
     }
 
+    // A sub-phase that "compiles" annotations in annotated types.
+    private class TypeAnnotate extends TreeScanner {
+        private Env<AttrContext> env;
+        public TypeAnnotate(Env<AttrContext> env) { this.env = env; }
+
+        private void enterTypeAnnotations(List<JCTypeAnnotation> annotations) {
+            Set<TypeSymbol> annotated = new HashSet<TypeSymbol>();
+            if (!skipAnnotations)
+                for (List<JCTypeAnnotation> al = annotations; al.nonEmpty(); al = al.tail) {
+                    JCTypeAnnotation a = al.head;
+                    Attribute.Compound c = annotate.enterAnnotation(a,
+                            syms.annotationType,
+                            env);
+                    if (c == null) continue;
+                    Attribute.TypeCompound tc = new Attribute.TypeCompound(c.type, c.values, a.annotation_position);
+                    a.attribute_field = tc;
+                    // Note: @Deprecated has no effect on local variables and parameters
+                    if (!annotated.add(a.type.tsym))
+                        log.error(a.pos, "duplicate.annotation");
+                }
+        }
+
+        // each class (including enclosed inner classes) should be visited
+        // separately through MemberEnter.complete(Symbol)
+        // this flag is used to prevent from visiting inner classes.
+        private boolean isEnclosingClass = false;
+        @Override
+        public void visitClassDef(final JCClassDecl tree) {
+            if (isEnclosingClass)
+                return;
+            isEnclosingClass = true;
+            scan(tree.mods);
+            // type parameter need to be visited with a separate env
+            // scan(tree.typarams);
+            scan(tree.extending);
+            scan(tree.implementing);
+            scan(tree.defs);
+        }
+
+        private void annotate(final JCTree tree, final List<JCTypeAnnotation> annotations) {
+            annotate.later(new Annotate.Annotator() {
+                public String toString() {
+                    return "annotate " + annotations + " onto " + tree;
+                }
+                public void enterAnnotation() {
+                    JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
+                    try {
+                        enterTypeAnnotations(annotations);
+
+                        // enrich type parameter symbols... easier for annotation processors
+                        if (tree instanceof JCTypeParameter) {
+                            JCTypeParameter typeparam = (JCTypeParameter)tree;
+                            ListBuffer<Attribute.Compound> buf = ListBuffer.lb();
+                            for (JCTypeAnnotation anno : annotations)
+                                buf.add(anno.attribute_field);
+                            typeparam.type.tsym.attributes_field = buf.toList();
+                        }
+                    } finally {
+                        log.useSource(prev);
+                    }
+                }
+            });
+        }
+
+        @Override
+        public void visitAnnotatedType(final JCAnnotatedType tree) {
+            annotate(tree, tree.annotations);
+            super.visitAnnotatedType(tree);
+        }
+        @Override
+        public void visitTypeParameter(final JCTypeParameter tree) {
+            annotate(tree, tree.annotations);
+            super.visitTypeParameter(tree);
+        }
+        @Override
+        public void visitNewArray(final JCNewArray tree) {
+            annotate(tree, tree.annotations);
+            for (List<JCTypeAnnotation> dimAnnos : tree.dimAnnotations)
+                annotate(tree, dimAnnos);
+            super.visitNewArray(tree);
+        }
+        @Override
+        public void visitApply(JCMethodInvocation tree) {
+            super.visitApply(tree);
+            scan(tree.typeargs);
+        }
+        @Override
+        public void visitMethodDef(JCMethodDecl tree) {
+            annotate(tree, tree.receiverAnnotations);
+            super.visitMethodDef(tree);
+        }
+    }
+
+
     private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) {
         Scope typaramScope = new Scope(tree.sym);
         if (tree.typarams != null)
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Tue Jul 21 13:02:23 2009 -0700
@@ -82,15 +82,15 @@
         syms = Symtab.instance(context);
 
         varNotFound = new
-            ResolveError(ABSENT_VAR, syms.errSymbol, "variable not found");
+            SymbolNotFoundError(ABSENT_VAR);
         wrongMethod = new
-            ResolveError(WRONG_MTH, syms.errSymbol, "method not found");
+            InapplicableSymbolError(syms.errSymbol);
         wrongMethods = new
-            ResolveError(WRONG_MTHS, syms.errSymbol, "wrong methods");
+            InapplicableSymbolsError(syms.errSymbol);
         methodNotFound = new
-            ResolveError(ABSENT_MTH, syms.errSymbol, "method not found");
+            SymbolNotFoundError(ABSENT_MTH);
         typeNotFound = new
-            ResolveError(ABSENT_TYP, syms.errSymbol, "type not found");
+            SymbolNotFoundError(ABSENT_TYP);
 
         names = Names.instance(context);
         log = Log.instance(context);
@@ -110,11 +110,11 @@
 
     /** error symbols, which are returned when resolution fails
      */
-    final ResolveError varNotFound;
-    final ResolveError wrongMethod;
-    final ResolveError wrongMethods;
-    final ResolveError methodNotFound;
-    final ResolveError typeNotFound;
+    final SymbolNotFoundError varNotFound;
+    final InapplicableSymbolError wrongMethod;
+    final InapplicableSymbolsError wrongMethods;
+    final SymbolNotFoundError methodNotFound;
+    final SymbolNotFoundError typeNotFound;
 
 /* ************************************************************************
  * Identifier resolution
@@ -299,7 +299,7 @@
                         boolean allowBoxing,
                         boolean useVarargs,
                         Warner warn)
-        throws Infer.NoInstanceException {
+        throws Infer.InferenceException {
         if (useVarargs && (m.flags() & VARARGS) == 0) return null;
         Type mt = types.memberType(site, m);
 
@@ -370,7 +370,7 @@
         try {
             return rawInstantiate(env, site, m, argtypes, typeargtypes,
                                   allowBoxing, useVarargs, warn);
-        } catch (Infer.NoInstanceException ex) {
+        } catch (Infer.InferenceException ex) {
             return null;
         }
     }
@@ -584,7 +584,7 @@
                 default: return bestSoFar;
                 }
             }
-        } catch (Infer.NoInstanceException ex) {
+        } catch (Infer.InferenceException ex) {
             switch (bestSoFar.kind) {
             case ABSENT_MTH:
                 return wrongMethod.setWrongSym(sym, ex.getDiagnostic());
@@ -710,13 +710,13 @@
             return new AmbiguityError(m1, m2);
         case AMBIGUOUS:
             AmbiguityError e = (AmbiguityError)m2;
-            Symbol err1 = mostSpecific(m1, e.sym1, env, site, allowBoxing, useVarargs);
+            Symbol err1 = mostSpecific(m1, e.sym, env, site, allowBoxing, useVarargs);
             Symbol err2 = mostSpecific(m1, e.sym2, env, site, allowBoxing, useVarargs);
             if (err1 == err2) return err1;
-            if (err1 == e.sym1 && err2 == e.sym2) return m2;
+            if (err1 == e.sym && err2 == e.sym2) return m2;
             if (err1 instanceof AmbiguityError &&
                 err2 instanceof AmbiguityError &&
-                ((AmbiguityError)err1).sym1 == ((AmbiguityError)err2).sym1)
+                ((AmbiguityError)err1).sym == ((AmbiguityError)err2).sym)
                 return new AmbiguityError(m1, m2);
             else
                 return new AmbiguityError(err1, err2);
@@ -1192,18 +1192,12 @@
                   List<Type> argtypes,
                   List<Type> typeargtypes) {
         if (sym.kind >= AMBIGUOUS) {
-//          printscopes(site.tsym.members());//DEBUG
+            ResolveError errSym = (ResolveError)sym;
             if (!site.isErroneous() &&
                 !Type.isErroneous(argtypes) &&
                 (typeargtypes==null || !Type.isErroneous(typeargtypes)))
-                ((ResolveError)sym).report(log, pos, site, name, argtypes, typeargtypes);
-            do {
-                sym = ((ResolveError)sym).sym;
-            } while (sym.kind >= AMBIGUOUS);
-            if (sym == syms.errSymbol // preserve the symbol name through errors
-                || ((sym.kind & ERRONEOUS) == 0 // make sure an error symbol is returned
-                    && (sym.kind & TYP) != 0))
-                sym = types.createErrorType(name, qualified ? site.tsym : syms.noSymbol, sym.type).tsym;
+                logResolveError(errSym, pos, site, name, argtypes, typeargtypes);
+            sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol);
         }
         return sym;
     }
@@ -1583,7 +1577,19 @@
 
     public void logAccessError(Env<AttrContext> env, JCTree tree, Type type) {
         AccessError error = new AccessError(env, type.getEnclosingType(), type.tsym);
-        error.report(log, tree.pos(), type.getEnclosingType(), null, null, null);
+        logResolveError(error, tree.pos(), type.getEnclosingType(), null, null, null);
+    }
+    //where
+    private void logResolveError(ResolveError error,
+            DiagnosticPosition pos,
+            Type site,
+            Name name,
+            List<Type> argtypes,
+            List<Type> typeargtypes) {
+        JCDiagnostic d = error.getDiagnostic(JCDiagnostic.DiagnosticType.ERROR,
+                pos, site, name, argtypes, typeargtypes);
+        if (d != null)
+            log.report(d);
     }
 
     private final LocalizedString noArgs = new LocalizedString("compiler.misc.no.args");
@@ -1592,152 +1598,71 @@
         return argtypes.isEmpty() ? noArgs : argtypes;
     }
 
-    /** Root class for resolve errors.
-     *  Instances of this class indicate "Symbol not found".
-     *  Instances of subclass indicate other errors.
+    /**
+     * Root class for resolution errors. Subclass of ResolveError
+     * represent a different kinds of resolution error - as such they must
+     * specify how they map into concrete compiler diagnostics.
      */
-    private class ResolveError extends Symbol {
+    private abstract class ResolveError extends Symbol {
 
-        ResolveError(int kind, Symbol sym, String debugName) {
-            super(kind, 0, null, null, null);
-            this.debugName = debugName;
-            this.sym = sym;
-        }
-
-        /** The name of the kind of error, for debugging only.
-         */
+        /** The name of the kind of error, for debugging only. */
         final String debugName;
 
-        /** The symbol that was determined by resolution, or errSymbol if none
-         *  was found.
-         */
-        final Symbol sym;
+        ResolveError(int kind, String debugName) {
+            super(kind, 0, null, null, null);
+            this.debugName = debugName;
+        }
 
-        /** The symbol that was a close mismatch, or null if none was found.
-         *  wrongSym is currently set if a simgle method with the correct name, but
-         *  the wrong parameters was found.
-         */
-        Symbol wrongSym;
-
-        /** An auxiliary explanation set in case of instantiation errors.
-         */
-        JCDiagnostic explanation;
-
-
+        @Override
         public <R, P> R accept(ElementVisitor<R, P> v, P p) {
             throw new AssertionError();
         }
 
-        /** Print the (debug only) name of the kind of error.
-         */
+        @Override
         public String toString() {
-            return debugName + " wrongSym=" + wrongSym + " explanation=" + explanation;
+            return debugName;
         }
 
-        /** Update wrongSym and explanation and return this.
-         */
-        ResolveError setWrongSym(Symbol sym, JCDiagnostic explanation) {
-            this.wrongSym = sym;
-            this.explanation = explanation;
-            return this;
+        @Override
+        public boolean exists() {
+            return false;
         }
 
-        /** Update wrongSym and return this.
+        /**
+         * Create an external representation for this erroneous symbol to be
+         * used during attribution - by default this returns the symbol of a
+         * brand new error type which stores the original type found
+         * during resolution.
+         *
+         * @param name     the name used during resolution
+         * @param location the location from which the symbol is accessed
          */
-        ResolveError setWrongSym(Symbol sym) {
-            this.wrongSym = sym;
-            this.explanation = null;
-            return this;
-        }
-
-        public boolean exists() {
-            switch (kind) {
-            case HIDDEN:
-            case ABSENT_VAR:
-            case ABSENT_MTH:
-            case ABSENT_TYP:
-                return false;
-            default:
-                return true;
-            }
+        protected Symbol access(Name name, TypeSymbol location) {
+            return types.createErrorType(name, location, syms.errSymbol.type).tsym;
         }
 
-        /** Report error.
-         *  @param log       The error log to be used for error reporting.
-         *  @param pos       The position to be used for error reporting.
-         *  @param site      The original type from where the selection took place.
-         *  @param name      The name of the symbol to be resolved.
-         *  @param argtypes  The invocation's value arguments,
-         *                   if we looked for a method.
-         *  @param typeargtypes  The invocation's type arguments,
-         *                   if we looked for a method.
+        /**
+         * Create a diagnostic representing this resolution error.
+         *
+         * @param dkind     The kind of the diagnostic to be created (e.g error).
+         * @param pos       The position to be used for error reporting.
+         * @param site      The original type from where the selection took place.
+         * @param name      The name of the symbol to be resolved.
+         * @param argtypes  The invocation's value arguments,
+         *                  if we looked for a method.
+         * @param typeargtypes  The invocation's type arguments,
+         *                      if we looked for a method.
          */
-        void report(Log log, DiagnosticPosition pos, Type site, Name name,
-                    List<Type> argtypes, List<Type> typeargtypes) {
-            if (argtypes == null)
-                argtypes = List.nil();
-            if (typeargtypes == null)
-                typeargtypes = List.nil();
-            if (name != names.error) {
-                KindName kindname = absentKind(kind);
-                Name idname = name;
-                if (kind >= WRONG_MTHS && kind <= ABSENT_MTH) {
-                    if (isOperator(name)) {
-                        log.error(pos, "operator.cant.be.applied",
-                                  name, argtypes);
-                        return;
-                    }
-                    if (name == names.init) {
-                        kindname = KindName.CONSTRUCTOR;
-                        idname = site.tsym.name;
-                    }
-                }
-                if (kind == WRONG_MTH) {
-                    Symbol ws = wrongSym.asMemberOf(site, types);
-                    log.error(pos,
-                              "cant.apply.symbol" + (explanation != null ? ".1" : ""),
-                              kindname,
-                              ws.name == names.init ? ws.owner.name : ws.name,
-                              methodArguments(ws.type.getParameterTypes()),
-                              methodArguments(argtypes),
-                              kindName(ws.owner),
-                              ws.owner.type,
-                              explanation);
-                } else if (!site.tsym.name.isEmpty()) {
-                    if (site.tsym.kind == PCK && !site.tsym.exists())
-                        log.error(pos, "doesnt.exist", site.tsym);
-                    else {
-                        String errKey = getErrorKey("cant.resolve.location",
-                                                    argtypes, typeargtypes,
-                                                    kindname);
-                        log.error(pos, errKey, kindname, idname, //symbol kindname, name
-                                  typeargtypes, argtypes, //type parameters and arguments (if any)
-                                  typeKindName(site), site); //location kindname, type
-                    }
-                } else {
-                    String errKey = getErrorKey("cant.resolve",
-                                                argtypes, typeargtypes,
-                                                kindname);
-                    log.error(pos, errKey, kindname, idname, //symbol kindname, name
-                              typeargtypes, argtypes); //type parameters and arguments (if any)
-                }
-            }
-        }
-        //where
-        String getErrorKey(String key, List<Type> argtypes, List<Type> typeargtypes, KindName kindname) {
-            String suffix = "";
-            switch (kindname) {
-                case METHOD:
-                case CONSTRUCTOR: {
-                    suffix += ".args";
-                    suffix += typeargtypes.nonEmpty() ? ".params" : "";
-                }
-            }
-            return key + suffix;
-        }
+        abstract JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
+                DiagnosticPosition pos,
+                Type site,
+                Name name,
+                List<Type> argtypes,
+                List<Type> typeargtypes);
 
-        /** A name designates an operator if it consists
-         *  of a non-empty sequence of operator symbols +-~!/*%&|^<>=
+        /**
+         * A name designates an operator if it consists
+         * of a non-empty sequence of operator symbols +-~!/*%&|^<>=
          */
         boolean isOperator(Name name) {
             int i = 0;
@@ -1747,9 +1672,206 @@
         }
     }
 
-    /** Resolve error class indicating that a symbol is not accessible.
+    /**
+     * This class is the root class of all resolution errors caused by
+     * an invalid symbol being found during resolution.
+     */
+    abstract class InvalidSymbolError extends ResolveError {
+
+        /** The invalid symbol found during resolution */
+        Symbol sym;
+
+        InvalidSymbolError(int kind, Symbol sym, String debugName) {
+            super(kind, debugName);
+            this.sym = sym;
+        }
+
+        @Override
+        public boolean exists() {
+            return true;
+        }
+
+        @Override
+        public String toString() {
+             return super.toString() + " wrongSym=" + sym;
+        }
+
+        @Override
+        public Symbol access(Name name, TypeSymbol location) {
+            if (sym.kind >= AMBIGUOUS)
+                return ((ResolveError)sym).access(name, location);
+            else if ((sym.kind & ERRONEOUS) == 0 && (sym.kind & TYP) != 0)
+                return types.createErrorType(name, location, sym.type).tsym;
+            else
+                return sym;
+        }
+    }
+
+    /**
+     * InvalidSymbolError error class indicating that a symbol matching a
+     * given name does not exists in a given site.
      */
-    class AccessError extends ResolveError {
+    class SymbolNotFoundError extends ResolveError {
+
+        SymbolNotFoundError(int kind) {
+            super(kind, "symbol not found error");
+        }
+
+        @Override
+        JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
+                DiagnosticPosition pos,
+                Type site,
+                Name name,
+                List<Type> argtypes,
+                List<Type> typeargtypes) {
+            argtypes = argtypes == null ? List.<Type>nil() : argtypes;
+            typeargtypes = typeargtypes == null ? List.<Type>nil() : typeargtypes;
+            if (name == names.error)
+                return null;
+
+            if (isOperator(name)) {
+                return diags.create(dkind, false, log.currentSource(), pos,
+                        "operator.cant.be.applied", name, argtypes);
+            }
+            boolean hasLocation = false;
+            if (!site.tsym.name.isEmpty()) {
+                if (site.tsym.kind == PCK && !site.tsym.exists()) {
+                    return diags.create(dkind, false, log.currentSource(), pos,
+                        "doesnt.exist", site.tsym);
+                }
+                hasLocation = true;
+            }
+            boolean isConstructor = kind == ABSENT_MTH &&
+                    name == names.table.names.init;
+            KindName kindname = isConstructor ? KindName.CONSTRUCTOR : absentKind(kind);
+            Name idname = isConstructor ? site.tsym.name : name;
+            String errKey = getErrorKey(kindname, typeargtypes.nonEmpty(), hasLocation);
+            if (hasLocation) {
+                return diags.create(dkind, false, log.currentSource(), pos,
+                        errKey, kindname, idname, //symbol kindname, name
+                        typeargtypes, argtypes, //type parameters and arguments (if any)
+                        typeKindName(site), site); //location kindname, type
+            }
+            else {
+                return diags.create(dkind, false, log.currentSource(), pos,
+                        errKey, kindname, idname, //symbol kindname, name
+                        typeargtypes, argtypes); //type parameters and arguments (if any)
+            }
+        }
+        //where
+        private String getErrorKey(KindName kindname, boolean hasTypeArgs, boolean hasLocation) {
+            String key = "cant.resolve";
+            String suffix = hasLocation ? ".location" : "";
+            switch (kindname) {
+                case METHOD:
+                case CONSTRUCTOR: {
+                    suffix += ".args";
+                    suffix += hasTypeArgs ? ".params" : "";
+                }
+            }
+            return key + suffix;
+        }
+    }
+
+    /**
+     * InvalidSymbolError error class indicating that a given symbol
+     * (either a method, a constructor or an operand) is not applicable
+     * given an actual arguments/type argument list.
+     */
+    class InapplicableSymbolError extends InvalidSymbolError {
+
+        /** An auxiliary explanation set in case of instantiation errors. */
+        JCDiagnostic explanation;
+
+        InapplicableSymbolError(Symbol sym) {
+            super(WRONG_MTH, sym, "inapplicable symbol error");
+        }
+
+        /** Update sym and explanation and return this.
+         */
+        InapplicableSymbolError setWrongSym(Symbol sym, JCDiagnostic explanation) {
+            this.sym = sym;
+            this.explanation = explanation;
+            return this;
+        }
+
+        /** Update sym and return this.
+         */
+        InapplicableSymbolError setWrongSym(Symbol sym) {
+            this.sym = sym;
+            this.explanation = null;
+            return this;
+        }
+
+        @Override
+        public String toString() {
+            return super.toString() + " explanation=" + explanation;
+        }
+
+        @Override
+        JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
+                DiagnosticPosition pos,
+                Type site,
+                Name name,
+                List<Type> argtypes,
+                List<Type> typeargtypes) {
+            if (name == names.error)
+                return null;
+
+            if (isOperator(name)) {
+                return diags.create(dkind, false, log.currentSource(),
+                        pos, "operator.cant.be.applied", name, argtypes);
+            }
+            else {
+                Symbol ws = sym.asMemberOf(site, types);
+                return diags.create(dkind, false, log.currentSource(), pos,
+                          "cant.apply.symbol" + (explanation != null ? ".1" : ""),
+                          kindName(ws),
+                          ws.name == names.init ? ws.owner.name : ws.name,
+                          methodArguments(ws.type.getParameterTypes()),
+                          methodArguments(argtypes),
+                          kindName(ws.owner),
+                          ws.owner.type,
+                          explanation);
+            }
+        }
+
+        @Override
+        public Symbol access(Name name, TypeSymbol location) {
+            return types.createErrorType(name, location, syms.errSymbol.type).tsym;
+        }
+    }
+
+    /**
+     * ResolveError error class indicating that a set of symbols
+     * (either methods, constructors or operands) is not applicable
+     * given an actual arguments/type argument list.
+     */
+    class InapplicableSymbolsError extends ResolveError {
+        InapplicableSymbolsError(Symbol sym) {
+            super(WRONG_MTHS, "inapplicable symbols");
+        }
+
+        @Override
+        JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
+                DiagnosticPosition pos,
+                Type site,
+                Name name,
+                List<Type> argtypes,
+                List<Type> typeargtypes) {
+            return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos,
+                    site, name, argtypes, typeargtypes);
+        }
+    }
+
+    /**
+     * An InvalidSymbolError error class indicating that a symbol is not
+     * accessible from a given site
+     */
+    class AccessError extends InvalidSymbolError {
+
+        private Env<AttrContext> env;
+        private Type site;
 
         AccessError(Symbol sym) {
             this(null, null, sym);
@@ -1763,111 +1885,107 @@
                 log.error("proc.messager", sym + " @ " + site + " is inaccessible.");
         }
 
-        private Env<AttrContext> env;
-        private Type site;
+        @Override
+        public boolean exists() {
+            return false;
+        }
+
+        @Override
+        JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
+                DiagnosticPosition pos,
+                Type site,
+                Name name,
+                List<Type> argtypes,
+                List<Type> typeargtypes) {
+            if (sym.owner.type.tag == ERROR)
+                return null;
 
-        /** Report error.
-         *  @param log       The error log to be used for error reporting.
-         *  @param pos       The position to be used for error reporting.
-         *  @param site      The original type from where the selection took place.
-         *  @param name      The name of the symbol to be resolved.
-         *  @param argtypes  The invocation's value arguments,
-         *                   if we looked for a method.
-         *  @param typeargtypes  The invocation's type arguments,
-         *                   if we looked for a method.
-         */
-        void report(Log log, DiagnosticPosition pos, Type site, Name name,
-                    List<Type> argtypes, List<Type> typeargtypes) {
-            if (sym.owner.type.tag != ERROR) {
-                if (sym.name == names.init && sym.owner != site.tsym)
-                    new ResolveError(ABSENT_MTH, sym.owner, "absent method " + sym).report(
-                        log, pos, site, name, argtypes, typeargtypes);
-                if ((sym.flags() & PUBLIC) != 0
-                    || (env != null && this.site != null
-                        && !isAccessible(env, this.site)))
-                    log.error(pos, "not.def.access.class.intf.cant.access",
-                        sym, sym.location());
-                else if ((sym.flags() & (PRIVATE | PROTECTED)) != 0)
-                    log.error(pos, "report.access", sym,
-                              asFlagSet(sym.flags() & (PRIVATE | PROTECTED)),
-                              sym.location());
-                else
-                    log.error(pos, "not.def.public.cant.access",
-                              sym, sym.location());
+            if (sym.name == names.init && sym.owner != site.tsym) {
+                return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind,
+                        pos, site, name, argtypes, typeargtypes);
+            }
+            else if ((sym.flags() & PUBLIC) != 0
+                || (env != null && this.site != null
+                    && !isAccessible(env, this.site))) {
+                return diags.create(dkind, false, log.currentSource(),
+                        pos, "not.def.access.class.intf.cant.access",
+                    sym, sym.location());
+            }
+            else if ((sym.flags() & (PRIVATE | PROTECTED)) != 0) {
+                return diags.create(dkind, false, log.currentSource(),
+                        pos, "report.access", sym,
+                        asFlagSet(sym.flags() & (PRIVATE | PROTECTED)),
+                        sym.location());
+            }
+            else {
+                return diags.create(dkind, false, log.currentSource(),
+                        pos, "not.def.public.cant.access", sym, sym.location());
             }
         }
     }
 
-    /** Resolve error class indicating that an instance member was accessed
-     *  from a static context.
+    /**
+     * InvalidSymbolError error class indicating that an instance member
+     * has erroneously been accessed from a static context.
      */
-    class StaticError extends ResolveError {
+    class StaticError extends InvalidSymbolError {
+
         StaticError(Symbol sym) {
             super(STATICERR, sym, "static error");
         }
 
-        /** Report error.
-         *  @param log       The error log to be used for error reporting.
-         *  @param pos       The position to be used for error reporting.
-         *  @param site      The original type from where the selection took place.
-         *  @param name      The name of the symbol to be resolved.
-         *  @param argtypes  The invocation's value arguments,
-         *                   if we looked for a method.
-         *  @param typeargtypes  The invocation's type arguments,
-         *                   if we looked for a method.
-         */
-        void report(Log log,
-                    DiagnosticPosition pos,
-                    Type site,
-                    Name name,
-                    List<Type> argtypes,
-                    List<Type> typeargtypes) {
+        @Override
+        JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
+                DiagnosticPosition pos,
+                Type site,
+                Name name,
+                List<Type> argtypes,
+                List<Type> typeargtypes) {
             Symbol errSym = ((sym.kind == TYP && sym.type.tag == CLASS)
                 ? types.erasure(sym.type).tsym
                 : sym);
-            log.error(pos, "non-static.cant.be.ref",
-                      kindName(sym), errSym);
+            return diags.create(dkind, false, log.currentSource(), pos,
+                    "non-static.cant.be.ref", kindName(sym), errSym);
         }
     }
 
-    /** Resolve error class indicating an ambiguous reference.
+    /**
+     * InvalidSymbolError error class indicating that a pair of symbols
+     * (either methods, constructors or operands) are ambiguous
+     * given an actual arguments/type argument list.
      */
-    class AmbiguityError extends ResolveError {
-        Symbol sym1;
+    class AmbiguityError extends InvalidSymbolError {
+
+        /** The other maximally specific symbol */
         Symbol sym2;
 
         AmbiguityError(Symbol sym1, Symbol sym2) {
             super(AMBIGUOUS, sym1, "ambiguity error");
-            this.sym1 = sym1;
             this.sym2 = sym2;
         }
 
-        /** Report error.
-         *  @param log       The error log to be used for error reporting.
-         *  @param pos       The position to be used for error reporting.
-         *  @param site      The original type from where the selection took place.
-         *  @param name      The name of the symbol to be resolved.
-         *  @param argtypes  The invocation's value arguments,
-         *                   if we looked for a method.
-         *  @param typeargtypes  The invocation's type arguments,
-         *                   if we looked for a method.
-         */
-        void report(Log log, DiagnosticPosition pos, Type site, Name name,
-                    List<Type> argtypes, List<Type> typeargtypes) {
+        @Override
+        JCDiagnostic getDiagnostic(JCDiagnostic.DiagnosticType dkind,
+                DiagnosticPosition pos,
+                Type site,
+                Name name,
+                List<Type> argtypes,
+                List<Type> typeargtypes) {
             AmbiguityError pair = this;
             while (true) {
-                if (pair.sym1.kind == AMBIGUOUS)
-                    pair = (AmbiguityError)pair.sym1;
+                if (pair.sym.kind == AMBIGUOUS)
+                    pair = (AmbiguityError)pair.sym;
                 else if (pair.sym2.kind == AMBIGUOUS)
                     pair = (AmbiguityError)pair.sym2;
                 else break;
             }
-            Name sname = pair.sym1.name;
-            if (sname == names.init) sname = pair.sym1.owner.name;
-            log.error(pos, "ref.ambiguous", sname,
-                      kindName(pair.sym1),
-                      pair.sym1,
-                      pair.sym1.location(site, types),
+            Name sname = pair.sym.name;
+            if (sname == names.init) sname = pair.sym.owner.name;
+            return diags.create(dkind, false, log.currentSource(),
+                      pos, "ref.ambiguous", sname,
+                      kindName(pair.sym),
+                      pair.sym,
+                      pair.sym.location(site, types),
                       kindName(pair.sym2),
                       pair.sym2,
                       pair.sym2.location(site, types));
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Tue Jul 21 13:02:23 2009 -0700
@@ -27,6 +27,8 @@
 
 import java.util.*;
 
+import javax.lang.model.element.ElementKind;
+
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.*;
@@ -59,6 +61,8 @@
         return instance;
     }
 
+    private boolean debugJSR308;
+
     private Names names;
     private Log log;
     private Symtab syms;
@@ -88,6 +92,7 @@
         types = Types.instance(context);
         make = TreeMaker.instance(context);
         resolve = Resolve.instance(context);
+        debugJSR308 = Options.instance(context).get("TA:trans") != null;
     }
 
     /** A hashtable mapping bridge methods to the methods they override after
@@ -435,12 +440,15 @@
     }
 
     public void visitClassDef(JCClassDecl tree) {
+        new TypeAnnotationPositions().scan(tree);
+        new TypeAnnotationLift().scan(tree);
         translateClass(tree.sym);
         result = tree;
     }
 
     JCMethodDecl currentMethod = null;
     public void visitMethodDef(JCMethodDecl tree) {
+        tree.sym.typeAnnotations = tree.sym.typeAnnotations;
         JCMethodDecl previousMethod = currentMethod;
         try {
             currentMethod = tree;
@@ -726,8 +734,8 @@
     /** Visitor method for parameterized types.
      */
     public void visitTypeApply(JCTypeApply tree) {
-        // Delete all type parameters.
-        result = translate(tree.clazz, null);
+        JCTree clazz = translate(tree.clazz, null);
+        result = clazz;
     }
 
 /**************************************************************************
@@ -793,4 +801,342 @@
         pt = null;
         return translate(cdef, null);
     }
+
+    private class TypeAnnotationPositions extends TreeScanner {
+
+        private ListBuffer<JCTree> frames = ListBuffer.lb();
+        private void push(JCTree t) { frames = frames.prepend(t); }
+        private JCTree pop() { return frames.next(); }
+        private JCTree peek() { return frames.first(); }
+        private JCTree peek2() { return frames.toList().tail.head; }
+
+        @Override
+        public void scan(JCTree tree) {
+            push(tree);
+            super.scan(tree);
+            pop();
+        }
+
+        private TypeAnnotationPosition resolveFrame(JCTree tree, JCTree frame,
+                List<JCTree> path, TypeAnnotationPosition p) {
+            switch (frame.getKind()) {
+                case TYPE_CAST:
+                    p.type = TargetType.TYPECAST;
+                    p.pos = frame.pos;
+                    return p;
+
+                case INSTANCE_OF:
+                    p.type = TargetType.INSTANCEOF;
+                    p.pos = frame.pos;
+                    return p;
+
+                case NEW_CLASS:
+                    p.type = TargetType.NEW;
+                    p.pos = frame.pos;
+                    return p;
+
+                case NEW_ARRAY:
+                    p.type = TargetType.NEW;
+                    p.pos = frame.pos;
+                    return p;
+
+                case CLASS:
+                    p.pos = frame.pos;
+                    if (((JCClassDecl)frame).extending == tree) {
+                        p.type = TargetType.CLASS_EXTENDS;
+                        p.type_index = -1;
+                    } else if (((JCClassDecl)frame).implementing.contains(tree)) {
+                        p.type = TargetType.CLASS_EXTENDS;
+                        p.type_index = ((JCClassDecl)frame).implementing.indexOf(tree);
+                    } else if (((JCClassDecl)frame).typarams.contains(tree)) {
+                        p.type = TargetType.CLASS_TYPE_PARAMETER;
+                        p.parameter_index = ((JCClassDecl)frame).typarams.indexOf(tree);
+                    } else
+                        throw new AssertionError();
+                    return p;
+
+                case METHOD: {
+                    JCMethodDecl frameMethod = (JCMethodDecl)frame;
+                    p.pos = frame.pos;
+                    if (frameMethod.receiverAnnotations.contains(tree))
+                        p.type = TargetType.METHOD_RECEIVER;
+                    else if (frameMethod.thrown.contains(tree)) {
+                        p.type = TargetType.THROWS;
+                        p.type_index = frameMethod.thrown.indexOf(tree);
+                    } else if (((JCMethodDecl)frame).restype == tree) {
+                        p.type = TargetType.METHOD_RETURN_GENERIC_OR_ARRAY;
+                    } else if (frameMethod.typarams.contains(tree)) {
+                        p.type = TargetType.METHOD_TYPE_PARAMETER;
+                        p.parameter_index = frameMethod.typarams.indexOf(tree);
+                    } else
+                        throw new AssertionError();
+                    return p;
+                }
+                case MEMBER_SELECT: {
+                    JCFieldAccess fieldFrame = (JCFieldAccess)frame;
+                    if (fieldFrame.name == names._class) {
+                        p.type = TargetType.CLASS_LITERAL;
+                        if (fieldFrame.selected instanceof JCAnnotatedType) {
+                            p.pos = TreeInfo.typeIn(fieldFrame).pos;
+                        } else if (fieldFrame.selected instanceof JCArrayTypeTree) {
+                            p.pos = fieldFrame.selected.pos;
+                        }
+                    } else
+                        throw new AssertionError();
+                    return p;
+                }
+                case PARAMETERIZED_TYPE: {
+                    TypeAnnotationPosition nextP;
+                    if (((JCTypeApply)frame).clazz == tree)
+                        nextP = p; // generic: RAW; noop
+                    else if (((JCTypeApply)frame).arguments.contains(tree))
+                        p.location = p.location.prepend(
+                                ((JCTypeApply)frame).arguments.indexOf(tree));
+                    else
+                        throw new AssertionError();
+
+                    List<JCTree> newPath = path.tail;
+                    return resolveFrame(newPath.head, newPath.tail.head, newPath, p);
+                }
+
+                case ARRAY_TYPE: {
+                    p.location = p.location.prepend(0);
+                    List<JCTree> newPath = path.tail;
+                    return resolveFrame(newPath.head, newPath.tail.head, newPath, p);
+                }
+
+                case TYPE_PARAMETER:
+                    if (path.tail.tail.head.getTag() == JCTree.CLASSDEF) {
+                        JCClassDecl clazz = (JCClassDecl)path.tail.tail.head;
+                        p.type = TargetType.CLASS_TYPE_PARAMETER_BOUND;
+                        p.parameter_index = clazz.typarams.indexOf(path.tail.head);
+                        p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree);
+                    } else if (path.tail.tail.head.getTag() == JCTree.METHODDEF) {
+                        JCMethodDecl method = (JCMethodDecl)path.tail.tail.head;
+                        p.type = TargetType.METHOD_TYPE_PARAMETER_BOUND;
+                        p.parameter_index = method.typarams.indexOf(path.tail.head);
+                        p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree);
+                    } else
+                        throw new AssertionError();
+                    p.pos = frame.pos;
+                    return p;
+
+                case VARIABLE:
+                    VarSymbol v = ((JCVariableDecl)frame).sym;
+                    p.pos = frame.pos;
+                    switch (v.getKind()) {
+                        case LOCAL_VARIABLE:
+                            p.type = TargetType.LOCAL_VARIABLE; break;
+                        case FIELD:
+                            p.type = TargetType.FIELD_GENERIC_OR_ARRAY; break;
+                        case PARAMETER:
+                            p.type = TargetType.METHOD_PARAMETER_GENERIC_OR_ARRAY;
+                            p.parameter_index = methodParamIndex(path, frame);
+                            break;
+                        default: throw new AssertionError();
+                    }
+                    return p;
+
+                case ANNOTATED_TYPE: {
+                    List<JCTree> newPath = path.tail;
+                    return resolveFrame(newPath.head, newPath.tail.head,
+                            newPath, p);
+                }
+
+                case METHOD_INVOCATION: {
+                    JCMethodInvocation invocation = (JCMethodInvocation)frame;
+                    if (!invocation.typeargs.contains(tree))
+                        throw new AssertionError("{" + tree + "} is not an argument in the invocation: " + invocation);
+                    p.type = TargetType.METHOD_TYPE_ARGUMENT;
+                    p.pos = invocation.pos;
+                    p.type_index = invocation.typeargs.indexOf(tree);
+                    return p;
+                }
+
+                case EXTENDS_WILDCARD:
+                case SUPER_WILDCARD: {
+                    p.type = TargetType.WILDCARD_BOUND;
+                    List<JCTree> newPath = path.tail;
+
+                    TypeAnnotationPosition wildcard =
+                        resolveFrame(newPath.head, newPath.tail.head, newPath,
+                                new TypeAnnotationPosition());
+                    if (!wildcard.location.isEmpty())
+                        wildcard.type = wildcard.type.getGenericComplement();
+                    p.wildcard_position = wildcard;
+                    p.pos = frame.pos;
+                    return p;
+                }
+            }
+            return p;
+        }
+
+        @Override
+        public void visitApply(JCMethodInvocation tree) {
+            scan(tree.meth);
+            scan(tree.typeargs);
+            scan(tree.args);
+        }
+
+        private void setTypeAnnotationPos(List<JCTypeAnnotation> annotations, TypeAnnotationPosition position) {
+            for (JCTypeAnnotation anno : annotations) {
+                anno.annotation_position = position;
+                anno.attribute_field.position = position;
+            }
+        }
+
+        @Override
+        public void visitNewArray(JCNewArray tree) {
+            findPosition(tree, tree, tree.annotations);
+            int dimAnnosCount = tree.dimAnnotations.size();
+
+            // handle annotations associated with dimentions
+            for (int i = 0; i < dimAnnosCount; ++i) {
+                TypeAnnotationPosition p = new TypeAnnotationPosition();
+                p.type = TargetType.NEW_GENERIC_OR_ARRAY;
+                p.pos = tree.pos;
+                p.location = p.location.append(i);
+                setTypeAnnotationPos(tree.dimAnnotations.get(i), p);
+            }
+
+            // handle "free" annotations
+            int i = dimAnnosCount == 0 ? 0 : dimAnnosCount - 1;
+            JCExpression elemType = tree.elemtype;
+            while (elemType != null) {
+                if (elemType.getTag() == JCTree.ANNOTATED_TYPE) {
+                    JCAnnotatedType at = (JCAnnotatedType)elemType;
+                    TypeAnnotationPosition p = new TypeAnnotationPosition();
+                    p.type = TargetType.NEW_GENERIC_OR_ARRAY;
+                    p.pos = tree.pos;
+                    p.location = p.location.append(i);
+                    setTypeAnnotationPos(at.annotations, p);
+                    elemType = at.underlyingType;
+                } else if (elemType.getTag() == JCTree.TYPEARRAY) {
+                    ++i;
+                    elemType = ((JCArrayTypeTree)elemType).elemtype;
+                } else
+                    break;
+            }
+
+            // find annotations locations of initializer elements
+            scan(tree.elems);
+        }
+
+        @Override
+        public void visitAnnotatedType(JCAnnotatedType tree) {
+            findPosition(tree, peek2(), tree.annotations);
+            super.visitAnnotatedType(tree);
+        }
+
+        @Override
+        public void visitMethodDef(JCMethodDecl tree) {
+            TypeAnnotationPosition p = new TypeAnnotationPosition();
+            p.type = TargetType.METHOD_RECEIVER;
+            setTypeAnnotationPos(tree.receiverAnnotations, p);
+            super.visitMethodDef(tree);
+        }
+        @Override
+        public void visitTypeParameter(JCTypeParameter tree) {
+            findPosition(tree, peek2(), tree.annotations);
+            super.visitTypeParameter(tree);
+        }
+
+        void findPosition(JCTree tree, JCTree frame, List<JCTypeAnnotation> annotations) {
+            if (!annotations.isEmpty()) {
+                TypeAnnotationPosition p =
+                        resolveFrame(tree, frame, frames.toList(),
+                                new TypeAnnotationPosition());
+                if (!p.location.isEmpty())
+                    p.type = p.type.getGenericComplement();
+                setTypeAnnotationPos(annotations, p);
+                if (debugJSR308) {
+                    System.out.println("trans: " + tree);
+                    System.out.println("  target: " + p);
+                }
+            }
+        }
+
+        private int methodParamIndex(List<JCTree> path, JCTree param) {
+            List<JCTree> curr = path;
+            if (curr.head != param)
+                curr = path.tail;
+            JCMethodDecl method = (JCMethodDecl)curr.tail.head;
+            return method.params.indexOf(param);
+        }
+    }
+
+    private class TypeAnnotationLift extends TreeScanner {
+        List<Attribute.TypeCompound> recordedTypeAnnotations = List.nil();
+
+        boolean isInner = false;
+        @Override
+        public void visitClassDef(JCClassDecl tree) {
+            if (isInner) {
+                // tree is an inner class tree.  stop now.
+                // TransTypes.visitClassDef makes an invocation for each class
+                // seperately.
+                return;
+            }
+            isInner = true;
+            List<Attribute.TypeCompound> prevTAs = recordedTypeAnnotations;
+            recordedTypeAnnotations = List.nil();
+            try {
+                super.visitClassDef(tree);
+            } finally {
+                tree.sym.typeAnnotations = tree.sym.typeAnnotations.appendList(recordedTypeAnnotations);
+                recordedTypeAnnotations = prevTAs;
+            }
+        }
+
+        @Override
+        public void visitMethodDef(JCMethodDecl tree) {
+            List<Attribute.TypeCompound> prevTAs = recordedTypeAnnotations;
+            recordedTypeAnnotations = List.nil();
+            try {
+                super.visitMethodDef(tree);
+            } finally {
+                tree.sym.typeAnnotations = tree.sym.typeAnnotations.appendList(recordedTypeAnnotations);
+                recordedTypeAnnotations = prevTAs;
+            }
+        }
+
+        @Override
+        public void visitVarDef(JCVariableDecl tree) {
+            List<Attribute.TypeCompound> prevTAs = recordedTypeAnnotations;
+            recordedTypeAnnotations = List.nil();
+            ElementKind kind = tree.sym.getKind();
+            if (kind == ElementKind.LOCAL_VARIABLE && tree.mods.annotations.nonEmpty()) {
+                // need to lift the annotations
+                TypeAnnotationPosition position = new TypeAnnotationPosition();
+                position.pos = tree.pos;
+                position.type = TargetType.LOCAL_VARIABLE;
+                for (Attribute.Compound attribute : tree.sym.attributes_field) {
+                    Attribute.TypeCompound tc =
+                        new Attribute.TypeCompound(attribute.type, attribute.values, position);
+                    recordedTypeAnnotations = recordedTypeAnnotations.append(tc);
+                }
+            }
+            try {
+                super.visitVarDef(tree);
+            } finally {
+                if (kind.isField() || kind == ElementKind.LOCAL_VARIABLE)
+                    tree.sym.typeAnnotations = tree.sym.typeAnnotations.appendList(recordedTypeAnnotations);
+                recordedTypeAnnotations = kind.isField() ? prevTAs : prevTAs.appendList(recordedTypeAnnotations);
+            }
+        }
+
+        @Override
+        public void visitApply(JCMethodInvocation tree) {
+            scan(tree.meth);
+            scan(tree.typeargs);
+            scan(tree.args);
+        }
+
+        public void visitAnnotation(JCAnnotation tree) {
+            if (tree instanceof JCTypeAnnotation)
+                recordedTypeAnnotations = recordedTypeAnnotations.append(((JCTypeAnnotation)tree).attribute_field);
+            super.visitAnnotation(tree);
+        }
+    }
+
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue Jul 21 13:02:23 2009 -0700
@@ -47,7 +47,6 @@
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.file.BaseFileObject;
 import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.List;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
@@ -187,6 +186,10 @@
     /** The minor version number of the class file being read. */
     int minorVersion;
 
+    /** Switch: debug output for JSR 308-related operations.
+     */
+    boolean debugJSR308;
+
     /** Get the ClassReader instance for this invocation. */
     public static ClassReader instance(Context context) {
         ClassReader instance = context.get(classReaderKey);
@@ -256,6 +259,7 @@
             : null;
 
         typevars = new Scope(syms.noSymbol);
+        debugJSR308 = options.get("TA:reader") != null;
 
         initAttributeReaders();
     }
@@ -303,6 +307,12 @@
         return (char)(((buf[bp++] & 0xFF) << 8) + (buf[bp++] & 0xFF));
     }
 
+    /** Read a byte.
+     */
+    byte nextByte() {
+        return buf[bp++];
+    }
+
     /** Read an integer.
      */
     int nextInt() {
@@ -1060,7 +1070,21 @@
                     if (allowVarargs)
                         sym.flags_field |= VARARGS;
                 }
-            }
+            },
+
+            // v51 attributes
+            new AttributeReader(names.RuntimeVisibleTypeAnnotations, V51, CLASS_OR_MEMBER_ATTRIBUTE) {
+                void read(Symbol sym, int attrLen) {
+                    attachTypeAnnotations(sym);
+                }
+            },
+
+            new AttributeReader(names.RuntimeInvisibleTypeAnnotations, V51, CLASS_OR_MEMBER_ATTRIBUTE) {
+                void read(Symbol sym, int attrLen) {
+                    attachTypeAnnotations(sym);
+                }
+            },
+
 
             // The following attributes for a Code attribute are not currently handled
             // StackMapTable
@@ -1268,6 +1292,17 @@
         }
     }
 
+    void attachTypeAnnotations(final Symbol sym) {
+        int numAttributes = nextChar();
+        if (numAttributes != 0) {
+            ListBuffer<TypeAnnotationProxy> proxies =
+                ListBuffer.lb();
+            for (int i = 0; i < numAttributes; i++)
+                proxies.append(readTypeAnnotation());
+            annotate.later(new TypeAnnotationCompleter(sym, proxies.toList()));
+        }
+    }
+
     /** Attach the default value for an annotation element.
      */
     void attachAnnotationDefault(final Symbol sym) {
@@ -1304,6 +1339,121 @@
         return new CompoundAnnotationProxy(t, pairs.toList());
     }
 
+    TypeAnnotationProxy readTypeAnnotation() {
+        CompoundAnnotationProxy proxy = readCompoundAnnotation();
+        TypeAnnotationPosition position = readPosition();
+
+        if (debugJSR308)
+            System.out.println("TA: reading: " + proxy + " @ " + position
+                    + " in " + log.currentSourceFile());
+
+        return new TypeAnnotationProxy(proxy, position);
+    }
+
+    TypeAnnotationPosition readPosition() {
+        byte tag = nextByte();
+
+        if (!TargetType.isValidTargetTypeValue(tag))
+            throw this.badClassFile("bad.type.annotation.value", tag);
+
+        TypeAnnotationPosition position = new TypeAnnotationPosition();
+        TargetType type = TargetType.fromTargetTypeValue(tag);
+
+        position.type = type;
+
+        switch (type) {
+        // type case
+        case TYPECAST:
+        case TYPECAST_GENERIC_OR_ARRAY:
+        // object creation
+        case INSTANCEOF:
+        case INSTANCEOF_GENERIC_OR_ARRAY:
+        // new expression
+        case NEW:
+        case NEW_GENERIC_OR_ARRAY:
+            position.offset = nextChar();
+            break;
+         // local variable
+        case LOCAL_VARIABLE:
+        case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
+            int table_length = nextChar();
+            position.lvarOffset = new int[table_length];
+            position.lvarLength = new int[table_length];
+            position.lvarIndex = new int[table_length];
+
+            for (int i = 0; i < table_length; ++i) {
+                position.lvarOffset[i] = nextChar();
+                position.lvarLength[i] = nextChar();
+                position.lvarIndex[i] = nextChar();
+            }
+            break;
+         // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+        // type parameters
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            position.parameter_index = nextByte();
+            break;
+        // type parameter bounds
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+        case METHOD_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+            position.parameter_index = nextByte();
+            position.bound_index = nextByte();
+            break;
+         // wildcard
+        case WILDCARD_BOUND:
+        case WILDCARD_BOUND_GENERIC_OR_ARRAY:
+            position.wildcard_position = readPosition();
+            break;
+         // Class extends and implements clauses
+        case CLASS_EXTENDS:
+        case CLASS_EXTENDS_GENERIC_OR_ARRAY:
+            position.type_index = nextByte();
+            break;
+        // throws
+        case THROWS:
+            position.type_index = nextByte();
+            break;
+        case CLASS_LITERAL:
+        case CLASS_LITERAL_GENERIC_OR_ARRAY:
+            position.offset = nextChar();
+            break;
+        // method parameter: not specified
+        case METHOD_PARAMETER_GENERIC_OR_ARRAY:
+            position.parameter_index = nextByte();
+            break;
+        // method type argument: wasn't specified
+        case NEW_TYPE_ARGUMENT:
+        case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+        case METHOD_TYPE_ARGUMENT:
+        case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+            position.offset = nextChar();
+            position.type_index = nextByte();
+            break;
+        // We don't need to worry abut these
+        case METHOD_RETURN_GENERIC_OR_ARRAY:
+        case FIELD_GENERIC_OR_ARRAY:
+            break;
+        case UNKNOWN:
+            break;
+        default:
+            throw new AssertionError("unknown type: " + position);
+        }
+
+        if (type.hasLocation()) {
+            int len = nextChar();
+            ListBuffer<Integer> loc = ListBuffer.lb();
+            for (int i = 0; i < len; i++)
+                loc = loc.append((int)nextByte());
+            position.location = loc.toList();
+        }
+
+        return position;
+    }
     Attribute readAttributeValue() {
         char c = (char) buf[bp++];
         switch (c) {
@@ -1408,6 +1558,18 @@
         }
     }
 
+    /** A temporary proxy representing a type annotation.
+     */
+    static class TypeAnnotationProxy {
+        final CompoundAnnotationProxy compound;
+        final TypeAnnotationPosition position;
+        public TypeAnnotationProxy(CompoundAnnotationProxy compound,
+                TypeAnnotationPosition position) {
+            this.compound = compound;
+            this.position = position;
+        }
+    }
+
     class AnnotationDeproxy implements ProxyVisitor {
         private ClassSymbol requestingOwner = currentOwner.kind == MTH
             ? currentOwner.enclClass() : (ClassSymbol)currentOwner;
@@ -1604,6 +1766,45 @@
         }
     }
 
+    class TypeAnnotationCompleter extends AnnotationCompleter {
+
+        List<TypeAnnotationProxy> proxies;
+
+        TypeAnnotationCompleter(Symbol sym,
+                List<TypeAnnotationProxy> proxies) {
+            super(sym, List.<CompoundAnnotationProxy>nil());
+            this.proxies = proxies;
+        }
+
+        List<Attribute.TypeCompound> deproxyTypeCompoundList(List<TypeAnnotationProxy> proxies) {
+            ListBuffer<Attribute.TypeCompound> buf = ListBuffer.lb();
+            for (TypeAnnotationProxy proxy: proxies) {
+                Attribute.Compound compound = deproxyCompound(proxy.compound);
+                Attribute.TypeCompound typeCompound = new Attribute.TypeCompound(compound, proxy.position);
+                buf.add(typeCompound);
+            }
+            return buf.toList();
+        }
+
+        @Override
+        public void enterAnnotation() {
+            JavaFileObject previousClassFile = currentClassFile;
+            try {
+                currentClassFile = classFile;
+                List<Attribute.TypeCompound> newList = deproxyTypeCompoundList(proxies);
+              if (debugJSR308)
+              System.out.println("TA: reading: adding " + newList
+                      + " to symbol " + sym + " in " + log.currentSourceFile());
+                sym.typeAnnotations = ((sym.typeAnnotations == null)
+                                        ? newList
+                                        : newList.prependList(sym.typeAnnotations));
+
+            } finally {
+                currentClassFile = previousClassFile;
+            }
+        }
+    }
+
 
 /************************************************************************
  * Reading Symbols
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -37,7 +37,6 @@
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.List;
 
 import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.code.Flags.*;
@@ -62,6 +61,10 @@
 
     private final Options options;
 
+    /** Switch: debugging output for JSR 308-related operations.
+     */
+    private boolean debugJSR308;
+
     /** Switch: verbose output.
      */
     private boolean verbose;
@@ -173,6 +176,7 @@
         types = Types.instance(context);
         fileManager = context.get(JavaFileManager.class);
 
+        debugJSR308    = options.get("TA:writer") != null;
         verbose        = options.get("-verbose")     != null;
         scramble       = options.get("-scramble")    != null;
         scrambleAll    = options.get("-scrambleAll") != null;
@@ -668,6 +672,7 @@
             acount++;
         }
         acount += writeJavaAnnotations(sym.getAnnotationMirrors());
+        acount += writeTypeAnnotations(sym.typeAnnotations);
         return acount;
     }
 
@@ -762,6 +767,46 @@
         return attrCount;
     }
 
+    int writeTypeAnnotations(List<Attribute.TypeCompound> typeAnnos) {
+        if (typeAnnos.isEmpty()) return 0;
+
+        ListBuffer<Attribute.TypeCompound> visibles = ListBuffer.lb();
+        ListBuffer<Attribute.TypeCompound> invisibles = ListBuffer.lb();
+
+        for (Attribute.TypeCompound tc : typeAnnos) {
+            if (tc.position.type == TargetType.UNKNOWN
+                || !tc.position.emitToClassfile())
+                continue;
+            switch (getRetention(tc.type.tsym)) {
+            case SOURCE: break;
+            case CLASS: invisibles.append(tc); break;
+            case RUNTIME: visibles.append(tc); break;
+            default: ;// /* fail soft */ throw new AssertionError(vis);
+            }
+        }
+
+        int attrCount = 0;
+        if (visibles.length() != 0) {
+            int attrIndex = writeAttr(names.RuntimeVisibleTypeAnnotations);
+            databuf.appendChar(visibles.length());
+            for (Attribute.TypeCompound p : visibles)
+                writeTypeAnnotation(p);
+            endAttr(attrIndex);
+            attrCount++;
+        }
+
+        if (invisibles.length() != 0) {
+            int attrIndex = writeAttr(names.RuntimeInvisibleTypeAnnotations);
+            databuf.appendChar(invisibles.length());
+            for (Attribute.TypeCompound p : invisibles)
+                writeTypeAnnotation(p);
+            endAttr(attrIndex);
+            attrCount++;
+        }
+
+        return attrCount;
+    }
+
     /** A mirror of java.lang.annotation.RetentionPolicy. */
     enum RetentionPolicy {
         SOURCE,
@@ -862,6 +907,103 @@
         }
     }
 
+    void writeTypeAnnotation(Attribute.TypeCompound c) {
+        if (debugJSR308)
+            System.out.println("TA: writing " + c + " at " + c.position
+                    + " in " + log.currentSourceFile());
+        writeCompoundAttribute(c);
+        writePosition(c.position);
+    }
+
+    void writePosition(TypeAnnotationPosition p) {
+        databuf.appendByte(p.type.targetTypeValue());
+        switch (p.type) {
+        // type case
+        case TYPECAST:
+        case TYPECAST_GENERIC_OR_ARRAY:
+        // object creation
+        case INSTANCEOF:
+        case INSTANCEOF_GENERIC_OR_ARRAY:
+        // new expression
+        case NEW:
+        case NEW_GENERIC_OR_ARRAY:
+            databuf.appendChar(p.offset);
+            break;
+         // local variable
+        case LOCAL_VARIABLE:
+        case LOCAL_VARIABLE_GENERIC_OR_ARRAY:
+            databuf.appendChar(p.lvarOffset.length);  // for table length
+            for (int i = 0; i < p.lvarOffset.length; ++i) {
+                databuf.appendChar(p.lvarOffset[i]);
+                databuf.appendChar(p.lvarLength[i]);
+                databuf.appendChar(p.lvarIndex[i]);
+            }
+            break;
+         // method receiver
+        case METHOD_RECEIVER:
+            // Do nothing
+            break;
+        // type parameters
+        case CLASS_TYPE_PARAMETER:
+        case METHOD_TYPE_PARAMETER:
+            databuf.appendByte(p.parameter_index);
+            break;
+        // type parameters bounds
+        case CLASS_TYPE_PARAMETER_BOUND:
+        case CLASS_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+        case METHOD_TYPE_PARAMETER_BOUND:
+        case METHOD_TYPE_PARAMETER_BOUND_GENERIC_OR_ARRAY:
+            databuf.appendByte(p.parameter_index);
+            databuf.appendByte(p.bound_index);
+            break;
+         // wildcards
+        case WILDCARD_BOUND:
+        case WILDCARD_BOUND_GENERIC_OR_ARRAY:
+            writePosition(p.wildcard_position);
+            break;
+         // Class extends and implements clauses
+        case CLASS_EXTENDS:
+        case CLASS_EXTENDS_GENERIC_OR_ARRAY:
+            databuf.appendByte(p.type_index);
+            break;
+        // throws
+        case THROWS:
+            databuf.appendByte(p.type_index);
+            break;
+        case CLASS_LITERAL:
+        case CLASS_LITERAL_GENERIC_OR_ARRAY:
+            databuf.appendChar(p.offset);
+            break;
+        // method parameter: not specified
+        case METHOD_PARAMETER_GENERIC_OR_ARRAY:
+            databuf.appendByte(p.parameter_index);
+            break;
+        // method type argument: wasn't specified
+        case NEW_TYPE_ARGUMENT:
+        case NEW_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+        case METHOD_TYPE_ARGUMENT:
+        case METHOD_TYPE_ARGUMENT_GENERIC_OR_ARRAY:
+            databuf.appendChar(p.offset);
+            databuf.appendByte(p.type_index);
+            break;
+        // We don't need to worry abut these
+        case METHOD_RETURN_GENERIC_OR_ARRAY:
+        case FIELD_GENERIC_OR_ARRAY:
+            break;
+        case UNKNOWN:
+            break;
+        default:
+            throw new AssertionError("unknown position: " + p);
+        }
+
+        // Append location data for generics/arrays.
+        if (p.type.hasLocation()) {
+            databuf.appendChar(p.location.size());
+            for (int i : p.location)
+                databuf.appendByte((byte)i);
+        }
+    }
+
 /**********************************************************************
  * Writing Objects
  **********************************************************************/
@@ -1521,9 +1663,9 @@
         int acount = 0;
 
         boolean sigReq =
-            typarams.length() != 0 || supertype.getTypeArguments().length() != 0;
+            typarams.length() != 0 || supertype.allparams().length() != 0;
         for (List<Type> l = interfaces; !sigReq && l.nonEmpty(); l = l.tail)
-            sigReq = l.head.getTypeArguments().length() != 0;
+            sigReq = l.head.allparams().length() != 0;
         if (sigReq) {
             assert source.allowGenerics();
             int alenIdx = writeAttr(names.Signature);
@@ -1569,6 +1711,7 @@
 
         acount += writeFlagAttrs(c.flags());
         acount += writeJavaAnnotations(c.getAnnotationMirrors());
+        acount += writeTypeAnnotations(c.typeAnnotations);
         acount += writeEnclosingMethodAttribute(c);
 
         poolbuf.appendInt(JAVA_MAGIC);
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java	Tue Jul 21 13:02:23 2009 -0700
@@ -1912,12 +1912,29 @@
                 if (length < Character.MAX_VALUE) {
                     v.length = length;
                     putVar(v);
+                    fillLocalVarPosition(v);
                 }
             }
         }
         state.defined.excl(adr);
     }
 
+    private void fillLocalVarPosition(LocalVar lv) {
+        if (lv == null || lv.sym == null
+                || lv.sym.typeAnnotations == null)
+            return;
+        for (Attribute.TypeCompound ta : lv.sym.typeAnnotations) {
+            TypeAnnotationPosition p = ta.position;
+            while (p != null) {
+                p.lvarOffset[0] = (int)lv.start_pc;
+                p.lvarLength[0] = (int)lv.length;
+                p.lvarIndex[0] = (int)lv.reg;
+                p.isValidOffset = true;
+                p = p.wildcard_position;
+            }
+        }
+    }
+
     /** Put a live variable range into the buffer to be output to the
      *  class file.
      */
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Tue Jul 21 13:02:23 2009 -0700
@@ -26,6 +26,8 @@
 package com.sun.tools.javac.jvm;
 import java.util.*;
 
+import javax.lang.model.element.ElementKind;
+
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
@@ -939,7 +941,6 @@
                                  startpcCrt,
                                  code.curPc());
 
-                // End the scope of all local variables in variable info.
                 code.endScopes(0);
 
                 // If we exceeded limits, panic
@@ -1439,7 +1440,6 @@
             // Resolve all breaks.
             code.resolve(exitChain);
 
-            // End the scopes of all try-local variables in variable info.
             code.endScopes(limit);
         }
 
@@ -1672,6 +1672,7 @@
  *************************************************************************/
 
     public void visitApply(JCMethodInvocation tree) {
+        setTypeAnnotationPositions(tree.pos);
         // Generate code for method.
         Item m = genExpr(tree.meth, methodType);
         // Generate code for all arguments, where the expected types are
@@ -1707,10 +1708,48 @@
         result = items.makeStackItem(pt);
     }
 
+    private void setTypeAnnotationPositions(int treePos) {
+        MethodSymbol meth = code.meth;
+
+        for (Attribute.TypeCompound ta : meth.typeAnnotations) {
+            if (ta.position.pos == treePos) {
+                ta.position.offset = code.cp;
+                ta.position.lvarOffset[0] = code.cp;
+                ta.position.isValidOffset = true;
+            }
+        }
+
+        if (code.meth.getKind() != ElementKind.CONSTRUCTOR
+                && code.meth.getKind() != ElementKind.STATIC_INIT)
+            return;
+
+        for (Attribute.TypeCompound ta : meth.owner.typeAnnotations) {
+            if (ta.position.pos == treePos) {
+                ta.position.offset = code.cp;
+                ta.position.lvarOffset[0] = code.cp;
+                ta.position.isValidOffset = true;
+            }
+        }
+
+        ClassSymbol clazz = meth.enclClass();
+        for (Symbol s : new com.sun.tools.javac.model.FilteredMemberList(clazz.members())) {
+            if (!s.getKind().isField())
+                continue;
+            for (Attribute.TypeCompound ta : s.typeAnnotations) {
+                if (ta.position.pos == treePos) {
+                    ta.position.offset = code.cp;
+                    ta.position.lvarOffset[0] = code.cp;
+                    ta.position.isValidOffset = true;
+                }
+            }
+        }
+    }
+
     public void visitNewClass(JCNewClass tree) {
         // Enclosing instances or anonymous classes should have been eliminated
         // by now.
         assert tree.encl == null && tree.def == null;
+        setTypeAnnotationPositions(tree.pos);
 
         code.emitop2(new_, makeRef(tree.pos(), tree.type));
         code.emitop0(dup);
@@ -1725,6 +1764,8 @@
     }
 
     public void visitNewArray(JCNewArray tree) {
+        setTypeAnnotationPositions(tree.pos);
+
         if (tree.elems != null) {
             Type elemtype = types.elemtype(tree.type);
             loadIntConst(tree.elems.length());
@@ -2053,6 +2094,7 @@
         }
 
     public void visitTypeCast(JCTypeCast tree) {
+        setTypeAnnotationPositions(tree.pos);
         result = genExpr(tree.expr, tree.clazz.type).load();
         // Additional code is only needed if we cast to a reference type
         // which is not statically a supertype of the expression's type.
@@ -2069,6 +2111,8 @@
     }
 
     public void visitTypeTest(JCInstanceOf tree) {
+        setTypeAnnotationPositions(tree.pos);
+
         genExpr(tree.expr, tree.expr.type).load();
         code.emitop2(instanceof_, makeRef(tree.pos(), tree.clazz.type));
         result = items.makeStackItem(syms.booleanType);
@@ -2110,6 +2154,7 @@
 
         if (tree.name == names._class) {
             assert target.hasClassLiterals();
+            setTypeAnnotationPositions(tree.pos);
             code.emitop2(ldc2, makeRef(tree.pos(), tree.selected.type));
             result = items.makeStackItem(pt);
             return;
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Jul 21 13:02:23 2009 -0700
@@ -477,7 +477,7 @@
     public Todo todo;
 
     /** Ordered list of compiler phases for each compilation unit. */
-    protected enum CompileState {
+    public enum CompileState {
         PARSE(1),
         ENTER(2),
         PROCESS(3),
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Jul 21 13:02:23 2009 -0700
@@ -75,6 +75,42 @@
     /** The name table. */
     private Names names;
 
+    // Because of javac's limited lookahead, some contexts are ambiguous in
+    // the presence of type annotations even though they are not ambiguous
+    // in the absence of type annotations.  Consider this code:
+    //   void m(String [] m) { }
+    //   void m(String ... m) { }
+    // After parsing "String", javac calls bracketsOpt which immediately
+    // returns if the next character is not '['.  Similarly, javac can see
+    // if the next token is ... and in that case parse an ellipsis.  But in
+    // the presence of type annotations:
+    //   void m(String @A [] m) { }
+    //   void m(String @A ... m) { }
+    // no finite lookahead is enough to determine whether to read array
+    // levels or an ellipsis.  Furthermore, if you call bracketsOpt, then
+    // bracketsOpt first reads all the leading annotations and only then
+    // discovers that it needs to fail.  bracketsOpt needs a way to push
+    // back the extra annotations that it read.  (But, bracketsOpt should
+    // not *always* be allowed to push back extra annotations that it finds
+    // -- in most contexts, any such extra annotation is an error.
+    // Another similar case occurs with arrays and receiver annotations:
+    //   String b() @Array [] @Receiver { }
+    //   String b() @Receiver { }
+    //
+    // The following two variables permit type annotations that have
+    // already been read to be stored for later use.  Alternate
+    // implementations are possible but would cause much larger changes to
+    // the parser.
+    /** Type annotations that have already been read but have not yet been used. **/
+    private List<JCTypeAnnotation> typeAnnotationsPushedBack = null;
+    /**
+     * If the parser notices extra annotations, then it either immediately
+     * issues an error (if this variable is false) or places the extra
+     * annotations in variable typeAnnotationsPushedBack (if this variable
+     * is true).
+     */
+    private boolean permitTypeAnnotationsPushBack = false;
+
     /** Construct a parser from a given scanner, tree factory and log.
      */
     protected JavacParser(ParserFactory fac,
@@ -95,13 +131,19 @@
         this.allowForeach = source.allowForeach();
         this.allowStaticImport = source.allowStaticImport();
         this.allowAnnotations = source.allowAnnotations();
+        this.allowTypeAnnotations = source.allowTypeAnnotations();
         this.keepDocComments = keepDocComments;
         if (keepDocComments)
             docComments = new HashMap<JCTree,String>();
         this.keepLineMap = keepLineMap;
         this.errorTree = F.Erroneous();
+        this.debugJSR308 = fac.options.get("TA:parser") != null;
     }
 
+    /** Switch: debug output for type-annotations operations
+     */
+    boolean debugJSR308;
+
     /** Switch: Should generics be recognized?
      */
     boolean allowGenerics;
@@ -130,6 +172,10 @@
      */
     boolean allowAnnotations;
 
+    /** Switch: should we recognize type annotations?
+     */
+    boolean allowTypeAnnotations;
+
     /** Switch: should we keep docComments?
      */
     boolean keepDocComments;
@@ -558,7 +604,33 @@
         return term(EXPR);
     }
 
+    /**
+     * parses (optional) type annotations followed by a type. If the
+     * annotations are present before the type and are not consumed during array
+     * parsing, this method returns a {@link JCAnnotatedType} consisting of
+     * these annotations and the underlying type. Otherwise, it returns the
+     * underlying type.
+     *
+     * <p>
+     *
+     * Note that this method sets {@code mode} to {@code TYPE} first, before
+     * parsing annotations.
+     */
     public JCExpression parseType() {
+        List<JCTypeAnnotation> annotations = typeAnnotationsOpt();
+        return parseType(annotations);
+    }
+
+    public JCExpression parseType(List<JCTypeAnnotation> annotations) {
+        JCExpression result = unannotatedType();
+
+        if (!annotations.isEmpty())
+            result = F.AnnotatedType(annotations, result);
+
+        return result;
+    }
+
+    public JCExpression unannotatedType() {
         return term(TYPE);
     }
 
@@ -792,8 +864,8 @@
      *                 | [TypeArguments] THIS [Arguments]
      *                 | [TypeArguments] SUPER SuperSuffix
      *                 | NEW [TypeArguments] Creator
-     *                 | Ident { "." Ident }
-     *                   [ "[" ( "]" BracketsOpt "." CLASS | Expression "]" )
+     *                 | [Annotations] Ident { "." Ident }
+     *                   [ [Annotations] "[" ( "]" BracketsOpt "." CLASS | Expression "]" )
      *                   | Arguments
      *                   | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator )
      *                   ]
@@ -942,23 +1014,62 @@
                 typeArgs = null;
             } else return illegal();
             break;
+        case MONKEYS_AT:
+
+            // only annotated targetting class literals or cast types are valid
+            List<JCTypeAnnotation> typeAnnos = typeAnnotationsOpt();
+            if (typeAnnos.isEmpty()) {
+                // else there would be no '@'
+                throw new AssertionError("type annos is empty");
+            }
+
+            JCExpression expr = term3();
+
+            // Type annotations: If term3 just parsed a non-type, expect a
+            // class literal (and issue a syntax error if there is no class
+            // literal). Otherwise, create a JCAnnotatedType.
+            if ((mode & TYPE) == 0) {
+                if (expr.getTag() != JCTree.SELECT)
+                    return illegal(typeAnnos.head.pos);
+                JCFieldAccess sel = (JCFieldAccess)expr;
+                if (sel.name != names._class)
+                    return illegal();
+                else {
+                    sel.selected = F.AnnotatedType(typeAnnos, sel.selected);
+                    t = expr;
+                }
+            } else {
+                // type annotation targeting a cast
+                t = toP(F.at(S.pos()).AnnotatedType(typeAnnos, expr));
+            }
+            break;
         case IDENTIFIER: case ASSERT: case ENUM:
             if (typeArgs != null) return illegal();
             t = toP(F.at(S.pos()).Ident(ident()));
             loop: while (true) {
                 pos = S.pos();
+                final List<JCTypeAnnotation> annos = typeAnnotationsOpt();
+
+                // need to report an error later if LBRACKET is for array
+                // index access rather than array creation level
+                if (!annos.isEmpty() && S.token() != LBRACKET && S.token() != ELLIPSIS)
+                    return illegal(annos.head.pos);
                 switch (S.token()) {
                 case LBRACKET:
                     S.nextToken();
+
                     if (S.token() == RBRACKET) {
+
                         S.nextToken();
-                        t = bracketsOpt(t);
+
+                        t = bracketsOpt(t, annos);
                         t = toP(F.at(pos).TypeArray(t));
                         t = bracketsSuffix(t);
                     } else {
                         if ((mode & EXPR) != 0) {
                             mode = EXPR;
                             JCExpression t1 = term();
+                            if (!annos.isEmpty()) t = illegal(annos.head.pos);
                             t = to(F.at(pos).Indexed(t, t1));
                         }
                         accept(RBRACKET);
@@ -1011,6 +1122,10 @@
                     // typeArgs saved for next loop iteration.
                     t = toP(F.at(pos).Select(t, ident()));
                     break;
+                case ELLIPSIS:
+                    assert this.permitTypeAnnotationsPushBack;
+                    typeAnnotationsPushedBack = annos;
+                    break loop;
                 default:
                     break loop;
                 }
@@ -1049,14 +1164,18 @@
         if (typeArgs != null) illegal();
         while (true) {
             int pos1 = S.pos();
+
+            final List<JCTypeAnnotation> annos = typeAnnotationsOpt();
+
             if (S.token() == LBRACKET) {
                 S.nextToken();
+
                 if ((mode & TYPE) != 0) {
                     int oldmode = mode;
                     mode = TYPE;
                     if (S.token() == RBRACKET) {
                         S.nextToken();
-                        t = bracketsOpt(t);
+                        t = bracketsOpt(t, annos);
                         t = toP(F.at(pos1).TypeArray(t));
                         return t;
                     }
@@ -1091,6 +1210,12 @@
                     typeArgs = null;
                 }
             } else {
+                if (!annos.isEmpty()) {
+                    if (permitTypeAnnotationsPushBack)
+                        typeAnnotationsPushedBack = annos;
+                    else
+                        return illegal(annos.head.pos);
+                }
                 break;
             }
         }
@@ -1100,6 +1225,7 @@
                   S.token() == PLUSPLUS ? JCTree.POSTINC : JCTree.POSTDEC, t));
             S.nextToken();
         }
+
         return toP(t);
     }
 
@@ -1232,22 +1358,24 @@
     }
 
     /** TypeArgument = Type
-     *               | "?"
-     *               | "?" EXTENDS Type {"&" Type}
-     *               | "?" SUPER Type
+     *               | [Annotations] "?"
+     *               | [Annotations] "?" EXTENDS Type {"&" Type}
+     *               | [Annotations] "?" SUPER Type
      */
     JCExpression typeArgument() {
-        if (S.token() != QUES) return parseType();
+        List<JCTypeAnnotation> annotations = typeAnnotationsOpt();
+        if (S.token() != QUES) return parseType(annotations);
         int pos = S.pos();
         S.nextToken();
+        JCExpression result;
         if (S.token() == EXTENDS) {
             TypeBoundKind t = to(F.at(S.pos()).TypeBoundKind(BoundKind.EXTENDS));
             S.nextToken();
-            return F.at(pos).Wildcard(t, parseType());
+            result = F.at(pos).Wildcard(t, parseType());
         } else if (S.token() == SUPER) {
             TypeBoundKind t = to(F.at(S.pos()).TypeBoundKind(BoundKind.SUPER));
             S.nextToken();
-            return F.at(pos).Wildcard(t, parseType());
+            result = F.at(pos).Wildcard(t, parseType());
         } else if (S.token() == IDENTIFIER) {
             //error recovery
             reportSyntaxError(S.prevEndPos(), "expected3",
@@ -1255,11 +1383,14 @@
             TypeBoundKind t = F.at(Position.NOPOS).TypeBoundKind(BoundKind.UNBOUND);
             JCExpression wc = toP(F.at(pos).Wildcard(t, null));
             JCIdent id = toP(F.at(S.pos()).Ident(ident()));
-            return F.at(pos).Erroneous(List.<JCTree>of(wc, id));
+            result = F.at(pos).Erroneous(List.<JCTree>of(wc, id));
         } else {
             TypeBoundKind t = F.at(Position.NOPOS).TypeBoundKind(BoundKind.UNBOUND);
-            return toP(F.at(pos).Wildcard(t, null));
+            result = toP(F.at(pos).Wildcard(t, null));
         }
+        if (!annotations.isEmpty())
+            result = toP(F.at(annotations.head.pos).AnnotatedType(annotations,result));
+        return result;
     }
 
     JCTypeApply typeArguments(JCExpression t) {
@@ -1268,21 +1399,47 @@
         return toP(F.at(pos).TypeApply(t, args));
     }
 
-    /** BracketsOpt = {"[" "]"}
+    /**
+     * BracketsOpt = { [Annotations] "[" "]" }
+     *
+     * <p>
+     *
+     * <code>annotations</code> is the list of annotations targeting
+     * the expression <code>t</code>.
      */
-    private JCExpression bracketsOpt(JCExpression t) {
+    private JCExpression bracketsOpt(JCExpression t,
+            List<JCTypeAnnotation> annotations) {
+        List<JCTypeAnnotation> nextLevelAnnotations = typeAnnotationsOpt();
+
         if (S.token() == LBRACKET) {
             int pos = S.pos();
             S.nextToken();
-            t = bracketsOptCont(t, pos);
-            F.at(pos);
+
+            JCExpression orig = t;
+            t = bracketsOptCont(t, pos, nextLevelAnnotations);
+        } else if (!nextLevelAnnotations.isEmpty()) {
+            if (permitTypeAnnotationsPushBack) {
+                this.typeAnnotationsPushedBack = nextLevelAnnotations;
+            } else
+                return illegal(nextLevelAnnotations.head.pos);
         }
+
+        int apos = S.pos();
+        if (!annotations.isEmpty())
+            t = F.at(apos).AnnotatedType(annotations, t);
         return t;
     }
 
-    private JCArrayTypeTree bracketsOptCont(JCExpression t, int pos) {
+    /** BracketsOpt = {"[" TypeAnnotations "]"}
+     */
+    private JCExpression bracketsOpt(JCExpression t) {
+        return bracketsOpt(t, List.<JCTypeAnnotation>nil());
+    }
+
+    private JCArrayTypeTree bracketsOptCont(JCExpression t, int pos,
+            List<JCTypeAnnotation> annotations) {
         accept(RBRACKET);
-        t = bracketsOpt(t);
+        t = bracketsOpt(t, annotations);
         return toP(F.at(pos).TypeArray(t));
     }
 
@@ -1316,18 +1473,29 @@
         return t;
     }
 
-    /** Creator = Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
+    /** Creator = [Annotations] Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
      */
     JCExpression creator(int newpos, List<JCExpression> typeArgs) {
+
+        List<JCTypeAnnotation> newAnnotations = typeAnnotationsOpt();
+
         switch (S.token()) {
         case BYTE: case SHORT: case CHAR: case INT: case LONG: case FLOAT:
         case DOUBLE: case BOOLEAN:
-            if (typeArgs == null)
-                return arrayCreatorRest(newpos, basicType());
+            if (typeArgs == null) {
+                if (newAnnotations.isEmpty())
+                    return arrayCreatorRest(newpos, basicType());
+                else
+                    return arrayCreatorRest(newpos, F.AnnotatedType(newAnnotations, basicType()));
+            }
             break;
         default:
         }
         JCExpression t = qualident();
+        // handle type annotations for non primitive arrays
+        if (!newAnnotations.isEmpty())
+            t = F.AnnotatedType(newAnnotations, t);
+
         int oldmode = mode;
         mode = TYPE;
         if (S.token() == LT) {
@@ -1344,7 +1512,7 @@
             }
         }
         mode = oldmode;
-        if (S.token() == LBRACKET) {
+        if (S.token() == LBRACKET || S.token() == MONKEYS_AT) {
             JCExpression e = arrayCreatorRest(newpos, t);
             if (typeArgs != null) {
                 int pos = newpos;
@@ -1360,7 +1528,12 @@
             }
             return e;
         } else if (S.token() == LPAREN) {
-            return classCreatorRest(newpos, null, typeArgs, t);
+            JCNewClass newClass = classCreatorRest(newpos, null, typeArgs, t);
+            if (newClass.def != null) {
+                assert newClass.def.mods.annotations.isEmpty();
+                newClass.def.mods.annotations = List.convert(JCAnnotation.class, newAnnotations);
+            }
+            return newClass;
         } else {
             reportSyntaxError(S.pos(), "expected2",
                                LPAREN, LBRACKET);
@@ -1380,40 +1553,73 @@
         return classCreatorRest(newpos, encl, typeArgs, t);
     }
 
-    /** ArrayCreatorRest = "[" ( "]" BracketsOpt ArrayInitializer
-     *                         | Expression "]" {"[" Expression "]"} BracketsOpt )
+    /** ArrayCreatorRest = [Annotations] "[" ( "]" BracketsOpt ArrayInitializer
+     *                         | Expression "]" {[Annotations]  "[" Expression "]"} BracketsOpt )
      */
     JCExpression arrayCreatorRest(int newpos, JCExpression elemtype) {
+
+        List<JCTypeAnnotation> topAnnos = List.nil();
+        if (elemtype.getTag() == JCTree.ANNOTATED_TYPE) {
+            JCAnnotatedType atype = (JCAnnotatedType) elemtype;
+            topAnnos = atype.annotations;
+            elemtype = atype.underlyingType;
+        }
+
+        List<JCTypeAnnotation> annos = typeAnnotationsOpt();
+
         accept(LBRACKET);
+
         if (S.token() == RBRACKET) {
             accept(RBRACKET);
-            elemtype = bracketsOpt(elemtype);
+
+            elemtype = bracketsOpt(elemtype, annos);
+
             if (S.token() == LBRACE) {
-                return arrayInitializer(newpos, elemtype);
+                JCNewArray na = (JCNewArray)arrayInitializer(newpos, elemtype);
+
+                na.annotations = topAnnos;
+
+                return na;
             } else {
                 return syntaxError(S.pos(), "array.dimension.missing");
             }
         } else {
             ListBuffer<JCExpression> dims = new ListBuffer<JCExpression>();
+
+            // maintain array dimension type annotations
+            ListBuffer<List<JCTypeAnnotation>> dimAnnotations = ListBuffer.lb();
+            dimAnnotations.append(annos);
+
             dims.append(parseExpression());
             accept(RBRACKET);
-            while (S.token() == LBRACKET) {
+            while (S.token() == LBRACKET
+                    || (S.token() == MONKEYS_AT)) {
+                List<JCTypeAnnotation> maybeDimAnnos = typeAnnotationsOpt();
                 int pos = S.pos();
                 S.nextToken();
                 if (S.token() == RBRACKET) {
-                    elemtype = bracketsOptCont(elemtype, pos);
+                    elemtype = bracketsOptCont(elemtype, pos, maybeDimAnnos);
                 } else {
-                    dims.append(parseExpression());
-                    accept(RBRACKET);
+                    if (S.token() == RBRACKET) { // no dimension
+                        elemtype = bracketsOptCont(elemtype, pos, maybeDimAnnos);
+                    } else {
+                        dimAnnotations.append(maybeDimAnnos);
+                        dims.append(parseExpression());
+                        accept(RBRACKET);
+                    }
                 }
             }
-            return toP(F.at(newpos).NewArray(elemtype, dims.toList(), null));
+
+            JCNewArray na = toP(F.at(newpos).NewArray(elemtype, dims.toList(), null));
+            na.annotations = topAnnos;
+            na.dimAnnotations = dimAnnotations.toList();
+            return na;
         }
     }
 
     /** ClassCreatorRest = Arguments [ClassBody]
      */
-    JCExpression classCreatorRest(int newpos,
+    JCNewClass classCreatorRest(int newpos,
                                   JCExpression encl,
                                   List<JCExpression> typeArgs,
                                   JCExpression t)
@@ -1860,17 +2066,32 @@
                                         new ListBuffer<JCExpressionStatement>()).toList();
     }
 
+    enum AnnotationKind { DEFAULT_ANNO, TYPE_ANNO };
+
     /** AnnotationsOpt = { '@' Annotation }
      */
-    List<JCAnnotation> annotationsOpt() {
+    List<JCAnnotation> annotationsOpt(AnnotationKind kind) {
         if (S.token() != MONKEYS_AT) return List.nil(); // optimization
         ListBuffer<JCAnnotation> buf = new ListBuffer<JCAnnotation>();
+        int prevmode = mode;
         while (S.token() == MONKEYS_AT) {
             int pos = S.pos();
             S.nextToken();
-            buf.append(annotation(pos));
+            buf.append(annotation(pos, kind));
         }
-        return buf.toList();
+        lastmode = mode;
+        mode = prevmode;
+        List<JCAnnotation> annotations = buf.toList();
+
+        if (debugJSR308 && kind == AnnotationKind.TYPE_ANNO)
+            System.out.println("TA: parsing " + annotations
+                    + " in " + log.currentSourceFile());
+        return annotations;
+    }
+
+    List<JCTypeAnnotation> typeAnnotationsOpt() {
+        List<JCAnnotation> annotations = annotationsOpt(AnnotationKind.TYPE_ANNO);
+        return List.convert(JCTypeAnnotation.class, annotations);
     }
 
     /** ModifiersOpt = { Modifier }
@@ -1915,7 +2136,7 @@
             if (flag == Flags.ANNOTATION) {
                 checkAnnotations();
                 if (S.token() != INTERFACE) {
-                JCAnnotation ann = annotation(lastPos);
+                JCAnnotation ann = annotation(lastPos, AnnotationKind.DEFAULT_ANNO);
                 // if first modifier is an annotation, set pos to annotation's.
                 if (flags == 0 && annotations.isEmpty())
                     pos = ann.pos;
@@ -1946,12 +2167,18 @@
     /** Annotation              = "@" Qualident [ "(" AnnotationFieldValues ")" ]
      * @param pos position of "@" token
      */
-    JCAnnotation annotation(int pos) {
+    JCAnnotation annotation(int pos, AnnotationKind kind) {
         // accept(AT); // AT consumed by caller
         checkAnnotations();
+        if (kind == AnnotationKind.TYPE_ANNO)
+            checkTypeAnnotations();
         JCTree ident = qualident();
         List<JCExpression> fieldValues = annotationFieldValuesOpt();
-        JCAnnotation ann = F.at(pos).Annotation(ident, fieldValues);
+        JCAnnotation ann;
+        if (kind == AnnotationKind.DEFAULT_ANNO)
+            ann = F.at(pos).Annotation(ident, fieldValues);
+        else
+            ann = F.at(pos).TypeAnnotation(ident, fieldValues);
         storeEnd(ann, S.prevEndPos());
         return ann;
     }
@@ -2003,7 +2230,7 @@
         case MONKEYS_AT:
             pos = S.pos();
             S.nextToken();
-            return annotation(pos);
+            return annotation(pos, AnnotationKind.DEFAULT_ANNO);
         case LBRACE:
             pos = S.pos();
             accept(LBRACE);
@@ -2357,7 +2584,7 @@
             S.resetDeprecatedFlag();
         }
         int pos = S.pos();
-        List<JCAnnotation> annotations = annotationsOpt();
+        List<JCAnnotation> annotations = annotationsOpt(AnnotationKind.DEFAULT_ANNO);
         JCModifiers mods = F.at(annotations.isEmpty() ? Position.NOPOS : pos).Modifiers(flags, annotations);
         List<JCExpression> typeArgs = typeArgumentsOpt();
         int identPos = S.pos();
@@ -2460,16 +2687,23 @@
                 if (typarams.length() > 0 && mods.pos == Position.NOPOS) {
                     mods.pos = pos;
                 }
+
+                List<JCAnnotation> annosAfterParams = annotationsOpt(AnnotationKind.DEFAULT_ANNO);
+
                 Token token = S.token();
                 Name name = S.name();
                 pos = S.pos();
                 JCExpression type;
                 boolean isVoid = S.token() == VOID;
                 if (isVoid) {
+                    if (annosAfterParams.nonEmpty())
+                        illegal(annosAfterParams.head.pos);
                     type = to(F.at(pos).TypeIdent(TypeTags.VOID));
                     S.nextToken();
                 } else {
-                    type = parseType();
+                    mods.annotations = mods.annotations.appendList(annosAfterParams);
+                    // method returns types are un-annotated types
+                    type = unannotatedType();
                 }
                 if (S.token() == LPAREN && !isInterface && type.getTag() == JCTree.IDENT) {
                     if (isInterface || name != className)
@@ -2505,15 +2739,15 @@
     }
 
     /** MethodDeclaratorRest =
-     *      FormalParameters BracketsOpt [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";")
+     *      FormalParameters BracketsOpt [Annotations] [Throws TypeList] ( MethodBody | [DEFAULT AnnotationValue] ";")
      *  VoidMethodDeclaratorRest =
-     *      FormalParameters [Throws TypeList] ( MethodBody | ";")
+     *      FormalParameters [Annotations] [Throws TypeList] ( MethodBody | ";")
      *  InterfaceMethodDeclaratorRest =
-     *      FormalParameters BracketsOpt [THROWS TypeList] ";"
+     *      FormalParameters BracketsOpt [Annotations] [THROWS TypeList] ";"
      *  VoidInterfaceMethodDeclaratorRest =
-     *      FormalParameters [THROWS TypeList] ";"
+     *      FormalParameters [Annotations] [THROWS TypeList] ";"
      *  ConstructorDeclaratorRest =
-     *      "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody
+     *      "(" FormalParameterListOpt ")" [Annotations] [THROWS TypeList] MethodBody
      */
     JCTree methodDeclaratorRest(int pos,
                               JCModifiers mods,
@@ -2523,7 +2757,22 @@
                               boolean isInterface, boolean isVoid,
                               String dc) {
         List<JCVariableDecl> params = formalParameters();
-        if (!isVoid) type = bracketsOpt(type);
+
+        List<JCTypeAnnotation> receiverAnnotations;
+        if (!isVoid) {
+            // need to distinguish between receiver anno and array anno
+            // look at typeAnnotationsPushedBack comment
+            this.permitTypeAnnotationsPushBack = true;
+            type = methodReturnArrayRest(type);
+            this.permitTypeAnnotationsPushBack = false;
+            if (typeAnnotationsPushedBack == null)
+                receiverAnnotations = List.nil();
+            else
+                receiverAnnotations = typeAnnotationsPushedBack;
+            typeAnnotationsPushedBack = null;
+        } else
+            receiverAnnotations = typeAnnotationsOpt();
+
         List<JCExpression> thrown = List.nil();
         if (S.token() == THROWS) {
             S.nextToken();
@@ -2552,20 +2801,51 @@
         }
         JCMethodDecl result =
             toP(F.at(pos).MethodDef(mods, name, type, typarams,
-                                    params, thrown,
+                                    params, receiverAnnotations, thrown,
                                     body, defaultValue));
         attach(result, dc);
         return result;
     }
 
-    /** QualidentList = Qualident {"," Qualident}
+    /** Parses the array levels after the format parameters list, and append
+     * them to the return type, while preseving the order of type annotations
+     */
+    private JCExpression methodReturnArrayRest(JCExpression type) {
+        if (type.getTag() != JCTree.TYPEARRAY)
+            return bracketsOpt(type);
+
+        JCArrayTypeTree baseArray = (JCArrayTypeTree)type;
+        while (TreeInfo.typeIn(baseArray.elemtype) instanceof JCArrayTypeTree)
+            baseArray = (JCArrayTypeTree)TreeInfo.typeIn(baseArray.elemtype);
+
+        if (baseArray.elemtype.getTag() == JCTree.ANNOTATED_TYPE) {
+            JCAnnotatedType at = (JCAnnotatedType)baseArray.elemtype;
+            at.underlyingType = bracketsOpt(at.underlyingType);
+        } else {
+            baseArray.elemtype = bracketsOpt(baseArray.elemtype);
+        }
+
+        return type;
+    }
+
+    /** QualidentList = [Annotations] Qualident {"," [Annotations] Qualident}
      */
     List<JCExpression> qualidentList() {
         ListBuffer<JCExpression> ts = new ListBuffer<JCExpression>();
-        ts.append(qualident());
+
+        List<JCTypeAnnotation> typeAnnos = typeAnnotationsOpt();
+        if (!typeAnnos.isEmpty())
+            ts.append(F.AnnotatedType(typeAnnos, qualident()));
+        else
+            ts.append(qualident());
         while (S.token() == COMMA) {
             S.nextToken();
-            ts.append(qualident());
+
+            typeAnnos = typeAnnotationsOpt();
+            if (!typeAnnos.isEmpty())
+                ts.append(F.AnnotatedType(typeAnnos, qualident()));
+            else
+                ts.append(qualident());
         }
         return ts.toList();
     }
@@ -2589,12 +2869,13 @@
         }
     }
 
-    /** TypeParameter = TypeVariable [TypeParameterBound]
+    /** TypeParameter = [Annotations] TypeVariable [TypeParameterBound]
      *  TypeParameterBound = EXTENDS Type {"&" Type}
      *  TypeVariable = Ident
      */
     JCTypeParameter typeParameter() {
         int pos = S.pos();
+        List<JCTypeAnnotation> annos = typeAnnotationsOpt();
         Name name = ident();
         ListBuffer<JCExpression> bounds = new ListBuffer<JCExpression>();
         if (S.token() == EXTENDS) {
@@ -2605,7 +2886,7 @@
                 bounds.append(parseType());
             }
         }
-        return toP(F.at(pos).TypeParameter(name, bounds.toList()));
+        return toP(F.at(pos).TypeParameter(name, bounds.toList(), annos));
     }
 
     /** FormalParameters = "(" [ FormalParameterList ] ")"
@@ -2639,12 +2920,31 @@
      */
     JCVariableDecl formalParameter() {
         JCModifiers mods = optFinal(Flags.PARAMETER);
+        // need to distinguish between vararg annos and array annos
+        // look at typeAnnotaitonsPushedBack comment
+        this.permitTypeAnnotationsPushBack = true;
         JCExpression type = parseType();
+        this.permitTypeAnnotationsPushBack = false;
+
         if (S.token() == ELLIPSIS) {
+            List<JCTypeAnnotation> varargsAnnos = typeAnnotationsPushedBack;
+            typeAnnotationsPushedBack = null;
             checkVarargs();
             mods.flags |= Flags.VARARGS;
+            // insert var arg type annotations
+            if (varargsAnnos != null && varargsAnnos.nonEmpty())
+                type = F.at(S.pos()).AnnotatedType(varargsAnnos, type);
             type = to(F.at(S.pos()).TypeArray(type));
+
             S.nextToken();
+        } else {
+            // if not a var arg, then typeAnnotationsPushedBack should be null
+            if (typeAnnotationsPushedBack != null
+                    && !typeAnnotationsPushedBack.isEmpty()) {
+                reportSyntaxError(typeAnnotationsPushedBack.head.pos,
+                        "illegal.start.of.type");
+            }
+            typeAnnotationsPushedBack = null;
         }
         return variableDeclaratorId(mods, type);
     }
@@ -2829,4 +3129,10 @@
             allowAnnotations = true;
         }
     }
+    void checkTypeAnnotations() {
+        if (!allowTypeAnnotations) {
+            log.error(S.pos(), "type.annotations.not.supported.in.source", source.name);
+            allowTypeAnnotations = true;
+        }
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Tue Jul 21 13:02:23 2009 -0700
@@ -50,6 +50,7 @@
 import javax.tools.JavaFileObject;
 import javax.tools.DiagnosticListener;
 
+import com.sun.source.util.AbstractTypeProcessor;
 import com.sun.source.util.TaskEvent;
 import com.sun.source.util.TaskListener;
 import com.sun.tools.javac.api.JavacTaskImpl;
@@ -58,6 +59,7 @@
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.main.JavaCompiler.CompileState;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.model.JavacTypes;
 import com.sun.tools.javac.parser.*;
@@ -93,6 +95,7 @@
     private final boolean lint;
     private final boolean procOnly;
     private final boolean fatalErrors;
+    private boolean foundTypeProcessors;
 
     private final JavacFiler filer;
     private final JavacMessager messager;
@@ -153,6 +156,7 @@
             options.get("-Xprint") != null;
         fatalErrors = options.get("fatalEnterError") != null;
         platformAnnotations = initPlatformAnnotations();
+        foundTypeProcessors = false;
 
         // Initialize services before any processors are initialzied
         // in case processors use them.
@@ -670,6 +674,7 @@
             }
 
             if (matchedNames.size() > 0 || ps.contributed) {
+                foundTypeProcessors = foundTypeProcessors || (ps.processor instanceof AbstractTypeProcessor);
                 boolean processingResult = callProcessor(ps.processor, typeElements, renv);
                 ps.contributed = true;
                 ps.removeSupportedOptions(unmatchedProcessorOptions);
@@ -916,12 +921,16 @@
             compiler.log.nerrors += messager.errorCount();
             if (compiler.errorCount() == 0)
                 compiler.log.nerrors++;
-        } else if (procOnly) {
+        } else if (procOnly && !foundTypeProcessors) {
             compiler.todo.clear();
         } else { // Final compilation
             compiler.close(false);
             currentContext = contextForNextRound(currentContext, true);
+            this.context = currentContext;
+            updateProcessingState(currentContext, true);
             compiler = JavaCompiler.instance(currentContext);
+            if (procOnly && foundTypeProcessors)
+                compiler.shouldStopPolicy = CompileState.FLOW;
 
             if (true) {
                 compiler.enterTrees(cleanTrees(roots));
@@ -1213,6 +1222,10 @@
                 node.sym = null;
                 super.visitIdent(node);
             }
+            public void visitApply(JCMethodInvocation node) {
+                scan(node.typeargs);
+                super.visitApply(node);
+            }
         };
 
 
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacRoundEnvironment.java	Tue Jul 21 13:02:23 2009 -0700
@@ -37,6 +37,9 @@
 /**
  * Object providing state about a prior round of annotation processing.
  *
+ * <p>The methods in this class do not take type annotations into account,
+ * as target types, not java elements.
+ *
  * <p><b>This is NOT part of any API supported by Sun Microsystems.
  * If you write code that depends on this, you do so at your own risk.
  * This code and its internal interfaces are subject to change or
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Jul 21 13:02:23 2009 -0700
@@ -84,7 +84,7 @@
     {0} {1} in {4} {5} cannot be applied to given types\n\
     required: {2}\n\
     found: {3}
- compiler.err.cant.apply.symbol.1=\
+compiler.err.cant.apply.symbol.1=\
     {0} {1} in {4} {5} cannot be applied to given types;\n\
     required: {2}\n\
     found: {3}\n\
@@ -469,6 +469,8 @@
     type parameters of {0} cannot be determined
 compiler.err.undetermined.type.1=\
     type parameters of {0} cannot be determined; {1}
+compiler.err.invalid.inferred.types=\
+    invalid inferred types for {0}; {1}
 compiler.err.unreachable.stmt=\
     unreachable statement
 compiler.err.initializer.must.be.able.to.complete.normally=\
@@ -880,6 +882,8 @@
     bad constant pool tag: {0} at {1}
 compiler.misc.bad.signature=\
     bad signature: {0}
+compiler.misc.bad.type.annotation.value=\
+    bad type annotation target type value: {0}
 compiler.misc.class.file.wrong.class=\
     class file contains wrong class: {0}
 compiler.misc.class.file.not.found=\
@@ -995,7 +999,13 @@
 compiler.misc.arg.length.mismatch=\
     cannot instantiate from arguments because actual and formal argument lists differ in length
 compiler.misc.inferred.do.not.conform.to.bounds=\
-    inferred type argument(s) {0} do not conform to bounds of type variable(s) {1}
+    inferred type does not conform to declared bound(s)\n\
+    inferred: {0}\n\
+    bound(s): {1}
+compiler.misc.inferred.do.not.conform.to.params=\
+    actual arguments do not conforms to inferred formal arguments\n\
+    required: {0}\n\
+    found: {1}
 
 #####
 
@@ -1154,6 +1164,10 @@
     annotations are not supported in -source {0}\n\
 (use -source 5 or higher to enable annotations)
 
+compiler.err.type.annotations.not.supported.in.source=\
+    type annotations are not supported in -source {0}\n\
+(use -source 7 or higher to enable type annotations)
+
 compiler.err.foreach.not.supported.in.source=\
     for-each loops are not supported in -source {0}\n\
 (use -source 5 or higher to enable for-each loops)
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/legacy.properties	Tue Jul 21 13:02:23 2009 -0700
@@ -112,6 +112,7 @@
 com.sun.java.swing.plaf.motif = tiger legacy
 com.sun.java.swing.plaf.motif.icons = tiger legacy
 com.sun.java.swing.plaf.motif.resources = tiger legacy
+com.sun.java.swing.plaf.nimbus = tiger legacy
 com.sun.java.swing.plaf.windows = tiger legacy
 com.sun.java.swing.plaf.windows.icons = tiger legacy
 com.sun.java.swing.plaf.windows.resources = tiger legacy
@@ -378,6 +379,7 @@
 javax.swing.plaf.metal.icons.ocean = tiger legacy
 javax.swing.plaf.metal.sounds = tiger legacy
 javax.swing.plaf.multi = tiger legacy
+javax.swing.plaf.nimbus = tiger legacy
 javax.swing.plaf.synth = tiger legacy
 javax.swing.table = tiger legacy
 javax.swing.text = tiger legacy
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Tue Jul 21 13:02:23 2009 -0700
@@ -256,9 +256,11 @@
      */
     public static final int MODIFIERS = ANNOTATION + 1;
 
+    public static final int ANNOTATED_TYPE = MODIFIERS + 1;
+
     /** Error trees, of type Erroneous.
      */
-    public static final int ERRONEOUS = MODIFIERS + 1;
+    public static final int ERRONEOUS = ANNOTATED_TYPE + 1;
 
     /** Unary operators, of type Unary.
      */
@@ -622,6 +624,7 @@
         public JCExpression restype;
         public List<JCTypeParameter> typarams;
         public List<JCVariableDecl> params;
+        public List<JCTypeAnnotation> receiverAnnotations;
         public List<JCExpression> thrown;
         public JCBlock body;
         public JCExpression defaultValue; // for annotation types
@@ -631,6 +634,7 @@
                             JCExpression restype,
                             List<JCTypeParameter> typarams,
                             List<JCVariableDecl> params,
+                            List<JCTypeAnnotation> receiver,
                             List<JCExpression> thrown,
                             JCBlock body,
                             JCExpression defaultValue,
@@ -641,6 +645,7 @@
             this.restype = restype;
             this.typarams = typarams;
             this.params = params;
+            this.receiverAnnotations = (receiver != null ? receiver : List.<JCTypeAnnotation>nil());
             this.thrown = thrown;
             this.body = body;
             this.defaultValue = defaultValue;
@@ -659,6 +664,7 @@
         public List<JCVariableDecl> getParameters() {
             return params;
         }
+        public List<JCTypeAnnotation> getReceiverAnnotations() { return receiverAnnotations; }
         public List<JCExpression> getThrows() {
             return thrown;
         }
@@ -1371,6 +1377,8 @@
     public static class JCNewArray extends JCExpression implements NewArrayTree {
         public JCExpression elemtype;
         public List<JCExpression> dims;
+        public List<JCTypeAnnotation> annotations;
+        public List<List<JCTypeAnnotation>> dimAnnotations;
         public List<JCExpression> elems;
         protected JCNewArray(JCExpression elemtype,
                            List<JCExpression> dims,
@@ -1378,6 +1386,8 @@
         {
             this.elemtype = elemtype;
             this.dims = dims;
+            this.annotations = List.nil();
+            this.dimAnnotations = List.nil();
             this.elems = elems;
         }
         @Override
@@ -1860,9 +1870,11 @@
     public static class JCTypeParameter extends JCTree implements TypeParameterTree {
         public Name name;
         public List<JCExpression> bounds;
-        protected JCTypeParameter(Name name, List<JCExpression> bounds) {
+        public List<JCTypeAnnotation> annotations;
+        protected JCTypeParameter(Name name, List<JCExpression> bounds, List<JCTypeAnnotation> annotations) {
             this.name = name;
             this.bounds = bounds;
+            this.annotations = annotations;
         }
         @Override
         public void accept(Visitor v) { v.visitTypeParameter(this); }
@@ -1872,6 +1884,9 @@
         public List<JCExpression> getBounds() {
             return bounds;
         }
+        public List<JCTypeAnnotation> getAnnotations() {
+            return annotations;
+        }
         @Override
         public <R,D> R accept(TreeVisitor<R,D> v, D d) {
             return v.visitTypeParameter(this, d);
@@ -1962,6 +1977,16 @@
         }
     }
 
+    public static class JCTypeAnnotation extends JCAnnotation {
+        public TypeAnnotationPosition annotation_position;
+        public Attribute.TypeCompound attribute_field;
+
+        protected JCTypeAnnotation(JCTree annotationType, List<JCExpression> args) {
+            super(annotationType, args);
+            this.annotation_position = new TypeAnnotationPosition();
+        }
+    }
+
     public static class JCModifiers extends JCTree implements com.sun.source.tree.ModifiersTree {
         public long flags;
         public List<JCAnnotation> annotations;
@@ -1989,6 +2014,33 @@
         }
     }
 
+    public static class JCAnnotatedType extends JCExpression implements com.sun.source.tree.AnnotatedTypeTree {
+        public List<JCTypeAnnotation> annotations;
+        public JCExpression underlyingType;
+        protected JCAnnotatedType(List<JCTypeAnnotation> annotations, JCExpression underlyingType) {
+            this.annotations = annotations;
+            this.underlyingType = underlyingType;
+        }
+        @Override
+        public void accept(Visitor v) { v.visitAnnotatedType(this); }
+
+        public Kind getKind() { return Kind.ANNOTATED_TYPE; }
+        public List<JCTypeAnnotation> getAnnotations() {
+            return annotations;
+        }
+        public JCExpression getUnderlyingType() {
+            return underlyingType;
+        }
+        @Override
+        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
+            return v.visitAnnotatedType(this, d);
+        }
+        @Override
+        public int getTag() {
+            return ANNOTATED_TYPE;
+        }
+    }
+
     public static class JCErroneous extends JCExpression
             implements com.sun.source.tree.ErroneousTree {
         public List<? extends JCTree> errs;
@@ -2056,6 +2108,7 @@
                             JCExpression restype,
                             List<JCTypeParameter> typarams,
                             List<JCVariableDecl> params,
+                            List<JCTypeAnnotation> receiver,
                             List<JCExpression> thrown,
                             JCBlock body,
                             JCExpression defaultValue);
@@ -2172,6 +2225,7 @@
         public void visitTypeBoundKind(TypeBoundKind that)   { visitTree(that); }
         public void visitAnnotation(JCAnnotation that)       { visitTree(that); }
         public void visitModifiers(JCModifiers that)         { visitTree(that); }
+        public void visitAnnotatedType(JCAnnotatedType that) { visitTree(that); }
         public void visitErroneous(JCErroneous that)         { visitTree(that); }
         public void visitLetExpr(LetExpr that)               { visitTree(that); }
 
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Tue Jul 21 13:02:23 2009 -0700
@@ -224,6 +224,15 @@
         }
     }
 
+    public void printTypeAnnotations(List<JCTypeAnnotation> trees) throws IOException {
+        if (trees.nonEmpty())
+            print(" ");
+        for (List<JCTypeAnnotation> l = trees; l.nonEmpty(); l = l.tail) {
+            printExpr(l.head);
+            print(" ");
+        }
+    }
+
     /** Print documentation comment, if it exists
      *  @param tree    The tree for which a documentation comment should be printed.
      */
@@ -850,21 +859,33 @@
         try {
             if (tree.elemtype != null) {
                 print("new ");
+                printTypeAnnotations(tree.annotations);
                 JCTree elem = tree.elemtype;
-                if (elem instanceof JCArrayTypeTree)
-                    printBaseElementType((JCArrayTypeTree) elem);
-                else
-                    printExpr(elem);
+                printBaseElementType(elem);
+                boolean isElemAnnoType = elem instanceof JCAnnotatedType;
+                int i = 0;
+                List<List<JCTypeAnnotation>> da = tree.dimAnnotations;
                 for (List<JCExpression> l = tree.dims; l.nonEmpty(); l = l.tail) {
+                    if (da.size() > i) {
+                        printTypeAnnotations(da.get(i));
+                    }
                     print("[");
+                    i++;
                     printExpr(l.head);
                     print("]");
                 }
+                if (tree.elems != null) {
+                    if (isElemAnnoType) {
+                        printTypeAnnotations(((JCAnnotatedType)tree.elemtype).annotations);
+                    }
+                    print("[]");
+                }
+                if (isElemAnnoType)
+                    elem = ((JCAnnotatedType)elem).underlyingType;
                 if (elem instanceof JCArrayTypeTree)
                     printBrackets((JCArrayTypeTree) elem);
             }
             if (tree.elems != null) {
-                if (tree.elemtype != null) print("[]");
                 print("{");
                 printExprs(tree.elems);
                 print("}");
@@ -1112,14 +1133,21 @@
     }
 
     // Prints the inner element type of a nested array
-    private void printBaseElementType(JCArrayTypeTree tree) throws IOException {
-        JCTree elem = tree.elemtype;
-        while (elem instanceof JCWildcard)
-            elem = ((JCWildcard) elem).inner;
-        if (elem instanceof JCArrayTypeTree)
-            printBaseElementType((JCArrayTypeTree) elem);
-        else
-            printExpr(elem);
+    private void printBaseElementType(JCTree tree) throws IOException {
+        switch (tree.getTag()) {
+        case JCTree.TYPEARRAY:
+            printBaseElementType(((JCArrayTypeTree)tree).elemtype);
+            return;
+        case JCTree.WILDCARD:
+            printBaseElementType(((JCWildcard)tree).inner);
+            return;
+        case JCTree.ANNOTATED_TYPE:
+            printBaseElementType(((JCAnnotatedType)tree).underlyingType);
+            return;
+        default:
+            printExpr(tree);
+            return;
+        }
     }
 
     // prints the brackets of a nested array in reverse order
@@ -1127,8 +1155,13 @@
         JCTree elem;
         while (true) {
             elem = tree.elemtype;
+            if (elem.getTag() == JCTree.ANNOTATED_TYPE) {
+                JCAnnotatedType atype = (JCAnnotatedType) elem;
+                printTypeAnnotations(atype.annotations);
+                elem = atype.underlyingType;
+            }
             print("[]");
-            if (!(elem instanceof JCArrayTypeTree)) break;
+            if (elem.getTag() != JCTree.TYPEARRAY) break;
             tree = (JCArrayTypeTree) elem;
         }
     }
@@ -1213,6 +1246,15 @@
         }
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        try {
+            printTypeAnnotations(tree.annotations);
+            printExpr(tree.underlyingType);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
     public void visitTree(JCTree tree) {
         try {
             print("(UNKNOWN: " + tree + ")");
@@ -1221,4 +1263,5 @@
             throw new UncheckedIOException(e);
         }
     }
+
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Tue Jul 21 13:02:23 2009 -0700
@@ -71,6 +71,13 @@
         return lb.toList();
     }
 
+    public JCTree visitAnnotatedType(AnnotatedTypeTree node, P p) {
+        JCAnnotatedType t = (JCAnnotatedType) node;
+        List<JCTypeAnnotation> annotations = copy(t.annotations, p);
+        JCExpression underlyingType = copy(t.underlyingType, p);
+        return M.at(t.pos).AnnotatedType(annotations, underlyingType);
+    }
+
     public JCTree visitAnnotation(AnnotationTree node, P p) {
         JCAnnotation t = (JCAnnotation) node;
         JCTree annotationType = copy(t.annotationType, p);
@@ -233,10 +240,11 @@
         JCExpression restype = copy(t.restype, p);
         List<JCTypeParameter> typarams = copy(t.typarams, p);
         List<JCVariableDecl> params = copy(t.params, p);
+        List<JCTypeAnnotation> receiver = copy(t.receiverAnnotations, p);
         List<JCExpression> thrown = copy(t.thrown, p);
         JCBlock body = copy(t.body, p);
         JCExpression defaultValue = copy(t.defaultValue, p);
-        return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, params, thrown, body, defaultValue);
+        return M.at(t.pos).MethodDef(mods, t.name, restype, typarams, params, receiver, thrown, body, defaultValue);
     }
 
     public JCTree visitMethodInvocation(MethodInvocationTree node, P p) {
@@ -357,8 +365,9 @@
 
     public JCTree visitTypeParameter(TypeParameterTree node, P p) {
         JCTypeParameter t = (JCTypeParameter) node;
+        List<JCTypeAnnotation> annos = copy(t.annotations, p);
         List<JCExpression> bounds = copy(t.bounds, p);
-        return M.at(t.pos).TypeParameter(t.name, t.bounds);
+        return M.at(t.pos).TypeParameter(t.name, bounds, annos);
     }
 
     public JCTree visitInstanceOf(InstanceOfTree node, P p) {
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Tue Jul 21 13:02:23 2009 -0700
@@ -298,6 +298,8 @@
         case(JCTree.POSTINC):
         case(JCTree.POSTDEC):
             return getStartPos(((JCUnary) tree).arg);
+        case(JCTree.ANNOTATED_TYPE):
+            return getStartPos(((JCAnnotatedType) tree).underlyingType);
         case(JCTree.VARDEF): {
             JCVariableDecl node = (JCVariableDecl)tree;
             if (node.mods.pos != Position.NOPOS) {
@@ -859,4 +861,25 @@
             return null;
         }
     }
+
+    /**
+     * Returns the underlying type of the tree if it is annotated type,
+     * or the tree itself otherwise
+     */
+    public static JCExpression typeIn(JCExpression tree) {
+        switch (tree.getTag()) {
+        case JCTree.ANNOTATED_TYPE:
+            return ((JCAnnotatedType)tree).underlyingType;
+        case JCTree.IDENT: /* simple names */
+        case JCTree.TYPEIDENT: /* primitive name */
+        case JCTree.SELECT: /* qualified name */
+        case JCTree.TYPEARRAY: /* array types */
+        case JCTree.WILDCARD: /* wild cards */
+        case JCTree.TYPEPARAMETER: /* type parameters */
+        case JCTree.TYPEAPPLY: /* parameterized types */
+            return tree;
+        default:
+            throw new AssertionError("Unexpected type tree: " + tree);
+        }
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Tue Jul 21 13:02:23 2009 -0700
@@ -168,6 +168,20 @@
                                List<JCVariableDecl> params,
                                List<JCExpression> thrown,
                                JCBlock body,
+                               JCExpression defaultValue) {
+        return MethodDef(
+                mods, name, restype, typarams, params,
+                null, thrown, body, defaultValue);
+    }
+
+    public JCMethodDecl MethodDef(JCModifiers mods,
+                               Name name,
+                               JCExpression restype,
+                               List<JCTypeParameter> typarams,
+                               List<JCVariableDecl> params,
+                               List<JCTypeAnnotation> receiver,
+                               List<JCExpression> thrown,
+                               JCBlock body,
                                JCExpression defaultValue)
     {
         JCMethodDecl tree = new JCMethodDecl(mods,
@@ -175,6 +189,7 @@
                                        restype,
                                        typarams,
                                        params,
+                                       receiver,
                                        thrown,
                                        body,
                                        defaultValue,
@@ -430,7 +445,11 @@
     }
 
     public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds) {
-        JCTypeParameter tree = new JCTypeParameter(name, bounds);
+        return TypeParameter(name, bounds, List.<JCTypeAnnotation>nil());
+    }
+
+    public JCTypeParameter TypeParameter(Name name, List<JCExpression> bounds, List<JCTypeAnnotation> annos) {
+        JCTypeParameter tree = new JCTypeParameter(name, bounds, annos);
         tree.pos = pos;
         return tree;
     }
@@ -453,6 +472,12 @@
         return tree;
     }
 
+    public JCTypeAnnotation TypeAnnotation(JCTree annotationType, List<JCExpression> args) {
+        JCTypeAnnotation tree = new JCTypeAnnotation(annotationType, args);
+        tree.pos = pos;
+        return tree;
+    }
+
     public JCModifiers Modifiers(long flags, List<JCAnnotation> annotations) {
         JCModifiers tree = new JCModifiers(flags, annotations);
         boolean noFlags = (flags & Flags.StandardFlags) == 0;
@@ -464,6 +489,12 @@
         return Modifiers(flags, List.<JCAnnotation>nil());
     }
 
+    public JCAnnotatedType AnnotatedType(List<JCTypeAnnotation> annotations, JCExpression underlyingType) {
+        JCAnnotatedType tree = new JCAnnotatedType(annotations, underlyingType);
+        tree.pos = pos;
+        return tree;
+    }
+
     public JCErroneous Erroneous() {
         return Erroneous(List.<JCTree>nil());
     }
@@ -772,6 +803,7 @@
                 Type(mtype.getReturnType()),
                 TypeParams(mtype.getTypeArguments()),
                 Params(mtype.getParameterTypes(), m),
+                null,
                 Types(mtype.getThrownTypes()),
                 body,
                 null,
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java	Tue Jul 21 13:02:23 2009 -0700
@@ -85,6 +85,7 @@
         scan(tree.restype);
         scan(tree.typarams);
         scan(tree.params);
+        scan(tree.receiverAnnotations);
         scan(tree.thrown);
         scan(tree.defaultValue);
         scan(tree.body);
@@ -204,8 +205,11 @@
     }
 
     public void visitNewArray(JCNewArray tree) {
+        scan(tree.annotations);
         scan(tree.elemtype);
         scan(tree.dims);
+        for (List<JCTypeAnnotation> annos : tree.dimAnnotations)
+            scan(annos);
         scan(tree.elems);
     }
 
@@ -270,6 +274,7 @@
     }
 
     public void visitTypeParameter(JCTypeParameter tree) {
+        scan(tree.annotations);
         scan(tree.bounds);
     }
 
@@ -293,6 +298,11 @@
         scan(tree.args);
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        scan(tree.annotations);
+        scan(tree.underlyingType);
+    }
+
     public void visitErroneous(JCErroneous tree) {
     }
 
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java	Tue Jul 21 13:02:23 2009 -0700
@@ -282,6 +282,11 @@
     }
 
     public void visitNewArray(JCNewArray tree) {
+        tree.annotations = translate(tree.annotations);
+        List<List<JCTypeAnnotation>> dimAnnos = List.nil();
+        for (List<JCTypeAnnotation> origDimAnnos : tree.dimAnnotations)
+            dimAnnos = dimAnnos.append(translate(origDimAnnos));
+        tree.dimAnnotations = dimAnnos;
         tree.elemtype = translate(tree.elemtype);
         tree.dims = translate(tree.dims);
         tree.elems = translate(tree.elems);
@@ -363,6 +368,7 @@
     }
 
     public void visitTypeParameter(JCTypeParameter tree) {
+        tree.annotations = translate(tree.annotations);
         tree.bounds = translate(tree.bounds);
         result = tree;
     }
@@ -400,6 +406,12 @@
         result = tree;
     }
 
+    public void visitAnnotatedType(JCAnnotatedType tree) {
+        tree.annotations = translate(tree.annotations);
+        tree.underlyingType = translate(tree.underlyingType);
+        result = tree;
+    }
+
     public void visitTree(JCTree tree) {
         throw new AssertionError(tree);
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -109,7 +109,7 @@
         return formatDiagnostic(d, locale);
     }
 
-    abstract String formatDiagnostic(JCDiagnostic d, Locale locale);
+    protected abstract String formatDiagnostic(JCDiagnostic d, Locale locale);
 
     public String formatPosition(JCDiagnostic d, PositionKind pk,Locale l) {
         assert (d.getPosition() != Position.NOPOS);
@@ -172,9 +172,6 @@
             return formatIterable(d, (Iterable<?>)arg, l);
         }
         else if (arg instanceof Type) {
-            if (!allCaptured.contains(arg)) {
-                allCaptured = allCaptured.append((Type)arg);
-            }
             return printer.visit((Type)arg, l);
         }
         else if (arg instanceof Symbol) {
@@ -482,5 +479,12 @@
         protected String capturedVarId(CapturedType t, Locale locale) {
             return "" + (allCaptured.indexOf(t) + 1);
         }
+        @Override
+        public String visitCapturedType(CapturedType t, Locale locale) {
+            if (!allCaptured.contains(t)) {
+                allCaptured = allCaptured.append(t);
+            }
+            return super.visitCapturedType(t, locale);
+        }
     };
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/AbstractLog.java	Tue Jul 21 13:02:23 2009 -0700
@@ -58,7 +58,7 @@
 
     protected DiagnosticSource getSource(JavaFileObject file) {
         if (file == null)
-            return null;
+            return DiagnosticSource.NO_SOURCE;
         DiagnosticSource s = sourceMap.get(file);
         if (s == null) {
             s = new DiagnosticSource(file, this);
--- a/langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java	Tue Jul 21 13:02:23 2009 -0700
@@ -46,11 +46,22 @@
  *  deletion without notice.</b>
  */
 public class DiagnosticSource {
+
+    /* constant DiagnosticSource to be used when sourcefile is missing */
+    public static final DiagnosticSource NO_SOURCE = new DiagnosticSource() {
+        @Override
+        protected boolean findLine(int pos) {
+            return false;
+        }
+    };
+
     public DiagnosticSource(JavaFileObject fo, AbstractLog log) {
         this.fileObject = fo;
         this.log = log;
     }
 
+    private DiagnosticSource() {}
+
     /** Return the underlying file object handled by this
      *  DiagnosticSource object.
      */
@@ -134,7 +145,7 @@
     /** Find the line in the buffer that contains the current position
      * @param pos      Character offset into the buffer
      */
-    private boolean findLine(int pos) {
+    protected boolean findLine(int pos) {
         if (pos == Position.NOPOS)
             return false;
 
--- a/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Tue Jul 21 13:02:23 2009 -0700
@@ -83,7 +83,7 @@
          */
         public JCDiagnostic error(
                 DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return new JCDiagnostic(formatter, ERROR, true, source, pos, qualify(ERROR, key), args);
+            return create(ERROR, true, source, pos, key, args);
         }
 
         /**
@@ -96,7 +96,7 @@
          */
         public JCDiagnostic mandatoryWarning(
                  DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return new JCDiagnostic(formatter, WARNING, true, source, pos, qualify(WARNING, key), args);
+            return create(WARNING, true, source, pos, key, args);
         }
 
         /**
@@ -108,7 +108,7 @@
          */
         public JCDiagnostic warning(
                 DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return new JCDiagnostic(formatter, WARNING, false, source, pos, qualify(WARNING, key), args);
+            return create(WARNING, false, source, pos, key, args);
         }
 
         /**
@@ -118,7 +118,7 @@
          *  @see MandatoryWarningHandler
          */
         public JCDiagnostic mandatoryNote(DiagnosticSource source, String key, Object... args) {
-            return new JCDiagnostic(formatter, NOTE, true, source, null, qualify(NOTE, key), args);
+            return create(NOTE, true, source, null, key, args);
         }
 
         /**
@@ -127,7 +127,7 @@
          *  @param args   Fields of the error message.
          */
         public JCDiagnostic note(String key, Object... args) {
-            return note(null, null, key, args);
+            return create(NOTE, false, null, null, key, args);
         }
 
         /**
@@ -139,7 +139,7 @@
          */
         public JCDiagnostic note(
                 DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return new JCDiagnostic(formatter, NOTE, false, source, pos, qualify(NOTE, key), args);
+            return create(NOTE, false, source, pos, key, args);
         }
 
         /**
@@ -148,7 +148,21 @@
          *  @param args   Fields of the error message.
          */
         public JCDiagnostic fragment(String key, Object... args) {
-            return new JCDiagnostic(formatter, FRAGMENT, false, null, null, qualify(FRAGMENT, key), args);
+            return create(FRAGMENT, false, null, null, key, args);
+        }
+
+        /**
+         * Create a new diagnostic of the given kind.
+         *  @param kind        The diagnostic kind
+         *  @param isMandatory is diagnostic mandatory?
+         *  @param source      The source of the compilation unit, if any, in which to report the note.
+         *  @param pos         The source position at which to report the note.
+         *  @param key         The key for the localized error message.
+         *  @param args        Fields of the error message.
+         */
+        public JCDiagnostic create(
+                DiagnosticType kind, boolean isMandatory, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
+            return new JCDiagnostic(formatter, kind, isMandatory, source, pos, qualify(kind, key), args);
         }
 
         protected String qualify(DiagnosticType t, String key) {
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Names.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java	Tue Jul 21 13:02:23 2009 -0700
@@ -99,6 +99,8 @@
     public final Name Annotation;
     public final Name RuntimeVisibleAnnotations;
     public final Name RuntimeInvisibleAnnotations;
+    public final Name RuntimeVisibleTypeAnnotations;
+    public final Name RuntimeInvisibleTypeAnnotations;
     public final Name RuntimeVisibleParameterAnnotations;
     public final Name RuntimeInvisibleParameterAnnotations;
     public final Name Value;
@@ -115,6 +117,8 @@
     public final Name getClass;
     public final Name invoke;
     public final Name TYPE;
+    public final Name TYPE_USE;
+    public final Name TYPE_PARAMETER;
     public final Name FIELD;
     public final Name METHOD;
     public final Name PARAMETER;
@@ -205,6 +209,8 @@
         Annotation = fromString("Annotation");
         RuntimeVisibleAnnotations = fromString("RuntimeVisibleAnnotations");
         RuntimeInvisibleAnnotations = fromString("RuntimeInvisibleAnnotations");
+        RuntimeVisibleTypeAnnotations = fromString("RuntimeVisibleTypeAnnotations");
+        RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
         RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
         RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
         Value = fromString("Value");
@@ -224,6 +230,8 @@
         invoke = fromString("invoke");
 
         TYPE = fromString("TYPE");
+        TYPE_USE = fromString("TYPE_USE");
+        TYPE_PARAMETER = fromString("TYPE_PARAMETER");
         FIELD = fromString("FIELD");
         METHOD = fromString("METHOD");
         PARAMETER = fromString("PARAMETER");
--- a/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -68,7 +68,10 @@
     final JavacMessages messages;
 
     /* name simplifier used by this formatter */
-    ClassNameSimplifier nameSimplifier;
+    protected ClassNameSimplifier nameSimplifier;
+
+    /* type/symbol printer used by this formatter */
+    private RichPrinter printer;
 
     /* map for keeping track of a where clause associated to a given type */
     Map<WhereClauseKind, Map<Type, JCDiagnostic>> whereClauses;
@@ -83,7 +86,7 @@
 
     protected RichDiagnosticFormatter(Context context) {
         super((AbstractDiagnosticFormatter)Log.instance(context).getDiagnosticFormatter());
-        this.formatter.setPrinter(printer);
+        setRichPrinter(new RichPrinter());
         this.syms = Symtab.instance(context);
         this.diags = JCDiagnostic.Factory.instance(context);
         this.types = Types.instance(context);
@@ -117,6 +120,23 @@
     }
 
     /**
+     * Sets the type/symbol printer used by this formatter.
+     * @param printer the rich printer to be set
+     */
+    protected void setRichPrinter(RichPrinter printer) {
+        this.printer = printer;
+        formatter.setPrinter(printer);
+    }
+
+    /**
+     * Gets the type/symbol printer used by this formatter.
+     * @return type/symbol rich printer
+     */
+    protected RichPrinter getRichPrinter() {
+        return printer;
+    }
+
+    /**
      * Preprocess a given diagnostic by looking both into its arguments and into
      * its subdiagnostics (if any). This preprocessing is responsible for
      * generating info corresponding to features like where clauses, name
@@ -217,7 +237,7 @@
      * name belong to different packages - in this case the formatter reverts
      * to fullnames as compact names might lead to a confusing diagnostic.
      */
-    class ClassNameSimplifier {
+    protected class ClassNameSimplifier {
 
         /* table for keeping track of all short name usages */
         Map<Name, List<Symbol>> nameClashes = new HashMap<Name, List<Symbol>>();
@@ -272,7 +292,7 @@
      * discovered during type/symbol preprocessing. This printer is set on the delegate
      * formatter so that rich type/symbol info can be properly rendered.
      */
-    protected Printer printer = new Printer() {
+    protected class RichPrinter extends Printer {
 
         @Override
         public String localize(Locale locale, String key, Object... args) {
--- a/langtools/src/share/classes/com/sun/tools/javap/AnnotationWriter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javap/AnnotationWriter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -26,6 +26,7 @@
 package com.sun.tools.javap;
 
 import com.sun.tools.classfile.Annotation;
+import com.sun.tools.classfile.ExtendedAnnotation;
 import com.sun.tools.classfile.Annotation.Annotation_element_value;
 import com.sun.tools.classfile.Annotation.Array_element_value;
 import com.sun.tools.classfile.Annotation.Class_element_value;
@@ -62,6 +63,12 @@
         print(")");
     }
 
+    public void write(ExtendedAnnotation annot) {
+        write(annot.annotation);
+        print('@');
+        print(annot.position.toString());
+    }
+
     public void write(Annotation.element_value_pair pair) {
         print("#" + pair.element_name_index + ":");
         write(pair.value);
--- a/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -51,8 +51,10 @@
 import com.sun.tools.classfile.Module_attribute;
 import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute;
 import com.sun.tools.classfile.RuntimeInvisibleParameterAnnotations_attribute;
+import com.sun.tools.classfile.RuntimeInvisibleTypeAnnotations_attribute;
 import com.sun.tools.classfile.RuntimeVisibleAnnotations_attribute;
 import com.sun.tools.classfile.RuntimeVisibleParameterAnnotations_attribute;
+import com.sun.tools.classfile.RuntimeVisibleTypeAnnotations_attribute;
 import com.sun.tools.classfile.Signature_attribute;
 import com.sun.tools.classfile.SourceDebugExtension_attribute;
 import com.sun.tools.classfile.SourceFile_attribute;
@@ -74,7 +76,7 @@
 public class AttributeWriter extends BasicWriter
         implements Attribute.Visitor<Void,Void>
 {
-    static AttributeWriter instance(Context context) {
+    public static AttributeWriter instance(Context context) {
         AttributeWriter instance = context.get(AttributeWriter.class);
         if (instance == null)
             instance = new AttributeWriter(context);
@@ -434,6 +436,26 @@
         return null;
     }
 
+    public Void visitRuntimeVisibleTypeAnnotations(RuntimeVisibleTypeAnnotations_attribute attr, Void ignore) {
+        println("  RuntimeVisibleTypeAnnotations: ");
+        for (int i = 0; i < attr.annotations.length; i++) {
+            print("    " + i + ": ");
+            annotationWriter.write(attr.annotations[i]);
+            println();
+        }
+        return null;
+    }
+
+    public Void visitRuntimeInvisibleTypeAnnotations(RuntimeInvisibleTypeAnnotations_attribute attr, Void ignore) {
+        println("  RuntimeInvisibleTypeAnnotations: ");
+        for (int i = 0; i < attr.annotations.length; i++) {
+            print("    " + i + ": ");
+            annotationWriter.write(attr.annotations[i]);
+            println();
+        }
+        return null;
+    }
+
     public Void visitRuntimeVisibleParameterAnnotations(RuntimeVisibleParameterAnnotations_attribute attr, Void ignore) {
         println("  RuntimeVisibleParameterAnnotations: ");
         for (int param = 0; param < attr.parameter_annotations.length; param++) {
--- a/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -93,17 +93,25 @@
         this.lastModified = lastModified;
     }
 
-    ClassFile getClassFile() {
+    protected ClassFile getClassFile() {
         return classFile;
     }
 
-    Method getMethod() {
+    protected void setClassFile(ClassFile cf) {
+        classFile = cf;
+        constant_pool = classFile.constant_pool;
+    }
+
+    protected Method getMethod() {
         return method;
     }
 
+    protected void setMethod(Method m) {
+        method = m;
+    }
+
     public void write(ClassFile cf) {
-        classFile = cf;
-        constant_pool = classFile.constant_pool;
+        setClassFile(cf);
 
         if ((options.sysInfo || options.verbose) && !options.compat) {
             if (uri != null) {
@@ -197,13 +205,13 @@
         println();
     }
 
-    void writeFields() {
+    protected void writeFields() {
         for (Field f: classFile.fields) {
             writeField(f);
         }
     }
 
-    void writeField(Field f) {
+    protected void writeField(Field f) {
         if (!options.checkAccess(f.access_flags))
             return;
 
@@ -259,12 +267,12 @@
             println();
     }
 
-    void writeMethods() {
+    protected void writeMethods() {
         for (Method m: classFile.methods)
             writeMethod(m);
     }
 
-    void writeMethod(Method m) {
+    protected void writeMethod(Method m) {
         if (!options.checkAccess(m.access_flags))
             return;
 
--- a/langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javap/ConstantWriter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -40,7 +40,7 @@
  *  deletion without notice.</b>
  */
 public class ConstantWriter extends BasicWriter {
-    static ConstantWriter instance(Context context) {
+    public static ConstantWriter instance(Context context) {
         ConstantWriter instance = context.get(ConstantWriter.class);
         if (instance == null)
             instance = new ConstantWriter(context);
@@ -54,7 +54,12 @@
         options = Options.instance(context);
     }
 
-    void writeConstantPool() {
+    protected void writeConstantPool() {
+        ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
+        writeConstantPool(constant_pool);
+    }
+
+    protected void writeConstantPool(ConstantPool constant_pool) {
         ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() {
             public Integer visitClass(CONSTANT_Class_info info, Void p) {
                 println("#" + info.name_index + ";\t//  " + stringValue(info));
@@ -114,7 +119,6 @@
 
         };
         println("  Constant pool:");
-        ConstantPool constant_pool = classWriter.getClassFile().constant_pool;
         int cpx = 1;
         while (cpx < constant_pool.size()) {
             try {
@@ -127,7 +131,7 @@
         }
     }
 
-    void write(int cpx) {
+    protected void write(int cpx) {
         ClassFile classFile = classWriter.getClassFile();
         if (cpx == 0) {
             print("#0");
--- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java	Tue Jul 21 13:02:23 2009 -0700
@@ -36,6 +36,7 @@
 import java.io.Writer;
 import java.security.DigestInputStream;
 import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -298,21 +299,28 @@
 
     };
 
-    JavapTask() {
+    public JavapTask() {
         context = new Context();
         context.put(Messages.class, this);
         options = Options.instance(context);
+        attributeFactory = new Attribute.Factory();
     }
 
-    JavapTask(Writer out,
+    public JavapTask(Writer out,
+            JavaFileManager fileManager,
+            DiagnosticListener<? super JavaFileObject> diagnosticListener) {
+        this();
+        this.log = getPrintWriterForWriter(out);
+        this.fileManager = fileManager;
+        this.diagnosticListener = diagnosticListener;
+    }
+
+    public JavapTask(Writer out,
             JavaFileManager fileManager,
             DiagnosticListener<? super JavaFileObject> diagnosticListener,
             Iterable<String> options,
             Iterable<String> classes) {
-        this();
-        this.log = getPrintWriterForWriter(out);
-        this.fileManager = fileManager;
-        this.diagnosticListener = diagnosticListener;
+        this(out, fileManager, diagnosticListener);
 
         try {
             handleOptions(options, false);
@@ -553,29 +561,10 @@
                        continue;
                     }
                 }
-                Attribute.Factory attributeFactory = new Attribute.Factory();
                 attributeFactory.setCompat(options.compat);
                 attributeFactory.setJSR277(options.jsr277);
 
-                InputStream in = fo.openInputStream();
-                SizeInputStream sizeIn = null;
-                MessageDigest md  = null;
-                if (options.sysInfo || options.verbose) {
-                    md = MessageDigest.getInstance("MD5");
-                    in = new DigestInputStream(in, md);
-                    in = sizeIn = new SizeInputStream(in);
-                }
-
-                ClassFile cf = ClassFile.read(in, attributeFactory);
-
-                if (options.sysInfo || options.verbose) {
-                    classWriter.setFile(fo.toUri());
-                    classWriter.setLastModified(fo.getLastModified());
-                    classWriter.setDigest("MD5", md.digest());
-                    classWriter.setFileSize(sizeIn.size());
-                }
-
-                classWriter.write(cf);
+                write(read(fo));
 
             } catch (ConstantPoolException e) {
                 diagnosticListener.report(createDiagnostic("err.bad.constant.pool", className, e.getLocalizedMessage()));
@@ -606,6 +595,103 @@
         return ok;
     }
 
+    public static class ClassFileInfo {
+        ClassFileInfo(JavaFileObject fo, ClassFile cf, byte[] digest, int size) {
+            this.fo = fo;
+            this.cf = cf;
+            this.digest = digest;
+            this.size = size;
+        }
+        public final JavaFileObject fo;
+        public final ClassFile cf;
+        public final byte[] digest;
+        public final int size;
+    }
+
+    public ClassFileInfo read(JavaFileObject fo) throws IOException, ConstantPoolException {
+        InputStream in = fo.openInputStream();
+        try {
+            SizeInputStream sizeIn = null;
+            MessageDigest md  = null;
+            if (options.sysInfo || options.verbose) {
+                try {
+                    md = MessageDigest.getInstance("MD5");
+                } catch (NoSuchAlgorithmException ignore) {
+                }
+                in = new DigestInputStream(in, md);
+                in = sizeIn = new SizeInputStream(in);
+            }
+
+            ClassFile cf = ClassFile.read(in, attributeFactory);
+            byte[] digest = (md == null) ? null : md.digest();
+            int size = (sizeIn == null) ? -1 : sizeIn.size();
+            return new ClassFileInfo(fo, cf, digest, size);
+        } finally {
+            in.close();
+        }
+    }
+
+    public void write(ClassFileInfo info) {
+        ClassWriter classWriter = ClassWriter.instance(context);
+        if (options.sysInfo || options.verbose) {
+            classWriter.setFile(info.fo.toUri());
+            classWriter.setLastModified(info.fo.getLastModified());
+            classWriter.setDigest("MD5", info.digest);
+            classWriter.setFileSize(info.size);
+        }
+
+        classWriter.write(info.cf);
+    }
+
+    protected void setClassFile(ClassFile classFile) {
+        ClassWriter classWriter = ClassWriter.instance(context);
+        classWriter.setClassFile(classFile);
+    }
+
+    protected void setMethod(Method enclosingMethod) {
+        ClassWriter classWriter = ClassWriter.instance(context);
+        classWriter.setMethod(enclosingMethod);
+    }
+
+    protected void write(Attribute value) {
+        AttributeWriter attrWriter = AttributeWriter.instance(context);
+        ClassWriter classWriter = ClassWriter.instance(context);
+        ClassFile cf = classWriter.getClassFile();
+        attrWriter.write(cf, value, cf.constant_pool);
+    }
+
+    protected void write(Attributes attrs) {
+        AttributeWriter attrWriter = AttributeWriter.instance(context);
+        ClassWriter classWriter = ClassWriter.instance(context);
+        ClassFile cf = classWriter.getClassFile();
+        attrWriter.write(cf, attrs, cf.constant_pool);
+    }
+
+    protected void write(ConstantPool constant_pool) {
+        ConstantWriter constantWriter = ConstantWriter.instance(context);
+        constantWriter.writeConstantPool(constant_pool);
+    }
+
+    protected void write(ConstantPool constant_pool, int value) {
+        ConstantWriter constantWriter = ConstantWriter.instance(context);
+        constantWriter.write(value);
+    }
+
+    protected void write(ConstantPool.CPInfo value) {
+        ConstantWriter constantWriter = ConstantWriter.instance(context);
+        constantWriter.println(value);
+    }
+
+    protected void write(Field value) {
+        ClassWriter classWriter = ClassWriter.instance(context);
+        classWriter.writeField(value);
+    }
+
+    protected void write(Method value) {
+        ClassWriter classWriter = ClassWriter.instance(context);
+        classWriter.writeMethod(value);
+    }
+
     private JavaFileManager getDefaultFileManager(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) {
         return JavapFileManager.create(dl, log, options);
     }
@@ -735,7 +821,7 @@
         }
     }
 
-    Context context;
+    protected Context context;
     JavaFileManager fileManager;
     PrintWriter log;
     DiagnosticListener<? super JavaFileObject> diagnosticListener;
@@ -744,6 +830,7 @@
     //ResourceBundle bundle;
     Locale task_locale;
     Map<Locale, ResourceBundle> bundles;
+    protected Attribute.Factory attributeFactory;
 
     private static final String progname = "javap";
 
--- a/langtools/src/share/classes/com/sun/tools/javap/SourceWriter.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javap/SourceWriter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -134,6 +134,9 @@
     }
 
     private String readSource(ClassFile cf) {
+        if (fileManager == null)
+            return null;
+
         Location location;
         if (fileManager.hasLocation((StandardLocation.SOURCE_PATH)))
             location = StandardLocation.SOURCE_PATH;
--- a/langtools/src/share/classes/javax/lang/model/type/MirroredTypeException.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/src/share/classes/javax/lang/model/type/MirroredTypeException.java	Tue Jul 21 13:02:23 2009 -0700
@@ -54,7 +54,7 @@
      * @param type  the type being accessed
      */
     public MirroredTypeException(TypeMirror type) {
-        super("Attempt to access Class object for TypeMirror " + type);
+        super("Attempt to access Class object for TypeMirror " + type.toString());
         this.type = type;
     }
 
--- a/langtools/test/tools/javac/6341866/T6341866.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/test/tools/javac/6341866/T6341866.java	Tue Jul 21 13:02:23 2009 -0700
@@ -97,7 +97,7 @@
         processorServices.delete();
 
         List<String> opts = new ArrayList<String>();
-        opts.addAll(Arrays.asList("-d", ".", "-sourcepath", testSrc, "-classpath", testClasses));
+        opts.addAll(Arrays.asList("-d", ".", "-sourcepath", testSrc, "-classpath", testClasses, "-source", "1.6"));
         if (implicitType.opt != null)
             opts.add(implicitType.opt);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6835430/A.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+class A<T extends A<T>> {
+    class C {
+        public T getT() { return null; }
+    }
+}
+
+class B extends A<B> {
+    public class D extends A<B>.C {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6835430/T6835430.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * 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 6835430
+ * @summary 6835430: javac does not generate signature attributes for classes extending parameterized inner classes
+ * @author mcimadamore
+ *
+ * @compile A.java
+ * @compile T6835430.java
+ */
+
+class T6835430 {
+    void test(B.D d) {
+        B b = d.getT();
+    }
+}
--- a/langtools/test/tools/javac/Diagnostics/6799605/T6799605.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/test/tools/javac/Diagnostics/6799605/T6799605.java	Tue Jul 21 13:02:23 2009 -0700
@@ -27,6 +27,7 @@
  * @summary Basic/Raw formatters should use type/symbol printer instead of toString()
  * @author  mcimadamore
  * @compile/fail/ref=T6799605.out -XDrawDiagnostics  T6799605.java
+ * @compile/fail/ref=T6799605.out -XDoldDiags -XDrawDiagnostics  T6799605.java
  */
 
 class T6799605<X> {
--- a/langtools/test/tools/javac/Diagnostics/6799605/T6799605.out	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/test/tools/javac/Diagnostics/6799605/T6799605.out	Tue Jul 21 13:02:23 2009 -0700
@@ -1,4 +1,4 @@
-T6799605.java:39:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X>
-T6799605.java:40:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>, kindname.class, T6799605<X>
-T6799605.java:41:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>, kindname.class, T6799605<X>
+T6799605.java:40:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X>
+T6799605.java:41:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>, kindname.class, T6799605<X>
+T6799605.java:42:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>, kindname.class, T6799605<X>
 3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/6852595/T6852595.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,66 @@
+/*
+ * 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     6852595
+ * @summary Accessing scope using JSR199 API on erroneous tree causes Illegal Argument Exception
+ * @author  mcimadamore
+ */
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.source.tree.*;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTrees;
+import com.sun.tools.javac.tree.JCTree.*;
+
+import static javax.tools.JavaFileObject.Kind;
+
+public class T6852595 {
+    public static void main(String[] args) throws IOException {
+        JavaFileObject sfo = new SimpleJavaFileObject(URI.create("myfo:/Test.java"),Kind.SOURCE) {
+            public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+                return "class BadName { Object o = j; }";
+            }
+        };
+        List<? extends JavaFileObject> files = Arrays.asList(sfo);
+        JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, files);
+        Iterable<? extends CompilationUnitTree> compUnits = ct.parse();
+        CompilationUnitTree cu = compUnits.iterator().next();
+        ClassTree cdef = (ClassTree)cu.getTypeDecls().get(0);
+        JCVariableDecl vdef = (JCVariableDecl)cdef.getMembers().get(0);
+        TreePath path = TreePath.getPath(cu, vdef.init);
+        Trees.instance(ct).getScope(path);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/TestTreePath.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2006 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 6473148
+ * @summary TreePath.iterator() throws NPE
+ */
+import java.io.*;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.ElementFilter;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import com.sun.source.tree.Tree;
+import com.sun.source.util.*;
+
+@SupportedAnnotationTypes("*")
+public class TestTreePath extends AbstractProcessor {
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations,
+            RoundEnvironment roundEnv) {
+        final Trees trees = Trees.instance(this.processingEnv);
+        for (Element element : ElementFilter.typesIn(roundEnv.getRootElements())) {
+            checkTreePath(trees, element, 2);
+            for (Element member : element.getEnclosedElements())
+                checkTreePath(trees, member, 3);
+        }
+        return true;
+    }
+
+    private void checkTreePath(Trees trees, Element element, int expectedLength) {
+        TreePath path = trees.getPath(element);
+        assert path != null;
+
+        int enhancedLength = 0;
+        for (Tree tree : path)
+            ++enhancedLength;
+
+        if (enhancedLength != expectedLength)
+            throw new RuntimeException("found path length is wrong");
+
+        int normalLoopLength = 0;
+        Iterator<Tree> iter = path.iterator();
+        while (iter.hasNext()) {
+          iter.next();
+          ++normalLoopLength;
+        }
+        if (normalLoopLength != expectedLength)
+            throw new RuntimeException("found path length is wrong");
+
+        TreePath curr = path;
+        // using getParent
+        int whileLoopLength = 0;
+        while (curr != null) {
+          ++whileLoopLength;
+          curr = curr.getParentPath();
+        }
+        if (whileLoopLength != expectedLength)
+            throw new RuntimeException("found path length is wrong");
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new FileWriter(f));
+        out.println("class Test { void method() { } }");
+        out.close();
+        return f;
+    }
+
+    public void run() throws IOException {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fileManager
+            = compiler.getStandardFileManager(null, null, null);
+        Iterable<? extends JavaFileObject> tests
+            = fileManager.getJavaFileObjects(writeTestFile());
+
+        JavaCompiler.CompilationTask task =
+            ToolProvider.getSystemJavaCompiler().getTask(
+                    null, null, null,
+                    Arrays.asList("-processor", this.getClass().getName()), null,
+                    tests);
+        task.call();
+    }
+
+    public static void main(String[] args) throws IOException {
+        new TestTreePath().run();
+    }
+}
--- a/langtools/test/tools/javac/generics/inference/6302954/T6476073.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/test/tools/javac/generics/inference/6302954/T6476073.java	Tue Jul 21 13:02:23 2009 -0700
@@ -25,6 +25,7 @@
  * @test
  * @bug     6476073
  * @summary Capture using super wildcard of type variables doesn't work
+ * @ignore awaiting for 6650759 (see bug report for a detailed evaluation)
  * @compile T6476073.java
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712a.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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     6638712
+ * @author  mcimadamore
+ * @summary Inference with wildcard types causes selection of inapplicable method
+ * @compile/fail/ref=T6638712a.out -XDrawDiagnostics T6638712a.java
+ */
+
+import java.util.*;
+
+class T6638712a {
+
+    <T> Comparator<T> compound(Iterable<? extends Comparator<? super T>> it) {}
+
+    public void test(List<Comparator<?>> x) {
+        Comparator<String> c3 = compound(x);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712a.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+T6638712a.java:39:41: compiler.err.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Iterable<? extends java.util.Comparator<? super java.lang.String>>, java.util.List<java.util.Comparator<?>>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712b.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,39 @@
+/*
+ * 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     6638712
+ * @author  mcimadamore
+ * @summary Inference with wildcard types causes selection of inapplicable method
+ * @compile/fail/ref=T6638712b.out -XDrawDiagnostics T6638712b.java
+ */
+
+class T6638712b<X> {
+
+    <I extends T6638712b<T>, T> T m(I test) { return null; }
+
+    void test(T6638712b<Integer> x) {
+        String i = m(x);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712b.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+T6638712b.java:37:21: compiler.err.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.bounds: T6638712b<java.lang.Integer>, T6638712b<java.lang.String>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712c.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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     6638712 6707034
+ * @author  mcimadamore
+ * @summary Inference with wildcard types causes selection of inapplicable method
+ * @compile/fail/ref=T6638712c.out -XDrawDiagnostics T6638712c.java
+ */
+
+import java.util.*;
+
+class T6638712c {
+
+    <T> T sort(T[] a, Comparator<? super T> c) { return null; }
+
+    void test(Enum[] e, Comparator<Enum<?>> comp) {
+        sort(e, comp);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712c.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+T6638712c.java:39:9: compiler.err.cant.apply.symbol: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, null
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712d.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,41 @@
+/*
+ * 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     6638712 6730468
+ * @author  mcimadamore
+ * @summary Inference with wildcard types causes selection of inapplicable method
+ * @compile/fail/ref=T6638712d.out -XDrawDiagnostics T6638712d.java
+ */
+
+import java.util.*;
+
+public class T6638712d {
+
+    <U> U m(U u, List<List<U>> list) { return null; }
+
+    void test(List<List<String>> lls) {
+        m(1, lls);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712d.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+T6638712d.java:39:9: compiler.err.cant.apply.symbol: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, null
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712e.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,43 @@
+/*
+ * 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     6638712 6795689
+ * @author  mcimadamore
+ * @summary Inference with wildcard types causes selection of inapplicable method
+ * @compile/fail/ref=T6638712e.out -XDrawDiagnostics T6638712e.java
+ */
+
+class T6638712e {
+
+    static class Foo<A, B> {
+        <X> Foo<X, B> m(Foo<? super X, ? extends A> foo) { return null;}
+    }
+
+    static class Test {
+        Foo<Object, String> test(Foo<Boolean, String> foo1, Foo<Boolean, Boolean> foo2) {
+             return foo1.m(foo2);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/6638712/T6638712e.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+T6638712e.java:40:27: compiler.err.invalid.inferred.types: X, (compiler.misc.inferred.do.not.conform.to.params: T6638712e.Foo<? super java.lang.Object,? extends java.lang.Boolean>, T6638712e.Foo<java.lang.Boolean,java.lang.Boolean>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/T6835428.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * 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 6835428
+ * @author mcimadamore
+ * @summary regression: return-type inference rejects valid code
+ * @compile T6835428.java
+ */
+
+class T6835428<T> {
+    interface X<T> {}
+   <T extends Comparable<? super T>> T6835428<X<T>> m() { return null; }
+   <T extends Comparable<? super T>> void test() {
+      T6835428<X<T>> t = m();
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/meth/InvokeMH_BAD68.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2008 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 6754038
+ * ##summary Generate call sites for method handle
+ * ##author jrose
+ *
+ * ##compile/fail -source 7 -target 7 InvokeMH_BAD68.java
+ */
+
+/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
+ * $ (cd make; make)
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH_BAD68.java
+ * $ javap -c -classpath dist meth.InvokeMH_BAD68
+ * </code>
+ */
+
+package meth;
+
+import java.dyn.MethodHandle;
+
+public class InvokeMH_BAD68 {
+    void test(MethodHandle mh_SiO,
+              MethodHandle mh_vS,
+              MethodHandle mh_vi,
+              MethodHandle mh_vv) {
+        Object o; String s; int i;  // for return type testing
+
+        // next five must have sig = (String,int)Object
+        mh_SiO.invoke("world", 123);
+        mh_SiO.invoke("mundus", 456);
+        Object k = "kosmos";
+        mh_SiO.invoke((String)k, 789);
+        o = mh_SiO.invoke((String)null, 000);
+        o = mh_SiO.<Object>invoke("arda", -123);
+
+        // sig = ()String
+        s = mh_vS.<String>invoke();
+
+        // sig = ()int
+        i = mh_vi.<int>invoke();
+        o = mh_vi.<int>invoke();
+    s = mh_vi.<int>invoke(); //BAD
+        mh_vi.<int>invoke();
+
+        // sig = ()void
+        //o = mh_vv.<void>invoke(); //BAD
+        mh_vv.<void>invoke();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/meth/InvokeMH_BAD72.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2008 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 6754038
+ * ##summary Generate call sites for method handle
+ * ##author jrose
+ *
+ * ##compile/fail -source 7 -target 7 InvokeMH_BAD72.java
+ */
+
+/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
+ * $ (cd make; make)
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH_BAD72.java
+ * $ javap -c -classpath dist meth.InvokeMH_BAD72
+ * </code>
+ */
+
+package meth;
+
+import java.dyn.MethodHandle;
+
+public class InvokeMH_BAD72 {
+    void test(MethodHandle mh_SiO,
+              MethodHandle mh_vS,
+              MethodHandle mh_vi,
+              MethodHandle mh_vv) {
+        Object o; String s; int i;  // for return type testing
+
+        // next five must have sig = (String,int)Object
+        mh_SiO.invoke("world", 123);
+        mh_SiO.invoke("mundus", 456);
+        Object k = "kosmos";
+        mh_SiO.invoke((String)k, 789);
+        o = mh_SiO.invoke((String)null, 000);
+        o = mh_SiO.<Object>invoke("arda", -123);
+
+        // sig = ()String
+        s = mh_vS.<String>invoke();
+
+        // sig = ()int
+        i = mh_vi.<int>invoke();
+        o = mh_vi.<int>invoke();
+        //s = mh_vi.<int>invoke(); //BAD
+        mh_vi.<int>invoke();
+
+        // sig = ()void
+    o = mh_vv.<void>invoke(); //BAD
+        mh_vv.<void>invoke();
+    }
+}
--- a/langtools/test/tools/javac/processing/6348499/T6348499.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/test/tools/javac/processing/6348499/T6348499.java	Tue Jul 21 13:02:23 2009 -0700
@@ -54,6 +54,7 @@
             fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
         Iterable<String> opts = Arrays.asList("-proc:only",
                                               "-processor", "A",
+                                              "-source", "1.6",
                                               "-processorpath", testClasses);
         StringWriter out = new StringWriter();
         JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
--- a/langtools/test/tools/javac/processing/6414633/T6414633.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/test/tools/javac/processing/6414633/T6414633.java	Tue Jul 21 13:02:23 2009 -0700
@@ -55,6 +55,7 @@
             fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java")));
         String[] opts = { "-proc:only",
                           "-processor", A.class.getName(),
+                          "-source", "1.6",
                           "-classpath", testClasses };
         JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files);
         task.call();
--- a/langtools/test/tools/javac/processing/6430209/T6430209.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/test/tools/javac/processing/6430209/T6430209.java	Tue Jul 21 13:02:23 2009 -0700
@@ -63,6 +63,7 @@
             new File(testSrc, "test0.java"), new File(testSrc, "test1.java")));
         Iterable<String> opts = Arrays.asList("-proc:only",
                                               "-processor", "b6341534",
+                                              "-source", "1.6",
                                               "-processorpath", testClasses);
         StringWriter out = new StringWriter();
         JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
--- a/langtools/test/tools/javac/processing/T6439826.java	Wed Jul 15 10:46:42 2009 -0700
+++ b/langtools/test/tools/javac/processing/T6439826.java	Tue Jul 21 13:02:23 2009 -0700
@@ -49,7 +49,8 @@
         StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
         Iterable<? extends JavaFileObject> files =
             fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java")));
-        Iterable<String> opts = Arrays.asList("-proc:only",
+        Iterable<String> opts = Arrays.asList("-source","1.6",
+                                              "-proc:only",
                                               "-processor", "T6439826",
                                               "-processorpath", testClasses);
         StringWriter out = new StringWriter();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/type/MirroredTypeEx/NpeTest.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,42 @@
+/*
+ * 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     6593082
+ * @summary MirroredTypeException constructor should not accept null
+ * @author  Joseph D. Darcy
+ */
+
+import javax.lang.model.type.*;
+
+public class NpeTest  {
+    public static void main(String... args) {
+        try {
+            MirroredTypeException mte = new MirroredTypeException(null);
+            throw new RuntimeException("Expected NPE not thrown.");
+        } catch (NullPointerException npe) {
+            ; // success
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/quid/QuotedIdent_BAD61.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2008 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 6746458
+ * ##summary Verify correct lexing of quoted identifiers.
+ * ##author jrose
+ *
+ * ##library ..
+ * ##run main quid.QuotedIdent_BAD61
+ */
+
+/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
+ * $ (cd make; make)
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD61.java
+ * $ java -version  # should print 1.6 or later
+ * $ java -cp dist quid.QuotedIdent_BAD61
+ * </code>
+ */
+
+package quid;
+
+public class QuotedIdent_BAD61 {
+    static void check(int testid, String have, String expect)
+                throws RuntimeException {
+        if ((have == null && have != expect) ||
+                (have != null && !have.equals(expect))) {
+            String msg =
+                "TEST " + testid + ": HAVE \"" +
+                have + "\" EXPECT \"" + expect + "\"";
+            System.out.println("StringConversion: " + msg);
+            throw new RuntimeException(msg);
+        }
+    }
+
+    // negative tests:
+    static class #"" { } //BAD empty ident name
+    //static class #"<foo>" { } //BAD bad char in ident name
+    /*static class /*(//BAD ident name interrupted by newline) #"jump:
+    " { } /* uncomment previous line to attempt class w/ bad name */
+
+    static class #"int" extends Number {
+        final int #"int";
+        #"int"(int #"int") {
+            this.#"int" = #"int";
+        }
+        static #"int" valueOf(int #"int") {
+            return new #"int"(#"int");
+        }
+        public int intValue() { return #"int"; }
+        public long longValue() { return #"int"; }
+        public float floatValue() { return #"int"; }
+        public double doubleValue() { return #"int"; }
+        public String toString() { return String.valueOf(#"int"); }
+    }
+
+    class #"*86" {
+        String #"555-1212"() { return "[*86.555-1212]"; }
+    }
+    static#"*86"#"MAKE-*86"() {   // note close spacing
+        return new QuotedIdent_BAD61().new#"*86"();
+    }
+
+    static String bar() { return "[bar]"; }
+
+    public static void main(String[] args) throws Exception {
+        String s;
+
+        String #"sticky \' wicket" = "wicked ' stick";
+        s = #"sticky ' wicket";
+        check(11, s, "wicked \' stick");
+        check(12, #"s", s);
+        check(13, #"\163", s);
+
+        s = #"QuotedIdent_BAD61".bar();
+        check(21, s, "[bar]");
+
+        s = #"int".valueOf(123).toString();
+        check(22, s, "123");
+
+        s = #"MAKE-*86"().#"555-1212"();
+        check(23, s, "[*86.555-1212]");
+
+        class#"{{{inmost}}}" { }
+        s = new#"{{{inmost}}}"().getClass().getName();
+        if (!s.endsWith("{{{inmost}}}"))
+            check(24, s, "should end with \"{{{inmost}}}\"");
+
+        s = #"Yog-Shoggoth".#"(nameless ululation)";
+        check(25, s, "Tekeli-li!");
+
+        s = #"int".class.getName();
+        check(31, s, QuotedIdent_BAD61.class.getName()+"$int");
+
+        Class x86 = Class.forName(QuotedIdent_BAD61.class.getName()+"$*86");
+        if (x86 != #"*86".class)
+            check(32, "reflected "+x86, "static "+#"*86".class);
+
+        s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
+        check(31, s, "[*86.555-1212]");
+
+        System.out.println("OK");
+    }
+}
+
+interface #"Yog-Shoggoth" {
+    final String #"(nameless ululation)" = "Tekeli-li!";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/quid/QuotedIdent_BAD62.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2008 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 6746458
+ * ##summary Verify correct lexing of quoted identifiers.
+ * ##author jrose
+ *
+ * ##library ..
+ * ##run main quid.QuotedIdent_BAD62
+ */
+
+/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
+ * $ (cd make; make)
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD62.java
+ * $ java -version  # should print 1.6 or later
+ * $ java -cp dist quid.QuotedIdent_BAD62
+ * </code>
+ */
+
+package quid;
+
+public class QuotedIdent_BAD62 {
+    static void check(int testid, String have, String expect)
+                throws RuntimeException {
+        if ((have == null && have != expect) ||
+                (have != null && !have.equals(expect))) {
+            String msg =
+                "TEST " + testid + ": HAVE \"" +
+                have + "\" EXPECT \"" + expect + "\"";
+            System.out.println("StringConversion: " + msg);
+            throw new RuntimeException(msg);
+        }
+    }
+
+    // negative tests:
+    //static class #"" { } //BAD empty ident name
+    static class #"<foo>" { } //BAD bad char in ident name
+    /*static class /*(//BAD ident name interrupted by newline) #"jump:
+    " { } /* uncomment previous line to attempt class w/ bad name */
+
+    static class #"int" extends Number {
+        final int #"int";
+        #"int"(int #"int") {
+            this.#"int" = #"int";
+        }
+        static #"int" valueOf(int #"int") {
+            return new #"int"(#"int");
+        }
+        public int intValue() { return #"int"; }
+        public long longValue() { return #"int"; }
+        public float floatValue() { return #"int"; }
+        public double doubleValue() { return #"int"; }
+        public String toString() { return String.valueOf(#"int"); }
+    }
+
+    class #"*86" {
+        String #"555-1212"() { return "[*86.555-1212]"; }
+    }
+    static#"*86"#"MAKE-*86"() {   // note close spacing
+        return new QuotedIdent_BAD62().new#"*86"();
+    }
+
+    static String bar() { return "[bar]"; }
+
+    public static void main(String[] args) throws Exception {
+        String s;
+
+        String #"sticky \' wicket" = "wicked ' stick";
+        s = #"sticky ' wicket";
+        check(11, s, "wicked \' stick");
+        check(12, #"s", s);
+        check(13, #"\163", s);
+
+        s = #"QuotedIdent_BAD62".bar();
+        check(21, s, "[bar]");
+
+        s = #"int".valueOf(123).toString();
+        check(22, s, "123");
+
+        s = #"MAKE-*86"().#"555-1212"();
+        check(23, s, "[*86.555-1212]");
+
+        class#"{{{inmost}}}" { }
+        s = new#"{{{inmost}}}"().getClass().getName();
+        if (!s.endsWith("{{{inmost}}}"))
+            check(24, s, "should end with \"{{{inmost}}}\"");
+
+        s = #"Yog-Shoggoth".#"(nameless ululation)";
+        check(25, s, "Tekeli-li!");
+
+        s = #"int".class.getName();
+        check(31, s, QuotedIdent_BAD62.class.getName()+"$int");
+
+        Class x86 = Class.forName(QuotedIdent_BAD62.class.getName()+"$*86");
+        if (x86 != #"*86".class)
+            check(32, "reflected "+x86, "static "+#"*86".class);
+
+        s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
+        check(31, s, "[*86.555-1212]");
+
+        System.out.println("OK");
+    }
+}
+
+interface #"Yog-Shoggoth" {
+    final String #"(nameless ululation)" = "Tekeli-li!";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/quid/QuotedIdent_BAD63.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2008 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 6746458
+ * ##summary Verify correct lexing of quoted identifiers.
+ * ##author jrose
+ *
+ * ##library ..
+ * ##run main quid.QuotedIdent_BAD63
+ */
+
+/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
+ * $ (cd make; make)
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/quid/QuotedIdent_BAD63.java
+ * $ java -version  # should print 1.6 or later
+ * $ java -cp dist quid.QuotedIdent_BAD63
+ * </code>
+ */
+
+package quid;
+
+public class QuotedIdent_BAD63 {
+    static void check(int testid, String have, String expect)
+                throws RuntimeException {
+        if ((have == null && have != expect) ||
+                (have != null && !have.equals(expect))) {
+            String msg =
+                "TEST " + testid + ": HAVE \"" +
+                have + "\" EXPECT \"" + expect + "\"";
+            System.out.println("StringConversion: " + msg);
+            throw new RuntimeException(msg);
+        }
+    }
+
+    // negative tests:
+    //static class #"" { } //BAD empty ident name
+    //static class #"<foo>" { } //BAD bad char in ident name
+    static class /*(//BAD ident name interrupted by newline) #"jump:
+    " { } /* uncomment previous line to attempt class w/ bad name */
+
+    static class #"int" extends Number {
+        final int #"int";
+        #"int"(int #"int") {
+            this.#"int" = #"int";
+        }
+        static #"int" valueOf(int #"int") {
+            return new #"int"(#"int");
+        }
+        public int intValue() { return #"int"; }
+        public long longValue() { return #"int"; }
+        public float floatValue() { return #"int"; }
+        public double doubleValue() { return #"int"; }
+        public String toString() { return String.valueOf(#"int"); }
+    }
+
+    class #"*86" {
+        String #"555-1212"() { return "[*86.555-1212]"; }
+    }
+    static#"*86"#"MAKE-*86"() {   // note close spacing
+        return new QuotedIdent_BAD63().new#"*86"();
+    }
+
+    static String bar() { return "[bar]"; }
+
+    public static void main(String[] args) throws Exception {
+        String s;
+
+        String #"sticky \' wicket" = "wicked ' stick";
+        s = #"sticky ' wicket";
+        check(11, s, "wicked \' stick");
+        check(12, #"s", s);
+        check(13, #"\163", s);
+
+        s = #"QuotedIdent_BAD63".bar();
+        check(21, s, "[bar]");
+
+        s = #"int".valueOf(123).toString();
+        check(22, s, "123");
+
+        s = #"MAKE-*86"().#"555-1212"();
+        check(23, s, "[*86.555-1212]");
+
+        class#"{{{inmost}}}" { }
+        s = new#"{{{inmost}}}"().getClass().getName();
+        if (!s.endsWith("{{{inmost}}}"))
+            check(24, s, "should end with \"{{{inmost}}}\"");
+
+        s = #"Yog-Shoggoth".#"(nameless ululation)";
+        check(25, s, "Tekeli-li!");
+
+        s = #"int".class.getName();
+        check(31, s, QuotedIdent_BAD63.class.getName()+"$int");
+
+        Class x86 = Class.forName(QuotedIdent_BAD63.class.getName()+"$*86");
+        if (x86 != #"*86".class)
+            check(32, "reflected "+x86, "static "+#"*86".class);
+
+        s = (String) x86.getDeclaredMethod("555-1212").invoke(#"MAKE-*86"());
+        check(31, s, "[*86.555-1212]");
+
+        System.out.println("OK");
+    }
+}
+
+interface #"Yog-Shoggoth" {
+    final String #"(nameless ululation)" = "Tekeli-li!";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/InnerClass.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * 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 6843077
+ * @summary compiler crashes when visiting inner classes
+ * @author Mahmood Ali
+ * @compile -source 1.7 InnerClass.java
+ */
+
+class InnerClass {
+    private void a() {
+        new Object() {
+            public <R> void method() { }
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/MultipleTargets.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check that type annotations may appear on void method if it is a
+ *          method annotation too.
+ * @author Mahmood Ali
+ * @compile -source 1.7 MultipleTargets.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class TypeUseTarget<K extends @A Object> {
+  @A void voidMethod() { }
+}
+
+@Target({ElementType.TYPE_USE, ElementType.METHOD})
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/TypeParameterTarget.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check that type annotations may appear on all type parameter
+ * @author Mahmood Ali
+ * @compile -source 1.7 TypeParameterTarget.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class TypeUseTarget<@A K extends Object> {
+  String[] field;
+
+  <@A K, @A V> String genericMethod(K k) { return null; }
+}
+
+interface MyInterface { }
+
+@interface MyAnnotation { }
+
+@Target(ElementType.TYPE_PARAMETER)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/TypeUseTarget.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check that type annotations may appear on all type declarations
+ * @author Mahmood Ali
+ * @compile -source 1.7 TypeUseTarget.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+@A
+class TypeUseTarget<K extends @A Object> {
+  @A String @A [] field;
+
+  @A String test(@A String param, @A String @A ... vararg) @A {
+    @A Object o = new @A String @A [3];
+    TypeUseTarget<@A String> target;
+    return (@A String) null;
+  }
+
+  <K> @A String genericMethod(K k) { return null; }
+}
+
+@A
+interface MyInterface { }
+
+@A
+@interface MyAnnotation { }
+
+@Target(ElementType.TYPE_USE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/attribution/Scopes.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test scopes of attribution
+ * @author Mahmood Ali
+ * @compile -source 1.7 Scopes.java
+ */
+class Scopes {
+
+  void test() @A(VALUE) { }
+  void test1() @A(value=VALUE) { }
+
+  private static final int VALUE = 1;
+  @interface A { int value(); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test that only java 7 allows type annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=AnnotationVersion.out -XDrawDiagnostics -source 1.6 AnnotationVersion.java
+ */
+class AnnotationVersion {
+  public void method() @A { }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/AnnotationVersion.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+AnnotationVersion.java:32:25: compiler.err.type.annotations.not.supported.in.source: 1.6
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test incomplete array declaration
+ * @author Mahmood Ali
+ * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics -source 1.7 IncompleteArray.java
+ */
+class IncompleteArray {
+  int @A [] @A var;
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/IncompleteArray.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+IncompleteArray.java:32:13: compiler.err.illegal.start.of.type
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test incomplete vararg declaration
+ * @author Mahmood Ali
+ * @compile/fail/ref=IncompleteVararg.out -XDrawDiagnostics -source 1.7 IncompleteVararg.java
+ */
+class IncompleteArray {
+  // the last variable may be vararg
+  void method(int @A test) { }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/IncompleteVararg.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+IncompleteVararg.java:33:19: compiler.err.illegal.start.of.type
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test indexing of an array
+ * @author Mahmood Ali
+ * @compile/fail/ref=IndexArray.out -XDrawDiagnostics -source 1.7 IndexArray.java
+ */
+class IndexArray {
+  int[] var;
+  int a = var @A [1];
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/IndexArray.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+IndexArray.java:33:15: compiler.err.illegal.start.of.expr
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/LintCast.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2008 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.
+ */
+
+import java.util.List;
+
+/*
+ * @test
+ * @bug 6843077
+ * @summary test that compiler doesn't warn about annotated redundant casts
+ * @author Mahmood Ali
+ * @compile/ref=LintCast.out -Xlint:cast -XDrawDiagnostics -source 1.7 LintCast.java
+ */
+class LintCast {
+    void unparameterized() {
+        String s = "m";
+        String s1 = (String)s;
+        String s2 = (@A String)s;
+    }
+
+    void parameterized() {
+        List<String> l = null;
+        List<String> l1 = (List<String>)l;
+        List<String> l2 = (List<@A String>)l;
+    }
+
+    void array() {
+        int @A [] a = null;
+        int[] a1 = (int[])a;
+        int[] a2 = (int @A [])a;
+    }
+
+    void sameAnnotations() {
+        @A String annotated = null;
+        String unannotated = null;
+
+        // compiler ignore annotated casts even if redundant
+        @A String anno1 = (@A String)annotated;
+
+        // warn if redundant without an annotation
+        String anno2 = (String)annotated;
+        String unanno2 = (String)unannotated;
+    }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/LintCast.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,6 @@
+LintCast.java:36:21: compiler.warn.redundant.cast: java.lang.String
+LintCast.java:42:27: compiler.warn.redundant.cast: java.util.List<java.lang.String>
+LintCast.java:48:20: compiler.warn.redundant.cast: int[]
+LintCast.java:60:24: compiler.warn.redundant.cast: java.lang.String
+LintCast.java:61:26: compiler.warn.redundant.cast: java.lang.String
+5 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/OldArray.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test old array syntax
+ * @author Mahmood Ali
+ * @compile/fail -XDrawDiagnostics -source 1.7 OldArray.java
+ */
+class OldArray {
+  String [@A]  s() { return null; }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/Scopes.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check that A is accessible in the class type parameters
+ * @author Mahmood Ali
+ * @compile/fail/ref=Scopes.out -XDrawDiagnostics -source 1.7 Scopes.java
+ */
+class Scopes<T extends @UniqueInner Object> {
+  @interface UniqueInner { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/Scopes.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+Scopes.java:31:25: compiler.err.cant.resolve: kindname.class, UniqueInner, , 
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary static field access isn't a valid location
+ * @author Mahmood Ali
+ * @compile/fail/ref=StaticFields.out -XDrawDiagnostics -source 1.7 StaticFields.java
+ */
+class C {
+  int f;
+  int a = @A C.f;
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/StaticFields.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+StaticFields.java:33:17: compiler.err.illegal.start.of.expr
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary static methods don't have receivers
+ * @author Mahmood Ali
+ * @compile/fail/ref=StaticMethods.out -XDrawDiagnostics -source 1.7 StaticMethods.java
+ */
+class StaticMethods {
+  static void main() @A { }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/StaticMethods.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+StaticMethods.java:32:22: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/VoidGenericMethod.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test type annotation on void generic methods
+ * @author Mahmood Ali
+ * @compile/fail -source 1.7 VoidGenericMethod.java
+ */
+class VoidGenericMethod {
+  public <T> @A void method() { }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotation values
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue {
+  void test() {
+    Object a = String @A(value = 2, value = 1) [].class;
+  }
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:45: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnnotation {
+  void test() {
+    Object a = String @A @A [].class;
+  }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:34:26: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+
+class InvalidLocation {
+  void test() {
+    Object a = String @A [].class;
+  }
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:34:23: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void test() {
+    Object a = String @A [].class;
+  }
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrayclass/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:23: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotation values
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue {
+  void test() {
+    String @A(value = 2, value = 1) [] s;
+  }
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:34: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnnotation {
+  void test() {
+    String @A @A [] s;
+  }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:34:15: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+
+class InvalidLocation {
+  void test() {
+    String @A [] s;
+  }
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:34:12: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void test() {
+    String @A [] s;
+  }
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/arrays/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:12: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue {
+  void method() {
+    class Inner<@A(value = 2, value = 1) K> {}
+  }
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:39: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+class DuplicateTypeAnno {
+  void innermethod() {
+    class Inner<@A @A K> { }
+  }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:33:20: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+class InvalidLocation {
+  void innermethod() {
+    class Inner<@A K> {}
+  }
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:33:17: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void innermethod() {
+    class Inner<@A K> { }
+  }
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/innertypeparams/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:17: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotation values
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue {
+  void test() {
+    String[] a = new String @A(value = 2, value = 1) [5] ;
+  }
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:51: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnnotation {
+  void test() {
+    String[] a = new String @A @A [5] ;
+  }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:34:32: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+
+class InvalidLocation {
+  void test() {
+    String[] s = new String @A [5] ;
+  }
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:34:29: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void test() {
+    String[] a = new String @A [5];
+  }
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/newarray/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:29: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue<K extends @A(value = 2, value = 1) Object> {
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:31:64: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnno<K extends @A @A Object> {
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:32:38: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+
+class InvalidLocation<K extends @A Object> {
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:32:33: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<K extends @A Object> {
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/parambounds/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:31:40: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotation values in receiver
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue {
+  void test() @A(value = 2, value = 1) { }
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:32:37: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations in receiver
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnnotation {
+  void test() @A @A { }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:33:18: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+
+class InvalidLocation {
+  void test() @A {
+  }
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:33:15: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void test() @A { }
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/receiver/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:32:15: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for Duplicate annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue {
+  void test() {
+    new @A String();
+  }
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:33:9: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnnotation {
+  void test() {
+    new @A @A String();
+  }
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:34:12: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+
+class InvalidLocation {
+  void test() {
+    new @A String();
+  }
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:34:9: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue {
+  void test() {
+    new @A String();
+  }
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/rest/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:33:9: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue<K> {
+  DuplicateAnnotationValue<@A(value = 2, value = 1) String> l;
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:32:50: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnno<K> {
+  DuplicateTypeAnno<@A @A String> l;
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:33:24: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+
+class InvalidLocation<K> {
+  InvalidLocation<@A String> l;
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:33:19: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<K> {
+  MissingAnnotationValue<@A String> l;
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeArgs/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:32:26: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue<@A(value = 2, value = 1) K> {
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:31:54: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnno<@A @A K> {
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:32:28: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+
+class InvalidLocation<@A K> {
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:32:23: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<@A K> {
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/typeparams/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:31:30: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotation values for type parameter
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateAnnotationValue.out -XDrawDiagnostics -source 1.7 DuplicateAnnotationValue.java
+ */
+class DuplicateAnnotationValue<K> {
+  DuplicateAnnotationValue<@A(value = 2, value = 1) ?> l;
+}
+
+@interface A { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateAnnotationValue.java:32:50: compiler.err.duplicate.annotation.member.value: value, A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for duplicate annotations
+ * @author Mahmood Ali
+ * @compile/fail/ref=DuplicateTypeAnnotation.out -XDrawDiagnostics -source 1.7 DuplicateTypeAnnotation.java
+ */
+
+class DuplicateTypeAnno<K> {
+  DuplicateTypeAnno<@A @A ?> l;
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/DuplicateTypeAnnotation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+DuplicateTypeAnnotation.java:33:24: compiler.err.duplicate.annotation
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for invalid annotatins given the target
+ * @author Mahmood Ali
+ * @compile/fail/ref=InvalidLocation.out -XDrawDiagnostics -source 1.7 InvalidLocation.java
+ */
+
+class InvalidLocation<K> {
+  InvalidLocation<@A ?> l;
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/InvalidLocation.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+InvalidLocation.java:33:19: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary check for missing annotation value
+ * @author Mahmood Ali
+ * @compile/fail/ref=MissingAnnotationValue.out -XDrawDiagnostics -source 1.7 MissingAnnotationValue.java
+ */
+class MissingAnnotationValue<K> {
+  MissingAnnotationValue<@A ?> l;
+}
+
+@interface A { int field(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/common/wildcards/MissingAnnotationValue.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+MissingAnnotationValue.java:32:26: compiler.err.annotation.missing.default.value: A, field
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=Constructor.out -XDrawDiagnostics -source 1.7 Constructor.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class Constructor {
+  @A Constructor() { }
+}
+
+@Target(ElementType.TYPE_USE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/Constructor.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+Constructor.java:36:3: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test incomplete array declaration
+ * @author Mahmood Ali
+ * @compile/fail/ref=IncompleteArray.out -XDrawDiagnostics -source 1.7 IncompleteArray.java
+ */
+class IncompleteArray {
+  int @A [] @A var;
+}
+
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/IncompleteArray.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+IncompleteArray.java:32:13: compiler.err.illegal.start.of.type
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=NotTypeParameter.out -XDrawDiagnostics -source 1.7 NotTypeParameter.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod<@A K> {
+  @A void test() { }
+}
+
+@Target(ElementType.TYPE_USE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeParameter.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,3 @@
+NotTypeParameter.java:36:3: compiler.err.annotation.type.not.applicable
+NotTypeParameter.java:35:18: compiler.err.annotation.type.not.applicable
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=NotTypeUse.out -XDrawDiagnostics -source 1.7 NotTypeUse.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod {
+  @A void test() { }
+}
+
+@Target(ElementType.TYPE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/NotTypeUse.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+NotTypeUse.java:36:3: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary test invalid location of TypeUse
+ * @author Mahmood Ali
+ * @compile/fail/ref=VoidMethod.out -XDrawDiagnostics -source 1.7 VoidMethod.java
+ */
+
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+class VoidMethod {
+  @A void test() { }
+}
+
+@Target(ElementType.TYPE_USE)
+@interface A { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/failures/target/VoidMethod.out	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,2 @@
+VoidMethod.java:36:3: compiler.err.annotation.type.not.applicable
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/BasicTest.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,75 @@
+
+/*
+ * Copyright 2008 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 6843077
+ * @summary random tests for new locations
+ * @author Matt Papi
+ * @compile -source 1.7 BasicTest.java
+ */
+
+import java.util.*;
+import java.io.*;
+
+@interface A {}
+@interface B {}
+@interface C {}
+@interface D {}
+
+/**
+ * Tests basic JSR 308 parser functionality. We don't really care about what
+ * the parse tree looks like, just that these annotations can be parsed.
+ */
+class BasicTest<T extends @A Object> extends @B LinkedList<T> implements @C List<T> {
+
+    void test() {
+
+        // Handle annotated class literals/cast types
+        Class<?> c = @A String.class;
+        Object o = (@A Object) "foo";
+
+        // Handle annotated "new" expressions (except arrays; see ArrayTest)
+        String s = new @A String("bar");
+
+        boolean b = o instanceof @A Object;
+
+
+        @A Map<@B List<@C String>, @D String> map =
+            new @A HashMap<@B List<@C String>, @D String>();
+
+        Class<? extends @A String> c2 = @A String.class;
+    }
+
+    // Handle receiver annotations
+    // Handle annotations on a qualified identifier list
+    void test2() @C @D throws @A IllegalArgumentException, @B IOException {
+
+    }
+
+    // Handle annotations on a varargs element type
+    void test3(Object @A... objs) {
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/ClassExtends.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: class extends/implements
+ * @author Mahmood Ali
+ * @compile -source 1.7 ClassExtends.java
+ */
+abstract class MyClass extends @A ParameterizedClass<@B String>
+  implements @B CharSequence, @A ParameterizedInterface<@B String> { }
+
+interface MyInterface extends @A ParameterizedInterface<@A String>,
+                              @B CharSequence { }
+
+class ParameterizedClass<K> {}
+interface ParameterizedInterface<K> {}
+@interface A {}
+@interface B {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/ClassLiterals.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: class literals
+ * @author Mahmood Ali
+ * @compile -source 1.7 ClassLiterals.java
+ */
+
+class ClassLiterals {
+
+  public static void main(String[] args) {
+    if (String.class != @A String.class) throw new Error();
+    if (@A int.class != int.class) throw new Error();
+    if (@A int.class != Integer.TYPE) throw new Error();
+    if (@A int @B(0) [].class != int[].class) throw new Error();
+
+    if (String[].class != @A String[].class) throw new Error();
+    if (String[].class != String @A [].class) throw new Error();
+    if (@A int[].class != int[].class) throw new Error();
+    if (@A int @B(0) [].class != int[].class) throw new Error();
+  }
+}
+
+@interface A {}
+@interface B { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/ClassParameters.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: class type parameter bounds
+ * @author Mahmood Ali
+ * @compile -source 1.7 ClassParameters.java
+ */
+class Unannotated<K> { }
+
+class ExtendsBound<K extends @A String> { }
+class ExtendsGeneric<K extends @A Unannotated<@B String>> { }
+class TwoBounds<K extends @A String, V extends @B String> { }
+
+class Complex1<K extends @A String&Runnable> { }
+class Complex2<K extends String & @B Runnable> { }
+class ComplexBoth<K extends @A String & @A Runnable> { }
+
+class Outer {
+  void inner() {
+    class Unannotated<K> { }
+
+    class ExtendsBound<K extends @A String> { }
+    class ExtendsGeneric<K extends @A Unannotated<@B String>> { }
+    class TwoBounds<K extends @A String, V extends @B String> { }
+
+    class Complex1<K extends @A String&Runnable> { }
+    class Complex2<K extends String & @B Runnable> { }
+    class ComplexBoth<K extends @A String & @A Runnable> { }
+  }
+}
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/ConstructorTypeArgs.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: constructor type args
+ * @author Mahmood Ali
+ * @compile -source 1.7 ConstructorTypeArgs.java
+ */
+
+class ConstructorTypeArgs {
+  void oneArg() {
+    new @A MyList<@A String>();
+    new MyList<@A MyList<@B(0) String>>();
+  }
+
+  void twoArg() {
+    new MyMap<String, String>();
+    new MyMap<@A String, @B(0) MyList<@A String>>();
+  }
+
+  void withArraysIn() {
+    new MyList<String[]>();
+    new MyList<@A String @B(0) [] @A []>();
+
+    new MyMap<@A String[], @B(0) MyList<@A String> @A []>();
+  }
+}
+
+class MyList<E> { }
+class MyMap<K, V> { }
+
+@interface A { }
+@interface B { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/Expressions.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: expressions
+ * @author Mahmood Ali
+ * @compile -source 1.7 Expressions.java
+ */
+class Expressions {
+  void instanceOf() {
+    Object o = null;
+    boolean a = o instanceof @A String;
+    boolean b = o instanceof @B(0) String;
+  }
+
+  void instanceOfArray() {
+    Object o = null;
+    boolean a1 = o instanceof @A String [];
+    boolean a2 = o instanceof @B(0) String [];
+
+    boolean b1 = o instanceof String @A [];
+    boolean b2 = o instanceof String @B(0) [];
+  }
+
+  void objectCreation() {
+    new @A String();
+    new @B(0) String();
+  }
+
+  void objectCreationArray() {
+    Object a1 = new @A String [] [] { };
+    Object a2 = new @A String [1] [];
+    Object a3 = new @A String [1] [2];
+
+    Object b1 = new @A String @B(0) [] [] { };
+    Object b2 = new @A String @B(0) [1] [];
+    Object b3 = new @A String @B(0) [1] [2];
+
+    Object c1 = new @A String []  @B(0) [] { };
+    Object c2 = new @A String [1] @B(0) [];
+    Object c3 = new @A String [1] @B(0) [2];
+
+    Object d1 = new @A String @B(0) []  @B(0) [] { };
+    Object d2 = new @A String @B(0) [1] @B(0) [];
+    Object d3 = new @A String @B(0) [1] @B(0) [2];
+
+    Object rand = new @A String @B(value = 0) [1] @B(value = 0) [2];
+
+  }
+}
+
+@interface A { }
+@interface B { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/Fields.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: field type array/generics
+ * @author Mahmood Ali
+ * @compile -source 1.7 Fields.java
+ */
+
+class DefaultScope {
+  Parameterized<String, String> unannotated;
+  Parameterized<@A String, String> firstTypeArg;
+  Parameterized<String, @A String> secondTypeArg;
+  Parameterized<@A String, @B String> bothTypeArgs;
+
+  Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized;
+
+  @A String [] array1;
+  @A String @B [] array1Deep;
+  @A String [] [] array2;
+  @A String @A [] @B [] array2Deep;
+  String @A [] [] array2First;
+  String [] @B [] array2Second;
+}
+
+class ModifiedScoped {
+  public final Parameterized<String, String> unannotated = null;
+  public final Parameterized<@A String, String> firstTypeArg = null;
+  public final Parameterized<String, @A String> secondTypeArg = null;
+  public final Parameterized<@A String, @B String> bothTypeArgs = null;
+
+  public final Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized = null;
+
+  public final @A String [] array1 = null;
+  public final @A String @B [] array1Deep = null;
+  public final @A String [] [] array2 = null;
+  public final @A String @A [] @B [] array2Deep = null;
+  public final String @A [] [] array2First = null;
+  public final String [] @B [] array2Second = null;
+}
+
+class Parameterized<K, V> { }
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/LocalVariables.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: local variables array/generics
+ * @author Mahmood Ali
+ * @compile -source 1.7 LocalVariables.java
+ */
+
+class DefaultScope {
+  void parameterized() {
+    Parameterized<String, String> unannotated;
+    Parameterized<@A String, String> firstTypeArg;
+    Parameterized<String, @A String> secondTypeArg;
+    Parameterized<@A String, @B String> bothTypeArgs;
+
+    Parameterized<@A Parameterized<@A String, @B String>, @B String>
+      nestedParameterized;
+  }
+
+  void arrays() {
+    @A String [] array1;
+    @A String @B [] array1Deep;
+    @A String [] [] array2;
+    @A String @A [] @B [] array2Deep;
+    String @A [] [] array2First;
+    String [] @B [] array2Second;
+  }
+}
+
+class ModifiedVars {
+  void parameterized() {
+    final Parameterized<String, String> unannotated = null;
+    final Parameterized<@A String, String> firstTypeArg = null;
+    final Parameterized<String, @A String> secondTypeArg = null;
+    final Parameterized<@A String, @B String> bothTypeArgs = null;
+
+    final Parameterized<@A Parameterized<@A String, @B String>, @B String>
+      nestedParameterized = null;
+  }
+
+  void arrays() {
+    final @A String [] array1 = null;
+    final @A String @B [] array1Deep = null;
+    final @A String [] [] array2 = null;
+    final @A String @A [] @B [] array2Deep = null;
+    final String @A [] [] array2First = null;
+    final String [] @B [] array2Second = null;
+  }
+}
+
+class Parameterized<K, V> { }
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/MethodReturnType.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: method return type array/generics
+ * @author Mahmood Ali
+ * @compile -source 1.7 MethodReturnType.java
+ */
+
+class DefaultScope {
+  Parameterized<String, String> unannotated() { return null; }
+  Parameterized<@A String, String> firstTypeArg() { return null; }
+  Parameterized<String, @A String> secondTypeArg() { return null; }
+  Parameterized<@A String, @B String> bothTypeArgs() { return null; }
+
+  Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized() { return null; }
+
+  public <T> @A String method() { return null; }
+
+  @A String [] array1() { return null; }
+  @A String @B [] array1Deep() { return null; }
+  @A String [] [] array2() { return null; }
+  @A String @A [] @B [] array2Deep() { return null; }
+  String @A [] [] array2First() { return null; }
+  String [] @B [] array2Second() { return null; }
+}
+
+class ModifiedScoped {
+  public final Parameterized<String, String> unannotated() { return null; }
+  public final Parameterized<@A String, String> firstTypeArg() { return null; }
+  public final Parameterized<String, @A String> secondTypeArg() { return null; }
+  public final Parameterized<@A String, @B String> bothTypeArgs() { return null; }
+
+  public final Parameterized<@A Parameterized<@A String, @B String>, @B String>
+    nestedParameterized() { return null; }
+
+  public final @A String [] array1() { return null; }
+  public final @A String @B [] array1Deep() { return null; }
+  public final @A String [] [] array2() { return null; }
+  public final @A String @A [] @B [] array2Deep() { return null; }
+  public final String @A [] [] array2First() { return null; }
+  public final String [] @B [] array2Second() { return null; }
+}
+
+class Parameterized<K, V> { }
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeArgs.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: method type args
+ * @author Mahmood Ali
+ * @compile -source 1.7 MethodTypeArgs.java
+ */
+
+class MethodTypeArgs {
+  void oneArg() {
+    this.<@A String>newList();
+    this.<@A MyList<@B(0) String>>newList();
+
+    MethodTypeArgs.<@A String>newList();
+    MethodTypeArgs.<@A MyList<@B(0) String>>newList();
+  }
+
+  void twoArg() {
+    this.<String, String>newMap();
+    this.<@A String, @B(0) MyList<@A String>>newMap();
+
+    MethodTypeArgs.<String, String>newMap();
+    MethodTypeArgs.<@A String, @B(0) MyList<@A String>>newMap();
+  }
+
+  void withArraysIn() {
+    this.<String[]>newList();
+    this.<@A String @B(0) [] @A []>newList();
+
+    this.<@A String[], @B(0) MyList<@A String> @A []>newMap();
+  }
+
+  static <E> void newList() { }
+  static <K, V> void newMap() { }
+}
+
+class MyList<E> { }
+@interface A { }
+@interface B { int value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/MethodTypeParameters.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: method type parameter bounds
+ * @author Mahmood Ali
+ * @compile -source 1.7 MethodTypeParameters.java
+ */
+
+class UnscopedUnmodified {
+  <K extends @A String> void methodExtends() {}
+  <K extends @A Parameterized<@B String>> void nestedExtends() {}
+  <K extends @A String, V extends @A Parameterized<@B String>> void dual() {}
+  <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {}
+}
+
+class PublicModifiedMethods {
+  public final <K extends @A String> void methodExtends() {}
+  public final <K extends @A Parameterized<@B String>> void nestedExtends() {}
+  public final <K extends @A String, V extends @A Parameterized<@B String>> void dual() {}
+  public final <K extends String, V extends Parameterized<@B String>> void dualOneAnno() {}
+}
+
+class Parameterized<K> { }
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/Parameters.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: parameter type array/generics
+ * @author Mahmood Ali
+ * @compile -source 1.7 Parameters.java
+ */
+
+class Parameters {
+  void unannotated(Parameterized<String, String> a) {}
+  void firstTypeArg(Parameterized<@A String, String> a) {}
+  void secondTypeArg(Parameterized<String, @A String> a) {}
+  void bothTypeArgs(Parameterized<@A String, @B String> both) {}
+
+  void nestedParameterized(Parameterized<@A Parameterized<@A String, @B String>, @B String> a) {}
+
+  void array1(@A String [] a) {}
+  void array1Deep(@A String @B [] a) {}
+  void array2(@A String [] [] a) {}
+  void array2Deep(@A String @A [] @B [] a) {}
+  void array2First(String @A [] [] a) {}
+  void array2Second(String [] @B [] a) {}
+}
+
+class Parameterized<K, V> { }
+
+@interface A { }
+@interface B { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/Receivers.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: receivers
+ * @author Mahmood Ali
+ * @compile -source 1.7 Receivers.java
+ */
+class DefaultUnmodified {
+  void plain() @A { }
+  <T> void generic() @A { }
+  void withException() @A throws Exception { }
+  String nonVoid() @A { return null; }
+  <T extends Runnable> void accept(T r) @A throws Exception { }
+}
+
+class PublicModified {
+  public final void plain() @A { }
+  public final <T> void generic() @A { }
+  public final void withException() @A throws Exception { }
+  public final String nonVoid() @A { return null; }
+  public final <T extends Runnable> void accept(T r) @A throws Exception { }
+}
+
+class WithValue {
+  void plain() @B("m") { }
+  <T> void generic() @B("m") { }
+  void withException() @B("m") throws Exception { }
+  String nonVoid() @B("m") { return null; }
+  <T extends Runnable> void accept(T r) @B("m") throws Exception { }
+}
+
+@interface A {}
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/Throws.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: throw clauses
+ * @author Mahmood Ali
+ * @compile -source 1.7 Throws.java
+ */
+class DefaultUnmodified {
+  void oneException() throws @A Exception {}
+  void twoExceptions() throws @A RuntimeException, @A Exception {}
+}
+
+class PublicModified {
+  public final void oneException(String a) throws @A Exception {}
+  public final void twoExceptions(String a) throws @A RuntimeException, @A Exception {}
+}
+
+class WithValue {
+  void oneException() throws @B("m") Exception {}
+  void twoExceptions() throws @B(value="m") RuntimeException, @A Exception {}
+}
+
+@interface A {}
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/TypeCasts.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: type casts
+ * @author Mahmood Ali
+ * @compile -source 1.7 TypeCasts.java
+ */
+class TypeCasts {
+  void methodA() {
+    String s = (@A String) null;
+    Object o = (@A Class<@A String>) null;
+  }
+
+  void methodB() {
+    String s = (@B("m") String) null;
+    Object o = (@B("m") Class<@B("m") String>) null;
+  }
+}
+
+@interface A { }
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/TypeParameters.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: class and method type parameters
+ * @author Mahmood Ali
+ * @compile -source 1.7 TypeParameters.java
+ */
+
+class Unannotated<K> { }
+class OneAnnotated<@A K> { }
+class TwoAnnotated<@A K, @A V> { }
+class SecondAnnotated<K, @A V extends String> { }
+
+class TestMethods {
+  <K> void unannotated() { }
+  <@A K> void oneAnnotated() { }
+  <@A K, @B("m") V> void twoAnnotated() { }
+  <K, @A V extends @A String> void secondAnnotated() { }
+}
+
+class UnannotatedB<K> { }
+class OneAnnotatedB<@B("m") K> { }
+class TwoAnnotatedB<@B("m") K, @B("m") V> { }
+class SecondAnnotatedB<K, @B("m") V extends @B("m") String> { }
+
+@interface A { }
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/typeAnnotations/newlocations/Wildcards.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2008 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 6843077
+ * @summary new type annotation location: wildcard bound
+ * @author Mahmood Ali
+ * @compile -source 1.7 Wildcards.java
+ */
+class BoundTest {
+  void wcExtends(MyList<? extends @A String> l) { }
+  void wcSuper(MyList<? super @A String> l) { }
+
+  MyList<? extends @A String> returnWcExtends() { return null; }
+  MyList<? super @A String> returnWcSuper() { return null; }
+  MyList<? extends @A MyList<? super @B("m") String>> complex() { return null; }
+}
+
+class BoundWithValue {
+  void wcExtends(MyList<? extends @B("m") String> l) { }
+  void wcSuper(MyList<? super @B(value="m") String> l) { }
+
+  MyList<? extends @B("m") String> returnWcExtends() { return null; }
+  MyList<? super @B(value="m") String> returnWcSuper() { return null; }
+  MyList<? extends @B("m") MyList<? super @B("m") String>> complex() { return null; }
+}
+
+class SelfTest {
+  void wcExtends(MyList<@A ?> l) { }
+  void wcSuper(MyList<@A ?> l) { }
+
+  MyList<@A ?> returnWcExtends() { return null; }
+  MyList<@A ?> returnWcSuper() { return null; }
+  MyList<@A ? extends @A MyList<@B("m") ?>> complex() { return null; }
+}
+
+class SelfWithValue {
+  void wcExtends(MyList<@B("m") ?> l) { }
+  void wcSuper(MyList<@B(value="m") ?> l) { }
+
+  MyList<@B("m") ?> returnWcExtends() { return null; }
+  MyList<@B(value="m") ?> returnWcSuper() { return null; }
+  MyList<@B("m") ? extends MyList<@B("m") ? super String>> complex() { return null; }
+}
+
+class MyList<K> { }
+
+@interface A { }
+@interface B { String value(); }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/typeAnnotations/ClassLiterals.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,174 @@
+/*
+ * Copyright 2008 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test ClassLiterals
+ * @bug 6843077
+ * @summary test that all type annotations are present in the classfile
+ */
+
+public class ClassLiterals {
+    public static void main(String[] args) throws Exception {
+        new ClassLiterals().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf) {
+        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, String name, boolean visible) {
+        int index = cf.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = cf.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+      File f = new File("Testa.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.util.*;");
+        out.println("class Testa { ");
+        out.println("  @interface A { }");
+
+        out.println(" void test() {");
+        out.println("  Object a = @A String.class;");
+        out.println("  Object b = @A String @A [] @A [].class;");
+        out.println(" }");
+        out.println("}");
+
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+      int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 4;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/typeAnnotations/JSR175Annotations.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2008 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test JSR175Annotations
+ * @bug 6843077
+ * @summary test that only type annotations are recorded as such in classfile
+ */
+
+public class JSR175Annotations {
+    public static void main(String[] args) throws Exception {
+        new JSR175Annotations().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.lang.annotation.Retention;");
+        out.println("import java.lang.annotation.RetentionPolicy;");
+        out.println("abstract class Test { ");
+        out.println("  @Retention(RetentionPolicy.RUNTIME)");
+        out.println("  @interface A { }");
+        out.println("  @A String m;");
+        out.println("  @A String method(@A String a) {");
+        out.println("    return a;");
+        out.println("  }");
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 0;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/typeAnnotations/NewArray.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2008 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test NewArray
+ * @bug 6843077
+ * @summary test that all type annotations are present in the classfile
+ */
+
+public class NewArray {
+    public static void main(String[] args) throws Exception {
+        new NewArray().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf) {
+        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, String name, boolean visible) {
+        int index = cf.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = cf.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+      File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.util.*;");
+        out.println("class Test { ");
+        out.println("  @interface A { }");
+
+        out.println(" void test() {");
+        out.println("  Object a = new @A String @A [5] @A  [];");
+        out.println("  Object b = new @A String @A [5] @A [3];");
+        out.println("  Object c = new @A String @A [] @A [] {};");
+        out.println(" }");
+        out.println("}");
+
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 9;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/typeAnnotations/Presence.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2008 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test Presence
+ * @bug 6843077
+ * @summary test that all type annotations are present in the classfile
+ */
+
+public class Presence {
+    public static void main(String[] args) throws Exception {
+        new Presence().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf) {
+        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, String name, boolean visible) {
+        int index = cf.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = cf.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.util.*;");
+        out.println("class Test<@Test.A T extends @Test.A List<@Test.A String>> { ");
+        out.println("  @interface A { }");
+
+        out.println("  Map<@A String, Map<@A String, @A String>> f1;");
+
+        out.println("  <@A T extends @A List<@A String>>");
+        out.println("  Map<@A String, @A List<@A String>>");
+        out.println("  method(List<@A String> @A [] param1, String @A [] @A ... param2) @A");
+        out.println("  throws @A Exception {");
+        out.println("    @A String lc1 = null;");
+        out.println("    @A List<@A String> lc2 = null;");
+        out.println("    @A String @A [] [] @A[] lc3 = null;");
+        out.println("    List<? extends @A List<@A String>> lc4 = null;");
+        out.println("    Object lc5 = (@A List<@A String>) null;");
+        out.println("    boolean lc6 = lc1 instanceof @A String;");
+        out.println("    boolean lc7 = lc5 instanceof @A String @A [] @A [];");
+        out.println("    new @A ArrayList<@A String>();");
+        out.println("    Object lc8 = new @A String @A [4];");
+        out.println("    Object lc9 = @A String.class;");
+        out.println("    Object lc10 = @A int.class;");
+        out.println("    return null;");
+        out.println("  }");
+        out.println("  void vararg1(String @A ... t) { } ");
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_visibles = 0, expected_invisibles = 39;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/typeAnnotations/PresenceInner.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,185 @@
+/*
+ * 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test PresenceInner
+ * @bug 6843077
+ * @summary test that annotations in inner types count only once
+ */
+
+public class PresenceInner {
+    public static void main(String[] args) throws Exception {
+        new PresenceInner().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        test(cf);
+        for (Field f : cf.fields) {
+            test(cf, f);
+        }
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        // counts are zero when vising outer class
+        countAnnotations(0);
+
+        // visit inner class
+        File innerFile = new File("Test$1Inner.class");
+        ClassFile icf = ClassFile.read(innerFile);
+        test(icf);
+        for (Field f : icf.fields) {
+            test(cf, f);
+        }
+        for (Method m: icf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations(1);
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf) {
+        test(cf, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    void test(ClassFile cf, Field m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, String name, boolean visible) {
+        int index = cf.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = cf.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Field m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+
+        out.println("class Test {");
+        out.println("  void method() {");
+        out.println("    class Inner<T extends @A Object> { }");
+        out.println("  }");
+        out.println("}");
+        out.println("@interface A { }");
+        out.close();
+        System.out.println(f.getAbsolutePath());
+        return f;
+    }
+
+    File compileTestFile(File f) {
+        int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations(int expected_invisibles) {
+        int expected_visibles = 0;
+        int expected_all = expected_visibles + expected_invisibles;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/typeAnnotations/Visibility.java	Tue Jul 21 13:02:23 2009 -0700
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2008 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.
+ */
+
+import java.io.*;
+import com.sun.tools.classfile.*;
+
+/*
+ * @test Visibility
+ * @bug 6843077
+ * @summary test that type annotations are recorded in the classfile
+ */
+
+public class Visibility {
+    public static void main(String[] args) throws Exception {
+        new Visibility().run();
+    }
+
+    public void run() throws Exception {
+        File javaFile = writeTestFile();
+        File classFile = compileTestFile(javaFile);
+
+        ClassFile cf = ClassFile.read(classFile);
+        for (Method m: cf.methods) {
+            test(cf, m);
+        }
+
+        countAnnotations();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+        System.out.println("PASSED");
+    }
+
+    void test(ClassFile cf, Method m) {
+        test(cf, m, Attribute.RuntimeVisibleTypeAnnotations, true);
+        test(cf, m, Attribute.RuntimeInvisibleTypeAnnotations, false);
+    }
+
+    // test the result of Attributes.getIndex according to expectations
+    // encoded in the method's name
+    void test(ClassFile cf, Method m, String name, boolean visible) {
+        int index = m.attributes.getIndex(cf.constant_pool, name);
+        if (index != -1) {
+            Attribute attr = m.attributes.get(index);
+            assert attr instanceof RuntimeTypeAnnotations_attribute;
+            RuntimeTypeAnnotations_attribute tAttr = (RuntimeTypeAnnotations_attribute)attr;
+            all += tAttr.annotations.length;
+            if (visible)
+                visibles += tAttr.annotations.length;
+            else
+                invisibles += tAttr.annotations.length;
+        }
+    }
+
+    File writeTestFile() throws IOException {
+        File f = new File("Test.java");
+        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(f)));
+        out.println("import java.lang.annotation.Retention;");
+        out.println("import java.lang.annotation.RetentionPolicy;");
+        out.println("abstract class Test { ");
+        // visible annotations: RUNTIME
+        out.println("  @Retention(RetentionPolicy.RUNTIME)");
+        out.println("  @interface A { }");
+        out.println("  void visible() @A { }");
+
+        // invisible annotations: CLASS
+        out.println("  @Retention(RetentionPolicy.CLASS)");
+        out.println("  @interface B { }");
+        out.println("  void invisible() @B { }");
+
+        // source annotations
+        out.println("  @Retention(RetentionPolicy.SOURCE)");
+        out.println("  @interface C { }");
+        out.println("  void source() @C { }");
+
+        // default visibility: CLASS
+        out.println("  @interface D { }");
+        out.println("  void def() @D { }");
+        out.println("}");
+        out.close();
+        return f;
+    }
+
+    File compileTestFile(File f) {
+      int rc = com.sun.tools.javac.Main.compile(new String[] { "-source", "1.7", "-g", f.getPath() });
+        if (rc != 0)
+            throw new Error("compilation failed. rc=" + rc);
+        String path = f.getPath();
+        return new File(path.substring(0, path.length() - 5) + ".class");
+    }
+
+    void countAnnotations() {
+        int expected_all = 3, expected_visibles = 1, expected_invisibles = 2;
+
+        if (expected_all != all) {
+            errors++;
+            System.err.println("expected " + expected_all
+                    + " annotations but found " + all);
+        }
+
+        if (expected_visibles != visibles) {
+            errors++;
+            System.err.println("expected " + expected_visibles
+                    + " visibles annotations but found " + visibles);
+        }
+
+        if (expected_invisibles != invisibles) {
+            errors++;
+            System.err.println("expected " + expected_invisibles
+                    + " invisibles annotations but found " + invisibles);
+        }
+
+    }
+
+    int errors;
+    int all;
+    int visibles;
+    int invisibles;
+}
--- a/make/Defs-internal.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/make/Defs-internal.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -153,6 +153,20 @@
   endif
   SKIP_OPENJDK_BUILD = true
 else
+  
+  # Various non-OPENJDK reasons to NOT build the deploy repository
+  ifeq ($(ARCH), ia64)
+    BUILD_DEPLOY=false
+  endif
+  ifeq ($(ARCH), sparcv9)
+    BUILD_DEPLOY=false
+  endif
+  ifeq ($(ARCH), amd64)
+    ifeq ($(PLATFORM), solaris)
+      BUILD_DEPLOY=false
+    endif
+  endif
+
   ifndef SKIP_OPENJDK_BUILD
     #SKIP_OPENJDK_BUILD = false
     # Until 6675289 is resolved, or this feature is removed.
--- a/make/deploy-rules.gmk	Wed Jul 15 10:46:42 2009 -0700
+++ b/make/deploy-rules.gmk	Tue Jul 21 13:02:23 2009 -0700
@@ -27,11 +27,7 @@
 # DEPLOY TARGETS
 ################################################################
 
-ifeq ($(ARCH_DATA_MODEL), 32)
 deploy:  deploy-build
-else
-deploy:
-endif
 
 DEPLOY = deploy
 
@@ -45,7 +41,51 @@
   IMAGES_TARGET = images
 endif
 
-DEPLOY_BUILD_TARGETS = sanity javaws-all plugin-all
+DEPLOY_BUILD_TARGETS = sanity javaws-all plugin-all 
+# Only build 7-Zip LZMA file compression if it is available
+# Enable 7-Zip LZMA file (de)compression for Java Kernel if it is available
+ifeq ($(ARCH_DATA_MODEL), 32)
+  ifeq ($(PLATFORM), windows)
+    ifneq ($(KERNEL), off)
+      EC_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/lzma ] ; then \
+        $(ECHO) true ; \
+      else \
+  $(ECHO) false ; \
+      fi )
+  ifeq ($(EC_TMP), true)
+        DEPLOY_BUILD_TARGETS += extra-comp-all
+      endif
+    endif
+  endif
+endif
+
+ifneq ($(JQS), off)
+  ifeq ($(ARCH_DATA_MODEL), 32)
+    ifeq ($(PLATFORM), windows)
+      DEPLOY_BUILD_TARGETS += jqs-all
+    endif
+  endif
+endif
+  
+ifneq ($(KERNEL), off)
+  ifeq ($(ARCH_DATA_MODEL), 32)
+    ifeq ($(PLATFORM), windows)
+      # Only set up to use UPX compression if it is available
+      UP_TMP = $(shell if [ -d $(DEPLOY_TOPDIR)/make/upx ] ; then \
+        $(ECHO) true ; \
+      else \
+        $(ECHO) false ; \
+      fi )
+      ifeq ($(UP_TMP), true)
+        DEPLOY_BUILD_TARGETS += cmd-comp-all
+      endif
+      DEPLOY_BUILD_TARGETS += kernel-all
+    endif
+  endif
+endif
+
+
+
 ifndef DEV_ONLY
   DEPLOY_BUILD_TARGETS += images
 else
@@ -80,27 +120,21 @@
 endif
 
 deploy-build:
-ifeq ($(ARCH_DATA_MODEL), 32)
-  ifeq ($(BUILD_DEPLOY), true)
+ifeq ($(BUILD_DEPLOY), true)
 	($(CD) $(DEPLOY_TOPDIR)/make && \
-	  $(MAKE) $(DEPLOY_BUILD_TARGETS) $(DEPLOY_BUILD_ARGUMENTS))
-  endif
+	$(MAKE) $(DEPLOY_BUILD_TARGETS) $(DEPLOY_BUILD_ARGUMENTS))
 endif
 
 deploy-clobber::
-ifeq ($(ARCH_DATA_MODEL), 32)
-  ifeq ($(BUILD_DEPLOY), true)
+ifeq ($(BUILD_DEPLOY), true)
 	($(CD) $(DEPLOY_TOPDIR)/make && \
-	  $(MAKE) clobber $(DEPLOY_BUILD_ARGUMENTS))
-  endif 
+	$(MAKE) clobber $(DEPLOY_BUILD_ARGUMENTS))
 endif 
 
 deploy-sanity::
-ifeq ($(ARCH_DATA_MODEL), 32)
-  ifeq ($(BUILD_DEPLOY), true)
+ifeq ($(BUILD_DEPLOY), true)
 	($(CD) $(DEPLOY_TOPDIR)/make && \
-	  $(MAKE) sanity $(DEPLOY_BUILD_ARGUMENTS))
-  endif
+	$(MAKE) sanity $(DEPLOY_BUILD_ARGUMENTS))
 endif
 
 .PHONY: deploy deploy-build deploy-clobber deploy-sanity