diff --git a/.hgtags b/.hgtags
index 7f1a9ea9d24..7863eadbd4a 100644
--- a/.hgtags
+++ b/.hgtags
@@ -108,3 +108,5 @@ a36beda9b9de91231d92a2c529f21cc218fcf8d5 jdk7-b130
 d8af56da89bc0fc02a6b6ad78f51157a46d665ab jdk7-b131
 d61280d36755d1941fb487f554e8b7a6d0bca6a1 jdk7-b132
 fd444c61e7ed3d92b2a730da7c737b02191b682f jdk7-b133
+def8e16dd237a47fc067d66d4c616d7baaec6001 jdk7-b134
+f75a1efb141210901aabe00a834e0fc32bb8b337 jdk7-b135
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index c3352d42a78..8b7fabe214d 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -108,3 +108,5 @@ cc58c11af15411042719e9c82707fdbef60a9e0f jdk7-b130
 5d86d951426aaf340b1ba84ae2d5ab5da65a71e2 jdk7-b131
 0f62a65fb666b337caa585015ab6ea2e60e709ca jdk7-b132
 c6f380693342feadccc5fe2c5adf500e861361aa jdk7-b133
+ddc2fcb3682ffd27f44354db666128827be7e3c3 jdk7-b134
+783bd02b4ab4596059c74b10a1793d7bd2f1c157 jdk7-b135
diff --git a/README b/README
index 722131d683f..db7346b4432 100644
--- a/README
+++ b/README
@@ -29,13 +29,14 @@ Simple Build Instructions:
      Set the environment variable ALT_BOOTDIR to the location of JDK 6.
 
   2. Check the sanity of doing a build with your current system:
-       gnumake sanity
+       make sanity
      See README-builds.html if you run into problems.
   
   3. Do a complete build of the OpenJDK:
-       gnumake all
+       make all
      The resulting JDK image should be found in build/*/j2sdk-image
 
-where gnumake is GNU make 3.81 or newer, /usr/bin/make on Linux and
-/usr/sfw/bin/gmake or /opt/sfw/bin/gmake on Solaris.
+where make is GNU make 3.81 or newer, /usr/bin/make on Linux usually
+is 3.81 or newer.
 
+Complete details are available in README-builds.html.
diff --git a/README-builds.html b/README-builds.html
index b59457c74ab..87b7cd80af2 100644
--- a/README-builds.html
+++ b/README-builds.html
@@ -54,7 +54,11 @@
                         <li><a href="#opensolaris">OpenSolaris</a></li>
                     </ul>
                 </li>
-                <li><a href="#directories">Source Directory Structure</a> </li>
+                <li><a href="#directories">Source Directory Structure</a> 
+                    <ul>
+                        <li><a href="#drops">Managing the Source Drops</a></li>
+                    </ul>
+                </li>
                 <li><a href="#building">Build Information</a>
                     <ul>
                         <li><a href="#gmake">GNU Make (<tt><i>gmake</i></tt>)</a> </li>
@@ -65,7 +69,7 @@
                             <ul>
                                 <li><a href="#bootjdk">Bootstrap JDK</a> </li>
                                 <li><a href="#importjdk">Optional Import JDK</a> </li>
-                                <li><a href="#ant">Ant</a> </li>
+                                <li><a href="#ant">Ant 1.7.1</a> </li>
                                 <li><a href="#cacerts">Certificate Authority File (cacert)</a> </li>
                                 <li><a href="#compilers">Compilers</a>
                                     <ul>
@@ -114,13 +118,13 @@
             <a href="http://mercurial.selenic.com/wiki/Mercurial">Mercurial</a>.
             If you are new to Mercurial, please see the
             <a href="http://mercurial.selenic.com/wiki/BeginnersGuides">Beginner Guides</a>
-            or refer to the <a href=""http://hgbook.red-bean.com/">Mercurial Book</a>.
+            or refer to the <a href="http://hgbook.red-bean.com/">Mercurial Book</a>.
             The first few chapters of the book provide an excellent overview of
             Mercurial, what it is and how it works.
             <br>
             For using Mercurial with the OpenJDK refer to the
-            <a href=""http://openjdk.java.net/guide/repositories.html#installConfig">
-               Developer Guide: Installing and Configuring Mercurial</a>
+            <a href="http://openjdk.java.net/guide/repositories.html#installConfig">
+                Developer Guide: Installing and Configuring Mercurial</a>
             section for more information.
             The Forest Extension is not part of the Mercurial install,
             and is optional,
@@ -146,14 +150,14 @@
                 using the Forest Extension:
                 <blockquote>
                     <tt>
-                        hg fclone http://openjdk.java.net/jdk7/jdk7 <i>YourOpenJDK</i>
+                        hg fclone http://hg.openjdk.java.net/jdk7/jdk7 <i>YourOpenJDK</i>
                     </tt>
                 </blockquote>
                 To get the entire set of OpenJDK Mercurial repositories
                 without using the Forest Extension:
                 <blockquote>
                     <tt>
-                        hg clone http://openjdk.java.net/jdk7/jdk7 <i>YourOpenJDK</i>
+                        hg clone http://hg.openjdk.java.net/jdk7/jdk7 <i>YourOpenJDK</i>
                         <br>cd <i>YourOpenJDK</i>
                         <br>sh ./get_source.sh
                     </tt>
@@ -207,66 +211,50 @@
                     <tr>
                         <td>Linux X86 (32-bit)</td>
                         <td>Fedora 9</td>
-                        <td>gcc 4 </td>
-                        <td>JDK 6u14 FCS </td>
+                        <td>gcc 4.3 </td>
+                        <td>JDK 6u18</td>
                     </tr>
                     <tr>
                         <td>Linux X64 (64-bit)</td>
                         <td>Fedora 9</td>
-                        <td>gcc 4 </td>
-                        <td>JDK 6u14 FCS </td>
+                        <td>gcc 4.3 </td>
+                        <td>JDK 6u18</td>
                     </tr>
                     <tr>
                         <td>Solaris SPARC (32-bit)</td>
-                        <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>Solaris 10 Update 6</td>
                         <td>Sun Studio 12 Update 1 + patches</td>
-                        <td>JDK 6u14 FCS </td>
+                        <td>JDK 6u18</td>
                     </tr>
                     <tr>
                         <td>Solaris SPARCV9 (64-bit)</td>
-                        <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>Solaris 10 Update 6</td>
                         <td>Sun Studio 12 Update 1 + patches</td>
-                        <td>JDK 6u14 FCS </td>
+                        <td>JDK 6u18</td>
                     </tr>
                     <tr>
                         <td>Solaris X86 (32-bit)</td>
-                        <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>Solaris 10 Update 6</td>
                         <td>Sun Studio 12 Update 1 + patches</td>
-                        <td>JDK 6u14 FCS </td>
+                        <td>JDK 6u18</td>
                     </tr>
                     <tr>
                         <td>Solaris X64 (64-bit)</td>
-                        <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>Solaris 10 Update 6</td>
                         <td>Sun Studio 12 Update 1 + patches</td>
-                        <td>JDK 6u14 FCS </td>
+                        <td>JDK 6u18</td>
                     </tr>
                     <tr>
                         <td>Windows X86 (32-bit)</td>
                         <td>Windows XP</td>
                         <td>Microsoft Visual Studio C++ 2010 Professional Edition</td>
-                        <td>JDK 6u14 FCS </td>
+                        <td>JDK 6u18</td>
                     </tr>
                     <tr>
                         <td>Windows X64 (64-bit)</td>
                         <td>Windows Server 2003 - Enterprise x64 Edition</td>
                         <td>Microsoft Visual Studio C++ 2010 Professional Edition</td>
-                        <td>JDK 6u14 FCS </td>
+                        <td>JDK 6u18</td>
                     </tr>
                 </tbody>
             </table>
@@ -300,7 +288,7 @@
 	      way to do it is to execute the following commands as user 
                 <tt>root</tt>:
                 <p/>
-                <code>yum-builddep java-openjdk</code>
+                <code>yum-builddep java-1.6.0-openjdk</code>
                 <p/>
                 <code>yum install gcc gcc-c++</code>
                 <p/>
@@ -345,10 +333,10 @@
             </blockquote>
         </blockquote>
         <!-- ------------------------------------------------------ -->
-        <h3><a name="centos">CentOS 5.2</a></h3>
+        <h3><a name="centos">CentOS 5.5</a></h3>
         <blockquote>
             After installing
-            <a href="http://www.centos.org/">CentOS 5.2</a>
+            <a href="http://www.centos.org/">CentOS 5.5</a>
             you need to make sure you have
             the following Development bundles installed:
             <blockquote>
@@ -356,7 +344,7 @@
                     <li>Development Libraries</li>
                     <li>Development Tools</li>
                     <li>Java Development</li>
-                    <li>X Software Development</li>
+                    <li>X Software Development (Including XFree86-devel)</li>
                 </ul>
             </blockquote>
             <p>
@@ -552,15 +540,105 @@
                 building the OpenJDK runtime libraries and misc files.
                 The top level <tt>Makefile</tt>
                 is used to build the entire OpenJDK.
+
+            <h3><a name="drops">Managing the Source Drops</a></h3>
+            <blockquote>
+                <p>
+                    The repositories <tt>jaxp</tt> and <tt>jaxws</tt> actually
+                    do not contain the sources for JAXP or JAX-WS.
+                    These products have their own open source procedures at their
+                    <a href="http://jaxp.java.net/">JAXP</a> and
+                    <a href="http://jax-ws.java.net/">JAX-WS</a> home pages.
+                    The OpenJDK project does need access to these sources to build
+                    a complete JDK image because JAXP and JAX-WS are part of the JDK.
+                    The current process for delivery of the JAXP and JAX-WS sources
+                    involves so called "source drop bundles" downloaded from a public
+                    website.
+                    There are many reasons for this current mechanism, and it is
+                    understood that this is not ideal for the open source community.
+                    It is possible this process could change in the future.
+                    <br>
+                    <b>NOTE:</b> The <a href="http://download.java.net/openjdk/jdk7/">
+                        Complete OpenJDK Source Bundles</a> <u>will</u> contain the JAXP and
+                    JAX-WS sources.
+                </p>
+
+                <h4><a name="dropcreation">Creation of New Source Drop Bundles</a></h4>
+                <blockquote>
+                    <ol>
+                        <li>
+                            The JAXP or JAX-WS team prepares a new zip bundle,
+                            places a copy in a public download area on java.net,
+                            sends us a link and a list of CRs (Change Request Numbers).
+                            The older download bundles should not be deleted.
+                            It is the responsibility of the JAXP and JAX-WS team to
+                            place the proper GPL legal notices on the sources
+                            and do any filtering or java re-packaging for the
+                            OpenJDK instances of these classes.
+                        </li>
+                        <li>
+                            The OpenJDK team copies this new bundle into shared
+                            area (e.g. <tt>/java/devtools/share/jdk7-drops</tt>).
+                            Older bundles are never deleted so we retain the history.
+                        </li>
+                        <li>
+                            The OpenJDK team edits the ant property file
+                            <tt>jaxp/jaxp.properties</tt> or
+                            <tt>jaxws/jaxws.properties</tt> to update the
+                            base URL, the zip bundle name, and the MD5 checksum
+                            of the zip bundle
+                            (on Solaris: <tt>sum -c md5 <i>bundlename</i></tt>)
+                        </li>
+                        <li>
+                            OpenJDK team reviews and commits those changes with the
+                            given CRs.
+                        </li>
+                    </ol>
+                </blockquote>
+
+                <h4><a name="dropusage">Using Source Drop Bundles</a></h4>
+                <blockquote>
+                    <p>
+                        The ant scripts that build <tt>jaxp</tt> and <tt>jaxws</tt>
+                        will attempt to locate these zip bundles from the directory
+                        in the environment variable
+                        <tt><a href="#ALT_DROPS_DIR">ALT_DROPS_DIR</a></tt>.
+                        The checksums protect from getting the wrong, corrupted, or
+                        improperly modified sources.
+                        Once the sources are made available, the population will not
+                        happen again unless a <tt>make clobber</tt> is requested
+                        or the <tt>jaxp/drop/</tt> or <tt>jaxws/drop/</tt>
+                        directory is explicitly deleted.
+                        <br>
+                        <b>NOTE:</b> The default Makefile and ant script behavior
+                        is to NOT download these bundles from the public http site.
+                        In general, doing downloads
+                        during the build process is not advised, it creates too much
+                        unpredictability in the build process.
+                        However, you can use <tt>make ALLOW_DOWNLOADS=true</tt> to
+                        tell the ant script that the download of the zip bundle is
+                        acceptable.
+                    </p>
+                    <p>
+                        The recommended procedure for keeping a cache of these
+                        source bundles would be to download them once, place them
+                        in a directory outside the repositories, and then set
+                        <tt><a href="#ALT_DROPS_DIR">ALT_DROPS_DIR</a></tt> to refer
+                        to that directory.
+                        These drop bundles do change occasionally, so the newer
+                        bundles may need to be added to this area from time to time.
+                    </p>
+                </blockquote>
+            </blockquote>
         </blockquote>
         <!-- ------------------------------------------------------ -->
         <hr>
         <h2><a name="building">Build Information</a></h2>
         <blockquote>
             Building the OpenJDK
-            is done with a <tt><i>gmake</i></tt>
-            command line and various
-            environment or make variable settings that direct the make rules
+            is done with a <a href="#gmake">GNU <tt>make</tt></a> command line
+            and various
+            environment or make variable settings that direct the makefile rules
             to where various components have been installed.
             Where possible the makefiles will attempt to located the various
             components in the default locations or any component specific 
@@ -578,7 +656,7 @@
                 <pre><tt>
                 bash
                 . jdk/make/jdk_generic_profile.sh
-                <i>gmake</i> sanity &amp;&amp; <i>gmake</i>
+                <a href="#gmake"><tt>make</tt></a> sanity &amp;&amp; <a href="#gmake"><tt>make</tt></a>
                 </tt></pre>
             </blockquote>
             <p>
@@ -599,25 +677,31 @@
             A few notes about using GNU make:
             <ul>
                 <li>
-                    In general, you need GNU make version 3.81 or newer.
+                    You need GNU make version 3.81 or newer.
                 </li>
                 <li>
                     Place the location of the GNU make binary in the <tt>PATH</tt>. 
                 </li>
                 <li>
                     <strong>Linux:</strong>
-                    The <tt>/usr/bin/make</tt> command should work fine for you.
+                    The <tt>/usr/bin/make</tt> should be 3.81 or newer
+                    and should work fine for you.
+                    If this version is not 3.81 or newer,
+                    see the <a href="#buildgmake">"Building GNU make"</a> section.
                 </li>
                 <li>
                     <strong>Solaris:</strong>
                     Do NOT use <tt>/usr/bin/make</tt> on Solaris.
                     If your Solaris system has the software
                     from the Solaris Companion CD installed, 
-                    you should use <tt>gmake</tt>
+                    you should try and use <tt>gmake</tt>
                     which will be located in either the <tt>/opt/sfw/bin</tt> or 
                     <tt>/usr/sfw/bin</tt> directory.
-                    In more recent versions of Solaris GNU make can be found
-                    at <tt>/usr/bin/gmake</tt>. 
+                    In more recent versions of Solaris GNU make might be found
+                    at <tt>/usr/bin/gmake</tt>.<br>
+                    <b>NOTE:</b> It is very likely that this <tt>gmake</tt>
+                    could be 3.80, you need 3.81, in which case,
+                    see the <a href="#buildgmake">"Building GNU make"</a> section.
                 </li>
                 <li>
                     <strong>Windows:</strong>
@@ -627,30 +711,25 @@
                     as a <tt>make.exe</tt> built for something like
                     <a href="http://www.mkssoftware.com/">MKS</a>). 
                     <br>
-                    <b>WARNING:</b> Watch out for make version 3.81, it may
+                    <b>WARNING:</b> Watch out on some make 3.81 versions, it may
                     not work due to a lack of support for MS-DOS drive letter paths
                     like <tt>C:/</tt> or <tt>C:\</tt>.
-                    Use a 3.80 version, or find a newer
-                    version that has this problem fixed.
-                    The older 3.80 version of make.exe can be downloaded with this
-                    <a href="http://cygwin.paracoda.com/release/make/make-3.80-1.tar.bz2" target="_blank">
-                        link</a>.
-                    Use of this older 3.80 make.exe may require that you install the
-                    libintl2.dll library or libintl2 cygwin package which is
-                    no longer installed by default by the cygwin installer.
                     <br>
-                    Also see the
+                    You may be able to use the information at the
                     <a href="http://developer.mozilla.org/en/docs/Windows_build_prerequisites_using_cygwin#make" target="_blank">
                         mozilla developer center</a>
                     on this topic.
                     <br>
                     It's hoped that when make 3.82 starts shipping in a future cygwin
                     release that this MS-DOS path issue will be fixed.
-                    In addition to the above 3.80 make.exe you can download 
-                    this
+                    <br>
+                    It may be possible to download the version at
                     <a href="http://www.cmake.org/files/cygwin/make.exe">
-                        www.cmake.org make.exe</a> which will not have a libintl2.dll
-                    dependency.
+                        www.cmake.org make.exe</a>.
+                    <br>
+                    It might be necessary for you to build your own GNU make 3.81,
+                    see the <a href="#buildgmake">"Building GNU make"</a> section
+                    in that case.
                 </li>
             </ul>
             <p>
@@ -662,6 +741,34 @@
                 The latest source to GNU make is available at
                 <a href="http://ftp.gnu.org/pub/gnu/make/" target="_blank">
                     ftp.gnu.org/pub/gnu/make/</a>.
+            </p>
+            <!-- ------------------------------------------------------ -->
+            <h4><a name="buildgmake">Building GNU make</a></h4>
+            <blockquote>
+                First step is to get the GNU make 3.81 source from
+                <a href="http://ftp.gnu.org/pub/gnu/make/" target="_blank">
+                    ftp.gnu.org/pub/gnu/make/</a>.
+                Building is a little different depending on the OS and unix toolset
+                on Windows:
+                <ul>
+                    <li>
+                        <strong>Linux:</strong>
+                        <tt>./configure && make</tt>
+                    </li>
+                    <li>
+                        <strong>Solaris:</strong>
+                        <tt>./configure && gmake CC=gcc</tt>
+                    </li>
+                    <li>
+                        <strong>Windows for CYGWIN:</strong>
+                        <tt>./configure && make</tt>
+                    </li>
+                    <li>
+                        <strong>Windows for MKS: (CYGWIN is recommended)</strong>
+                        <tt>./configure && make -f Makefile.win32</tt>
+                    </li>
+                </ul>
+            </blockquote>
         </blockquote>
         <!-- ------------------------------------------------------ -->
         <hr>
@@ -713,7 +820,7 @@
                 </li>
                 <li>
                     Install
-                    <a href="#ant">Ant</a>, 
+                    <a href="#ant">Ant 1.7.1 or newer</a>,
                     make sure it is in your PATH.
                 </li>
             </ol>
@@ -776,7 +883,7 @@
                 </li>
                 <li>
                     Install
-                    <a href="#ant">Ant</a>, 
+                    <a href="#ant">Ant 1.7.1 or newer</a>,
                     make sure it is in your PATH.
                 </li>
             </ol>
@@ -862,7 +969,7 @@
                 </li>
                 <li>
                     Install
-                    <a href="#ant">Ant</a>, 
+                    <a href="#ant">Ant 1.7.1 or newer</a>,
                     make sure it is in your PATH and set
                     <tt><a href="#ANT_HOME">ANT_HOME</a></tt>.
                 </li>
@@ -923,14 +1030,20 @@
             <blockquote>
                 All OpenJDK builds require access to least Ant 1.7.1.
                 The Ant tool is available from the 
-                <a href="http://ant.apache.org" target="_blank">
-                    Ant download site</a>.
+                <a href="http://archive.apache.org/dist/ant/binaries/apache-ant-1.7.1-bin.zip" target="_blank">
+                    Ant 1.7.1 archive download site</a>.
                 You should always make sure <tt>ant</tt> is in your PATH, and
                 on Windows you may also need to set 
                 <tt><a href="#ANT_HOME">ANT_HOME</a></tt>
                 to point to the location of
                 the Ant installation, this is the directory pathname
                 that contains a <tt>bin and lib</tt>.
+                <br>
+                <b>WARNING:</b> Ant versions used from IDE tools like NetBeans
+                or installed via system packages may not operate the same
+                as the one obtained from the Ant download bundles.
+                These system and IDE installers sometimes choose to change
+                the ant installation enough to cause differences.
             </blockquote>
             <!-- ------------------------------------------------------ -->
             <h4><a name="cacerts">Certificate Authority File (cacert)</a></h4>
@@ -962,7 +1075,7 @@
             <blockquote>
                 <strong><a name="gcc">Linux gcc/binutils</a></strong>
                 <blockquote>
-                    The GNU gcc compiler version should be 4 or newer.
+                    The GNU gcc compiler version should be 4.3 or newer.
                     The compiler used should be the default compiler installed
                     in <tt>/usr/bin</tt>.
                 </blockquote>
@@ -1047,21 +1160,16 @@
                 <strong><a name="msvc32">Windows i586: Microsoft Visual Studio 2010 Compilers</a></strong>
                 <blockquote>
                     <p>
-                        <b>BEGIN WARNING</b>: At this time (Spring/Summer 2010) JDK 7 is starting a transition to
-                        use the newest VS2010 Microsoft compilers. These build instructions are updated
-                        to show where we are going. We have a QA process to go through before
-                        official builds actually use VS2010. So for now, official builds are
-                        still using VS2003. No other compilers are known to build the entire JDK,
+                        <b>BEGIN WARNING</b>: JDK 7 has transitioned to
+                        use the newest VS2010 Microsoft compilers.
+                        No other compilers are known to build the entire JDK,
                         including non-open portions.
-                        So for now you should be able to build with either VS2003 or VS2010.
-                        We do not guarantee that VS2008 will work, although there is sufficient
-                        makefile support to make at least basic JDK builds plausible.
                         Visual Studio 2010 Express compilers are now able to build all the
                         open source repositories, but this is 32 bit only. To build 64 bit
-                        Windows binaries use the the 7.1 Windows SDK.<b>END WARNING.</b>
+                        Windows binaries use the the 7.1 Windows SDK.
+                        <b>END WARNING.</b>
                     <p>
-                        The 32-bit OpenJDK Windows build
-                        requires
+                        The 32-bit OpenJDK Windows build requires
                         Microsoft Visual Studio C++ 2010 (VS2010) Professional
                         Edition or Express compiler.
                         The compiler and other tools are expected to reside
@@ -1088,11 +1196,10 @@
                 </blockquote>
                 <strong><a name="msvc64">Windows x64: Microsoft Visual Studio 2010 Professional Compiler</a></strong>
                 <blockquote>
-                    For <b>X64</b>, builds, when using the VS2010 Professional
-                    compiler, the 64 bit build set up is much the same as 32 bit
+                    For <b>X64</b>, the set up is much the same as 32 bit
                     except that you run <tt>amd64\VCVARS64.BAT</tt>
                     to set the compiler environment variables.
-                    Previously 64 bit builds had used the 64 bit compiler in
+                    Previously 64 bit builds had to use the 64 bit compiler in
                     an unbundled Windows SDK but this is no longer necessary if
                     you have VS2010 Professional.
                 </blockquote>
@@ -1614,6 +1721,13 @@
                     and on Windows with CYGWIN
                     <tt>/usr/bin</tt>.
                 </dd>
+                <dt><tt><a name="ALT_DROPS_DIR">ALT_DROPS_DIR</a></tt> </dt>
+                <dd>
+                    The location of any source drop bundles
+                    (see <a href="#drops">Managing the Source Drops</a>).
+                    The default will be
+                    <tt>$(ALT_JDK_DEVTOOLS_PATH)/share/jdk7-drops</tt>.
+                </dd>
                 <dt><a name="ALT_UNIXCCS_PATH"><tt>ALT_UNIXCCS_PATH</tt></a></dt>
                 <dd>
                     <strong>Solaris only:</strong>
@@ -1649,6 +1763,12 @@
                     Where each of these directories contain the import JDK image
                     for that platform.
                 </dd>
+                <dt><a name="ALT_OPENWIN_HOME"><tt>ALT_OPENWIN_HOME</tt></a></dt>
+                <dd>
+		    The top-level directory of the libraries and include files for the platform's 
+		    graphical programming environment. The default location is platform specific. 
+		    For example, on Linux it defaults to <tt>/usr/X11R6/</tt>.
+		</dd>
                 <dt><strong>Windows specific:</strong></dt>
                 <dd>
                     <dl>
@@ -1659,9 +1779,8 @@
 			    located.
 			    The default is whatever WINDOWSSDKDIR is set to
 			    (or WindowsSdkDir) or the path
-			    <pre>
-                            c:\Program Files\Microsoft SDKs\Windows\v6.1a
-			    </pre>
+                            <br>
+                            <tt>c:\Program Files\Microsoft SDKs\Windows\v7.0a</tt>
                         </dd>
                         <dt><tt><a name="ALT_DXSDK_PATH">ALT_DXSDK_PATH</a></tt> </dt>
                         <dd>
@@ -1678,10 +1797,160 @@
                         </dd>
                     </dl>
                 </dd>
+                <dt><strong>Cross-Compilation Support:</strong></dt>
+                <dd>
+                    <dl>
+                        <dt><a name="CROSS_COMPILE_ARCH"><tt>CROSS_COMPILE_ARCH</tt></a> </dt>
+                        <dd>
+                            Set to the target architecture of a cross-compilation build. If set, this
+                            variable is used to signify that we are cross-compiling. The expectation
+                            is that <a href="#ALT_COMPILER_PATH"><tt>ALT_COMPILER_PATH</tt></a> is set
+                            to point to the cross-compiler and that any cross-compilation specific flags
+                            are passed using <a href="#EXTRA_CFLAGS"><tt>EXTRA_CFLAGS</tt></a>.
+			    The <a href="#ALT_OPENWIN_HOME"><tt>ALT_OPENWIN_HOME</tt></a> variable should 
+			    also be set to point to the graphical header files (e.g. X11) provided with 
+			    the cross-compiler.
+                            When cross-compiling we skip execution of any demos etc that may be built, and
+                            also skip binary-file verification.
+                        </dd>
+                        <dt><tt><a name="EXTRA_CFLAGS">EXTRA_CFLAGS</a></tt> </dt>
+                        <dd>
+			   Used to pass cross-compilation options to the cross-compiler.
+                           These are added to the <tt>CFLAGS</tt> and <tt>CXXFLAGS</tt> variables. 
+			</dd>
+                        <dt><tt><a name="USE_ONLY_BOOTDIR_TOOLS">USE_ONLY_BOOTDIR_TOOLS</a></tt> </dt>
+                        <dd>
+                            Used primarily for cross-compilation builds (and always set in that case)
+                            this variable indicates that tools from the boot JDK should be used during
+                            the build process, not the tools (<tt>javac</tt>, <tt>javah</tt>, <tt>jar</tt>)
+                            just built (which can't execute on the build host).
+                        </dd>
+                        <dt><tt><a name="HOST_CC">HOST_CC</a></tt> </dt>
+                        <dd>
+                            The location of the C compiler to generate programs to run on the build host.
+                            Some parts of the build generate programs that are then compiled and executed
+                            to produce other parts of the build. Normally the primary C compiler is used
+                            to do this, but when cross-compiling that would be the cross-compiler and the
+                            resulting program could not be executed. 
+                            On Linux this defaults to <tt>/usr/bin/gcc</tt>; on other platforms it must be
+                            set explicitly.
+                        </dd>
+                    </dl>
+                <dt><strong>Specialized Build Options:</strong></dt>
+                <dd>
+                  Some build variables exist to support specialized build environments and/or specialized
+                  build products. Their use is only supported in those contexts:
+                    <dl>
+                        <dt><tt><a name="BUILD_CLIENT_ONLY">BUILD_CLIENT_ONLY</a></tt> </dt>
+                        <dd>
+                            Indicates this build will only contain the Hotspot client VM. In addition to
+                            controlling the Hotspot build target, it ensures that we don't try to copy
+                            any server VM files/directories, and defines a default <tt>jvm.cfg</tt> file
+                            suitable for a client-only environment. Using this in a 64-bit build will
+                            generate a sanity warning as 64-bit client builds are not directly supported.
+                        </dd>
+                        <dt><tt><a name="BUILD_HEADLESS_ONLY"></a>BUILD_HEADLESS_ONLY</tt> </dt>
+                        <dd>
+                            Used when the build environment has no graphical capabilities at all. This
+			    excludes building anything that requires graphical libraries to be available.
+                        </dd>
+                        <dt><tt><a name="JAVASE_EMBEDDED"></a>JAVASE_EMBEDDED</tt> </dt>
+                        <dd>
+			    Used to indicate this is a build of the Oracle Java SE Embedded product. 
+			    This will enable the directives included in the SE-Embedded specific build 
+			    files.
+                        </dd>
+                        <dt><tt><a name="LIBZIP_CAN_USE_MMAP">LIBZIP_CAN_USE_MMAP</a></tt> </dt>
+                        <dd>
+			    If set to false, disables the use of mmap by the zip utility. Otherwise,
+	                    mmap will be used.
+                        </dd>
+                        <dt><tt><a name="COMPRESS_JARS"></a>COMPRESS_JARS</tt> </dt>
+                        <dd>
+			  If set to true, causes certain jar files that would otherwise be built without
+			  compression, to use compression.
+                        </dd>
+                    </dl>
+                </dd>
             </dl>
         </blockquote>
         <!-- ------------------------------------------------------ -->
         <hr>
+        <h2><a name="hints">Hints and Tips</a></h2>
+        <blockquote>
+            You don't have to use all these hints and tips, and in fact people do actually
+            build with systems that contradict these, but they might prove to be
+            helpful to some.
+            <ul>
+                <li>
+                    If <tt>make sanity</tt> does not work, find out why, fix that
+                    before going any further. Or at least understand what the
+                    complaints are from it.
+                </li>
+                <li>
+                    JDK: Keep in mind that you are building a JDK, but you need
+                    a JDK (BOOTDIR JDK) to build this JDK.
+                </li>
+                <li>
+                    Ant: The ant utility is a java application and besides having
+                    ant available to you, it's important that ant finds the right
+                    java to run with. Make sure you can type <tt>ant -version</tt>
+                    and get clean results with no error messages.
+                </li>
+                <li>
+                    Linux: Try and favor the system packages over building your own
+                    or getting packages from other areas.
+                    Most Linux builds should be possible with the system's
+                    available packages.
+                </li>
+                <li>
+                    Solaris: Typically you will need to get compilers on your systems
+                    and occasionally GNU make 3.81 if a gmake binary is not available.
+                    The gmake binary might not be 3.81, be careful.
+                </li>
+                <li>
+                    Windows VS2010:
+                    <ul>
+                        <li>
+                            Only the C++ part of VS2010 is needed.
+                            Try to let the installation go to the default install directory.
+                            Always reboot your system after installing VS2010.
+                            The system environment variable VS100COMNTOOLS should be
+                            set in your environment.
+                        </li>
+                        <li>
+                            Make sure that TMP and TEMP are also set in the environment
+                            and refer to Windows paths that exist, like <tt>C:\temp</tt>,
+                            not <tt>/tmp</tt>, not <tt>/cygdrive/c/temp</tt>, and not <tt>C:/temp</tt>.
+                            <tt>C:\temp</tt> is just an example, it is assumed that this area is
+                            private to the user, so by default after installs you should
+                            see a unique user path in these variables.
+                        </li>
+                        <li>
+                            You need to use vsvars32.bat or vsvars64.bat to get the
+                            PATH, INCLUDE, LIB, LIBPATH, and WINDOWSSDKDIR
+                            variables set in your shell environment.
+                            These bat files are not easy to use from a shell environment.
+                            However, there is a script placed in the root jdk7 repository called
+                            vsvars.sh that can help, it should only be done once in a shell
+                            that will be doing the build, e.g.<br>
+                            <tt>sh ./make/scripts/vsvars.sh -v10 > settings<br>
+                                eval `cat settings`</tt><br>
+                            Or just <tt>eval `sh ./make/scripts/vsvars.sh -v10`</tt>.
+                        </li>
+                    </ul>
+                </li>
+                <li>
+                    Windows: PATH order is critical, see the
+                    <a href="#paths">paths</a> section for more information.
+                </li>
+                <li>
+                    Windows 64bit builds: Use ARCH_DATA_MODEL=64.
+                </li>
+            </ul>
+        </blockquote>
+        <!-- ------------------------------------------------------ -->
+        <hr>
         <h2><a name="troubleshooting">Troubleshooting</a></h2>
         <blockquote>
             A build can fail for any number of reasons. 
@@ -1706,6 +1975,19 @@
                 Some of the more common problems with builds are briefly described
                 below, with suggestions for remedies.
             <ul>
+                <li>
+                    <b>Corrupted Bundles on Windows:</b>
+                    <blockquote>
+                        Some virus scanning software has been known to corrupt the
+                        downloading of zip bundles.
+                        It may be necessary to disable the 'on access' or 'real time'
+                        virus scanning features to prevent this corruption.
+                        This type of "real time" virus scanning can also slow down the
+                        build process significantly.
+                        Temporarily disabling the feature, or excluding the build
+                        output directory may be necessary to get correct and faster builds.
+                    </blockquote>
+                </li>
                 <li>
                     <b>Slow Builds:</b>
                     <blockquote>
@@ -1801,7 +2083,11 @@
                     </blockquote>
                 </li>
                 <li>
-                    <b>Windows Error Message: <tt>*** fatal error - couldn't allocate heap, ... </tt></b>
+                    <b>Windows Error Messages:</b><br>
+                    <tt>*** fatal error - couldn't allocate heap, ... </tt><br>
+                    <tt>rm fails with "Directory not empty"</tt><br>
+                    <tt>unzip fails with "cannot create ... Permission denied"</tt><br>
+                    <tt>unzip fails with "cannot create ... Error 50"</tt><br>
                     <blockquote>
                         The CYGWIN software can conflict with other non-CYGWIN
                         software. See the CYGWIN FAQ section on
@@ -1810,12 +2096,11 @@
                     </blockquote>
                 </li>
                 <li>
-                    <b>Windows Error Message: <tt>*** multiple target patterns.  Stop.</tt></b>
+                    <b>Windows Error Message: <tt>spawn failed</tt></b>
                     <blockquote>
-                        The CYGWIN make version 3.81 may not like the Windows <tt>C:/</tt>
-                        style paths, it may not like the ':' character in the path
-                        when used in a makefile target definition.
-                        See the <a href="#gmake"><tt><i>gmake</i></tt></a> section.
+                        Try rebooting the system, or there could be some kind of
+                        issue with the disk or disk partition being used.
+                        Sometimes it comes with a "Permission Denied" message.
                     </blockquote>
                 </li>
             </ul>
diff --git a/corba/.hgtags b/corba/.hgtags
index 6c99ee4d582..e8459c40d47 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -108,3 +108,5 @@ d7532bcd3742f1576dd07ff9fbb535c9c9a276e9 jdk7-b126
 9d6dd2cdfcb92612dbd836ecded87770d52b49db jdk7-b131
 1b1e75e8f476e5c07f0d2b035993895e2603e1f0 jdk7-b132
 671fe2e623ffefb4b7c312be919fc71eb48c1df1 jdk7-b133
+918003855fa0dba5acf4bf1fe36526d2fc4c1ba8 jdk7-b134
+e0b72ae5dc5e824b342801c8d1d336a55eb54e2c jdk7-b135
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index 0c59e415f6f..e5121254096 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -154,3 +154,7 @@ e9aa2ca89ad6c53420623d579765f9706ec523d7 hs21-b02
 0e531ab5ba04967a0e9aa6aef65e6eb3a0dcf632 jdk7-b132
 a8d643a4db47c7b58e0bcb49c77b5c3610de86a8 hs21-b03
 1b3a350709e4325d759bb453ff3fb6a463270488 jdk7-b133
+447e6faab4a8755d4860c2366630729dbaec111c jdk7-b134
+3c76374706ea8a77e15aec8310e831e5734f8775 hs21-b04
+b898f0fc3cedc972d884d31a751afd75969531cf jdk7-b135
+b898f0fc3cedc972d884d31a751afd75969531cf hs21-b05
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java
index e11ab3f0d2d..321acfb0321 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/jdi/FieldImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,7 @@ public class FieldImpl extends TypeComponentImpl implements Field {
 
     // get the value of static field
     ValueImpl getValue() {
-        return getValue(saField.getFieldHolder());
+        return getValue(saField.getFieldHolder().getJavaMirror());
     }
 
     // get the value of this Field from a specific Oop
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java
index c17610cb29f..bfbeb26cc1a 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/StringTable.java
@@ -44,12 +44,10 @@ public class StringTable extends sun.jvm.hotspot.utilities.Hashtable {
   private static synchronized void initialize(TypeDataBase db) {
     Type type = db.lookupType("StringTable");
     theTableField  = type.getAddressField("_the_table");
-    stringTableSize = db.lookupIntConstant("StringTable::string_table_size").intValue();
   }
 
   // Fields
   private static AddressField theTableField;
-  private static int stringTableSize;
 
   // Accessors
   public static StringTable getTheTable() {
@@ -57,10 +55,6 @@ public class StringTable extends sun.jvm.hotspot.utilities.Hashtable {
     return (StringTable) VMObjectFactory.newObject(StringTable.class, tmp);
   }
 
-  public static int getStringTableSize() {
-    return stringTableSize;
-  }
-
   public StringTable(Address addr) {
     super(addr);
   }
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
index 0b33b94e7be..c2756bb9e79 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -87,7 +87,7 @@ public class InstanceKlass extends Klass {
     innerClasses         = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize());
     nonstaticFieldSize   = new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize());
     staticFieldSize      = new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize());
-    staticOopFieldSize   = new CIntField(type.getCIntegerField("_static_oop_field_size"), Oop.getHeaderSize());
+    staticOopFieldCount   = new CIntField(type.getCIntegerField("_static_oop_field_count"), Oop.getHeaderSize());
     nonstaticOopMapSize  = new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize());
     isMarkedDependent    = new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize());
     initState            = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize());
@@ -140,7 +140,7 @@ public class InstanceKlass extends Klass {
   private static OopField  innerClasses;
   private static CIntField nonstaticFieldSize;
   private static CIntField staticFieldSize;
-  private static CIntField staticOopFieldSize;
+  private static CIntField staticOopFieldCount;
   private static CIntField nonstaticOopMapSize;
   private static CIntField isMarkedDependent;
   private static CIntField initState;
@@ -261,8 +261,7 @@ public class InstanceKlass extends Klass {
   public Symbol    getSourceDebugExtension(){ return getSymbol(sourceDebugExtension); }
   public TypeArray getInnerClasses()        { return (TypeArray)    innerClasses.getValue(this); }
   public long      getNonstaticFieldSize()  { return                nonstaticFieldSize.getValue(this); }
-  public long      getStaticFieldSize()     { return                staticFieldSize.getValue(this); }
-  public long      getStaticOopFieldSize()  { return                staticOopFieldSize.getValue(this); }
+  public long      getStaticOopFieldCount() { return                staticOopFieldCount.getValue(this); }
   public long      getNonstaticOopMapSize() { return                nonstaticOopMapSize.getValue(this); }
   public boolean   getIsMarkedDependent()   { return                isMarkedDependent.getValue(this) != 0; }
   public long      getVtableLen()           { return                vtableLen.getValue(this); }
@@ -453,7 +452,7 @@ public class InstanceKlass extends Klass {
       visitor.doOop(innerClasses, true);
       visitor.doCInt(nonstaticFieldSize, true);
       visitor.doCInt(staticFieldSize, true);
-      visitor.doCInt(staticOopFieldSize, true);
+      visitor.doCInt(staticOopFieldCount, true);
       visitor.doCInt(nonstaticOopMapSize, true);
       visitor.doCInt(isMarkedDependent, true);
       visitor.doCInt(initState, true);
@@ -692,7 +691,7 @@ public class InstanceKlass extends Klass {
   public long getObjectSize() {
     long bodySize =    alignObjectOffset(getVtableLen() * getHeap().getOopSize())
                      + alignObjectOffset(getItableLen() * getHeap().getOopSize())
-                     + (getStaticFieldSize() + getNonstaticOopMapSize()) * getHeap().getOopSize();
+                     + (getNonstaticOopMapSize()) * getHeap().getOopSize();
     return alignObjectSize(headerSize + bodySize);
   }
 
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java
index aeaea7c8576..a320ec4f126 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/IntField.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,12 @@ public class IntField extends Field {
     super(holder, fieldArrayIndex);
   }
 
-  public int getValue(Oop obj) { return obj.getHandle().getJIntAt(getOffset()); }
+  public int getValue(Oop obj) {
+    if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
+      throw new InternalError(obj.toString());
+    }
+    return obj.getHandle().getJIntAt(getOffset());
+  }
   public void setValue(Oop obj, int value) throws MutationException {
     // Fix this: setJIntAt is missing in Address
   }
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java
index 51c84f201c4..a5575cb99e1 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopField.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,11 +41,17 @@ public class OopField extends Field {
   }
 
   public Oop getValue(Oop obj) {
+    if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
+      throw new InternalError();
+    }
     return obj.getHeap().newOop(getValueAsOopHandle(obj));
   }
 
   /** Debugging support */
   public OopHandle getValueAsOopHandle(Oop obj) {
+    if (!isVMField() && !obj.isInstance() && !obj.isArray()) {
+      throw new InternalError(obj.toString());
+    }
     return obj.getHandle().getOopHandleAt(getOffset());
   }
 
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
index 5a1fd9faa58..a51b9e9fc47 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/oops/OopUtilities.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -274,13 +274,7 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
        // hc_klass is a HotSpot magic field and hence we can't
        // find it from InstanceKlass for java.lang.Class.
        TypeDataBase db = VM.getVM().getTypeDataBase();
-       int hcKlassOffset = (int) Instance.getHeaderSize();
-       try {
-          hcKlassOffset += (db.lookupIntConstant("java_lang_Class::hc_klass_offset").intValue() *
-                           VM.getVM().getHeapOopSize());
-       } catch (RuntimeException re) {
-          // ignore, currently java_lang_Class::hc_klass_offset is zero
-       }
+       int hcKlassOffset = (int) db.lookupType("java_lang_Class").getCIntegerField("klass_offset").getValue();
        if (VM.getVM().isCompressedOopsEnabled()) {
          hcKlassField = new NarrowOopField(new NamedFieldIdentifier("hc_klass"), hcKlassOffset, true);
        } else {
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
index c0b31065b72..23b4ab9da5b 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/VM.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -839,13 +839,13 @@ public class VM {
   }
 
   private void readSystemProperties() {
-     InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
+     final InstanceKlass systemKls = getSystemDictionary().getSystemKlass();
      systemKls.iterate(new DefaultOopVisitor() {
                                ObjectReader objReader = new ObjectReader();
                                public void doOop(sun.jvm.hotspot.oops.OopField field, boolean isVMField) {
                                   if (field.getID().getName().equals("props")) {
                                      try {
-                                        sysProps = (Properties) objReader.readObject(field.getValue(getObj()));
+                                        sysProps = (Properties) objReader.readObject(field.getValue(systemKls.getJavaMirror()));
                                      } catch (Exception e) {
                                         if (Assert.ASSERTS_ENABLED) {
                                            e.printStackTrace();
diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
index 8da90314005..f1e9c5dd95f 100644
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -746,7 +746,7 @@ public class HeapHprofBinWriter extends AbstractHeapGraphWriter {
             out.writeByte((byte)kind);
             if (ik != null) {
                 // static field
-                writeField(field, ik);
+                writeField(field, ik.getJavaMirror());
             }
         }
     }
diff --git a/hotspot/agent/test/jdi/sasanity.sh b/hotspot/agent/test/jdi/sasanity.sh
index de05cd545dc..4b033fa703e 100644
--- a/hotspot/agent/test/jdi/sasanity.sh
+++ b/hotspot/agent/test/jdi/sasanity.sh
@@ -43,6 +43,7 @@ if [ "$1" == "-help" ]; then
 fi
 
 jdk=$1
+shift
 OS=`uname`
 
 if [ "$OS" != "Linux" ]; then
@@ -68,7 +69,7 @@ fi
 
 tmp=/tmp/sagsetup
 rm -f $tmp
-$jdk/bin/java sagtarg > $tmp &
+$jdk/bin/java $* sagtarg > $tmp &
 pid=$!
 while [ ! -s $tmp ] ; do
   # Kludge alert!
diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version
index 82f6dea775a..b581b833334 100644
--- a/hotspot/make/hotspot_version
+++ b/hotspot/make/hotspot_version
@@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2011
 
 HS_MAJOR_VER=21
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=04
+HS_BUILD_NUMBER=06
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=7
diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp
index 9d8642b3c09..b1c1413740f 100644
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp
@@ -3179,7 +3179,7 @@ void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_re
                                               Label& wrong_method_type) {
   assert_different_registers(mtype_reg, mh_reg, temp_reg);
   // compare method type against that of the receiver
-  RegisterOrConstant mhtype_offset = delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg);
+  RegisterOrConstant mhtype_offset = delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg);
   load_heap_oop(mh_reg, mhtype_offset, temp_reg);
   cmp(temp_reg, mtype_reg);
   br(Assembler::notEqual, false, Assembler::pn, wrong_method_type);
@@ -3195,14 +3195,14 @@ void MacroAssembler::load_method_handle_vmslots(Register vmslots_reg, Register m
                                                 Register temp_reg) {
   assert_different_registers(vmslots_reg, mh_reg, temp_reg);
   // load mh.type.form.vmslots
-  if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) {
+  if (java_lang_invoke_MethodHandle::vmslots_offset_in_bytes() != 0) {
     // hoist vmslots into every mh to avoid dependent load chain
-    ld(           Address(mh_reg,    delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)),   vmslots_reg);
+    ld(           Address(mh_reg,    delayed_value(java_lang_invoke_MethodHandle::vmslots_offset_in_bytes, temp_reg)),   vmslots_reg);
   } else {
     Register temp2_reg = vmslots_reg;
-    load_heap_oop(Address(mh_reg,    delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)),      temp2_reg);
-    load_heap_oop(Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)),        temp2_reg);
-    ld(           Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg);
+    load_heap_oop(Address(mh_reg,    delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg)),      temp2_reg);
+    load_heap_oop(Address(temp2_reg, delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, temp_reg)),        temp2_reg);
+    ld(           Address(temp2_reg, delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)), vmslots_reg);
   }
 }
 
@@ -3213,7 +3213,7 @@ void MacroAssembler::jump_to_method_handle_entry(Register mh_reg, Register temp_
 
   // pick out the interpreted side of the handler
   // NOTE: vmentry is not an oop!
-  ld_ptr(mh_reg, delayed_value(java_dyn_MethodHandle::vmentry_offset_in_bytes, temp_reg), temp_reg);
+  ld_ptr(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes, temp_reg), temp_reg);
 
   // off we go...
   ld_ptr(temp_reg, MethodHandleEntry::from_interpreted_entry_offset_in_bytes(), temp_reg);
diff --git a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp
index 049b75144c3..f1f35998755 100644
--- a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp
@@ -301,7 +301,8 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {
     // thread.
     assert(_obj != noreg, "must be a valid register");
     assert(_oop_index >= 0, "must have oop index");
-    __ ld_ptr(_obj, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc), G3);
+    __ load_heap_oop(_obj, java_lang_Class::klass_offset_in_bytes(), G3);
+    __ ld_ptr(G3, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc), G3);
     __ cmp(G2_thread, G3);
     __ br(Assembler::notEqual, false, Assembler::pn, call_patch);
     __ delayed()->nop();
diff --git a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp
index 8cae2273632..1b25b2af831 100644
--- a/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/cppInterpreter_sparc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1188,7 +1188,7 @@ void CppInterpreterGenerator::generate_compute_interpreter_state(const Register
   __ st_ptr(O2, XXX_STATE(_stack));                // PREPUSH
 
   __ lduh(max_stack, O3);                      // Full size expression stack
-  guarantee(!EnableMethodHandles, "no support yet for java.dyn.MethodHandle"); //6815692
+  guarantee(!EnableMethodHandles, "no support yet for java.lang.invoke.MethodHandle"); //6815692
   //6815692//if (EnableMethodHandles)
   //6815692//  __ inc(O3, methodOopDesc::extra_stack_entries());
   __ sll(O3, LogBytesPerWord, O3);
diff --git a/hotspot/src/cpu/sparc/vm/dump_sparc.cpp b/hotspot/src/cpu/sparc/vm/dump_sparc.cpp
index 5bfa1cebffd..afe0d4f5952 100644
--- a/hotspot/src/cpu/sparc/vm/dump_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/dump_sparc.cpp
@@ -80,13 +80,19 @@ void CompactingPermGenGen::generate_vtable_methods(void** vtbl_list,
     for (int j = 0; j < num_virtuals; ++j) {
       dummy_vtable[num_virtuals * i + j] = (void*)masm->pc();
       __ save(SP, -256, SP);
+      int offset = (i << 8) + j;
+      Register src = G0;
+      if (!Assembler::is_simm13(offset)) {
+        __ sethi(offset, L0);
+        src = L0;
+        offset = offset & ((1 << 10) - 1);
+      }
       __ brx(Assembler::always, false, Assembler::pt, common_code);
 
       // Load L0 with a value indicating vtable/offset pair.
       // -- bits[ 7..0]  (8 bits) which virtual method in table?
-      // -- bits[12..8]  (5 bits) which virtual method table?
-      // -- must fit in 13-bit instruction immediate field.
-      __ delayed()->set((i << 8) + j, L0);
+      // -- bits[13..8]  (6 bits) which virtual method table?
+      __ delayed()->or3(src, offset, L0);
     }
   }
 
diff --git a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp
index 1854475a5a9..42a51bd200c 100644
--- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,7 @@ define_pd_global(intx, CodeEntryAlignment,    32);
 define_pd_global(intx, OptoLoopAlignment,     16);  // = 4*wordSize
 define_pd_global(intx, InlineFrequencyCount,  50);  // we can use more inlining on the SPARC
 define_pd_global(intx, InlineSmallCode,       1500);
+
 #ifdef _LP64
 // Stack slots are 2X larger in LP64 than in the 32 bit VM.
 define_pd_global(intx, ThreadStackSize,       1024);
@@ -71,4 +72,6 @@ define_pd_global(bool, RewriteFrequentPairs, true);
 
 define_pd_global(bool, UseMembar,            false);
 
+// GC Ergo Flags
+define_pd_global(intx, CMSYoungGenPerWorker, 16*M);  // default max size of CMS young gen, per GC worker thread
 #endif // CPU_SPARC_VM_GLOBALS_SPARC_HPP
diff --git a/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp
index 503fb67d1dc..06375d0b0ad 100644
--- a/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/interpreter_sparc.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -260,7 +260,7 @@ address InterpreterGenerator::generate_abstract_entry(void) {
 
 
 // Method handle invoker
-// Dispatch a method of the form java.dyn.MethodHandles::invoke(...)
+// Dispatch a method of the form java.lang.invoke.MethodHandles::invoke(...)
 address InterpreterGenerator::generate_method_handle_entry(void) {
   if (!EnableMethodHandles) {
     return generate_abstract_entry();
diff --git a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp
index a7d2e389e49..397a59431bc 100644
--- a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp
@@ -112,8 +112,8 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler*
   }
 
   // given the MethodType, find out where the MH argument is buried
-  __ load_heap_oop(Address(O0_mtype,   __ delayed_value(java_dyn_MethodType::form_offset_in_bytes,        O1_scratch)), O4_argslot);
-  __ ldsw(         Address(O4_argslot, __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, O1_scratch)), O4_argslot);
+  __ load_heap_oop(Address(O0_mtype,   __ delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes,        O1_scratch)), O4_argslot);
+  __ ldsw(         Address(O4_argslot, __ delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, O1_scratch)), O4_argslot);
   __ add(Gargs, __ argument_offset(O4_argslot, 1), O4_argbase);
   // Note: argument_address uses its input as a scratch register!
   __ ld_ptr(Address(O4_argbase, -Interpreter::stackElementSize), G3_method_handle);
@@ -141,10 +141,10 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler*
   // load up an adapter from the calling type (Java weaves this)
   Register O2_form    = O2_scratch;
   Register O3_adapter = O3_scratch;
-  __ load_heap_oop(Address(O0_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes,               O1_scratch)), O2_form);
-  // load_heap_oop(Address(O2_form,  __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter);
+  __ load_heap_oop(Address(O0_mtype, __ delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes,               O1_scratch)), O2_form);
+  // load_heap_oop(Address(O2_form,  __ delayed_value(java_lang_invoke_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter);
   // deal with old JDK versions:
-  __ add(          Address(O2_form,  __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter);
+  __ add(          Address(O2_form,  __ delayed_value(java_lang_invoke_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter);
   __ cmp(O3_adapter, O2_form);
   Label sorry_no_invoke_generic;
   __ brx(Assembler::lessUnsigned, false, Assembler::pn, sorry_no_invoke_generic);
@@ -376,16 +376,16 @@ void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adapt
 
 // which conversion op types are implemented here?
 int MethodHandles::adapter_conversion_ops_supported_mask() {
-  return ((1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_CHECK_CAST)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_ROT_ARGS)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_DUP_ARGS)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_DROP_ARGS)
-         //|(1<<sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
+  return ((1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS)
+         //|(1<<java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
          );
   // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS.
 }
@@ -413,22 +413,22 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
   const Register O1_actual   = O1;
   const Register O2_required = O2;
 
-  guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
+  guarantee(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
 
   // Some handy addresses:
   Address G5_method_fie(    G5_method,        in_bytes(methodOopDesc::from_interpreted_offset()));
   Address G5_method_fce(    G5_method,        in_bytes(methodOopDesc::from_compiled_offset()));
 
-  Address G3_mh_vmtarget(   G3_method_handle, java_dyn_MethodHandle::vmtarget_offset_in_bytes());
+  Address G3_mh_vmtarget(   G3_method_handle, java_lang_invoke_MethodHandle::vmtarget_offset_in_bytes());
 
-  Address G3_dmh_vmindex(   G3_method_handle, sun_dyn_DirectMethodHandle::vmindex_offset_in_bytes());
+  Address G3_dmh_vmindex(   G3_method_handle, java_lang_invoke_DirectMethodHandle::vmindex_offset_in_bytes());
 
-  Address G3_bmh_vmargslot( G3_method_handle, sun_dyn_BoundMethodHandle::vmargslot_offset_in_bytes());
-  Address G3_bmh_argument(  G3_method_handle, sun_dyn_BoundMethodHandle::argument_offset_in_bytes());
+  Address G3_bmh_vmargslot( G3_method_handle, java_lang_invoke_BoundMethodHandle::vmargslot_offset_in_bytes());
+  Address G3_bmh_argument(  G3_method_handle, java_lang_invoke_BoundMethodHandle::argument_offset_in_bytes());
 
-  Address G3_amh_vmargslot( G3_method_handle, sun_dyn_AdapterMethodHandle::vmargslot_offset_in_bytes());
-  Address G3_amh_argument ( G3_method_handle, sun_dyn_AdapterMethodHandle::argument_offset_in_bytes());
-  Address G3_amh_conversion(G3_method_handle, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes());
+  Address G3_amh_vmargslot( G3_method_handle, java_lang_invoke_AdapterMethodHandle::vmargslot_offset_in_bytes());
+  Address G3_amh_argument ( G3_method_handle, java_lang_invoke_AdapterMethodHandle::argument_offset_in_bytes());
+  Address G3_amh_conversion(G3_method_handle, java_lang_invoke_AdapterMethodHandle::conversion_offset_in_bytes());
 
   const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
 
@@ -453,7 +453,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
       __ mov(O5_savedSP, SP);  // Cut the stack back to where the caller started.
 
       Label L_no_method;
-      // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
+      // FIXME: fill in _raise_exception_method with a suitable java.lang.invoke method
       __ set(AddressLiteral((address) &_raise_exception_method), G5_method);
       __ ld_ptr(Address(G5_method, 0), G5_method);
       __ tst(G5_method);
@@ -775,9 +775,13 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
       switch (ek) {
       case _adapter_opt_i2l:
         {
-          __ ldsw(arg_lsw, O2_scratch);                           // Load LSW
-          NOT_LP64(__ srlx(O2_scratch, BitsPerInt, O3_scratch));  // Move high bits to lower bits for std
-          __ st_long(O2_scratch, arg_msw);                        // Uses O2/O3 on !_LP64
+#ifdef _LP64
+          __ ldsw(arg_lsw, O2_scratch);                 // Load LSW sign-extended
+#else
+          __ ldsw(arg_lsw, O3_scratch);                 // Load LSW sign-extended
+          __ srlx(O3_scratch, BitsPerInt, O2_scratch);  // Move MSW value to lower 32-bits for std
+#endif
+          __ st_long(O2_scratch, arg_msw);              // Uses O2/O3 on !_LP64
         }
         break;
       case _adapter_opt_unboxl:
diff --git a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp
index d38c979fa87..a5bcc5e7738 100644
--- a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.cpp
@@ -52,6 +52,22 @@ void NativeInstruction::set_data64_sethi(address instaddr, intptr_t x) {
   ICache::invalidate_range(instaddr, 7 * BytesPerInstWord);
 }
 
+void NativeInstruction::verify_data64_sethi(address instaddr, intptr_t x) {
+  ResourceMark rm;
+  unsigned char buffer[10 * BytesPerInstWord];
+  CodeBuffer buf(buffer, 10 * BytesPerInstWord);
+  MacroAssembler masm(&buf);
+
+  Register destreg = inv_rd(*(unsigned int *)instaddr);
+  // Generate the proper sequence into a temporary buffer and compare
+  // it with the original sequence.
+  masm.patchable_sethi(x, destreg);
+  int len = buffer - masm.pc();
+  for (int i = 0; i < len; i++) {
+    assert(instaddr[i] == buffer[i], "instructions must match");
+  }
+}
+
 void NativeInstruction::verify() {
   // make sure code pattern is actually an instruction address
   address addr = addr_at(0);
diff --git a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp
index 3ecb6d93720..7549281f0ba 100644
--- a/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp
+++ b/hotspot/src/cpu/sparc/vm/nativeInst_sparc.hpp
@@ -254,6 +254,7 @@ class NativeInstruction VALUE_OBJ_CLASS_SPEC {
   // sethi.  This only does the sethi.  The disp field (bottom 10 bits)
   // must be handled separately.
   static void set_data64_sethi(address instaddr, intptr_t x);
+  static void verify_data64_sethi(address instaddr, intptr_t x);
 
   // combine the fields of a sethi/simm13 pair (simm13 = or, add, jmpl, ld/st)
   static int data32(int sethi_insn, int arith_insn) {
diff --git a/hotspot/src/cpu/sparc/vm/relocInfo_sparc.cpp b/hotspot/src/cpu/sparc/vm/relocInfo_sparc.cpp
index d2cefd35d55..a2913f6f055 100644
--- a/hotspot/src/cpu/sparc/vm/relocInfo_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/relocInfo_sparc.cpp
@@ -30,7 +30,7 @@
 #include "oops/oop.inline.hpp"
 #include "runtime/safepoint.hpp"
 
-void Relocation::pd_set_data_value(address x, intptr_t o) {
+void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
   NativeInstruction* ip = nativeInstruction_at(addr());
   jint inst = ip->long_at(0);
   assert(inst != NativeInstruction::illegal_instruction(), "no breakpoint");
@@ -83,7 +83,11 @@ void Relocation::pd_set_data_value(address x, intptr_t o) {
     guarantee(Assembler::is_simm13(simm13), "offset can't overflow simm13");
     inst &= ~Assembler::simm(    -1, 13);
     inst |=  Assembler::simm(simm13, 13);
-    ip->set_long_at(0, inst);
+    if (verify_only) {
+      assert(ip->long_at(0) == inst, "instructions must match");
+    } else {
+      ip->set_long_at(0, inst);
+    }
     }
     break;
 
@@ -97,19 +101,36 @@ void Relocation::pd_set_data_value(address x, intptr_t o) {
       jint np = oopDesc::encode_heap_oop((oop)x);
       inst &= ~Assembler::hi22(-1);
       inst |=  Assembler::hi22((intptr_t)np);
-      ip->set_long_at(0, inst);
+      if (verify_only) {
+        assert(ip->long_at(0) == inst, "instructions must match");
+      } else {
+        ip->set_long_at(0, inst);
+      }
       inst2 = ip->long_at( NativeInstruction::nop_instruction_size );
       guarantee(Assembler::inv_op(inst2)==Assembler::arith_op, "arith op");
-      ip->set_long_at(NativeInstruction::nop_instruction_size, ip->set_data32_simm13( inst2, (intptr_t)np));
+      if (verify_only) {
+        assert(ip->long_at(NativeInstruction::nop_instruction_size) == NativeInstruction::set_data32_simm13( inst2, (intptr_t)np),
+               "instructions must match");
+      } else {
+        ip->set_long_at(NativeInstruction::nop_instruction_size, NativeInstruction::set_data32_simm13( inst2, (intptr_t)np));
+      }
       break;
     }
-    ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x );
+    if (verify_only) {
+      ip->verify_data64_sethi( ip->addr_at(0), (intptr_t)x );
+    } else {
+      ip->set_data64_sethi( ip->addr_at(0), (intptr_t)x );
+    }
 #else
     guarantee(Assembler::inv_op2(inst)==Assembler::sethi_op2, "must be sethi");
     inst &= ~Assembler::hi22(     -1);
     inst |=  Assembler::hi22((intptr_t)x);
     // (ignore offset; it doesn't play into the sethi)
-    ip->set_long_at(0, inst);
+    if (verify_only) {
+      assert(ip->long_at(0) == inst, "instructions must match");
+    } else {
+      ip->set_long_at(0, inst);
+    }
 #endif
     }
     break;
diff --git a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp
index 0706eb140df..e590cb8235d 100644
--- a/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp
+++ b/hotspot/src/cpu/sparc/vm/templateTable_sparc.cpp
@@ -3303,7 +3303,7 @@ void TemplateTable::invokedynamic(int byte_no) {
   __ sll(Rret, LogBytesPerWord, Rret);
   __ ld_ptr(Rtemp, Rret, Rret);  // get return address
 
-  __ load_heap_oop(G5_callsite, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, Rscratch), G3_method_handle);
+  __ load_heap_oop(G5_callsite, __ delayed_value(java_lang_invoke_CallSite::target_offset_in_bytes, Rscratch), G3_method_handle);
   __ null_check(G3_method_handle);
 
   // Adjust Rret first so Llast_SP can be same as Rret
diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp
index 863aac9bfa2..d621a3cbff9 100644
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp
@@ -7831,7 +7831,7 @@ RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_ad
 void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg,
                                               Register temp_reg,
                                               Label& wrong_method_type) {
-  Address type_addr(mh_reg, delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg));
+  Address type_addr(mh_reg, delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg));
   // compare method type against that of the receiver
   if (UseCompressedOops) {
     load_heap_oop(temp_reg, type_addr);
@@ -7851,14 +7851,14 @@ void MacroAssembler::load_method_handle_vmslots(Register vmslots_reg, Register m
                                                 Register temp_reg) {
   assert_different_registers(vmslots_reg, mh_reg, temp_reg);
   // load mh.type.form.vmslots
-  if (java_dyn_MethodHandle::vmslots_offset_in_bytes() != 0) {
+  if (java_lang_invoke_MethodHandle::vmslots_offset_in_bytes() != 0) {
     // hoist vmslots into every mh to avoid dependent load chain
-    movl(vmslots_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmslots_offset_in_bytes, temp_reg)));
+    movl(vmslots_reg, Address(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmslots_offset_in_bytes, temp_reg)));
   } else {
     Register temp2_reg = vmslots_reg;
-    load_heap_oop(temp2_reg, Address(mh_reg,    delayed_value(java_dyn_MethodHandle::type_offset_in_bytes, temp_reg)));
-    load_heap_oop(temp2_reg, Address(temp2_reg, delayed_value(java_dyn_MethodType::form_offset_in_bytes, temp_reg)));
-    movl(vmslots_reg, Address(temp2_reg, delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)));
+    load_heap_oop(temp2_reg, Address(mh_reg,    delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg)));
+    load_heap_oop(temp2_reg, Address(temp2_reg, delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, temp_reg)));
+    movl(vmslots_reg, Address(temp2_reg, delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, temp_reg)));
   }
 }
 
@@ -7873,7 +7873,7 @@ void MacroAssembler::jump_to_method_handle_entry(Register mh_reg, Register temp_
 
   // pick out the interpreted side of the handler
   // NOTE: vmentry is not an oop!
-  movptr(temp_reg, Address(mh_reg, delayed_value(java_dyn_MethodHandle::vmentry_offset_in_bytes, temp_reg)));
+  movptr(temp_reg, Address(mh_reg, delayed_value(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes, temp_reg)));
 
   // off we go...
   jmp(Address(temp_reg, MethodHandleEntry::from_interpreted_entry_offset_in_bytes()));
diff --git a/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp b/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
index 7453375353a..3603831155a 100644
--- a/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
@@ -313,10 +313,13 @@ void PatchingStub::emit_code(LIR_Assembler* ce) {
     }
     assert(_obj != noreg, "must be a valid register");
     Register tmp = rax;
-    if (_obj == tmp) tmp = rbx;
+    Register tmp2 = rbx;
     __ push(tmp);
+    __ push(tmp2);
+    __ load_heap_oop(tmp2, Address(_obj, java_lang_Class::klass_offset_in_bytes()));
     __ get_thread(tmp);
-    __ cmpptr(tmp, Address(_obj, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc)));
+    __ cmpptr(tmp, Address(tmp2, instanceKlass::init_thread_offset_in_bytes() + sizeof(klassOopDesc)));
+    __ pop(tmp2);
     __ pop(tmp);
     __ jcc(Assembler::notEqual, call_patch);
 
diff --git a/hotspot/src/cpu/x86/vm/globals_x86.hpp b/hotspot/src/cpu/x86/vm/globals_x86.hpp
index bdd705484a0..8b79f8ee984 100644
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,4 +72,6 @@ define_pd_global(bool, RewriteFrequentPairs, true);
 
 define_pd_global(bool, UseMembar,            false);
 
+// GC Ergo Flags
+define_pd_global(intx, CMSYoungGenPerWorker, 64*M);  // default max size of CMS young gen, per GC worker thread
 #endif // CPU_X86_VM_GLOBALS_X86_HPP
diff --git a/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp
index 20abf49e441..6261c81cd64 100644
--- a/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp
+++ b/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp
@@ -231,7 +231,7 @@ address InterpreterGenerator::generate_abstract_entry(void) {
 
 
 // Method handle invoker
-// Dispatch a method of the form java.dyn.MethodHandles::invoke(...)
+// Dispatch a method of the form java.lang.invoke.MethodHandles::invoke(...)
 address InterpreterGenerator::generate_method_handle_entry(void) {
   if (!EnableMethodHandles) {
     return generate_abstract_entry();
diff --git a/hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp
index 373379663a8..8d46c93490c 100644
--- a/hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/interpreter_x86_64.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -318,7 +318,7 @@ address InterpreterGenerator::generate_abstract_entry(void) {
 
 
 // Method handle invoker
-// Dispatch a method of the form java.dyn.MethodHandles::invoke(...)
+// Dispatch a method of the form java.lang.invoke.MethodHandles::invoke(...)
 address InterpreterGenerator::generate_method_handle_entry(void) {
   if (!EnableMethodHandles) {
     return generate_abstract_entry();
diff --git a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp
index 0fe165ff423..704fb7d3592 100644
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp
@@ -125,9 +125,9 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler*
   }
 
   // given the MethodType, find out where the MH argument is buried
-  __ load_heap_oop(rdx_temp, Address(rax_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, rdi_temp)));
+  __ load_heap_oop(rdx_temp, Address(rax_mtype, __ delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, rdi_temp)));
   Register rdx_vmslots = rdx_temp;
-  __ movl(rdx_vmslots, Address(rdx_temp, __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, rdi_temp)));
+  __ movl(rdx_vmslots, Address(rdx_temp, __ delayed_value(java_lang_invoke_MethodTypeForm::vmslots_offset_in_bytes, rdi_temp)));
   __ movptr(rcx_recv, __ argument_address(rdx_vmslots));
 
   trace_method_handle(_masm, "invokeExact");
@@ -154,11 +154,11 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler*
                    rcx_argslot, rbx_temp, rdx_temp);
 
   // load up an adapter from the calling type (Java weaves this)
-  __ load_heap_oop(rdx_temp, Address(rax_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, rdi_temp)));
+  __ load_heap_oop(rdx_temp, Address(rax_mtype, __ delayed_value(java_lang_invoke_MethodType::form_offset_in_bytes, rdi_temp)));
   Register rdx_adapter = rdx_temp;
-  // __ load_heap_oop(rdx_adapter, Address(rdx_temp, java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes()));
+  // __ load_heap_oop(rdx_adapter, Address(rdx_temp, java_lang_invoke_MethodTypeForm::genericInvoker_offset_in_bytes()));
   // deal with old JDK versions:
-  __ lea(rdi_temp, Address(rdx_temp, __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, rdi_temp)));
+  __ lea(rdi_temp, Address(rdx_temp, __ delayed_value(java_lang_invoke_MethodTypeForm::genericInvoker_offset_in_bytes, rdi_temp)));
   __ cmpptr(rdi_temp, rdx_temp);
   Label sorry_no_invoke_generic;
   __ jcc(Assembler::below, sorry_no_invoke_generic);
@@ -371,16 +371,16 @@ void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adapt
 
 // which conversion op types are implemented here?
 int MethodHandles::adapter_conversion_ops_supported_mask() {
-  return ((1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_CHECK_CAST)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_ROT_ARGS)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_DUP_ARGS)
-         |(1<<sun_dyn_AdapterMethodHandle::OP_DROP_ARGS)
-         //|(1<<sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
+  return ((1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS)
+         |(1<<java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS)
+         //|(1<<java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
          );
   // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS.
 }
@@ -415,21 +415,21 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
   const Register rarg2_required = LP64_ONLY(j_rarg2) NOT_LP64(rdi);
   assert_different_registers(rarg0_code, rarg1_actual, rarg2_required, saved_last_sp);
 
-  guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
+  guarantee(java_lang_invoke_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
 
   // some handy addresses
   Address rbx_method_fie(     rbx,      methodOopDesc::from_interpreted_offset() );
   Address rbx_method_fce(     rbx,      methodOopDesc::from_compiled_offset() );
 
-  Address rcx_mh_vmtarget(    rcx_recv, java_dyn_MethodHandle::vmtarget_offset_in_bytes() );
-  Address rcx_dmh_vmindex(    rcx_recv, sun_dyn_DirectMethodHandle::vmindex_offset_in_bytes() );
+  Address rcx_mh_vmtarget(    rcx_recv, java_lang_invoke_MethodHandle::vmtarget_offset_in_bytes() );
+  Address rcx_dmh_vmindex(    rcx_recv, java_lang_invoke_DirectMethodHandle::vmindex_offset_in_bytes() );
 
-  Address rcx_bmh_vmargslot(  rcx_recv, sun_dyn_BoundMethodHandle::vmargslot_offset_in_bytes() );
-  Address rcx_bmh_argument(   rcx_recv, sun_dyn_BoundMethodHandle::argument_offset_in_bytes() );
+  Address rcx_bmh_vmargslot(  rcx_recv, java_lang_invoke_BoundMethodHandle::vmargslot_offset_in_bytes() );
+  Address rcx_bmh_argument(   rcx_recv, java_lang_invoke_BoundMethodHandle::argument_offset_in_bytes() );
 
-  Address rcx_amh_vmargslot(  rcx_recv, sun_dyn_AdapterMethodHandle::vmargslot_offset_in_bytes() );
-  Address rcx_amh_argument(   rcx_recv, sun_dyn_AdapterMethodHandle::argument_offset_in_bytes() );
-  Address rcx_amh_conversion( rcx_recv, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes() );
+  Address rcx_amh_vmargslot(  rcx_recv, java_lang_invoke_AdapterMethodHandle::vmargslot_offset_in_bytes() );
+  Address rcx_amh_argument(   rcx_recv, java_lang_invoke_AdapterMethodHandle::argument_offset_in_bytes() );
+  Address rcx_amh_conversion( rcx_recv, java_lang_invoke_AdapterMethodHandle::conversion_offset_in_bytes() );
   Address vmarg;                // __ argument_address(vmargslot)
 
   const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
@@ -460,7 +460,7 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan
 
       Register rbx_method = rbx_temp;
       Label L_no_method;
-      // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
+      // FIXME: fill in _raise_exception_method with a suitable java.lang.invoke method
       __ movptr(rbx_method, ExternalAddress((address) &_raise_exception_method));
       __ testptr(rbx_method, rbx_method);
       __ jccb(Assembler::zero, L_no_method);
diff --git a/hotspot/src/cpu/x86/vm/relocInfo_x86.cpp b/hotspot/src/cpu/x86/vm/relocInfo_x86.cpp
index 97e3645bd3c..1f907533d48 100644
--- a/hotspot/src/cpu/x86/vm/relocInfo_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/relocInfo_x86.cpp
@@ -31,7 +31,7 @@
 #include "runtime/safepoint.hpp"
 
 
-void Relocation::pd_set_data_value(address x, intptr_t o) {
+void Relocation::pd_set_data_value(address x, intptr_t o, bool verify_only) {
 #ifdef AMD64
   x += o;
   typedef Assembler::WhichOperand WhichOperand;
@@ -40,19 +40,35 @@ void Relocation::pd_set_data_value(address x, intptr_t o) {
          which == Assembler::narrow_oop_operand ||
          which == Assembler::imm_operand, "format unpacks ok");
   if (which == Assembler::imm_operand) {
-    *pd_address_in_code() = x;
+    if (verify_only) {
+      assert(*pd_address_in_code() == x, "instructions must match");
+    } else {
+      *pd_address_in_code() = x;
+    }
   } else if (which == Assembler::narrow_oop_operand) {
     address disp = Assembler::locate_operand(addr(), which);
-    *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
+    if (verify_only) {
+      assert(*(uint32_t*) disp == oopDesc::encode_heap_oop((oop)x), "instructions must match");
+    } else {
+      *(int32_t*) disp = oopDesc::encode_heap_oop((oop)x);
+    }
   } else {
     // Note:  Use runtime_call_type relocations for call32_operand.
     address ip = addr();
     address disp = Assembler::locate_operand(ip, which);
     address next_ip = Assembler::locate_next_instruction(ip);
-    *(int32_t*) disp = x - next_ip;
+    if (verify_only) {
+      assert(*(int32_t*) disp == (x - next_ip), "instructions must match");
+    } else {
+      *(int32_t*) disp = x - next_ip;
+    }
   }
 #else
-  *pd_address_in_code() = x + o;
+  if (verify_only) {
+    assert(*pd_address_in_code() == (x + o), "instructions must match");
+  } else {
+    *pd_address_in_code() = x + o;
+  }
 #endif // AMD64
 }
 
diff --git a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp
index 742b20443c9..73ed5182d8e 100644
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp
@@ -3110,7 +3110,7 @@ void TemplateTable::invokedynamic(int byte_no) {
     __ profile_call(rsi);
   }
 
-  __ movptr(rcx_method_handle, Address(rax_callsite, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, rcx)));
+  __ movptr(rcx_method_handle, Address(rax_callsite, __ delayed_value(java_lang_invoke_CallSite::target_offset_in_bytes, rcx)));
   __ null_check(rcx_method_handle);
   __ prepare_to_jump_from_interpreted();
   __ jump_to_method_handle_entry(rcx_method_handle, rdx);
diff --git a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp
index 458d1fedc16..2638cbc7d4c 100644
--- a/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp
+++ b/hotspot/src/cpu/x86/vm/templateTable_x86_64.cpp
@@ -3145,7 +3145,7 @@ void TemplateTable::invokedynamic(int byte_no) {
     __ profile_call(r13);
   }
 
-  __ load_heap_oop(rcx_method_handle, Address(rax_callsite, __ delayed_value(java_dyn_CallSite::target_offset_in_bytes, rcx)));
+  __ load_heap_oop(rcx_method_handle, Address(rax_callsite, __ delayed_value(java_lang_invoke_CallSite::target_offset_in_bytes, rcx)));
   __ null_check(rcx_method_handle);
   __ prepare_to_jump_from_interpreted();
   __ jump_to_method_handle_entry(rcx_method_handle, rdx);
diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
index df40c5638b7..3321d54860c 100644
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp
@@ -436,6 +436,13 @@ void VM_Version::get_processor_features() {
         UseCountLeadingZerosInstruction = true;
       }
     }
+
+    // On family 21 processors default is no sw prefetch
+    if ( cpu_family() == 21 ) {
+      if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
+        AllocatePrefetchStyle = 0;
+      }
+    }
   }
 
   if( is_intel() ) { // Intel cpus specific settings
diff --git a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
index 1c945f22dd4..ee8d7a2b403 100644
--- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
+++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -281,7 +281,7 @@ int CppInterpreter::native_entry(methodOop method, intptr_t UNUSED, TRAPS) {
 
     if (method->is_static()) {
       istate->set_oop_temp(
-        method->constants()->pool_holder()->klass_part()->java_mirror());
+        method->constants()->pool_holder()->java_mirror());
       mirror = istate->oop_temp_addr();
       *(dst++) = &mirror;
     }
@@ -667,7 +667,7 @@ InterpreterFrame *InterpreterFrame::build(const methodOop method, TRAPS) {
       (BasicObjectLock *) stack->alloc(monitor_words * wordSize);
     oop object;
     if (method->is_static())
-      object = method->constants()->pool_holder()->klass_part()->java_mirror();
+      object = method->constants()->pool_holder()->java_mirror();
     else
       object = (oop) locals[0];
     monitor->set_obj(object);
diff --git a/hotspot/src/os/solaris/dtrace/libjvm_db.c b/hotspot/src/os/solaris/dtrace/libjvm_db.c
index 2c01516cedd..82cef0912bc 100644
--- a/hotspot/src/os/solaris/dtrace/libjvm_db.c
+++ b/hotspot/src/os/solaris/dtrace/libjvm_db.c
@@ -524,6 +524,8 @@ name_for_methodOop(jvm_agent_t* J, uint64_t methodOopPtr, char * result, size_t
   CHECK_FAIL(err);
   err = read_pointer(J, constantPool + nameIndex * POINTER_SIZE + SIZE_constantPoolOopDesc, &nameSymbol);
   CHECK_FAIL(err);
+  // The symbol is a CPSlot and has lower bit set to indicate metadata
+  nameSymbol &= (~1); // remove metadata lsb
   err = ps_pread(J->P, nameSymbol + OFFSET_Symbol_length, &nameSymbolLength, 2);
   CHECK_FAIL(err);
   nameString = (char*)calloc(nameSymbolLength + 1, 1);
@@ -535,6 +537,7 @@ name_for_methodOop(jvm_agent_t* J, uint64_t methodOopPtr, char * result, size_t
   CHECK_FAIL(err);
   err = read_pointer(J, constantPool + signatureIndex * POINTER_SIZE + SIZE_constantPoolOopDesc, &signatureSymbol);
   CHECK_FAIL(err);
+  signatureSymbol &= (~1);  // remove metadata lsb
   err = ps_pread(J->P, signatureSymbol + OFFSET_Symbol_length, &signatureSymbolLength, 2);
   CHECK_FAIL(err);
   signatureString = (char*)calloc(signatureSymbolLength + 1, 1);
diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp
index 6c050438d5a..885e9056552 100644
--- a/hotspot/src/os/windows/vm/os_windows.cpp
+++ b/hotspot/src/os/windows/vm/os_windows.cpp
@@ -3297,9 +3297,14 @@ bool os::is_interrupted(Thread* thread, bool clear_interrupted) {
          "possibility of dangling Thread pointer");
 
   OSThread* osthread = thread->osthread();
-  bool interrupted;
-  interrupted = osthread->interrupted();
-  if (clear_interrupted == true) {
+  bool interrupted = osthread->interrupted();
+  // There is no synchronization between the setting of the interrupt
+  // and it being cleared here. It is critical - see 6535709 - that
+  // we only clear the interrupt state, and reset the interrupt event,
+  // if we are going to report that we were indeed interrupted - else
+  // an interrupt can be "lost", leading to spurious wakeups or lost wakeups
+  // depending on the timing
+  if (interrupted && clear_interrupted) {
     osthread->set_interrupted(false);
     ResetEvent(osthread->interrupt_event());
   } // Otherwise leave the interrupted state alone
diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
index a2d4009408e..3291fe18fb2 100644
--- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
+++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp
@@ -209,7 +209,7 @@ void Canonicalizer::do_StoreField     (StoreField*      x) {
     // limit this optimization to current block
     if (value != NULL && in_current_block(conv)) {
       set_canonical(new StoreField(x->obj(), x->offset(), x->field(), value, x->is_static(),
-                                       x->state_before(), x->is_loaded(), x->is_initialized()));
+                                   x->state_before(), x->needs_patching()));
       return;
     }
   }
diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
index c31c407c352..4e5f4edf0e6 100644
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
@@ -1456,12 +1456,12 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
   BasicType field_type = field->type()->basic_type();
   ValueType* type = as_ValueType(field_type);
   // call will_link again to determine if the field is valid.
-  const bool is_loaded = holder->is_loaded() &&
-                         field->will_link(method()->holder(), code);
-  const bool is_initialized = is_loaded && holder->is_initialized();
+  const bool needs_patching = !holder->is_loaded() ||
+                              !field->will_link(method()->holder(), code) ||
+                              PatchALot;
 
   ValueStack* state_before = NULL;
-  if (!is_initialized || PatchALot) {
+  if (!holder->is_initialized() || needs_patching) {
     // save state before instruction for debug info when
     // deoptimization happens during patching
     state_before = copy_state_before();
@@ -1469,20 +1469,16 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
 
   Value obj = NULL;
   if (code == Bytecodes::_getstatic || code == Bytecodes::_putstatic) {
-    // commoning of class constants should only occur if the class is
-    // fully initialized and resolved in this constant pool.  The will_link test
-    // above essentially checks if this class is resolved in this constant pool
-    // so, the is_initialized flag should be suffiect.
     if (state_before != NULL) {
       // build a patching constant
-      obj = new Constant(new ClassConstant(holder), state_before);
+      obj = new Constant(new InstanceConstant(holder->java_mirror()), state_before);
     } else {
-      obj = new Constant(new ClassConstant(holder));
+      obj = new Constant(new InstanceConstant(holder->java_mirror()));
     }
   }
 
 
-  const int offset = is_loaded ? field->offset() : -1;
+  const int offset = !needs_patching ? field->offset() : -1;
   switch (code) {
     case Bytecodes::_getstatic: {
       // check for compile-time constants, i.e., initialized static final fields
@@ -1509,7 +1505,7 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
           state_before = copy_state_for_exception();
         }
         push(type, append(new LoadField(append(obj), offset, field, true,
-                                        state_before, is_loaded, is_initialized)));
+                                        state_before, needs_patching)));
       }
       break;
     }
@@ -1518,7 +1514,7 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
         if (state_before == NULL) {
           state_before = copy_state_for_exception();
         }
-        append(new StoreField(append(obj), offset, field, val, true, state_before, is_loaded, is_initialized));
+        append(new StoreField(append(obj), offset, field, val, true, state_before, needs_patching));
       }
       break;
     case Bytecodes::_getfield :
@@ -1526,8 +1522,8 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
         if (state_before == NULL) {
           state_before = copy_state_for_exception();
         }
-        LoadField* load = new LoadField(apop(), offset, field, false, state_before, is_loaded, true);
-        Value replacement = is_loaded ? _memory->load(load) : load;
+        LoadField* load = new LoadField(apop(), offset, field, false, state_before, needs_patching);
+        Value replacement = !needs_patching ? _memory->load(load) : load;
         if (replacement != load) {
           assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked");
           push(type, replacement);
@@ -1542,8 +1538,8 @@ void GraphBuilder::access_field(Bytecodes::Code code) {
         if (state_before == NULL) {
           state_before = copy_state_for_exception();
         }
-        StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, is_loaded, true);
-        if (is_loaded) store = _memory->store(store);
+        StoreField* store = new StoreField(apop(), offset, field, val, false, state_before, needs_patching);
+        if (!needs_patching) store = _memory->store(store);
         if (store != NULL) {
           append(store);
         }
diff --git a/hotspot/src/share/vm/c1/c1_Instruction.hpp b/hotspot/src/share/vm/c1/c1_Instruction.hpp
index 3a5eecc2d7b..d997c572c4e 100644
--- a/hotspot/src/share/vm/c1/c1_Instruction.hpp
+++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp
@@ -323,8 +323,6 @@ class Instruction: public CompilationResourceObj {
     CanTrapFlag,
     DirectCompareFlag,
     IsEliminatedFlag,
-    IsInitializedFlag,
-    IsLoadedFlag,
     IsSafepointFlag,
     IsStaticFlag,
     IsStrictfpFlag,
@@ -693,7 +691,7 @@ BASE(AccessField, Instruction)
  public:
   // creation
   AccessField(Value obj, int offset, ciField* field, bool is_static,
-              ValueStack* state_before, bool is_loaded, bool is_initialized)
+              ValueStack* state_before, bool needs_patching)
   : Instruction(as_ValueType(field->type()->basic_type()), state_before)
   , _obj(obj)
   , _offset(offset)
@@ -701,16 +699,9 @@ BASE(AccessField, Instruction)
   , _explicit_null_check(NULL)
   {
     set_needs_null_check(!is_static);
-    set_flag(IsLoadedFlag, is_loaded);
-    set_flag(IsInitializedFlag, is_initialized);
     set_flag(IsStaticFlag, is_static);
+    set_flag(NeedsPatchingFlag, needs_patching);
     ASSERT_VALUES
-      if (!is_loaded || (PatchALot && !field->is_volatile())) {
-      // need to patch if the holder wasn't loaded or we're testing
-      // using PatchALot.  Don't allow PatchALot for fields which are
-      // known to be volatile they aren't patchable.
-      set_flag(NeedsPatchingFlag, true);
-    }
     // pin of all instructions with memory access
     pin();
   }
@@ -721,11 +712,14 @@ BASE(AccessField, Instruction)
   ciField* field() const                         { return _field; }
   BasicType field_type() const                   { return _field->type()->basic_type(); }
   bool is_static() const                         { return check_flag(IsStaticFlag); }
-  bool is_loaded() const                         { return check_flag(IsLoadedFlag); }
-  bool is_initialized() const                    { return check_flag(IsInitializedFlag); }
   NullCheck* explicit_null_check() const         { return _explicit_null_check; }
   bool needs_patching() const                    { return check_flag(NeedsPatchingFlag); }
 
+  // Unresolved getstatic and putstatic can cause initialization.
+  // Technically it occurs at the Constant that materializes the base
+  // of the static fields but it's simpler to model it here.
+  bool is_init_point() const                     { return is_static() && (needs_patching() || !_field->holder()->is_initialized()); }
+
   // manipulation
 
   // Under certain circumstances, if a previous NullCheck instruction
@@ -745,15 +739,15 @@ LEAF(LoadField, AccessField)
  public:
   // creation
   LoadField(Value obj, int offset, ciField* field, bool is_static,
-            ValueStack* state_before, bool is_loaded, bool is_initialized)
-  : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized)
+            ValueStack* state_before, bool needs_patching)
+  : AccessField(obj, offset, field, is_static, state_before, needs_patching)
   {}
 
   ciType* declared_type() const;
   ciType* exact_type() const;
 
   // generic
-  HASHING2(LoadField, is_loaded() && !field()->is_volatile(), obj()->subst(), offset())  // cannot be eliminated if not yet loaded or if volatile
+  HASHING2(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset())  // cannot be eliminated if needs patching or if volatile
 };
 
 
@@ -764,8 +758,8 @@ LEAF(StoreField, AccessField)
  public:
   // creation
   StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
-             ValueStack* state_before, bool is_loaded, bool is_initialized)
-  : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized)
+             ValueStack* state_before, bool needs_patching)
+  : AccessField(obj, offset, field, is_static, state_before, needs_patching)
   , _value(value)
   {
     set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
diff --git a/hotspot/src/share/vm/c1/c1_LIR.hpp b/hotspot/src/share/vm/c1/c1_LIR.hpp
index 50bf4c4e9ba..c5c5d91c7ac 100644
--- a/hotspot/src/share/vm/c1/c1_LIR.hpp
+++ b/hotspot/src/share/vm/c1/c1_LIR.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1156,7 +1156,7 @@ class LIR_OpJavaCall: public LIR_OpCall {
     return
       is_invokedynamic()  // An invokedynamic is always a MethodHandle call site.
       ||
-      (method()->holder()->name() == ciSymbol::java_dyn_MethodHandle() &&
+      (method()->holder()->name() == ciSymbol::java_lang_invoke_MethodHandle() &&
        methodOopDesc::is_method_handle_invoke_name(method()->name()->sid()));
   }
 
diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
index 3faff5367fa..ae3773bcc29 100644
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
@@ -1559,9 +1559,7 @@ void LIRGenerator::do_StoreField(StoreField* x) {
                 (info ? new CodeEmitInfo(info) : NULL));
   }
 
-  if (is_volatile) {
-    assert(!needs_patching && x->is_loaded(),
-           "how do we know it's volatile if it's not loaded");
+  if (is_volatile && !needs_patching) {
     volatile_field_store(value.result(), address, info);
   } else {
     LIR_PatchCode patch_code = needs_patching ? lir_patch_normal : lir_patch_none;
@@ -1627,9 +1625,7 @@ void LIRGenerator::do_LoadField(LoadField* x) {
     address = generate_address(object.result(), x->offset(), field_type);
   }
 
-  if (is_volatile) {
-    assert(!needs_patching && x->is_loaded(),
-           "how do we know it's volatile if it's not loaded");
+  if (is_volatile && !needs_patching) {
     volatile_field_load(address, reg, info);
   } else {
     LIR_PatchCode patch_code = needs_patching ? lir_patch_normal : lir_patch_none;
@@ -2516,7 +2512,7 @@ void LIRGenerator::do_Invoke(Invoke* x) {
       __ load(new LIR_Address(tmp, call_site_offset, T_OBJECT), tmp);
 
       // Load target MethodHandle from CallSite object.
-      __ load(new LIR_Address(tmp, java_dyn_CallSite::target_offset_in_bytes(), T_OBJECT), receiver);
+      __ load(new LIR_Address(tmp, java_lang_invoke_CallSite::target_offset_in_bytes(), T_OBJECT), receiver);
 
       __ call_dynamic(target, receiver, result_register,
                       SharedRuntime::get_resolve_opt_virtual_call_stub(),
diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp
index 16fd0aea1ca..043ea39cdb5 100644
--- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp
+++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp
@@ -2703,7 +2703,7 @@ int LinearScan::append_scope_value_for_operand(LIR_Opr opr, GrowableArray<ScopeV
       assert(_fpu_stack_allocator != NULL, "must be present");
       opr = _fpu_stack_allocator->to_fpu_stack(opr);
 
-      assert(opr->fpu_regnrLo() == opr->fpu_regnrHi(), "assumed in calculation (only fpu_regnrHi is used)");
+      assert(opr->fpu_regnrLo() == opr->fpu_regnrHi(), "assumed in calculation (only fpu_regnrLo is used)");
 #endif
 #ifdef SPARC
       assert(opr->fpu_regnrLo() == opr->fpu_regnrHi() + 1, "assumed in calculation (only fpu_regnrHi is used)");
@@ -2715,7 +2715,12 @@ int LinearScan::append_scope_value_for_operand(LIR_Opr opr, GrowableArray<ScopeV
       assert(opr->fpu_regnrLo() == opr->fpu_regnrHi(), "assumed in calculation (only fpu_regnrHi is used)");
 #endif
 
+#ifdef VM_LITTLE_ENDIAN
+      VMReg rname_first = frame_map()->fpu_regname(opr->fpu_regnrLo());
+#else
       VMReg rname_first = frame_map()->fpu_regname(opr->fpu_regnrHi());
+#endif
+
 #ifdef _LP64
       first = new LocationValue(Location::new_reg_loc(Location::dbl, rname_first));
       second = &_int_0_scope_value;
diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp
index 115e19f3b32..63fe9c0a2a0 100644
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp
@@ -808,7 +808,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_i
         { klassOop klass = resolve_field_return_klass(caller_method, bci, CHECK);
           // Save a reference to the class that has to be checked for initialization
           init_klass = KlassHandle(THREAD, klass);
-          k = klass;
+          k = klass->java_mirror();
         }
         break;
       case Bytecodes::_new:
diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.hpp b/hotspot/src/share/vm/c1/c1_ValueMap.hpp
index 7dcae91f34f..248d174964d 100644
--- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp
@@ -141,7 +141,8 @@ class ValueNumberingVisitor: public InstructionVisitor {
 
   // visitor functions
   void do_StoreField     (StoreField*      x) {
-    if (!x->is_initialized()) {
+    if (x->is_init_point()) {
+      // putstatic is an initialization point so treat it as a wide kill
       kill_memory();
     } else {
       kill_field(x->field());
@@ -159,7 +160,8 @@ class ValueNumberingVisitor: public InstructionVisitor {
   void do_Local          (Local*           x) { /* nothing to do */ }
   void do_Constant       (Constant*        x) { /* nothing to do */ }
   void do_LoadField      (LoadField*       x) {
-    if (!x->is_initialized()) {
+    if (x->is_init_point()) {
+      // getstatic is an initialization point so treat it as a wide kill
       kill_memory();
     }
   }
diff --git a/hotspot/src/share/vm/ci/ciCPCache.cpp b/hotspot/src/share/vm/ci/ciCPCache.cpp
index 0396c2a8784..150107ececd 100644
--- a/hotspot/src/share/vm/ci/ciCPCache.cpp
+++ b/hotspot/src/share/vm/ci/ciCPCache.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * 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,8 +46,7 @@ size_t ciCPCache::get_f1_offset(int index) {
 // ciCPCache::is_f1_null_at
 bool ciCPCache::is_f1_null_at(int index) {
   VM_ENTRY_MARK;
-  oop f1 = entry_at(index)->f1();
-  return (f1 == NULL);
+  return entry_at(index)->is_f1_null();
 }
 
 
diff --git a/hotspot/src/share/vm/ci/ciCallSite.cpp b/hotspot/src/share/vm/ci/ciCallSite.cpp
index 849d8d58563..b2118e803d5 100644
--- a/hotspot/src/share/vm/ci/ciCallSite.cpp
+++ b/hotspot/src/share/vm/ci/ciCallSite.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
 // Return the target MethodHandle of this CallSite.
 ciMethodHandle* ciCallSite::get_target() const {
   VM_ENTRY_MARK;
-  oop method_handle_oop = java_dyn_CallSite::target(get_oop());
+  oop method_handle_oop = java_lang_invoke_CallSite::target(get_oop());
   return CURRENT_ENV->get_object(method_handle_oop)->as_method_handle();
 }
 
diff --git a/hotspot/src/share/vm/ci/ciCallSite.hpp b/hotspot/src/share/vm/ci/ciCallSite.hpp
index 6a92e686120..f9ad78d1086 100644
--- a/hotspot/src/share/vm/ci/ciCallSite.hpp
+++ b/hotspot/src/share/vm/ci/ciCallSite.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 
 // ciCallSite
 //
-// The class represents a java.dyn.CallSite object.
+// The class represents a java.lang.invoke.CallSite object.
 class ciCallSite : public ciInstance {
 public:
   ciCallSite(instanceHandle h_i) : ciInstance(h_i) {}
diff --git a/hotspot/src/share/vm/ci/ciField.cpp b/hotspot/src/share/vm/ci/ciField.cpp
index 82d141af9eb..0655b6e5545 100644
--- a/hotspot/src/share/vm/ci/ciField.cpp
+++ b/hotspot/src/share/vm/ci/ciField.cpp
@@ -177,7 +177,7 @@ static bool trust_final_non_static_fields(ciInstanceKlass* holder) {
     // Never trust strangely unstable finals:  System.out, etc.
     return false;
   // Even if general trusting is disabled, trust system-built closures in these packages.
-  if (holder->is_in_package("java/dyn") || holder->is_in_package("sun/dyn"))
+  if (holder->is_in_package("java/lang/invoke") || holder->is_in_package("sun/invoke"))
     return true;
   return TrustFinalNonStaticFields;
 }
@@ -191,8 +191,9 @@ void ciField::initialize_from(fieldDescriptor* fd) {
   // Check to see if the field is constant.
   if (_holder->is_initialized() && this->is_final()) {
     if (!this->is_static()) {
-      // A field can be constant if it's a final static field or if it's
-      // a final non-static field of a trusted class ({java,sun}.dyn).
+      // A field can be constant if it's a final static field or if
+      // it's a final non-static field of a trusted class (classes in
+      // java.lang.invoke and sun.invoke packages and subpackages).
       if (trust_final_non_static_fields(_holder)) {
         _is_constant = true;
         return;
@@ -212,7 +213,7 @@ void ciField::initialize_from(fieldDescriptor* fd) {
     //    may change.  The three examples are java.lang.System.in,
     //    java.lang.System.out, and java.lang.System.err.
 
-    Handle k = _holder->get_klassOop();
+    KlassHandle k = _holder->get_klassOop();
     assert( SystemDictionary::System_klass() != NULL, "Check once per vm");
     if( k() == SystemDictionary::System_klass() ) {
       // Check offsets for case 2: System.in, System.out, or System.err
@@ -224,36 +225,38 @@ void ciField::initialize_from(fieldDescriptor* fd) {
       }
     }
 
+    Handle mirror = k->java_mirror();
+
     _is_constant = true;
     switch(type()->basic_type()) {
     case T_BYTE:
-      _constant_value = ciConstant(type()->basic_type(), k->byte_field(_offset));
+      _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset));
       break;
     case T_CHAR:
-      _constant_value = ciConstant(type()->basic_type(), k->char_field(_offset));
+      _constant_value = ciConstant(type()->basic_type(), mirror->char_field(_offset));
       break;
     case T_SHORT:
-      _constant_value = ciConstant(type()->basic_type(), k->short_field(_offset));
+      _constant_value = ciConstant(type()->basic_type(), mirror->short_field(_offset));
       break;
     case T_BOOLEAN:
-      _constant_value = ciConstant(type()->basic_type(), k->bool_field(_offset));
+      _constant_value = ciConstant(type()->basic_type(), mirror->bool_field(_offset));
       break;
     case T_INT:
-      _constant_value = ciConstant(type()->basic_type(), k->int_field(_offset));
+      _constant_value = ciConstant(type()->basic_type(), mirror->int_field(_offset));
       break;
     case T_FLOAT:
-      _constant_value = ciConstant(k->float_field(_offset));
+      _constant_value = ciConstant(mirror->float_field(_offset));
       break;
     case T_DOUBLE:
-      _constant_value = ciConstant(k->double_field(_offset));
+      _constant_value = ciConstant(mirror->double_field(_offset));
       break;
     case T_LONG:
-      _constant_value = ciConstant(k->long_field(_offset));
+      _constant_value = ciConstant(mirror->long_field(_offset));
       break;
     case T_OBJECT:
     case T_ARRAY:
       {
-        oop o = k->obj_field(_offset);
+        oop o = mirror->obj_field(_offset);
 
         // A field will be "constant" if it is known always to be
         // a non-null reference to an instance of a particular class,
diff --git a/hotspot/src/share/vm/ci/ciInstance.cpp b/hotspot/src/share/vm/ci/ciInstance.cpp
index ae7b6d20e2c..d249caa2e0c 100644
--- a/hotspot/src/share/vm/ci/ciInstance.cpp
+++ b/hotspot/src/share/vm/ci/ciInstance.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -138,3 +138,9 @@ void ciInstance::print_impl(outputStream* st) {
   st->print(" type=");
   klass()->print(st);
 }
+
+
+ciKlass* ciInstance::java_lang_Class_klass() {
+  VM_ENTRY_MARK;
+  return CURRENT_ENV->get_object(java_lang_Class::as_klassOop(get_oop()))->as_klass();
+}
diff --git a/hotspot/src/share/vm/ci/ciInstance.hpp b/hotspot/src/share/vm/ci/ciInstance.hpp
index 1579402d9e6..e7f5bfe0734 100644
--- a/hotspot/src/share/vm/ci/ciInstance.hpp
+++ b/hotspot/src/share/vm/ci/ciInstance.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,6 +64,8 @@ public:
 
   // Constant value of a field at the specified offset.
   ciConstant field_value_by_offset(int field_offset);
+
+  ciKlass* java_lang_Class_klass();
 };
 
 #endif // SHARE_VM_CI_CIINSTANCE_HPP
diff --git a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp
index 8143649137e..35ee2b89e00 100644
--- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp
+++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -85,7 +85,6 @@ ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
     if (h_k() != SystemDictionary::Object_klass()) {
       super();
     }
-    java_mirror();
     //compute_nonstatic_fields();  // done outside of constructor
   }
 
@@ -320,6 +319,9 @@ ciInstanceKlass* ciInstanceKlass::super() {
 // Get the instance of java.lang.Class corresponding to this klass.
 // Cache it on this->_java_mirror.
 ciInstance* ciInstanceKlass::java_mirror() {
+  if (is_shared()) {
+    return ciKlass::java_mirror();
+  }
   if (_java_mirror == NULL) {
     _java_mirror = ciKlass::java_mirror();
   }
diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp
index 1805cfc26a4..d8de8d5277b 100644
--- a/hotspot/src/share/vm/ci/ciMethod.cpp
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -769,7 +769,7 @@ int ciMethod::scale_count(int count, float prof_factor) {
 // signature-polymorphic MethodHandle methods, invokeExact or invokeGeneric.
 bool ciMethod::is_method_handle_invoke() const {
   if (!is_loaded()) {
-    bool flag = (holder()->name() == ciSymbol::java_dyn_MethodHandle() &&
+    bool flag = (holder()->name() == ciSymbol::java_lang_invoke_MethodHandle() &&
                  methodOopDesc::is_method_handle_invoke_name(name()->sid()));
     return flag;
   }
diff --git a/hotspot/src/share/vm/ci/ciMethodHandle.hpp b/hotspot/src/share/vm/ci/ciMethodHandle.hpp
index 7573bffb9a5..69c1379946c 100644
--- a/hotspot/src/share/vm/ci/ciMethodHandle.hpp
+++ b/hotspot/src/share/vm/ci/ciMethodHandle.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 
 // ciMethodHandle
 //
-// The class represents a java.dyn.MethodHandle object.
+// The class represents a java.lang.invoke.MethodHandle object.
 class ciMethodHandle : public ciInstance {
 private:
   ciMethod* _callee;
diff --git a/hotspot/src/share/vm/ci/ciObjectFactory.cpp b/hotspot/src/share/vm/ci/ciObjectFactory.cpp
index 9956d323ce8..b0e9064a09d 100644
--- a/hotspot/src/share/vm/ci/ciObjectFactory.cpp
+++ b/hotspot/src/share/vm/ci/ciObjectFactory.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -342,9 +342,9 @@ ciObject* ciObjectFactory::create_new_object(oop o) {
     return new (arena()) ciMethodData(h_md);
   } else if (o->is_instance()) {
     instanceHandle h_i(THREAD, (instanceOop)o);
-    if (java_dyn_CallSite::is_instance(o))
+    if (java_lang_invoke_CallSite::is_instance(o))
       return new (arena()) ciCallSite(h_i);
-    else if (java_dyn_MethodHandle::is_instance(o))
+    else if (java_lang_invoke_MethodHandle::is_instance(o))
       return new (arena()) ciMethodHandle(h_i);
     else
       return new (arena()) ciInstance(h_i);
@@ -663,7 +663,7 @@ ciObjectFactory::NonPermObject* &ciObjectFactory::find_non_perm(oop key) {
   if (key->is_perm() && _non_perm_count == 0) {
     return emptyBucket;
   } else if (key->is_instance()) {
-    if (key->klass() == SystemDictionary::Class_klass()) {
+    if (key->klass() == SystemDictionary::Class_klass() && JavaObjectsInPerm) {
       // class mirror instances are always perm
       return emptyBucket;
     }
diff --git a/hotspot/src/share/vm/ci/ciStreams.cpp b/hotspot/src/share/vm/ci/ciStreams.cpp
index a93f40c0fcc..2801c3edd19 100644
--- a/hotspot/src/share/vm/ci/ciStreams.cpp
+++ b/hotspot/src/share/vm/ci/ciStreams.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -380,7 +380,7 @@ ciKlass* ciBytecodeStream::get_declared_method_holder() {
   bool ignore;
   // report as InvokeDynamic for invokedynamic, which is syntactically classless
   if (cur_bc() == Bytecodes::_invokedynamic)
-    return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_dyn_InvokeDynamic(), false);
+    return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_lang_invoke_InvokeDynamic(), false);
   return CURRENT_ENV->get_klass_by_index(cpool, get_method_holder_index(), ignore, _holder);
 }
 
diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp
index 3aacf66ff7b..8056159b51a 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.cpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,7 @@
 #include "memory/universe.inline.hpp"
 #include "oops/constantPoolOop.hpp"
 #include "oops/instanceKlass.hpp"
+#include "oops/instanceMirrorKlass.hpp"
 #include "oops/klass.inline.hpp"
 #include "oops/klassOop.hpp"
 #include "oops/klassVtable.hpp"
@@ -146,12 +147,14 @@ void ClassFileParser::parse_constant_pool_entries(constantPoolHandle cp, int len
         break;
       case JVM_CONSTANT_MethodHandle :
       case JVM_CONSTANT_MethodType :
-        if (!EnableMethodHandles ||
-            _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
+        if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
           classfile_parse_error(
-            (!EnableMethodHandles ?
-             "This JVM does not support constant tag %u in class file %s" :
-             "Class file version does not support constant tag %u in class file %s"),
+            "Class file version does not support constant tag %u in class file %s",
+            tag, CHECK);
+        }
+        if (!EnableMethodHandles) {
+          classfile_parse_error(
+            "This JVM does not support constant tag %u in class file %s",
             tag, CHECK);
         }
         if (tag == JVM_CONSTANT_MethodHandle) {
@@ -170,12 +173,14 @@ void ClassFileParser::parse_constant_pool_entries(constantPoolHandle cp, int len
       case JVM_CONSTANT_InvokeDynamicTrans :  // this tag appears only in old classfiles
       case JVM_CONSTANT_InvokeDynamic :
         {
-          if (!EnableInvokeDynamic ||
-              _major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
+          if (_major_version < Verifier::INVOKEDYNAMIC_MAJOR_VERSION) {
             classfile_parse_error(
-              (!EnableInvokeDynamic ?
-               "This JVM does not support constant tag %u in class file %s" :
-               "Class file version does not support constant tag %u in class file %s"),
+              "Class file version does not support constant tag %u in class file %s",
+              tag, CHECK);
+          }
+          if (!EnableInvokeDynamic) {
+            classfile_parse_error(
+              "This JVM does not support constant tag %u in class file %s",
               tag, CHECK);
           }
           cfs->guarantee_more(5, CHECK);  // bsm_index, nt, tag/access_flags
@@ -1616,8 +1621,13 @@ methodHandle ClassFileParser::parse_method(constantPoolHandle cp, bool is_interf
 
   AccessFlags access_flags;
   if (name == vmSymbols::class_initializer_name()) {
-    // We ignore the access flags for a class initializer. (JVM Spec. p. 116)
-    flags = JVM_ACC_STATIC;
+    // We ignore the other access flags for a valid class initializer.
+    // (JVM Spec 2nd ed., chapter 4.6)
+    if (_major_version < 51) { // backward compatibility
+      flags = JVM_ACC_STATIC;
+    } else if ((flags & JVM_ACC_STATIC) == JVM_ACC_STATIC) {
+      flags &= JVM_ACC_STATIC | JVM_ACC_STRICT;
+    }
   } else {
     verify_legal_method_modifiers(flags, is_interface, name, CHECK_(nullHandle));
   }
@@ -2597,54 +2607,6 @@ typeArrayHandle ClassFileParser::assemble_annotations(u1* runtime_visible_annota
 }
 
 
-static void initialize_static_field(fieldDescriptor* fd, TRAPS) {
-  KlassHandle h_k (THREAD, fd->field_holder());
-  assert(h_k.not_null() && fd->is_static(), "just checking");
-  if (fd->has_initial_value()) {
-    BasicType t = fd->field_type();
-    switch (t) {
-      case T_BYTE:
-        h_k()->byte_field_put(fd->offset(), fd->int_initial_value());
-              break;
-      case T_BOOLEAN:
-        h_k()->bool_field_put(fd->offset(), fd->int_initial_value());
-              break;
-      case T_CHAR:
-        h_k()->char_field_put(fd->offset(), fd->int_initial_value());
-              break;
-      case T_SHORT:
-        h_k()->short_field_put(fd->offset(), fd->int_initial_value());
-              break;
-      case T_INT:
-        h_k()->int_field_put(fd->offset(), fd->int_initial_value());
-        break;
-      case T_FLOAT:
-        h_k()->float_field_put(fd->offset(), fd->float_initial_value());
-        break;
-      case T_DOUBLE:
-        h_k()->double_field_put(fd->offset(), fd->double_initial_value());
-        break;
-      case T_LONG:
-        h_k()->long_field_put(fd->offset(), fd->long_initial_value());
-        break;
-      case T_OBJECT:
-        {
-          #ifdef ASSERT
-          TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
-          assert(fd->signature() == sym, "just checking");
-          #endif
-          oop string = fd->string_initial_value(CHECK);
-          h_k()->obj_field_put(fd->offset(), string);
-        }
-        break;
-      default:
-        THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
-                  "Illegal ConstantValue attribute in class file");
-    }
-  }
-}
-
-
 void ClassFileParser::java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
   constantPoolHandle cp, FieldAllocationCount *fac_ptr, TRAPS) {
   // This code is for compatibility with earlier jdk's that do not
@@ -2760,8 +2722,8 @@ void ClassFileParser::java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_pt
 }
 
 
-void ClassFileParser::java_lang_Class_fix_pre(objArrayHandle* methods_ptr,
-  FieldAllocationCount *fac_ptr, TRAPS) {
+void ClassFileParser::java_lang_Class_fix_pre(int* nonstatic_field_size,
+                                              FieldAllocationCount *fac_ptr) {
   // Add fake fields for java.lang.Class instances
   //
   // This is not particularly nice. We should consider adding a
@@ -2778,10 +2740,13 @@ void ClassFileParser::java_lang_Class_fix_pre(objArrayHandle* methods_ptr,
   // versions because when the offsets are computed at bootstrap
   // time we don't know yet which version of the JDK we're running in.
 
-  // The values below are fake but will force two non-static oop fields and
+  // The values below are fake but will force three non-static oop fields and
   // a corresponding non-static oop map block to be allocated.
   const int extra = java_lang_Class::number_of_fake_oop_fields;
   fac_ptr->nonstatic_oop_count += extra;
+
+  // Reserve some leading space for fake ints
+  *nonstatic_field_size += align_size_up(java_lang_Class::hc_number_of_fake_int_fields * BytesPerInt, heapOopSize) / heapOopSize;
 }
 
 
@@ -2797,11 +2762,11 @@ void ClassFileParser::java_lang_Class_fix_post(int* next_nonstatic_oop_offset_pt
 
 // Force MethodHandle.vmentry to be an unmanaged pointer.
 // There is no way for a classfile to express this, so we must help it.
-void ClassFileParser::java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
+void ClassFileParser::java_lang_invoke_MethodHandle_fix_pre(constantPoolHandle cp,
                                                     typeArrayHandle fields,
                                                     FieldAllocationCount *fac_ptr,
                                                     TRAPS) {
-  // Add fake fields for java.dyn.MethodHandle instances
+  // Add fake fields for java.lang.invoke.MethodHandle instances
   //
   // This is not particularly nice, but since there is no way to express
   // a native wordSize field in Java, we must do it at this level.
@@ -2818,9 +2783,10 @@ void ClassFileParser::java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
     }
   }
 
+  if (AllowTransitionalJSR292 && word_sig_index == 0)  return;
   if (word_sig_index == 0)
     THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
-              "missing I or J signature (for vmentry) in java.dyn.MethodHandle");
+              "missing I or J signature (for vmentry) in java.lang.invoke.MethodHandle");
 
   // Find vmentry field and change the signature.
   bool found_vmentry = false;
@@ -2857,9 +2823,10 @@ void ClassFileParser::java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
     }
   }
 
+  if (AllowTransitionalJSR292 && !found_vmentry)  return;
   if (!found_vmentry)
     THROW_MSG(vmSymbols::java_lang_VirtualMachineError(),
-              "missing vmentry byte field in java.dyn.MethodHandle");
+              "missing vmentry byte field in java.lang.invoke.MethodHandle");
 }
 
 
@@ -3194,9 +3161,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
     int next_nonstatic_field_offset;
 
     // Calculate the starting byte offsets
-    next_static_oop_offset      = (instanceKlass::header_size() +
-                                  align_object_offset(vtable_size) +
-                                  align_object_offset(itable_size)) * wordSize;
+    next_static_oop_offset      = instanceMirrorKlass::offset_of_static_fields();
     next_static_double_offset   = next_static_oop_offset +
                                   (fac.static_oop_count * heapOopSize);
     if ( fac.static_double_count &&
@@ -3215,18 +3180,28 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
                                   fac.static_byte_count ), wordSize );
     static_field_size           = (next_static_type_offset -
                                   next_static_oop_offset) / wordSize;
+
+    // Add fake fields for java.lang.Class instances (also see below)
+    if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
+      java_lang_Class_fix_pre(&nonstatic_field_size, &fac);
+    }
+
     first_nonstatic_field_offset = instanceOopDesc::base_offset_in_bytes() +
                                    nonstatic_field_size * heapOopSize;
     next_nonstatic_field_offset = first_nonstatic_field_offset;
 
-    // Add fake fields for java.lang.Class instances (also see below)
-    if (class_name == vmSymbols::java_lang_Class() && class_loader.is_null()) {
-      java_lang_Class_fix_pre(&methods, &fac, CHECK_(nullHandle));
+    // adjust the vmentry field declaration in java.lang.invoke.MethodHandle
+    if (EnableMethodHandles && class_name == vmSymbols::java_lang_invoke_MethodHandle() && class_loader.is_null()) {
+      java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
     }
-
-    // adjust the vmentry field declaration in java.dyn.MethodHandle
-    if (EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
-      java_dyn_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
+    if (AllowTransitionalJSR292 &&
+        EnableMethodHandles && class_name == vmSymbols::java_dyn_MethodHandle() && class_loader.is_null()) {
+      java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
+    }
+    if (AllowTransitionalJSR292 &&
+        EnableMethodHandles && class_name == vmSymbols::sun_dyn_MethodHandleImpl() && class_loader.is_null()) {
+      // allow vmentry field in MethodHandleImpl also
+      java_lang_invoke_MethodHandle_fix_pre(cp, fields, &fac, CHECK_(nullHandle));
     }
 
     // Add a fake "discovered" field if it is not present
@@ -3546,7 +3521,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
     }
 
     // We can now create the basic klassOop for this klass
-    klassOop ik = oopFactory::new_instanceKlass(vtable_size, itable_size,
+    klassOop ik = oopFactory::new_instanceKlass(name, vtable_size, itable_size,
                                                 static_field_size,
                                                 total_oop_map_count,
                                                 rt, CHECK_(nullHandle));
@@ -3568,7 +3543,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
     this_klass->set_class_loader(class_loader());
     this_klass->set_nonstatic_field_size(nonstatic_field_size);
     this_klass->set_has_nonstatic_fields(has_nonstatic_fields);
-    this_klass->set_static_oop_field_size(fac.static_oop_count);
+    this_klass->set_static_oop_field_count(fac.static_oop_count);
     cp->set_pool_holder(this_klass());
     error_handler.set_in_error(false);   // turn off error handler for cp
     this_klass->set_constants(cp());
@@ -3629,9 +3604,6 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
     // Make sure this is the end of class file stream
     guarantee_property(cfs->at_eos(), "Extra bytes at the end of class file %s", CHECK_(nullHandle));
 
-    // Initialize static fields
-    this_klass->do_local_static_fields(&initialize_static_field, CHECK_(nullHandle));
-
     // VerifyOops believes that once this has been set, the object is completely loaded.
     // Compute transitive closure of interfaces this class implements
     this_klass->set_transitive_interfaces(transitive_interfaces());
@@ -3665,6 +3637,9 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
       check_illegal_static_method(this_klass, CHECK_(nullHandle));
     }
 
+    // Allocate mirror and initialize static fields
+    java_lang_Class::create_mirror(this_klass, CHECK_(nullHandle));
+
     ClassLoadingService::notify_class_loaded(instanceKlass::cast(this_klass()),
                                              false /* not shared class */);
 
diff --git a/hotspot/src/share/vm/classfile/classFileParser.hpp b/hotspot/src/share/vm/classfile/classFileParser.hpp
index 4dc61fc32b0..b48bd99d532 100644
--- a/hotspot/src/share/vm/classfile/classFileParser.hpp
+++ b/hotspot/src/share/vm/classfile/classFileParser.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -154,17 +154,18 @@ class ClassFileParser VALUE_OBJ_CLASS_SPEC {
   // Add the "discovered" field to java.lang.ref.Reference if
   // it does not exist.
   void java_lang_ref_Reference_fix_pre(typeArrayHandle* fields_ptr,
-    constantPoolHandle cp, FieldAllocationCount *fac_ptr, TRAPS);
+                                       constantPoolHandle cp,
+                                       FieldAllocationCount *fac_ptr, TRAPS);
   // Adjust the field allocation counts for java.lang.Class to add
   // fake fields.
-  void java_lang_Class_fix_pre(objArrayHandle* methods_ptr,
-    FieldAllocationCount *fac_ptr, TRAPS);
+  void java_lang_Class_fix_pre(int* nonstatic_field_size,
+                               FieldAllocationCount *fac_ptr);
   // Adjust the next_nonstatic_oop_offset to place the fake fields
   // before any Java fields.
   void java_lang_Class_fix_post(int* next_nonstatic_oop_offset);
-  // Adjust the field allocation counts for java.dyn.MethodHandle to add
+  // Adjust the field allocation counts for java.lang.invoke.MethodHandle to add
   // a fake address (void*) field.
-  void java_dyn_MethodHandle_fix_pre(constantPoolHandle cp,
+  void java_lang_invoke_MethodHandle_fix_pre(constantPoolHandle cp,
                                      typeArrayHandle fields,
                                      FieldAllocationCount *fac_ptr, TRAPS);
 
diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp
index d23ff719e73..62f6500a5d4 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 #include "memory/resourceArea.hpp"
 #include "memory/universe.inline.hpp"
 #include "oops/instanceKlass.hpp"
+#include "oops/instanceMirrorKlass.hpp"
 #include "oops/klass.hpp"
 #include "oops/klassOop.hpp"
 #include "oops/methodOop.hpp"
@@ -66,6 +67,28 @@ static bool find_field(instanceKlass* ik,
     return ik->find_local_field(name_symbol, signature_symbol, fd);
 }
 
+static bool find_hacked_field(instanceKlass* ik,
+                              Symbol* name_symbol, Symbol* signature_symbol,
+                              fieldDescriptor* fd,
+                              bool allow_super = false) {
+  bool found = find_field(ik, name_symbol, signature_symbol, fd, allow_super);
+  if (!found && AllowTransitionalJSR292) {
+    Symbol* backup_sig = SystemDictionary::find_backup_signature(signature_symbol);
+    if (backup_sig != NULL) {
+      found = find_field(ik, name_symbol, backup_sig, fd, allow_super);
+      if (TraceMethodHandles) {
+        ResourceMark rm;
+        tty->print_cr("MethodHandles: %s.%s: backup for %s => %s%s",
+                      ik->name()->as_C_string(), name_symbol->as_C_string(),
+                      signature_symbol->as_C_string(), backup_sig->as_C_string(),
+                      (found ? "" : " (NOT FOUND)"));
+      }
+    }
+  }
+  return found;
+}
+#define find_field find_hacked_field  /* remove after AllowTransitionalJSR292 */
+
 // Helpful routine for computing field offsets at run time rather than hardcoding them
 static void
 compute_offset(int &dest_offset,
@@ -139,7 +162,7 @@ Handle java_lang_String::create_from_unicode(jchar* unicode, int length, TRAPS)
 }
 
 Handle java_lang_String::create_tenured_from_unicode(jchar* unicode, int length, TRAPS) {
-  return basic_create_from_unicode(unicode, length, true, CHECK_NH);
+  return basic_create_from_unicode(unicode, length, JavaObjectsInPerm, CHECK_NH);
 }
 
 oop java_lang_String::create_oop_from_unicode(jchar* unicode, int length, TRAPS) {
@@ -369,6 +392,75 @@ void java_lang_String::print(Handle java_string, outputStream* st) {
   }
 }
 
+static void initialize_static_field(fieldDescriptor* fd, TRAPS) {
+  Handle mirror (THREAD, fd->field_holder()->java_mirror());
+  assert(mirror.not_null() && fd->is_static(), "just checking");
+  if (fd->has_initial_value()) {
+    BasicType t = fd->field_type();
+    switch (t) {
+      case T_BYTE:
+        mirror()->byte_field_put(fd->offset(), fd->int_initial_value());
+              break;
+      case T_BOOLEAN:
+        mirror()->bool_field_put(fd->offset(), fd->int_initial_value());
+              break;
+      case T_CHAR:
+        mirror()->char_field_put(fd->offset(), fd->int_initial_value());
+              break;
+      case T_SHORT:
+        mirror()->short_field_put(fd->offset(), fd->int_initial_value());
+              break;
+      case T_INT:
+        mirror()->int_field_put(fd->offset(), fd->int_initial_value());
+        break;
+      case T_FLOAT:
+        mirror()->float_field_put(fd->offset(), fd->float_initial_value());
+        break;
+      case T_DOUBLE:
+        mirror()->double_field_put(fd->offset(), fd->double_initial_value());
+        break;
+      case T_LONG:
+        mirror()->long_field_put(fd->offset(), fd->long_initial_value());
+        break;
+      case T_OBJECT:
+        {
+          #ifdef ASSERT
+          TempNewSymbol sym = SymbolTable::new_symbol("Ljava/lang/String;", CHECK);
+          assert(fd->signature() == sym, "just checking");
+          #endif
+          oop string = fd->string_initial_value(CHECK);
+          mirror()->obj_field_put(fd->offset(), string);
+        }
+        break;
+      default:
+        THROW_MSG(vmSymbols::java_lang_ClassFormatError(),
+                  "Illegal ConstantValue attribute in class file");
+    }
+  }
+}
+
+
+// During bootstrap, java.lang.Class wasn't loaded so static field
+// offsets were computed without the size added it.  Go back and
+// update all the static field offsets to included the size.
+static void fixup_static_field(fieldDescriptor* fd, TRAPS) {
+  if (fd->is_static()) {
+    int real_offset = fd->offset() + instanceMirrorKlass::offset_of_static_fields();
+    typeArrayOop fields = instanceKlass::cast(fd->field_holder())->fields();
+    fields->short_at_put(fd->index() + instanceKlass::low_offset,  extract_low_short_from_int(real_offset));
+    fields->short_at_put(fd->index() + instanceKlass::high_offset, extract_high_short_from_int(real_offset));
+  }
+}
+
+void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
+  assert(instanceMirrorKlass::offset_of_static_fields() != 0, "must have been computed already");
+
+  if (k->oop_is_instance()) {
+    // Fixup the offsets
+    instanceKlass::cast(k())->do_local_static_fields(&fixup_static_field, CHECK);
+  }
+  create_mirror(k, CHECK);
+}
 
 oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) {
   assert(k->java_mirror() == NULL, "should only assign mirror once");
@@ -378,12 +470,17 @@ oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) {
   // class is put into the system dictionary.
   int computed_modifiers = k->compute_modifier_flags(CHECK_0);
   k->set_modifier_flags(computed_modifiers);
-  if (SystemDictionary::Class_klass_loaded()) {
+  if (SystemDictionary::Class_klass_loaded() && (k->oop_is_instance() || k->oop_is_javaArray())) {
     // Allocate mirror (java.lang.Class instance)
-    Handle mirror = instanceKlass::cast(SystemDictionary::Class_klass())->allocate_permanent_instance(CHECK_0);
+    Handle mirror = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance(k, CHECK_0);
     // Setup indirections
     mirror->obj_field_put(klass_offset,  k());
     k->set_java_mirror(mirror());
+
+    instanceMirrorKlass* mk = instanceMirrorKlass::cast(mirror->klass());
+    java_lang_Class::set_oop_size(mirror(), mk->instance_size(k));
+    java_lang_Class::set_static_oop_field_count(mirror(), mk->compute_static_oop_field_count(mirror()));
+
     // It might also have a component mirror.  This mirror must already exist.
     if (k->oop_is_javaArray()) {
       Handle comp_mirror;
@@ -406,6 +503,9 @@ oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) {
         arrayKlass::cast(k->as_klassOop())->set_component_mirror(comp_mirror());
         set_array_klass(comp_mirror(), k->as_klassOop());
       }
+    } else if (k->oop_is_instance()) {
+      // Initialize static fields
+      instanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, CHECK_NULL);
     }
     return mirror();
   } else {
@@ -414,21 +514,46 @@ oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) {
 }
 
 
+
+int  java_lang_Class::oop_size(oop java_class) {
+  assert(oop_size_offset != 0, "must be set");
+  return java_class->int_field(oop_size_offset);
+}
+void java_lang_Class::set_oop_size(oop java_class, int size) {
+  assert(oop_size_offset != 0, "must be set");
+  java_class->int_field_put(oop_size_offset, size);
+}
+int  java_lang_Class::static_oop_field_count(oop java_class) {
+  assert(static_oop_field_count_offset != 0, "must be set");
+  return java_class->int_field(static_oop_field_count_offset);
+}
+void java_lang_Class::set_static_oop_field_count(oop java_class, int size) {
+  assert(static_oop_field_count_offset != 0, "must be set");
+  java_class->int_field_put(static_oop_field_count_offset, size);
+}
+
+
+
+
 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
   // This should be improved by adding a field at the Java level or by
   // introducing a new VM klass (see comment in ClassFileParser)
-  oop java_class = instanceKlass::cast(SystemDictionary::Class_klass())->allocate_permanent_instance(CHECK_0);
+  oop java_class = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->allocate_instance((oop)NULL, CHECK_0);
   if (type != T_VOID) {
     klassOop aklass = Universe::typeArrayKlassObj(type);
     assert(aklass != NULL, "correct bootstrap");
     set_array_klass(java_class, aklass);
   }
+  instanceMirrorKlass* mk = instanceMirrorKlass::cast(SystemDictionary::Class_klass());
+  java_lang_Class::set_oop_size(java_class, mk->instance_size(oop(NULL)));
+  java_lang_Class::set_static_oop_field_count(java_class, 0);
   return java_class;
 }
 
 
 klassOop java_lang_Class::as_klassOop(oop java_class) {
   //%note memory_2
+  assert(java_lang_Class::is_instance(java_class), "must be a Class object");
   klassOop k = klassOop(java_class->obj_field(klass_offset));
   assert(k == NULL || k->is_klass(), "type check");
   return k;
@@ -2130,7 +2255,7 @@ void java_lang_boxing_object::print(BasicType type, jvalue* value, outputStream*
 // Support for java_lang_ref_Reference
 oop java_lang_ref_Reference::pending_list_lock() {
   instanceKlass* ik = instanceKlass::cast(SystemDictionary::Reference_klass());
-  char *addr = (((char *)ik->start_of_static_fields()) + static_lock_offset);
+  address addr = ik->static_field_addr(static_lock_offset);
   if (UseCompressedOops) {
     return oopDesc::load_decode_heap_oop((narrowOop *)addr);
   } else {
@@ -2140,7 +2265,7 @@ oop java_lang_ref_Reference::pending_list_lock() {
 
 HeapWord *java_lang_ref_Reference::pending_list_addr() {
   instanceKlass* ik = instanceKlass::cast(SystemDictionary::Reference_klass());
-  char *addr = (((char *)ik->start_of_static_fields()) + static_pending_offset);
+  address addr = ik->static_field_addr(static_pending_offset);
   // XXX This might not be HeapWord aligned, almost rather be char *.
   return (HeapWord*)addr;
 }
@@ -2163,54 +2288,54 @@ jlong java_lang_ref_SoftReference::timestamp(oop ref) {
 
 jlong java_lang_ref_SoftReference::clock() {
   instanceKlass* ik = instanceKlass::cast(SystemDictionary::SoftReference_klass());
-  int offset = ik->offset_of_static_fields() + static_clock_offset;
-
-  return SystemDictionary::SoftReference_klass()->long_field(offset);
+  jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
+  return *offset;
 }
 
 void java_lang_ref_SoftReference::set_clock(jlong value) {
   instanceKlass* ik = instanceKlass::cast(SystemDictionary::SoftReference_klass());
-  int offset = ik->offset_of_static_fields() + static_clock_offset;
-
-  SystemDictionary::SoftReference_klass()->long_field_put(offset, value);
+  jlong* offset = (jlong*)ik->static_field_addr(static_clock_offset);
+  *offset = value;
 }
 
 
-// Support for java_dyn_MethodHandle
+// Support for java_lang_invoke_MethodHandle
 
-int java_dyn_MethodHandle::_type_offset;
-int java_dyn_MethodHandle::_vmtarget_offset;
-int java_dyn_MethodHandle::_vmentry_offset;
-int java_dyn_MethodHandle::_vmslots_offset;
+int java_lang_invoke_MethodHandle::_type_offset;
+int java_lang_invoke_MethodHandle::_vmtarget_offset;
+int java_lang_invoke_MethodHandle::_vmentry_offset;
+int java_lang_invoke_MethodHandle::_vmslots_offset;
 
-int sun_dyn_MemberName::_clazz_offset;
-int sun_dyn_MemberName::_name_offset;
-int sun_dyn_MemberName::_type_offset;
-int sun_dyn_MemberName::_flags_offset;
-int sun_dyn_MemberName::_vmtarget_offset;
-int sun_dyn_MemberName::_vmindex_offset;
+int java_lang_invoke_MemberName::_clazz_offset;
+int java_lang_invoke_MemberName::_name_offset;
+int java_lang_invoke_MemberName::_type_offset;
+int java_lang_invoke_MemberName::_flags_offset;
+int java_lang_invoke_MemberName::_vmtarget_offset;
+int java_lang_invoke_MemberName::_vmindex_offset;
 
-int sun_dyn_DirectMethodHandle::_vmindex_offset;
+int java_lang_invoke_DirectMethodHandle::_vmindex_offset;
 
-int sun_dyn_BoundMethodHandle::_argument_offset;
-int sun_dyn_BoundMethodHandle::_vmargslot_offset;
+int java_lang_invoke_BoundMethodHandle::_argument_offset;
+int java_lang_invoke_BoundMethodHandle::_vmargslot_offset;
 
-int sun_dyn_AdapterMethodHandle::_conversion_offset;
+int java_lang_invoke_AdapterMethodHandle::_conversion_offset;
 
-void java_dyn_MethodHandle::compute_offsets() {
+void java_lang_invoke_MethodHandle::compute_offsets() {
   klassOop k = SystemDictionary::MethodHandle_klass();
   if (k != NULL && EnableMethodHandles) {
-    compute_offset(_type_offset,      k, vmSymbols::type_name(),      vmSymbols::java_dyn_MethodType_signature(), true);
-    compute_offset(_vmtarget_offset,  k, vmSymbols::vmtarget_name(),  vmSymbols::object_signature(), true);
-    compute_offset(_vmentry_offset,   k, vmSymbols::vmentry_name(),   vmSymbols::machine_word_signature(), true);
+    bool allow_super = false;
+    if (AllowTransitionalJSR292)  allow_super = true;  // temporary, to access java.dyn.MethodHandleImpl
+    compute_offset(_type_offset,      k, vmSymbols::type_name(),      vmSymbols::java_lang_invoke_MethodType_signature(), allow_super);
+    compute_offset(_vmtarget_offset,  k, vmSymbols::vmtarget_name(),  vmSymbols::object_signature(),                      allow_super);
+    compute_offset(_vmentry_offset,   k, vmSymbols::vmentry_name(),   vmSymbols::machine_word_signature(),                allow_super);
 
     // Note:  MH.vmslots (if it is present) is a hoisted copy of MH.type.form.vmslots.
     // It is optional pending experiments to keep or toss.
-    compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), true);
+    compute_optional_offset(_vmslots_offset, k, vmSymbols::vmslots_name(), vmSymbols::int_signature(), allow_super);
   }
 }
 
-void sun_dyn_MemberName::compute_offsets() {
+void java_lang_invoke_MemberName::compute_offsets() {
   klassOop k = SystemDictionary::MemberName_klass();
   if (k != NULL && EnableMethodHandles) {
     compute_offset(_clazz_offset,     k, vmSymbols::clazz_name(),     vmSymbols::class_signature());
@@ -2222,14 +2347,14 @@ void sun_dyn_MemberName::compute_offsets() {
   }
 }
 
-void sun_dyn_DirectMethodHandle::compute_offsets() {
+void java_lang_invoke_DirectMethodHandle::compute_offsets() {
   klassOop k = SystemDictionary::DirectMethodHandle_klass();
   if (k != NULL && EnableMethodHandles) {
     compute_offset(_vmindex_offset,   k, vmSymbols::vmindex_name(),   vmSymbols::int_signature(),    true);
   }
 }
 
-void sun_dyn_BoundMethodHandle::compute_offsets() {
+void java_lang_invoke_BoundMethodHandle::compute_offsets() {
   klassOop k = SystemDictionary::BoundMethodHandle_klass();
   if (k != NULL && EnableMethodHandles) {
     compute_offset(_vmargslot_offset, k, vmSymbols::vmargslot_name(), vmSymbols::int_signature(),    true);
@@ -2237,22 +2362,22 @@ void sun_dyn_BoundMethodHandle::compute_offsets() {
   }
 }
 
-void sun_dyn_AdapterMethodHandle::compute_offsets() {
+void java_lang_invoke_AdapterMethodHandle::compute_offsets() {
   klassOop k = SystemDictionary::AdapterMethodHandle_klass();
   if (k != NULL && EnableMethodHandles) {
     compute_offset(_conversion_offset, k, vmSymbols::conversion_name(), vmSymbols::int_signature(), true);
   }
 }
 
-oop java_dyn_MethodHandle::type(oop mh) {
+oop java_lang_invoke_MethodHandle::type(oop mh) {
   return mh->obj_field(_type_offset);
 }
 
-void java_dyn_MethodHandle::set_type(oop mh, oop mtype) {
+void java_lang_invoke_MethodHandle::set_type(oop mh, oop mtype) {
   mh->obj_field_put(_type_offset, mtype);
 }
 
-int java_dyn_MethodHandle::vmslots(oop mh) {
+int java_lang_invoke_MethodHandle::vmslots(oop mh) {
   int vmslots_offset = _vmslots_offset;
   if (vmslots_offset != 0) {
 #ifdef ASSERT
@@ -2267,7 +2392,7 @@ int java_dyn_MethodHandle::vmslots(oop mh) {
 }
 
 // if MH.vmslots exists, hoist into it the value of type.form.vmslots
-void java_dyn_MethodHandle::init_vmslots(oop mh) {
+void java_lang_invoke_MethodHandle::init_vmslots(oop mh) {
   int vmslots_offset = _vmslots_offset;
   if (vmslots_offset != 0) {
     mh->int_field_put(vmslots_offset, compute_vmslots(mh));
@@ -2276,20 +2401,20 @@ void java_dyn_MethodHandle::init_vmslots(oop mh) {
 
 // fetch type.form.vmslots, which is the number of JVM stack slots
 // required to carry the arguments of this MH
-int java_dyn_MethodHandle::compute_vmslots(oop mh) {
+int java_lang_invoke_MethodHandle::compute_vmslots(oop mh) {
   oop mtype = type(mh);
   if (mtype == NULL)  return 0;  // Java code would get NPE
-  oop form = java_dyn_MethodType::form(mtype);
+  oop form = java_lang_invoke_MethodType::form(mtype);
   if (form == NULL)   return 0;  // Java code would get NPE
-  return java_dyn_MethodTypeForm::vmslots(form);
+  return java_lang_invoke_MethodTypeForm::vmslots(form);
 }
 
 // fetch the low-level entry point for this mh
-MethodHandleEntry* java_dyn_MethodHandle::vmentry(oop mh) {
+MethodHandleEntry* java_lang_invoke_MethodHandle::vmentry(oop mh) {
   return (MethodHandleEntry*) mh->address_field(_vmentry_offset);
 }
 
-void java_dyn_MethodHandle::set_vmentry(oop mh, MethodHandleEntry* me) {
+void java_lang_invoke_MethodHandle::set_vmentry(oop mh, MethodHandleEntry* me) {
   assert(_vmentry_offset != 0, "must be present");
 
   // This is always the final step that initializes a valid method handle:
@@ -2303,123 +2428,123 @@ void java_dyn_MethodHandle::set_vmentry(oop mh, MethodHandleEntry* me) {
 
 /// MemberName accessors
 
-oop sun_dyn_MemberName::clazz(oop mname) {
+oop java_lang_invoke_MemberName::clazz(oop mname) {
   assert(is_instance(mname), "wrong type");
   return mname->obj_field(_clazz_offset);
 }
 
-void sun_dyn_MemberName::set_clazz(oop mname, oop clazz) {
+void java_lang_invoke_MemberName::set_clazz(oop mname, oop clazz) {
   assert(is_instance(mname), "wrong type");
   mname->obj_field_put(_clazz_offset, clazz);
 }
 
-oop sun_dyn_MemberName::name(oop mname) {
+oop java_lang_invoke_MemberName::name(oop mname) {
   assert(is_instance(mname), "wrong type");
   return mname->obj_field(_name_offset);
 }
 
-void sun_dyn_MemberName::set_name(oop mname, oop name) {
+void java_lang_invoke_MemberName::set_name(oop mname, oop name) {
   assert(is_instance(mname), "wrong type");
   mname->obj_field_put(_name_offset, name);
 }
 
-oop sun_dyn_MemberName::type(oop mname) {
+oop java_lang_invoke_MemberName::type(oop mname) {
   assert(is_instance(mname), "wrong type");
   return mname->obj_field(_type_offset);
 }
 
-void sun_dyn_MemberName::set_type(oop mname, oop type) {
+void java_lang_invoke_MemberName::set_type(oop mname, oop type) {
   assert(is_instance(mname), "wrong type");
   mname->obj_field_put(_type_offset, type);
 }
 
-int sun_dyn_MemberName::flags(oop mname) {
+int java_lang_invoke_MemberName::flags(oop mname) {
   assert(is_instance(mname), "wrong type");
   return mname->int_field(_flags_offset);
 }
 
-void sun_dyn_MemberName::set_flags(oop mname, int flags) {
+void java_lang_invoke_MemberName::set_flags(oop mname, int flags) {
   assert(is_instance(mname), "wrong type");
   mname->int_field_put(_flags_offset, flags);
 }
 
-oop sun_dyn_MemberName::vmtarget(oop mname) {
+oop java_lang_invoke_MemberName::vmtarget(oop mname) {
   assert(is_instance(mname), "wrong type");
   return mname->obj_field(_vmtarget_offset);
 }
 
-void sun_dyn_MemberName::set_vmtarget(oop mname, oop ref) {
+void java_lang_invoke_MemberName::set_vmtarget(oop mname, oop ref) {
   assert(is_instance(mname), "wrong type");
   mname->obj_field_put(_vmtarget_offset, ref);
 }
 
-int sun_dyn_MemberName::vmindex(oop mname) {
+int java_lang_invoke_MemberName::vmindex(oop mname) {
   assert(is_instance(mname), "wrong type");
   return mname->int_field(_vmindex_offset);
 }
 
-void sun_dyn_MemberName::set_vmindex(oop mname, int index) {
+void java_lang_invoke_MemberName::set_vmindex(oop mname, int index) {
   assert(is_instance(mname), "wrong type");
   mname->int_field_put(_vmindex_offset, index);
 }
 
-oop java_dyn_MethodHandle::vmtarget(oop mh) {
+oop java_lang_invoke_MethodHandle::vmtarget(oop mh) {
   assert(is_instance(mh), "MH only");
   return mh->obj_field(_vmtarget_offset);
 }
 
-void java_dyn_MethodHandle::set_vmtarget(oop mh, oop ref) {
+void java_lang_invoke_MethodHandle::set_vmtarget(oop mh, oop ref) {
   assert(is_instance(mh), "MH only");
   mh->obj_field_put(_vmtarget_offset, ref);
 }
 
-int sun_dyn_DirectMethodHandle::vmindex(oop mh) {
+int java_lang_invoke_DirectMethodHandle::vmindex(oop mh) {
   assert(is_instance(mh), "DMH only");
   return mh->int_field(_vmindex_offset);
 }
 
-void sun_dyn_DirectMethodHandle::set_vmindex(oop mh, int index) {
+void java_lang_invoke_DirectMethodHandle::set_vmindex(oop mh, int index) {
   assert(is_instance(mh), "DMH only");
   mh->int_field_put(_vmindex_offset, index);
 }
 
-int sun_dyn_BoundMethodHandle::vmargslot(oop mh) {
+int java_lang_invoke_BoundMethodHandle::vmargslot(oop mh) {
   assert(is_instance(mh), "BMH only");
   return mh->int_field(_vmargslot_offset);
 }
 
-oop sun_dyn_BoundMethodHandle::argument(oop mh) {
+oop java_lang_invoke_BoundMethodHandle::argument(oop mh) {
   assert(is_instance(mh), "BMH only");
   return mh->obj_field(_argument_offset);
 }
 
-int sun_dyn_AdapterMethodHandle::conversion(oop mh) {
+int java_lang_invoke_AdapterMethodHandle::conversion(oop mh) {
   assert(is_instance(mh), "AMH only");
   return mh->int_field(_conversion_offset);
 }
 
-void sun_dyn_AdapterMethodHandle::set_conversion(oop mh, int conv) {
+void java_lang_invoke_AdapterMethodHandle::set_conversion(oop mh, int conv) {
   assert(is_instance(mh), "AMH only");
   mh->int_field_put(_conversion_offset, conv);
 }
 
 
-// Support for java_dyn_MethodType
+// Support for java_lang_invoke_MethodType
 
-int java_dyn_MethodType::_rtype_offset;
-int java_dyn_MethodType::_ptypes_offset;
-int java_dyn_MethodType::_form_offset;
+int java_lang_invoke_MethodType::_rtype_offset;
+int java_lang_invoke_MethodType::_ptypes_offset;
+int java_lang_invoke_MethodType::_form_offset;
 
-void java_dyn_MethodType::compute_offsets() {
+void java_lang_invoke_MethodType::compute_offsets() {
   klassOop k = SystemDictionary::MethodType_klass();
   if (k != NULL) {
     compute_offset(_rtype_offset,  k, vmSymbols::rtype_name(),  vmSymbols::class_signature());
     compute_offset(_ptypes_offset, k, vmSymbols::ptypes_name(), vmSymbols::class_array_signature());
-    compute_offset(_form_offset,   k, vmSymbols::form_name(),   vmSymbols::java_dyn_MethodTypeForm_signature());
+    compute_offset(_form_offset,   k, vmSymbols::form_name(),   vmSymbols::java_lang_invoke_MethodTypeForm_signature());
   }
 }
 
-void java_dyn_MethodType::print_signature(oop mt, outputStream* st) {
+void java_lang_invoke_MethodType::print_signature(oop mt, outputStream* st) {
   st->print("(");
   objArrayOop pts = ptypes(mt);
   for (int i = 0, limit = pts->length(); i < limit; i++) {
@@ -2429,7 +2554,7 @@ void java_dyn_MethodType::print_signature(oop mt, outputStream* st) {
   java_lang_Class::print_signature(rtype(mt), st);
 }
 
-Symbol* java_dyn_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAPS) {
+Symbol* java_lang_invoke_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAPS) {
   ResourceMark rm;
   stringStream buffer(128);
   print_signature(mt, &buffer);
@@ -2444,103 +2569,83 @@ Symbol* java_dyn_MethodType::as_signature(oop mt, bool intern_if_not_found, TRAP
   return name;
 }
 
-oop java_dyn_MethodType::rtype(oop mt) {
+oop java_lang_invoke_MethodType::rtype(oop mt) {
   assert(is_instance(mt), "must be a MethodType");
   return mt->obj_field(_rtype_offset);
 }
 
-objArrayOop java_dyn_MethodType::ptypes(oop mt) {
+objArrayOop java_lang_invoke_MethodType::ptypes(oop mt) {
   assert(is_instance(mt), "must be a MethodType");
   return (objArrayOop) mt->obj_field(_ptypes_offset);
 }
 
-oop java_dyn_MethodType::form(oop mt) {
+oop java_lang_invoke_MethodType::form(oop mt) {
   assert(is_instance(mt), "must be a MethodType");
   return mt->obj_field(_form_offset);
 }
 
-oop java_dyn_MethodType::ptype(oop mt, int idx) {
+oop java_lang_invoke_MethodType::ptype(oop mt, int idx) {
   return ptypes(mt)->obj_at(idx);
 }
 
-int java_dyn_MethodType::ptype_count(oop mt) {
+int java_lang_invoke_MethodType::ptype_count(oop mt) {
   return ptypes(mt)->length();
 }
 
 
 
-// Support for java_dyn_MethodTypeForm
+// Support for java_lang_invoke_MethodTypeForm
 
-int java_dyn_MethodTypeForm::_vmslots_offset;
-int java_dyn_MethodTypeForm::_erasedType_offset;
-int java_dyn_MethodTypeForm::_genericInvoker_offset;
+int java_lang_invoke_MethodTypeForm::_vmslots_offset;
+int java_lang_invoke_MethodTypeForm::_erasedType_offset;
+int java_lang_invoke_MethodTypeForm::_genericInvoker_offset;
 
-void java_dyn_MethodTypeForm::compute_offsets() {
+void java_lang_invoke_MethodTypeForm::compute_offsets() {
   klassOop k = SystemDictionary::MethodTypeForm_klass();
   if (k != NULL) {
     compute_optional_offset(_vmslots_offset,    k, vmSymbols::vmslots_name(),    vmSymbols::int_signature(), true);
-    compute_optional_offset(_erasedType_offset, k, vmSymbols::erasedType_name(), vmSymbols::java_dyn_MethodType_signature(), true);
-    compute_optional_offset(_genericInvoker_offset, k, vmSymbols::genericInvoker_name(), vmSymbols::java_dyn_MethodHandle_signature(), true);
+    compute_optional_offset(_erasedType_offset, k, vmSymbols::erasedType_name(), vmSymbols::java_lang_invoke_MethodType_signature(), true);
+    compute_optional_offset(_genericInvoker_offset, k, vmSymbols::genericInvoker_name(), vmSymbols::java_lang_invoke_MethodHandle_signature(), true);
     if (_genericInvoker_offset == 0)  _genericInvoker_offset = -1;  // set to explicit "empty" value
   }
 }
 
-int java_dyn_MethodTypeForm::vmslots(oop mtform) {
+int java_lang_invoke_MethodTypeForm::vmslots(oop mtform) {
   assert(mtform->klass() == SystemDictionary::MethodTypeForm_klass(), "MTForm only");
   return mtform->int_field(_vmslots_offset);
 }
 
-oop java_dyn_MethodTypeForm::erasedType(oop mtform) {
+oop java_lang_invoke_MethodTypeForm::erasedType(oop mtform) {
   assert(mtform->klass() == SystemDictionary::MethodTypeForm_klass(), "MTForm only");
   return mtform->obj_field(_erasedType_offset);
 }
 
-oop java_dyn_MethodTypeForm::genericInvoker(oop mtform) {
+oop java_lang_invoke_MethodTypeForm::genericInvoker(oop mtform) {
   assert(mtform->klass() == SystemDictionary::MethodTypeForm_klass(), "MTForm only");
   return mtform->obj_field(_genericInvoker_offset);
 }
 
 
-// Support for java_dyn_CallSite
+// Support for java_lang_invoke_CallSite
 
-int java_dyn_CallSite::_target_offset;
-int java_dyn_CallSite::_caller_method_offset;
-int java_dyn_CallSite::_caller_bci_offset;
+int java_lang_invoke_CallSite::_target_offset;
 
-void java_dyn_CallSite::compute_offsets() {
+void java_lang_invoke_CallSite::compute_offsets() {
   if (!EnableInvokeDynamic)  return;
   klassOop k = SystemDictionary::CallSite_klass();
   if (k != NULL) {
-    compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_dyn_MethodHandle_signature());
-    compute_offset(_caller_method_offset, k, vmSymbols::vmmethod_name(), vmSymbols::sun_dyn_MemberName_signature());
-    compute_offset(_caller_bci_offset, k, vmSymbols::vmindex_name(), vmSymbols::int_signature());
+    compute_offset(_target_offset, k, vmSymbols::target_name(), vmSymbols::java_lang_invoke_MethodHandle_signature());
   }
 }
 
-oop java_dyn_CallSite::target(oop site) {
+oop java_lang_invoke_CallSite::target(oop site) {
   return site->obj_field(_target_offset);
 }
 
-void java_dyn_CallSite::set_target(oop site, oop target) {
+void java_lang_invoke_CallSite::set_target(oop site, oop target) {
   site->obj_field_put(_target_offset, target);
 }
 
-oop java_dyn_CallSite::caller_method(oop site) {
-  return site->obj_field(_caller_method_offset);
-}
-
-void java_dyn_CallSite::set_caller_method(oop site, oop ref) {
-  site->obj_field_put(_caller_method_offset, ref);
-}
-
-jint java_dyn_CallSite::caller_bci(oop site) {
-  return site->int_field(_caller_bci_offset);
-}
-
-void java_dyn_CallSite::set_caller_bci(oop site, jint bci) {
-  site->int_field_put(_caller_bci_offset, bci);
-}
-
 
 // Support for java_security_AccessControlContext
 
@@ -2621,26 +2726,18 @@ oop java_lang_ClassLoader::non_reflection_class_loader(oop loader) {
 
 
 // Support for java_lang_System
-
-void java_lang_System::compute_offsets() {
-  assert(offset_of_static_fields == 0, "offsets should be initialized only once");
-
-  instanceKlass* ik = instanceKlass::cast(SystemDictionary::System_klass());
-  offset_of_static_fields = ik->offset_of_static_fields();
-}
-
 int java_lang_System::in_offset_in_bytes() {
-  return (offset_of_static_fields + static_in_offset);
+  return (instanceMirrorKlass::offset_of_static_fields() + static_in_offset);
 }
 
 
 int java_lang_System::out_offset_in_bytes() {
-  return (offset_of_static_fields + static_out_offset);
+  return (instanceMirrorKlass::offset_of_static_fields() + static_out_offset);
 }
 
 
 int java_lang_System::err_offset_in_bytes() {
-  return (offset_of_static_fields + static_err_offset);
+  return (instanceMirrorKlass::offset_of_static_fields() + static_err_offset);
 }
 
 
@@ -2653,6 +2750,8 @@ int java_lang_Class::klass_offset;
 int java_lang_Class::array_klass_offset;
 int java_lang_Class::resolved_constructor_offset;
 int java_lang_Class::number_of_fake_oop_fields;
+int java_lang_Class::oop_size_offset;
+int java_lang_Class::static_oop_field_count_offset;
 int java_lang_Throwable::backtrace_offset;
 int java_lang_Throwable::detailMessage_offset;
 int java_lang_Throwable::cause_offset;
@@ -2696,7 +2795,6 @@ int java_lang_ref_Reference::number_of_fake_oop_fields;
 int java_lang_ref_SoftReference::timestamp_offset;
 int java_lang_ref_SoftReference::static_clock_offset;
 int java_lang_ClassLoader::parent_offset;
-int java_lang_System::offset_of_static_fields;
 int java_lang_System::static_in_offset;
 int java_lang_System::static_out_offset;
 int java_lang_System::static_err_offset;
@@ -2813,10 +2911,19 @@ void JavaClasses::compute_hard_coded_offsets() {
   java_lang_String::count_offset  = java_lang_String::offset_offset + sizeof (jint);
   java_lang_String::hash_offset   = java_lang_String::count_offset + sizeof (jint);
 
-  // Do the Class Class
-  java_lang_Class::klass_offset = java_lang_Class::hc_klass_offset * x + header;
-  java_lang_Class::array_klass_offset = java_lang_Class::hc_array_klass_offset * x + header;
-  java_lang_Class::resolved_constructor_offset = java_lang_Class::hc_resolved_constructor_offset * x + header;
+  {
+    // Do the Class Class
+    int offset = header;
+    java_lang_Class::oop_size_offset = header;
+    offset += BytesPerInt;
+    java_lang_Class::static_oop_field_count_offset = offset;
+    offset = align_size_up(offset + BytesPerInt, x);
+    java_lang_Class::klass_offset = offset;
+    offset += x;
+    java_lang_Class::array_klass_offset = offset;
+    offset += x;
+    java_lang_Class::resolved_constructor_offset = offset;
+  }
 
   // This is NOT an offset
   java_lang_Class::number_of_fake_oop_fields = java_lang_Class::hc_number_of_fake_oop_fields;
@@ -2873,20 +2980,19 @@ void JavaClasses::compute_hard_coded_offsets() {
 void JavaClasses::compute_offsets() {
 
   java_lang_Class::compute_offsets();
-  java_lang_System::compute_offsets();
   java_lang_Thread::compute_offsets();
   java_lang_ThreadGroup::compute_offsets();
   if (EnableMethodHandles) {
-    java_dyn_MethodHandle::compute_offsets();
-    sun_dyn_MemberName::compute_offsets();
-    sun_dyn_DirectMethodHandle::compute_offsets();
-    sun_dyn_BoundMethodHandle::compute_offsets();
-    sun_dyn_AdapterMethodHandle::compute_offsets();
-    java_dyn_MethodType::compute_offsets();
-    java_dyn_MethodTypeForm::compute_offsets();
+    java_lang_invoke_MethodHandle::compute_offsets();
+    java_lang_invoke_MemberName::compute_offsets();
+    java_lang_invoke_DirectMethodHandle::compute_offsets();
+    java_lang_invoke_BoundMethodHandle::compute_offsets();
+    java_lang_invoke_AdapterMethodHandle::compute_offsets();
+    java_lang_invoke_MethodType::compute_offsets();
+    java_lang_invoke_MethodTypeForm::compute_offsets();
   }
   if (EnableInvokeDynamic) {
-    java_dyn_CallSite::compute_offsets();
+    java_lang_invoke_CallSite::compute_offsets();
   }
   java_security_AccessControlContext::compute_offsets();
   // Initialize reflection classes. The layouts of these classes
@@ -2957,10 +3063,10 @@ bool JavaClasses::check_static_offset(const char *klass_name, int hardcoded_offs
     tty->print_cr("Static field %s.%s appears to be nonstatic", klass_name, field_name);
     return false;
   }
-  if (fd.offset() == hardcoded_offset + h_klass->offset_of_static_fields()) {
+  if (fd.offset() == hardcoded_offset + instanceMirrorKlass::offset_of_static_fields()) {
     return true;
   } else {
-    tty->print_cr("Offset of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_offset, fd.offset() - h_klass->offset_of_static_fields());
+    tty->print_cr("Offset of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_offset, fd.offset() - instanceMirrorKlass::offset_of_static_fields());
     return false;
   }
 }
diff --git a/hotspot/src/share/vm/classfile/javaClasses.hpp b/hotspot/src/share/vm/classfile/javaClasses.hpp
index 813ae615d1b..db4af2e6871 100644
--- a/hotspot/src/share/vm/classfile/javaClasses.hpp
+++ b/hotspot/src/share/vm/classfile/javaClasses.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -138,10 +138,8 @@ class java_lang_Class : AllStatic {
   // The fake offsets are added by the class loader when java.lang.Class is loaded
 
   enum {
-    hc_klass_offset                = 0,
-    hc_array_klass_offset          = 1,
-    hc_resolved_constructor_offset = 2,
-    hc_number_of_fake_oop_fields   = 3
+    hc_number_of_fake_oop_fields   = 3,
+    hc_number_of_fake_int_fields   = 2
   };
 
   static int klass_offset;
@@ -149,6 +147,9 @@ class java_lang_Class : AllStatic {
   static int array_klass_offset;
   static int number_of_fake_oop_fields;
 
+  static int oop_size_offset;
+  static int static_oop_field_count_offset;
+
   static void compute_offsets();
   static bool offsets_computed;
   static int classRedefinedCount_offset;
@@ -157,6 +158,7 @@ class java_lang_Class : AllStatic {
  public:
   // Instance creation
   static oop  create_mirror(KlassHandle k, TRAPS);
+  static void fixup_mirror(KlassHandle k, TRAPS);
   static oop  create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
   // Conversion
   static klassOop as_klassOop(oop java_class);
@@ -191,6 +193,12 @@ class java_lang_Class : AllStatic {
   static void set_classRedefinedCount(oop the_class_mirror, int value);
   // Support for parallelCapable field
   static bool parallelCapable(oop the_class_mirror);
+
+  static int oop_size(oop java_class);
+  static void set_oop_size(oop java_class, int size);
+  static int static_oop_field_count(oop java_class);
+  static void set_static_oop_field_count(oop java_class, int size);
+
   // Debugging
   friend class JavaClasses;
   friend class instanceKlass;   // verification code accesses offsets
@@ -794,11 +802,11 @@ class java_lang_ref_SoftReference: public java_lang_ref_Reference {
 };
 
 
-// Interface to java.dyn.MethodHandle objects
+// Interface to java.lang.invoke.MethodHandle objects
 
 class MethodHandleEntry;
 
-class java_dyn_MethodHandle: AllStatic {
+class java_lang_invoke_MethodHandle: AllStatic {
   friend class JavaClasses;
 
  private:
@@ -839,7 +847,7 @@ class java_dyn_MethodHandle: AllStatic {
   static int vmslots_offset_in_bytes()          { return _vmslots_offset; }
 };
 
-class sun_dyn_DirectMethodHandle: public java_dyn_MethodHandle {
+class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle {
   friend class JavaClasses;
 
  private:
@@ -864,7 +872,7 @@ class sun_dyn_DirectMethodHandle: public java_dyn_MethodHandle {
   static int vmindex_offset_in_bytes()          { return _vmindex_offset; }
 };
 
-class sun_dyn_BoundMethodHandle: public java_dyn_MethodHandle {
+class java_lang_invoke_BoundMethodHandle: public java_lang_invoke_MethodHandle {
   friend class JavaClasses;
 
  private:
@@ -891,7 +899,7 @@ public:
   static int vmargslot_offset_in_bytes()        { return _vmargslot_offset; }
 };
 
-class sun_dyn_AdapterMethodHandle: public sun_dyn_BoundMethodHandle {
+class java_lang_invoke_AdapterMethodHandle: public java_lang_invoke_BoundMethodHandle {
   friend class JavaClasses;
 
  private:
@@ -942,14 +950,14 @@ class sun_dyn_AdapterMethodHandle: public sun_dyn_BoundMethodHandle {
 };
 
 
-// Interface to sun.dyn.MemberName objects
+// Interface to java.lang.invoke.MemberName objects
 // (These are a private interface for Java code to query the class hierarchy.)
 
-class sun_dyn_MemberName: AllStatic {
+class java_lang_invoke_MemberName: AllStatic {
   friend class JavaClasses;
 
  private:
-  // From java.dyn.MemberName:
+  // From java.lang.invoke.MemberName:
   //    private Class<?>   clazz;       // class in which the method is defined
   //    private String     name;        // may be null if not yet materialized
   //    private Object     type;        // may be null if not yet materialized
@@ -1018,9 +1026,9 @@ class sun_dyn_MemberName: AllStatic {
 };
 
 
-// Interface to java.dyn.MethodType objects
+// Interface to java.lang.invoke.MethodType objects
 
-class java_dyn_MethodType: AllStatic {
+class java_lang_invoke_MethodType: AllStatic {
   friend class JavaClasses;
 
  private:
@@ -1052,7 +1060,7 @@ class java_dyn_MethodType: AllStatic {
   static int form_offset_in_bytes()             { return _form_offset; }
 };
 
-class java_dyn_MethodTypeForm: AllStatic {
+class java_lang_invoke_MethodTypeForm: AllStatic {
   friend class JavaClasses;
 
  private:
@@ -1075,9 +1083,9 @@ class java_dyn_MethodTypeForm: AllStatic {
 };
 
 
-// Interface to java.dyn.CallSite objects
+// Interface to java.lang.invoke.CallSite objects
 
-class java_dyn_CallSite: AllStatic {
+class java_lang_invoke_CallSite: AllStatic {
   friend class JavaClasses;
 
 private:
@@ -1165,13 +1173,10 @@ class java_lang_System : AllStatic {
    hc_static_err_offset = 2
   };
 
-  static int offset_of_static_fields;
   static int  static_in_offset;
   static int static_out_offset;
   static int static_err_offset;
 
-  static void compute_offsets();
-
  public:
   static int  in_offset_in_bytes();
   static int out_offset_in_bytes();
diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp
index f200b9a5f64..2ee98db4ef7 100644
--- a/hotspot/src/share/vm/classfile/symbolTable.cpp
+++ b/hotspot/src/share/vm/classfile/symbolTable.cpp
@@ -88,7 +88,7 @@ int SymbolTable::symbols_counted = 0;
 void SymbolTable::unlink() {
   int removed = 0;
   int total = 0;
-  int memory_total = 0;
+  size_t memory_total = 0;
   for (int i = 0; i < the_table()->table_size(); ++i) {
     for (HashtableEntry<Symbol*>** p = the_table()->bucket_addr(i); *p != NULL; ) {
       HashtableEntry<Symbol*>* entry = *p;
@@ -112,8 +112,10 @@ void SymbolTable::unlink() {
   }
   symbols_removed += removed;
   symbols_counted += total;
-  if (PrintGCDetails) {
-    gclog_or_tty->print(" [Symbols=%d size=%dK] ", total,
+  // Exclude printing for normal PrintGCDetails because people parse
+  // this output.
+  if (PrintGCDetails && Verbose && WizardMode) {
+    gclog_or_tty->print(" [Symbols=%d size=" SIZE_FORMAT "K] ", total,
                         (memory_total*HeapWordSize)/1024);
   }
 }
@@ -528,7 +530,7 @@ oop StringTable::basic_add(int index, Handle string_or_null, jchar* name,
 
   Handle string;
   // try to reuse the string if possible
-  if (!string_or_null.is_null() && string_or_null()->is_perm()) {
+  if (!string_or_null.is_null() && (!JavaObjectsInPerm || string_or_null()->is_perm())) {
     string = string_or_null;
   } else {
     string = java_lang_String::create_tenured_from_unicode(name, len, CHECK_NULL);
@@ -660,7 +662,7 @@ void StringTable::verify() {
     for ( ; p != NULL; p = p->next()) {
       oop s = p->literal();
       guarantee(s != NULL, "interned string is NULL");
-      guarantee(s->is_perm(), "interned string not in permspace");
+      guarantee(s->is_perm() || !JavaObjectsInPerm, "interned string not in permspace");
 
       int length;
       jchar* chars = java_lang_String::as_unicode_string(s, length);
diff --git a/hotspot/src/share/vm/classfile/symbolTable.hpp b/hotspot/src/share/vm/classfile/symbolTable.hpp
index 89acd79facb..13aef77ad7f 100644
--- a/hotspot/src/share/vm/classfile/symbolTable.hpp
+++ b/hotspot/src/share/vm/classfile/symbolTable.hpp
@@ -216,18 +216,14 @@ private:
   oop basic_add(int index, Handle string_or_null, jchar* name, int len,
                 unsigned int hashValue, TRAPS);
 
-  // Table size
-  enum {
-    string_table_size = 1009
-  };
-
   oop lookup(int index, jchar* chars, int length, unsigned int hashValue);
 
-  StringTable() : Hashtable<oop>(string_table_size, sizeof (HashtableEntry<oop>)) {}
+  StringTable() : Hashtable<oop>((int)StringTableSize,
+                                 sizeof (HashtableEntry<oop>)) {}
 
   StringTable(HashtableBucket* t, int number_of_entries)
-    : Hashtable<oop>(string_table_size, sizeof (HashtableEntry<oop>), t,
-                number_of_entries) {}
+    : Hashtable<oop>((int)StringTableSize, sizeof (HashtableEntry<oop>), t,
+                     number_of_entries) {}
 
 public:
   // The string table
@@ -241,7 +237,7 @@ public:
   static void create_table(HashtableBucket* t, int length,
                            int number_of_entries) {
     assert(_the_table == NULL, "One string table allowed.");
-    assert(length == string_table_size * sizeof(HashtableBucket),
+    assert((size_t)length == StringTableSize * sizeof(HashtableBucket),
            "bad shared string size.");
     _the_table = new StringTable(t, number_of_entries);
   }
diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp
index dfe58e18b2c..ac935f90510 100644
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1887,27 +1887,99 @@ static const short wk_init_info[] = {
   0
 };
 
+Symbol* SystemDictionary::find_backup_symbol(Symbol* symbol,
+                                             const char* from_prefix,
+                                             const char* to_prefix) {
+  assert(AllowTransitionalJSR292, "");  // delete this subroutine
+  Symbol* backup_symbol = NULL;
+  size_t from_len = strlen(from_prefix);
+  if (strncmp((const char*) symbol->base(), from_prefix, from_len) != 0)
+    return NULL;
+  char buf[100];
+  size_t to_len = strlen(to_prefix);
+  size_t tail_len = symbol->utf8_length() - from_len;
+  size_t new_len = to_len + tail_len;
+  guarantee(new_len < sizeof(buf), "buf too small");
+  memcpy(buf, to_prefix, to_len);
+  memcpy(buf + to_len, symbol->base() + from_len, tail_len);
+  buf[new_len] = '\0';
+  vmSymbols::SID backup_sid = vmSymbols::find_sid(buf);
+  if (backup_sid != vmSymbols::NO_SID) {
+    backup_symbol = vmSymbols::symbol_at(backup_sid);
+  }
+  return backup_symbol;
+}
+
+Symbol* SystemDictionary::find_backup_class_name(Symbol* symbol) {
+  assert(AllowTransitionalJSR292, "");  // delete this subroutine
+  if (symbol == NULL)  return NULL;
+  Symbol* backup_symbol = find_backup_symbol(symbol, "java/lang/invoke/", "java/dyn/");  // AllowTransitionalJSR292 ONLY
+  if (backup_symbol == NULL)
+    backup_symbol = find_backup_symbol(symbol, "java/dyn/", "sun/dyn/");  // AllowTransitionalJSR292 ONLY
+  return backup_symbol;
+}
+
+Symbol* SystemDictionary::find_backup_signature(Symbol* symbol) {
+  assert(AllowTransitionalJSR292, "");  // delete this subroutine
+  if (symbol == NULL)  return NULL;
+  return find_backup_symbol(symbol, "Ljava/lang/invoke/", "Ljava/dyn/");
+}
+
 bool SystemDictionary::initialize_wk_klass(WKID id, int init_opt, TRAPS) {
   assert(id >= (int)FIRST_WKID && id < (int)WKID_LIMIT, "oob");
   int  info = wk_init_info[id - FIRST_WKID];
   int  sid  = (info >> CEIL_LG_OPTION_LIMIT);
   Symbol* symbol = vmSymbols::symbol_at((vmSymbols::SID)sid);
   klassOop*    klassp = &_well_known_klasses[id];
-  bool must_load = (init_opt < SystemDictionary::Opt);
-  bool try_load  = true;
+  bool pre_load = (init_opt < SystemDictionary::Opt);
+  bool try_load = true;
   if (init_opt == SystemDictionary::Opt_Kernel) {
 #ifndef KERNEL
     try_load = false;
 #endif //KERNEL
   }
-  if ((*klassp) == NULL && try_load) {
+  Symbol* backup_symbol = NULL;  // symbol to try if the current symbol fails
+  if (init_opt == SystemDictionary::Pre_JSR292) {
+    if (!EnableMethodHandles)  try_load = false;  // do not bother to load such classes
+    if (AllowTransitionalJSR292) {
+      backup_symbol = find_backup_class_name(symbol);
+      if (try_load && PreferTransitionalJSR292) {
+        while (backup_symbol != NULL) {
+          (*klassp) = resolve_or_null(backup_symbol, CHECK_0); // try backup early
+          if (TraceMethodHandles) {
+            ResourceMark rm;
+            tty->print_cr("MethodHandles: try backup first for %s => %s (%s)",
+                          symbol->as_C_string(), backup_symbol->as_C_string(),
+                          ((*klassp) == NULL) ? "no such class" : "backup load succeeded");
+          }
+          if ((*klassp) != NULL)  return true;
+          backup_symbol = find_backup_class_name(backup_symbol);  // find next backup
+        }
+      }
+    }
+  }
+  if ((*klassp) != NULL)  return true;
+  if (!try_load)          return false;
+  while (symbol != NULL) {
+    bool must_load = (pre_load && (backup_symbol == NULL));
     if (must_load) {
       (*klassp) = resolve_or_fail(symbol, true, CHECK_0); // load required class
     } else {
       (*klassp) = resolve_or_null(symbol,       CHECK_0); // load optional klass
     }
+    if ((*klassp) != NULL)  return true;
+    // Go around again.  Example of long backup sequence:
+    // java.lang.invoke.MemberName, java.dyn.MemberName, sun.dyn.MemberName, ONLY if AllowTransitionalJSR292
+    if (TraceMethodHandles && (backup_symbol != NULL)) {
+      ResourceMark rm;
+      tty->print_cr("MethodHandles: backup for %s => %s",
+                    symbol->as_C_string(), backup_symbol->as_C_string());
+    }
+    symbol = backup_symbol;
+    if (AllowTransitionalJSR292)
+      backup_symbol = find_backup_class_name(symbol);
   }
-  return ((*klassp) != NULL);
+  return false;
 }
 
 void SystemDictionary::initialize_wk_klasses_until(WKID limit_id, WKID &start_id, TRAPS) {
@@ -2348,6 +2420,8 @@ methodOop SystemDictionary::find_method_handle_invoke(Symbol* name,
     if (THREAD->is_Compiler_thread())
       return NULL;              // do not attempt from within compiler
     bool for_invokeGeneric = (name_id == vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name));
+    if (AllowInvokeForInvokeGeneric && name_id == vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name))
+      for_invokeGeneric = true;
     bool found_on_bcp = false;
     Handle mt = find_method_handle_type(signature, accessing_klass,
                                         for_invokeGeneric,
@@ -2376,7 +2450,7 @@ methodOop SystemDictionary::find_method_handle_invoke(Symbol* name,
   }
 }
 
-// Ask Java code to find or construct a java.dyn.MethodType for the given
+// Ask Java code to find or construct a java.lang.invoke.MethodType for the given
 // signature, as interpreted relative to the given class loader.
 // Because of class loader constraints, all method handle usage must be
 // consistent with this loader.
@@ -2430,25 +2504,33 @@ Handle SystemDictionary::find_method_handle_type(Symbol* signature,
   }
   assert(arg == npts, "");
 
-  // call sun.dyn.MethodHandleNatives::findMethodType(Class rt, Class[] pts) -> MethodType
+  // call java.lang.invoke.MethodHandleNatives::findMethodType(Class rt, Class[] pts) -> MethodType
   JavaCallArguments args(Handle(THREAD, rt()));
   args.push_oop(pts());
   JavaValue result(T_OBJECT);
+  Symbol* findMethodHandleType_signature = vmSymbols::findMethodHandleType_signature();
+  if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodType_klass()->name() == vmSymbols::java_dyn_MethodType()) {
+    findMethodHandleType_signature = vmSymbols::findMethodHandleType_TRANS_signature();
+  }
   JavaCalls::call_static(&result,
                          SystemDictionary::MethodHandleNatives_klass(),
                          vmSymbols::findMethodHandleType_name(),
-                         vmSymbols::findMethodHandleType_signature(),
+                         findMethodHandleType_signature,
                          &args, CHECK_(empty));
   Handle method_type(THREAD, (oop) result.get_jobject());
 
   if (for_invokeGeneric) {
-    // call sun.dyn.MethodHandleNatives::notifyGenericMethodType(MethodType) -> void
+    // call java.lang.invoke.MethodHandleNatives::notifyGenericMethodType(MethodType) -> void
     JavaCallArguments args(Handle(THREAD, method_type()));
     JavaValue no_result(T_VOID);
+    Symbol* notifyGenericMethodType_signature = vmSymbols::notifyGenericMethodType_signature();
+    if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodType_klass()->name() == vmSymbols::java_dyn_MethodType()) {
+      notifyGenericMethodType_signature = vmSymbols::notifyGenericMethodType_TRANS_signature();
+    }
     JavaCalls::call_static(&no_result,
                            SystemDictionary::MethodHandleNatives_klass(),
                            vmSymbols::notifyGenericMethodType_name(),
-                           vmSymbols::notifyGenericMethodType_signature(),
+                           notifyGenericMethodType_signature,
                            &args, THREAD);
     if (HAS_PENDING_EXCEPTION) {
       // If the notification fails, just kill it.
@@ -2489,7 +2571,7 @@ Handle SystemDictionary::link_method_handle_constant(KlassHandle caller,
     THROW_MSG_(vmSymbols::java_lang_LinkageError(), "bad signature", empty);
   }
 
-  // call sun.dyn.MethodHandleNatives::linkMethodHandleConstant(Class caller, int refKind, Class callee, String name, Object type) -> MethodHandle
+  // call java.lang.invoke.MethodHandleNatives::linkMethodHandleConstant(Class caller, int refKind, Class callee, String name, Object type) -> MethodHandle
   JavaCallArguments args;
   args.push_oop(caller->java_mirror());  // the referring class
   args.push_int(ref_kind);
@@ -2497,15 +2579,19 @@ Handle SystemDictionary::link_method_handle_constant(KlassHandle caller,
   args.push_oop(name());
   args.push_oop(type());
   JavaValue result(T_OBJECT);
+  Symbol* linkMethodHandleConstant_signature = vmSymbols::linkMethodHandleConstant_signature();
+  if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodHandle_klass()->name() == vmSymbols::java_dyn_MethodHandle()) {
+    linkMethodHandleConstant_signature = vmSymbols::linkMethodHandleConstant_TRANS_signature();
+  }
   JavaCalls::call_static(&result,
                          SystemDictionary::MethodHandleNatives_klass(),
                          vmSymbols::linkMethodHandleConstant_name(),
-                         vmSymbols::linkMethodHandleConstant_signature(),
+                         linkMethodHandleConstant_signature,
                          &args, CHECK_(empty));
   return Handle(THREAD, (oop) result.get_jobject());
 }
 
-// Ask Java code to find or construct a java.dyn.CallSite for the given
+// Ask Java code to find or construct a java.lang.invoke.CallSite for the given
 // name and signature, as interpreted relative to the given class loader.
 Handle SystemDictionary::make_dynamic_call_site(Handle bootstrap_method,
                                                 Symbol* name,
@@ -2516,13 +2602,13 @@ Handle SystemDictionary::make_dynamic_call_site(Handle bootstrap_method,
                                                 TRAPS) {
   Handle empty;
   guarantee(bootstrap_method.not_null() &&
-            java_dyn_MethodHandle::is_instance(bootstrap_method()),
+            java_lang_invoke_MethodHandle::is_instance(bootstrap_method()),
             "caller must supply a valid BSM");
 
   Handle caller_mname = MethodHandles::new_MemberName(CHECK_(empty));
   MethodHandles::init_MemberName(caller_mname(), caller_method());
 
-  // call sun.dyn.MethodHandleNatives::makeDynamicCallSite(bootm, name, mtype, info, caller_mname, caller_pos)
+  // call java.lang.invoke.MethodHandleNatives::makeDynamicCallSite(bootm, name, mtype, info, caller_mname, caller_pos)
   oop name_str_oop = StringTable::intern(name, CHECK_(empty)); // not a handle!
   JavaCallArguments args(Handle(THREAD, bootstrap_method()));
   args.push_oop(name_str_oop);
@@ -2531,14 +2617,21 @@ Handle SystemDictionary::make_dynamic_call_site(Handle bootstrap_method,
   args.push_oop(caller_mname());
   args.push_int(caller_bci);
   JavaValue result(T_OBJECT);
+  Symbol* makeDynamicCallSite_signature = vmSymbols::makeDynamicCallSite_signature();
+  if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodHandleNatives_klass()->name() == vmSymbols::sun_dyn_MethodHandleNatives()) {
+    makeDynamicCallSite_signature = vmSymbols::makeDynamicCallSite_TRANS_signature();
+  }
+  if (AllowTransitionalJSR292 && SystemDictionaryHandles::MethodHandleNatives_klass()->name() == vmSymbols::java_dyn_MethodHandleNatives()) {
+    makeDynamicCallSite_signature = vmSymbols::makeDynamicCallSite_TRANS2_signature();
+  }
   JavaCalls::call_static(&result,
                          SystemDictionary::MethodHandleNatives_klass(),
                          vmSymbols::makeDynamicCallSite_name(),
-                         vmSymbols::makeDynamicCallSite_signature(),
+                         makeDynamicCallSite_signature,
                          &args, CHECK_(empty));
   oop call_site_oop = (oop) result.get_jobject();
   assert(call_site_oop->is_oop()
-         /*&& java_dyn_CallSite::is_instance(call_site_oop)*/, "must be sane");
+         /*&& java_lang_invoke_CallSite::is_instance(call_site_oop)*/, "must be sane");
   if (TraceMethodHandles) {
 #ifndef PRODUCT
     tty->print_cr("Linked invokedynamic bci=%d site="INTPTR_FORMAT":", caller_bci, call_site_oop);
diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp
index 89dbadef639..0719fc33b94 100644
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp
@@ -144,18 +144,18 @@ class SymbolPropertyTable;
   template(reflect_UnsafeStaticFieldAccessorImpl_klass, sun_reflect_UnsafeStaticFieldAccessorImpl, Opt_Only_JDK15) \
                                                                               \
   /* support for dynamic typing; it's OK if these are NULL in earlier JDKs */ \
-  template(MethodHandle_klass,           java_dyn_MethodHandle,          Opt) \
-  template(MemberName_klass,             sun_dyn_MemberName,             Opt) \
-  template(MethodHandleImpl_klass,       sun_dyn_MethodHandleImpl,       Opt) \
-  template(MethodHandleNatives_klass,    sun_dyn_MethodHandleNatives,    Opt) \
-  template(AdapterMethodHandle_klass,    sun_dyn_AdapterMethodHandle,    Opt) \
-  template(BoundMethodHandle_klass,      sun_dyn_BoundMethodHandle,      Opt) \
-  template(DirectMethodHandle_klass,     sun_dyn_DirectMethodHandle,     Opt) \
-  template(MethodType_klass,             java_dyn_MethodType,            Opt) \
-  template(MethodTypeForm_klass,         java_dyn_MethodTypeForm,        Opt) \
-  template(WrongMethodTypeException_klass, java_dyn_WrongMethodTypeException, Opt) \
-  template(Linkage_klass,                java_dyn_Linkage,               Opt) \
-  template(CallSite_klass,               java_dyn_CallSite,              Opt) \
+  template(MethodHandle_klass,           java_lang_invoke_MethodHandle,     Pre_JSR292) \
+  template(MemberName_klass,             java_lang_invoke_MemberName,       Pre_JSR292) \
+  template(MethodHandleImpl_klass,       sun_dyn_MethodHandleImpl,          Opt) /* AllowTransitionalJSR292 ONLY */ \
+  template(MethodHandleNatives_klass,    java_lang_invoke_MethodHandleNatives, Pre_JSR292) \
+  template(AdapterMethodHandle_klass,    java_lang_invoke_AdapterMethodHandle, Pre_JSR292) \
+  template(BoundMethodHandle_klass,      java_lang_invoke_BoundMethodHandle, Pre_JSR292) \
+  template(DirectMethodHandle_klass,     java_lang_invoke_DirectMethodHandle, Pre_JSR292) \
+  template(MethodType_klass,             java_lang_invoke_MethodType,       Pre_JSR292) \
+  template(MethodTypeForm_klass,         java_lang_invoke_MethodTypeForm,   Pre_JSR292) \
+  template(WrongMethodTypeException_klass, java_lang_invoke_WrongMethodTypeException, Pre_JSR292) \
+  template(Linkage_klass,                java_lang_invoke_Linkage,          Opt) /* AllowTransitionalJSR292 ONLY */ \
+  template(CallSite_klass,               java_lang_invoke_CallSite,         Pre_JSR292) \
   /* Note: MethodHandle must be first, and CallSite last in group */          \
                                                                               \
   template(StringBuffer_klass,           java_lang_StringBuffer,         Pre) \
@@ -207,6 +207,7 @@ class SystemDictionary : AllStatic {
 
   enum InitOption {
     Pre,                        // preloaded; error if not present
+    Pre_JSR292,                 // preloaded if EnableMethodHandles
 
     // Order is significant.  Options before this point require resolve_or_fail.
     // Options after this point will use resolve_or_null instead.
@@ -401,6 +402,7 @@ public:
   }
 
   static klassOop check_klass_Pre(klassOop k) { return check_klass(k); }
+  static klassOop check_klass_Pre_JSR292(klassOop k) { return EnableInvokeDynamic ? check_klass(k) : k; }
   static klassOop check_klass_Opt(klassOop k) { return k; }
   static klassOop check_klass_Opt_Kernel(klassOop k) { return k; } //== Opt
   static klassOop check_klass_Opt_Only_JDK15(klassOop k) {
@@ -420,6 +422,8 @@ public:
     initialize_wk_klasses_until((WKID) limit, start_id, THREAD);
   }
 
+  static Symbol* find_backup_symbol(Symbol* symbol, const char* from_prefix, const char* to_prefix);
+
 public:
   #define WK_KLASS_DECLARE(name, ignore_symbol, option) \
     static klassOop name() { return check_klass_##option(_well_known_klasses[WK_KLASS_ENUM_NAME(name)]); }
@@ -441,6 +445,9 @@ public:
 
   static void load_abstract_ownable_synchronizer_klass(TRAPS);
 
+  static Symbol* find_backup_class_name(Symbol* class_name_symbol);
+  static Symbol* find_backup_signature(Symbol* signature_symbol);
+
 private:
   // Tells whether ClassLoader.loadClassInternal is present
   static bool has_loadClassInternal()       { return _has_loadClassInternal; }
@@ -475,18 +482,18 @@ public:
                                        Handle loader2, bool is_method, TRAPS);
 
   // JSR 292
-  // find the java.dyn.MethodHandles::invoke method for a given signature
+  // find the java.lang.invoke.MethodHandles::invoke method for a given signature
   static methodOop find_method_handle_invoke(Symbol* name,
                                              Symbol* signature,
                                              KlassHandle accessing_klass,
                                              TRAPS);
-  // ask Java to compute a java.dyn.MethodType object for a given signature
+  // ask Java to compute a java.lang.invoke.MethodType object for a given signature
   static Handle    find_method_handle_type(Symbol* signature,
                                            KlassHandle accessing_klass,
                                            bool for_invokeGeneric,
                                            bool& return_bcp_flag,
                                            TRAPS);
-  // ask Java to compute a java.dyn.MethodHandle object for a given CP entry
+  // ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry
   static Handle    link_method_handle_constant(KlassHandle caller,
                                                int ref_kind, //e.g., JVM_REF_invokeVirtual
                                                KlassHandle callee,
diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp
index 65e6fbf5a54..67a2a66dbe8 100644
--- a/hotspot/src/share/vm/classfile/verifier.cpp
+++ b/hotspot/src/share/vm/classfile/verifier.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1671,13 +1671,19 @@ void ClassVerifier::verify_ldc(
       VerificationType::long_type(),
       VerificationType::long2_type(), CHECK_VERIFY(this));
   } else if (tag.is_method_handle()) {
+    Symbol* methodHandle_name = vmSymbols::java_lang_invoke_MethodHandle();
+    if (AllowTransitionalJSR292 && !Universe::is_bootstrapping())
+      methodHandle_name = SystemDictionaryHandles::MethodHandle_klass()->name();
     current_frame->push_stack(
       VerificationType::reference_type(
-        vmSymbols::java_dyn_MethodHandle()), CHECK_VERIFY(this));
+        methodHandle_name), CHECK_VERIFY(this));
   } else if (tag.is_method_type()) {
+    Symbol* methodType_name = vmSymbols::java_lang_invoke_MethodType();
+    if (AllowTransitionalJSR292 && !Universe::is_bootstrapping())
+      methodType_name = SystemDictionaryHandles::MethodType_klass()->name();
     current_frame->push_stack(
       VerificationType::reference_type(
-        vmSymbols::java_dyn_MethodType()), CHECK_VERIFY(this));
+        methodType_name), CHECK_VERIFY(this));
   } else {
     verify_error(bci, "Invalid index in ldc");
     return;
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp
index 716750c72ae..a0feab4bdcd 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.cpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -277,6 +277,12 @@ vmSymbols::SID vmSymbols::find_sid(Symbol* symbol) {
   return sid;
 }
 
+vmSymbols::SID vmSymbols::find_sid(const char* symbol_name) {
+  Symbol* symbol = SymbolTable::probe(symbol_name, (int) strlen(symbol_name));
+  if (symbol == NULL)  return NO_SID;
+  return find_sid(symbol);
+}
+
 static vmIntrinsics::ID wrapper_intrinsic(BasicType type, bool unboxing) {
 #define TYPE2(type, unboxing) ((int)(type)*2 + ((unboxing) ? 1 : 0))
   switch (TYPE2(type, unboxing)) {
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp
index d149e3f05b9..81376926f07 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp
@@ -229,33 +229,60 @@
   template(base_name,                                 "base")                                     \
                                                                                                   \
   /* Support for JSR 292 & invokedynamic (JDK 1.7 and above) */                                   \
-  template(java_dyn_InvokeDynamic,                    "java/dyn/InvokeDynamic")                   \
-  template(java_dyn_Linkage,                          "java/dyn/Linkage")                         \
-  template(java_dyn_CallSite,                         "java/dyn/CallSite")                        \
-  template(java_dyn_MethodHandle,                     "java/dyn/MethodHandle")                    \
-  template(java_dyn_MethodType,                       "java/dyn/MethodType")                      \
-  template(java_dyn_WrongMethodTypeException,         "java/dyn/WrongMethodTypeException")        \
-  template(java_dyn_MethodType_signature,             "Ljava/dyn/MethodType;")                    \
-  template(java_dyn_MethodHandle_signature,           "Ljava/dyn/MethodHandle;")                  \
+  template(java_lang_invoke_InvokeDynamic,            "java/lang/invoke/InvokeDynamic")           \
+  template(java_lang_invoke_Linkage,                  "java/lang/invoke/Linkage")                 \
+  template(java_lang_invoke_CallSite,                 "java/lang/invoke/CallSite")                \
+  template(java_lang_invoke_MethodHandle,             "java/lang/invoke/MethodHandle")            \
+  template(java_lang_invoke_MethodType,               "java/lang/invoke/MethodType")              \
+  template(java_lang_invoke_WrongMethodTypeException, "java/lang/invoke/WrongMethodTypeException") \
+  template(java_lang_invoke_MethodType_signature,     "Ljava/lang/invoke/MethodType;")            \
+  template(java_lang_invoke_MethodHandle_signature,   "Ljava/lang/invoke/MethodHandle;")          \
   /* internal classes known only to the JVM: */                                                   \
-  template(java_dyn_MethodTypeForm,                   "java/dyn/MethodTypeForm")                  \
-  template(java_dyn_MethodTypeForm_signature,         "Ljava/dyn/MethodTypeForm;")                \
-  template(sun_dyn_MemberName,                        "sun/dyn/MemberName")                       \
-  template(sun_dyn_MemberName_signature,              "Lsun/dyn/MemberName;")                     \
-  template(sun_dyn_MethodHandleImpl,                  "sun/dyn/MethodHandleImpl")                 \
-  template(sun_dyn_MethodHandleNatives,               "sun/dyn/MethodHandleNatives")              \
-  template(sun_dyn_AdapterMethodHandle,               "sun/dyn/AdapterMethodHandle")              \
-  template(sun_dyn_BoundMethodHandle,                 "sun/dyn/BoundMethodHandle")                \
-  template(sun_dyn_DirectMethodHandle,                "sun/dyn/DirectMethodHandle")               \
-  /* internal up-calls made only by the JVM, via class sun.dyn.MethodHandleNatives: */            \
+  template(java_lang_invoke_MethodTypeForm,           "java/lang/invoke/MethodTypeForm")          \
+  template(java_lang_invoke_MethodTypeForm_signature, "Ljava/lang/invoke/MethodTypeForm;")        \
+  template(java_lang_invoke_MemberName,               "java/lang/invoke/MemberName")              \
+  template(java_lang_invoke_MethodHandleNatives,      "java/lang/invoke/MethodHandleNatives")     \
+  template(java_lang_invoke_AdapterMethodHandle,      "java/lang/invoke/AdapterMethodHandle")     \
+  template(java_lang_invoke_BoundMethodHandle,        "java/lang/invoke/BoundMethodHandle")       \
+  template(java_lang_invoke_DirectMethodHandle,       "java/lang/invoke/DirectMethodHandle")      \
+  /* temporary transitional public names from 6839872: */                                         \
+  template(java_dyn_InvokeDynamic,                    "java/dyn/InvokeDynamic")         /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_Linkage,                          "java/dyn/Linkage")               /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_CallSite,                         "java/dyn/CallSite")              /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_MethodHandle,                     "java/dyn/MethodHandle")          /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_MethodType,                       "java/dyn/MethodType")            /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_WrongMethodTypeException,         "java/dyn/WrongMethodTypeException") /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_MethodType_signature,             "Ljava/dyn/MethodType;")          /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_MethodHandle_signature,           "Ljava/dyn/MethodHandle;")        /* AllowTransitionalJSR292 ONLY */ \
+  /* temporary transitional internal names from 6839872: */                                       \
+  template(java_dyn_MethodTypeForm,                   "java/dyn/MethodTypeForm")        /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_MethodTypeForm_signature,         "Ljava/dyn/MethodTypeForm;")      /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_MemberName,                       "java/dyn/MemberName")            /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_MethodHandleNatives,              "java/dyn/MethodHandleNatives")   /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_AdapterMethodHandle,              "java/dyn/AdapterMethodHandle")   /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_BoundMethodHandle,                "java/dyn/BoundMethodHandle")     /* AllowTransitionalJSR292 ONLY */ \
+  template(java_dyn_DirectMethodHandle,               "java/dyn/DirectMethodHandle")    /* AllowTransitionalJSR292 ONLY */ \
+  /* temporary transitional internal names from EDR: */                                           \
+  template(sun_dyn_MemberName,                        "sun/dyn/MemberName")             /* AllowTransitionalJSR292 ONLY */ \
+  template(sun_dyn_MethodHandleImpl,                  "sun/dyn/MethodHandleImpl")       /* AllowTransitionalJSR292 ONLY */ \
+  template(sun_dyn_MethodHandleNatives,               "sun/dyn/MethodHandleNatives")    /* AllowTransitionalJSR292 ONLY */ \
+  template(sun_dyn_AdapterMethodHandle,               "sun/dyn/AdapterMethodHandle")    /* AllowTransitionalJSR292 ONLY */ \
+  template(sun_dyn_BoundMethodHandle,                 "sun/dyn/BoundMethodHandle")      /* AllowTransitionalJSR292 ONLY */ \
+  template(sun_dyn_DirectMethodHandle,                "sun/dyn/DirectMethodHandle")     /* AllowTransitionalJSR292 ONLY */ \
+  /* internal up-calls made only by the JVM, via class sun.invoke.MethodHandleNatives: */         \
   template(findMethodHandleType_name,                 "findMethodHandleType")                     \
-  template(findMethodHandleType_signature, "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/dyn/MethodType;") \
+  template(findMethodHandleType_signature,       "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/lang/invoke/MethodType;") \
+  template(findMethodHandleType_TRANS_signature, "(Ljava/lang/Class;[Ljava/lang/Class;)Ljava/dyn/MethodType;") /* AllowTransitionalJSR292 ONLY */ \
   template(notifyGenericMethodType_name,              "notifyGenericMethodType")                  \
-  template(notifyGenericMethodType_signature,         "(Ljava/dyn/MethodType;)V")                 \
+  template(notifyGenericMethodType_signature,         "(Ljava/lang/invoke/MethodType;)V")         \
+  template(notifyGenericMethodType_TRANS_signature,   "(Ljava/dyn/MethodType;)V")       /* AllowTransitionalJSR292 ONLY */ \
   template(linkMethodHandleConstant_name,             "linkMethodHandleConstant")                 \
-  template(linkMethodHandleConstant_signature, "(Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/String;Ljava/lang/Object;)Ljava/dyn/MethodHandle;") \
+  template(linkMethodHandleConstant_signature, "(Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/invoke/MethodHandle;") \
+  template(linkMethodHandleConstant_TRANS_signature, "(Ljava/lang/Class;ILjava/lang/Class;Ljava/lang/String;Ljava/lang/Object;)Ljava/dyn/MethodHandle;") /* AllowTransitionalJSR292 ONLY */ \
   template(makeDynamicCallSite_name,                  "makeDynamicCallSite")                      \
-  template(makeDynamicCallSite_signature, "(Ljava/dyn/MethodHandle;Ljava/lang/String;Ljava/dyn/MethodType;Ljava/lang/Object;Lsun/dyn/MemberName;I)Ljava/dyn/CallSite;") \
+  template(makeDynamicCallSite_signature, "(Ljava/lang/invoke/MethodHandle;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Object;Ljava/lang/invoke/MemberName;I)Ljava/lang/invoke/CallSite;") \
+  template(makeDynamicCallSite_TRANS_signature, "(Ljava/dyn/MethodHandle;Ljava/lang/String;Ljava/dyn/MethodType;Ljava/lang/Object;Lsun/dyn/MemberName;I)Ljava/dyn/CallSite;") /* AllowTransitionalJSR292 ONLY */ \
+  template(makeDynamicCallSite_TRANS2_signature, "(Ljava/dyn/MethodHandle;Ljava/lang/String;Ljava/dyn/MethodType;Ljava/lang/Object;Ljava/dyn/MemberName;I)Ljava/dyn/CallSite;") /* AllowTransitionalJSR292 ONLY */ \
   NOT_LP64(  do_alias(machine_word_signature,         int_signature)  )                           \
   LP64_ONLY( do_alias(machine_word_signature,         long_signature) )                           \
                                                                                                   \
@@ -882,13 +909,15 @@
                                                                                                                           \
   do_intrinsic(_invoke,                   java_lang_reflect_Method, invoke_name, object_object_array_object_signature, F_R) \
   /*   (symbols invoke_name and invoke_signature defined above) */                                                      \
-  do_intrinsic(_checkSpreadArgument,      sun_dyn_MethodHandleImpl, checkSpreadArgument_name, checkSpreadArgument_signature, F_S) \
+  do_intrinsic(_checkSpreadArgument,      java_lang_invoke_MethodHandleNatives, checkSpreadArgument_name, checkSpreadArgument_signature, F_S) \
+  do_intrinsic(_checkSpreadArgument_TRANS,sun_dyn_MethodHandleImpl, checkSpreadArgument_name, checkSpreadArgument_signature, F_S) /* AllowTransitionalJSR292 ONLY */ \
+  do_intrinsic(_checkSpreadArgument_TRANS2,java_dyn_MethodHandleNatives, checkSpreadArgument_name, checkSpreadArgument_signature, F_S) /* AllowTransitionalJSR292 ONLY */ \
    do_name(    checkSpreadArgument_name,       "checkSpreadArgument")                                                   \
    do_name(    checkSpreadArgument_signature,  "(Ljava/lang/Object;I)V")                                                \
-  do_intrinsic(_invokeExact,              java_dyn_MethodHandle, invokeExact_name,   object_array_object_signature, F_RN) \
-  do_intrinsic(_invokeGeneric,            java_dyn_MethodHandle, invokeGeneric_name, object_array_object_signature, F_RN) \
-  do_intrinsic(_invokeVarargs,            java_dyn_MethodHandle, invokeVarargs_name, object_array_object_signature, F_R)  \
-  do_intrinsic(_invokeDynamic,            java_dyn_InvokeDynamic, star_name,         object_array_object_signature, F_SN) \
+  do_intrinsic(_invokeExact,              java_lang_invoke_MethodHandle, invokeExact_name,   object_array_object_signature, F_RN) \
+  do_intrinsic(_invokeGeneric,            java_lang_invoke_MethodHandle, invokeGeneric_name, object_array_object_signature, F_RN) \
+  do_intrinsic(_invokeVarargs,            java_lang_invoke_MethodHandle, invokeVarargs_name, object_array_object_signature, F_R)  \
+  do_intrinsic(_invokeDynamic,            java_lang_invoke_InvokeDynamic, star_name,         object_array_object_signature, F_SN) \
                                                                                                                         \
   /* unboxing methods: */                                                                                               \
   do_intrinsic(_booleanValue,             java_lang_Boolean,      booleanValue_name, void_boolean_signature, F_R)       \
@@ -995,6 +1024,7 @@ class vmSymbols: AllStatic {
 
   // Returns symbol's SID if one is assigned, else NO_SID.
   static SID find_sid(Symbol* symbol);
+  static SID find_sid(const char* symbol_name);
 
 #ifndef PRODUCT
   // No need for this in the product:
diff --git a/hotspot/src/share/vm/code/codeCache.cpp b/hotspot/src/share/vm/code/codeCache.cpp
index db35aea6e19..ce3b4dc9559 100644
--- a/hotspot/src/share/vm/code/codeCache.cpp
+++ b/hotspot/src/share/vm/code/codeCache.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -337,7 +337,6 @@ void CodeCache::scavenge_root_nmethods_do(CodeBlobClosure* f) {
     if (is_live) {
       // Perform cur->oops_do(f), maybe just once per nmethod.
       f->do_code_blob(cur);
-      cur->fix_oop_relocations();
     }
   }
 
@@ -552,6 +551,19 @@ void CodeCache::gc_epilogue() {
 }
 
 
+void CodeCache::verify_oops() {
+  MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
+  VerifyOopClosure voc;
+  FOR_ALL_ALIVE_BLOBS(cb) {
+    if (cb->is_nmethod()) {
+      nmethod *nm = (nmethod*)cb;
+      nm->oops_do(&voc);
+      nm->verify_oop_relocations();
+    }
+  }
+}
+
+
 address CodeCache::first_address() {
   assert_locked_or_safepoint(CodeCache_lock);
   return (address)_heap->begin();
@@ -939,9 +951,16 @@ void CodeCache::print_bounds(outputStream* st) {
                _heap->high(),
                _heap->high_boundary());
   st->print_cr(" total_blobs=" UINT32_FORMAT " nmethods=" UINT32_FORMAT
-               " adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT
+               " adapters=" UINT32_FORMAT " free_code_cache=" SIZE_FORMAT "Kb"
                " largest_free_block=" SIZE_FORMAT,
-               CodeCache::nof_blobs(), CodeCache::nof_nmethods(),
-               CodeCache::nof_adapters(), CodeCache::unallocated_capacity(),
-               CodeCache::largest_free_block());
+               nof_blobs(), nof_nmethods(), nof_adapters(),
+               unallocated_capacity()/K, largest_free_block());
+}
+
+void CodeCache::log_state(outputStream* st) {
+  st->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
+            " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'"
+            " largest_free_block='" SIZE_FORMAT "'",
+            nof_blobs(), nof_nmethods(), nof_adapters(),
+            unallocated_capacity(), largest_free_block());
 }
diff --git a/hotspot/src/share/vm/code/codeCache.hpp b/hotspot/src/share/vm/code/codeCache.hpp
index df8de7f3f2d..42ea1b68940 100644
--- a/hotspot/src/share/vm/code/codeCache.hpp
+++ b/hotspot/src/share/vm/code/codeCache.hpp
@@ -122,6 +122,7 @@ class CodeCache : AllStatic {
   // GC support
   static void gc_epilogue();
   static void gc_prologue();
+  static void verify_oops();
   // If "unloading_occurred" is true, then unloads (i.e., breaks root links
   // to) any unmarked codeBlobs in the cache.  Sets "marked_for_unloading"
   // to "true" iff some code got unloaded.
@@ -147,6 +148,7 @@ class CodeCache : AllStatic {
   static void verify();                          // verifies the code cache
   static void print_trace(const char* event, CodeBlob* cb, int size = 0) PRODUCT_RETURN;
   static void print_bounds(outputStream* st);    // Prints a summary of the bounds of the code cache
+  static void log_state(outputStream* st);
 
   // The full limits of the codeCache
   static address  low_bound()                    { return (address) _heap->low_boundary(); }
@@ -159,7 +161,7 @@ class CodeCache : AllStatic {
   static size_t  max_capacity()                  { return _heap->max_capacity(); }
   static size_t  unallocated_capacity()          { return _heap->unallocated_capacity(); }
   static size_t  largest_free_block()            { return _heap->largest_free_block(); }
-  static bool    needs_flushing()                { return unallocated_capacity() < CodeCacheFlushingMinimumFreeSpace; }
+  static bool    needs_flushing()                { return largest_free_block() < CodeCacheFlushingMinimumFreeSpace; }
 
   static bool needs_cache_clean()                { return _needs_cache_clean; }
   static void set_needs_cache_clean(bool v)      { _needs_cache_clean = v;    }
diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp
index b75569b54a6..40a1360c98e 100644
--- a/hotspot/src/share/vm/code/nmethod.cpp
+++ b/hotspot/src/share/vm/code/nmethod.cpp
@@ -170,7 +170,7 @@ struct nmethod_stats_struct {
   int pc_desc_resets;   // number of resets (= number of caches)
   int pc_desc_queries;  // queries to nmethod::find_pc_desc
   int pc_desc_approx;   // number of those which have approximate true
-  int pc_desc_repeats;  // number of _last_pc_desc hits
+  int pc_desc_repeats;  // number of _pc_descs[0] hits
   int pc_desc_hits;     // number of LRU cache hits
   int pc_desc_tests;    // total number of PcDesc examinations
   int pc_desc_searches; // total number of quasi-binary search steps
@@ -278,40 +278,44 @@ static inline bool match_desc(PcDesc* pc, int pc_offset, bool approximate) {
 
 void PcDescCache::reset_to(PcDesc* initial_pc_desc) {
   if (initial_pc_desc == NULL) {
-    _last_pc_desc = NULL;  // native method
+    _pc_descs[0] = NULL; // native method; no PcDescs at all
     return;
   }
   NOT_PRODUCT(++nmethod_stats.pc_desc_resets);
   // reset the cache by filling it with benign (non-null) values
   assert(initial_pc_desc->pc_offset() < 0, "must be sentinel");
-  _last_pc_desc = initial_pc_desc + 1;  // first valid one is after sentinel
   for (int i = 0; i < cache_size; i++)
     _pc_descs[i] = initial_pc_desc;
 }
 
 PcDesc* PcDescCache::find_pc_desc(int pc_offset, bool approximate) {
   NOT_PRODUCT(++nmethod_stats.pc_desc_queries);
-  NOT_PRODUCT(if (approximate)  ++nmethod_stats.pc_desc_approx);
+  NOT_PRODUCT(if (approximate) ++nmethod_stats.pc_desc_approx);
+
+  // Note: one might think that caching the most recently
+  // read value separately would be a win, but one would be
+  // wrong.  When many threads are updating it, the cache
+  // line it's in would bounce between caches, negating
+  // any benefit.
 
   // In order to prevent race conditions do not load cache elements
   // repeatedly, but use a local copy:
   PcDesc* res;
 
-  // Step one:  Check the most recently returned value.
-  res = _last_pc_desc;
-  if (res == NULL)  return NULL;  // native method; no PcDescs at all
+  // Step one:  Check the most recently added value.
+  res = _pc_descs[0];
+  if (res == NULL) return NULL;  // native method; no PcDescs at all
   if (match_desc(res, pc_offset, approximate)) {
     NOT_PRODUCT(++nmethod_stats.pc_desc_repeats);
     return res;
   }
 
-  // Step two:  Check the LRU cache.
-  for (int i = 0; i < cache_size; i++) {
+  // Step two:  Check the rest of the LRU cache.
+  for (int i = 1; i < cache_size; ++i) {
     res = _pc_descs[i];
-    if (res->pc_offset() < 0)  break;  // optimization: skip empty cache
+    if (res->pc_offset() < 0) break;  // optimization: skip empty cache
     if (match_desc(res, pc_offset, approximate)) {
       NOT_PRODUCT(++nmethod_stats.pc_desc_hits);
-      _last_pc_desc = res;  // record this cache hit in case of repeat
       return res;
     }
   }
@@ -322,24 +326,23 @@ PcDesc* PcDescCache::find_pc_desc(int pc_offset, bool approximate) {
 
 void PcDescCache::add_pc_desc(PcDesc* pc_desc) {
   NOT_PRODUCT(++nmethod_stats.pc_desc_adds);
-  // Update the LRU cache by shifting pc_desc forward:
+  // Update the LRU cache by shifting pc_desc forward.
   for (int i = 0; i < cache_size; i++)  {
     PcDesc* next = _pc_descs[i];
     _pc_descs[i] = pc_desc;
     pc_desc = next;
   }
-  // Note:  Do not update _last_pc_desc.  It fronts for the LRU cache.
 }
 
 // adjust pcs_size so that it is a multiple of both oopSize and
 // sizeof(PcDesc) (assumes that if sizeof(PcDesc) is not a multiple
 // of oopSize, then 2*sizeof(PcDesc) is)
-static int  adjust_pcs_size(int pcs_size) {
+static int adjust_pcs_size(int pcs_size) {
   int nsize = round_to(pcs_size,   oopSize);
   if ((nsize % sizeof(PcDesc)) != 0) {
     nsize = pcs_size + sizeof(PcDesc);
   }
-  assert((nsize %  oopSize) == 0, "correct alignment");
+  assert((nsize % oopSize) == 0, "correct alignment");
   return nsize;
 }
 
@@ -650,6 +653,9 @@ nmethod::nmethod(
     _pc_desc_cache.reset_to(NULL);
 
     code_buffer->copy_oops_to(this);
+    if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
+      CodeCache::add_scavenge_root_nmethod(this);
+    }
     debug_only(verify_scavenge_root_oops());
     CodeCache::commit(this);
   }
@@ -762,7 +768,7 @@ nmethod::nmethod(
 
 void* nmethod::operator new(size_t size, int nmethod_size) {
   // Always leave some room in the CodeCache for I2C/C2I adapters
-  if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) return NULL;
+  if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) return NULL;
   return CodeCache::allocate(nmethod_size);
 }
 
@@ -1102,6 +1108,20 @@ void nmethod::fix_oop_relocations(address begin, address end, bool initialize_im
 }
 
 
+void nmethod::verify_oop_relocations() {
+  // Ensure sure that the code matches the current oop values
+  RelocIterator iter(this, NULL, NULL);
+  while (iter.next()) {
+    if (iter.type() == relocInfo::oop_type) {
+      oop_Relocation* reloc = iter.oop_reloc();
+      if (!reloc->oop_is_immediate()) {
+        reloc->verify_oop_relocation();
+      }
+    }
+  }
+}
+
+
 ScopeDesc* nmethod::scope_desc_at(address pc) {
   PcDesc* pd = pc_desc_at(pc);
   guarantee(pd != NULL, "scope must be present");
@@ -1180,14 +1200,17 @@ void nmethod::mark_as_seen_on_stack() {
   set_stack_traversal_mark(NMethodSweeper::traversal_count());
 }
 
-// Tell if a non-entrant method can be converted to a zombie (i.e., there is no activations on the stack)
+// Tell if a non-entrant method can be converted to a zombie (i.e.,
+// there are no activations on the stack, not in use by the VM,
+// and not in use by the ServiceThread)
 bool nmethod::can_not_entrant_be_converted() {
   assert(is_not_entrant(), "must be a non-entrant method");
 
   // Since the nmethod sweeper only does partial sweep the sweeper's traversal
   // count can be greater than the stack traversal count before it hits the
   // nmethod for the second time.
-  return stack_traversal_mark()+1 < NMethodSweeper::traversal_count();
+  return stack_traversal_mark()+1 < NMethodSweeper::traversal_count() &&
+         !is_locked_by_vm();
 }
 
 void nmethod::inc_decompile_count() {
@@ -1294,6 +1317,7 @@ void nmethod::log_state_change() const {
 // Common functionality for both make_not_entrant and make_zombie
 bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
   assert(state == zombie || state == not_entrant, "must be zombie or not_entrant");
+  assert(!is_zombie(), "should not already be a zombie");
 
   // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below.
   nmethodLocker nml(this);
@@ -1301,11 +1325,6 @@ bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
   No_Safepoint_Verifier nsv;
 
   {
-    // If the method is already zombie there is nothing to do
-    if (is_zombie()) {
-      return false;
-    }
-
     // invalidate osr nmethod before acquiring the patching lock since
     // they both acquire leaf locks and we don't want a deadlock.
     // This logic is equivalent to the logic below for patching the
@@ -1375,13 +1394,12 @@ bool nmethod::make_not_entrant_or_zombie(unsigned int state) {
       flush_dependencies(NULL);
     }
 
-    {
-      // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload event
-      // and it hasn't already been reported for this nmethod then report it now.
-      // (the event may have been reported earilier if the GC marked it for unloading).
-      Pause_No_Safepoint_Verifier pnsv(&nsv);
-      post_compiled_method_unload();
-    }
+    // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload
+    // event and it hasn't already been reported for this nmethod then
+    // report it now. The event may have been reported earilier if the GC
+    // marked it for unloading). JvmtiDeferredEventQueue support means
+    // we no longer go to a safepoint here.
+    post_compiled_method_unload();
 
 #ifdef ASSERT
     // It's no longer safe to access the oops section since zombie
@@ -1566,7 +1584,7 @@ void nmethod::post_compiled_method_unload() {
   if (_jmethod_id != NULL && JvmtiExport::should_post_compiled_method_unload()) {
     assert(!unload_reported(), "already unloaded");
     JvmtiDeferredEvent event =
-      JvmtiDeferredEvent::compiled_method_unload_event(
+      JvmtiDeferredEvent::compiled_method_unload_event(this,
           _jmethod_id, insts_begin());
     if (SafepointSynchronize::is_at_safepoint()) {
       // Don't want to take the queueing lock. Add it as pending and
@@ -1822,6 +1840,7 @@ void nmethod::oops_do_marking_epilogue() {
     assert(cur != NULL, "not NULL-terminated");
     nmethod* next = cur->_oops_do_mark_link;
     cur->_oops_do_mark_link = NULL;
+    cur->fix_oop_relocations();
     NOT_PRODUCT(if (TraceScavenge)  cur->print_on(tty, "oops_do, unmark\n"));
     cur = next;
   }
@@ -1881,7 +1900,7 @@ void nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map
 
 
 oop nmethod::embeddedOop_at(u_char* p) {
-  RelocIterator iter(this, p, p + oopSize);
+  RelocIterator iter(this, p, p + 1);
   while (iter.next())
     if (iter.type() == relocInfo::oop_type) {
       return iter.oop_reloc()->oop_value();
@@ -2171,10 +2190,12 @@ nmethodLocker::nmethodLocker(address pc) {
   lock_nmethod(_nm);
 }
 
-void nmethodLocker::lock_nmethod(nmethod* nm) {
+// Only JvmtiDeferredEvent::compiled_method_unload_event()
+// should pass zombie_ok == true.
+void nmethodLocker::lock_nmethod(nmethod* nm, bool zombie_ok) {
   if (nm == NULL)  return;
   Atomic::inc(&nm->_lock_count);
-  guarantee(!nm->is_zombie(), "cannot lock a zombie method");
+  guarantee(zombie_ok || !nm->is_zombie(), "cannot lock a zombie method");
 }
 
 void nmethodLocker::unlock_nmethod(nmethod* nm) {
diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp
index 7e7025611f6..6bf5672eb37 100644
--- a/hotspot/src/share/vm/code/nmethod.hpp
+++ b/hotspot/src/share/vm/code/nmethod.hpp
@@ -69,14 +69,13 @@ class PcDescCache VALUE_OBJ_CLASS_SPEC {
   friend class VMStructs;
  private:
   enum { cache_size = 4 };
-  PcDesc* _last_pc_desc;         // most recent pc_desc found
   PcDesc* _pc_descs[cache_size]; // last cache_size pc_descs found
  public:
-  PcDescCache() { debug_only(_last_pc_desc = NULL); }
+  PcDescCache() { debug_only(_pc_descs[0] = NULL); }
   void    reset_to(PcDesc* initial_pc_desc);
   PcDesc* find_pc_desc(int pc_offset, bool approximate);
   void    add_pc_desc(PcDesc* pc_desc);
-  PcDesc* last_pc_desc() { return _last_pc_desc; }
+  PcDesc* last_pc_desc() { return _pc_descs[0]; }
 };
 
 
@@ -178,7 +177,7 @@ class nmethod : public CodeBlob {
   unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
 
   // Protected by Patching_lock
-  unsigned char _state;                      // {alive, not_entrant, zombie, unloaded)
+  unsigned char _state;                      // {alive, not_entrant, zombie, unloaded}
 
 #ifdef ASSERT
   bool _oops_are_stale;  // indicates that it's no longer safe to access oops section
@@ -194,7 +193,10 @@ class nmethod : public CodeBlob {
 
   NOT_PRODUCT(bool _has_debug_info; )
 
-  // Nmethod Flushing lock (if non-zero, then the nmethod is not removed)
+  // Nmethod Flushing lock. If non-zero, then the nmethod is not removed
+  // and is not made into a zombie. However, once the nmethod is made into
+  // a zombie, it will be locked one final time if CompiledMethodUnload
+  // event processing needs to be done.
   jint  _lock_count;
 
   // not_entrant method removal. Each mark_sweep pass will update
@@ -457,6 +459,7 @@ private:
 public:
   void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); }
   void fix_oop_relocations()                           { fix_oop_relocations(NULL, NULL, false); }
+  void verify_oop_relocations();
 
   bool is_at_poll_return(address pc);
   bool is_at_poll_or_poll_return(address pc);
@@ -522,8 +525,9 @@ public:
   void flush();
 
  public:
-  // If returning true, it is unsafe to remove this nmethod even though it is a zombie
-  // nmethod, since the VM might have a reference to it. Should only be called from a  safepoint.
+  // When true is returned, it is unsafe to remove this nmethod even if
+  // it is a zombie, since the VM or the ServiceThread might still be
+  // using it.
   bool is_locked_by_vm() const                    { return _lock_count >0; }
 
   // See comment at definition of _last_seen_on_stack
@@ -689,13 +693,20 @@ public:
 
 };
 
-// Locks an nmethod so its code will not get removed, even if it is a zombie/not_entrant method
+// Locks an nmethod so its code will not get removed and it will not
+// be made into a zombie, even if it is a not_entrant method. After the
+// nmethod becomes a zombie, if CompiledMethodUnload event processing
+// needs to be done, then lock_nmethod() is used directly to keep the
+// generated code from being reused too early.
 class nmethodLocker : public StackObj {
   nmethod* _nm;
 
  public:
 
-  static void lock_nmethod(nmethod* nm);   // note: nm can be NULL
+  // note: nm can be NULL
+  // Only JvmtiDeferredEvent::compiled_method_unload_event()
+  // should pass zombie_ok == true.
+  static void lock_nmethod(nmethod* nm, bool zombie_ok = false);
   static void unlock_nmethod(nmethod* nm); // (ditto)
 
   nmethodLocker(address pc); // derive nm from pc
diff --git a/hotspot/src/share/vm/code/relocInfo.cpp b/hotspot/src/share/vm/code/relocInfo.cpp
index 55676b444de..0264f20607f 100644
--- a/hotspot/src/share/vm/code/relocInfo.cpp
+++ b/hotspot/src/share/vm/code/relocInfo.cpp
@@ -798,6 +798,14 @@ void oop_Relocation::fix_oop_relocation() {
 }
 
 
+void oop_Relocation::verify_oop_relocation() {
+  if (!oop_is_immediate()) {
+    // get the oop from the pool, and re-insert it into the instruction:
+    verify_value(value());
+  }
+}
+
+
 RelocIterator virtual_call_Relocation::parse_ic(nmethod* &nm, address &ic_call, address &first_oop,
                                                 oop* &oop_addr, bool *is_optimized) {
   assert(ic_call != NULL, "ic_call address must be set");
diff --git a/hotspot/src/share/vm/code/relocInfo.hpp b/hotspot/src/share/vm/code/relocInfo.hpp
index e5587b259ed..7dc11fee084 100644
--- a/hotspot/src/share/vm/code/relocInfo.hpp
+++ b/hotspot/src/share/vm/code/relocInfo.hpp
@@ -765,7 +765,8 @@ class Relocation VALUE_OBJ_CLASS_SPEC {
 
  protected:
   // platform-dependent utilities for decoding and patching instructions
-  void       pd_set_data_value       (address x, intptr_t off); // a set or mem-ref
+  void       pd_set_data_value       (address x, intptr_t off, bool verify_only = false); // a set or mem-ref
+  void       pd_verify_data_value    (address x, intptr_t off) { pd_set_data_value(x, off, true); }
   address    pd_call_destination     (address orig_addr = NULL);
   void       pd_set_call_destination (address x);
   void       pd_swap_in_breakpoint   (address x, short* instrs, int instrlen);
@@ -880,6 +881,12 @@ class DataRelocation : public Relocation {
     else
       pd_set_data_value(x, o);
   }
+  void        verify_value(address x) {
+    if (addr_in_const())
+      assert(*(address*)addr() == x, "must agree");
+    else
+      pd_verify_data_value(x, offset());
+  }
 
   // The "o" (displacement) argument is relevant only to split relocations
   // on RISC machines.  In some CPUs (SPARC), the set-hi and set-lo ins'ns
@@ -950,6 +957,8 @@ class oop_Relocation : public DataRelocation {
 
   void fix_oop_relocation();        // reasserts oop value
 
+  void verify_oop_relocation();
+
   address value()  { return (address) *oop_addr(); }
 
   bool oop_is_immediate()  { return oop_index() == 0; }
diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp
index d12385f2f20..0d90e11d289 100644
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp
@@ -1364,7 +1364,7 @@ void CompileBroker::compiler_thread_loop() {
       // We need this HandleMark to avoid leaking VM handles.
       HandleMark hm(thread);
 
-      if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) {
+      if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) {
         // the code cache is really full
         handle_full_code_cache();
       } else if (UseCodeCacheFlushing && CodeCache::needs_flushing()) {
@@ -1645,11 +1645,13 @@ void CompileBroker::handle_full_code_cache() {
   if (UseCompiler || AlwaysCompileLoopMethods ) {
     if (xtty != NULL) {
       xtty->begin_elem("code_cache_full");
+      CodeCache::log_state(xtty);
       xtty->stamp();
       xtty->end_elem();
     }
     warning("CodeCache is full. Compiler has been disabled.");
     warning("Try increasing the code cache size using -XX:ReservedCodeCacheSize=");
+    CodeCache::print_bounds(tty);
 #ifndef PRODUCT
     if (CompileTheWorld || ExitOnFullCodeCache) {
       before_exit(JavaThread::current());
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
index e3134fecca3..307a8500ca6 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -292,13 +292,15 @@ void ConcurrentMarkSweepGeneration::ref_processor_init() {
 void CMSCollector::ref_processor_init() {
   if (_ref_processor == NULL) {
     // Allocate and initialize a reference processor
-    _ref_processor = ReferenceProcessor::create_ref_processor(
-        _span,                               // span
-        _cmsGen->refs_discovery_is_atomic(), // atomic_discovery
-        _cmsGen->refs_discovery_is_mt(),     // mt_discovery
-        &_is_alive_closure,
-        ParallelGCThreads,
-        ParallelRefProcEnabled);
+    _ref_processor =
+      new ReferenceProcessor(_span,                               // span
+                             (ParallelGCThreads > 1) && ParallelRefProcEnabled, // mt processing
+                             (int) ParallelGCThreads,             // mt processing degree
+                             _cmsGen->refs_discovery_is_mt(),     // mt discovery
+                             (int) MAX2(ConcGCThreads, ParallelGCThreads), // mt discovery degree
+                             _cmsGen->refs_discovery_is_atomic(), // discovery is not atomic
+                             &_is_alive_closure,                  // closure for liveness info
+                             false);                              // next field updates do not need write barrier
     // Initialize the _ref_processor field of CMSGen
     _cmsGen->set_ref_processor(_ref_processor);
 
@@ -641,7 +643,7 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen,
   }
 
   // Support for multi-threaded concurrent phases
-  if (CollectedHeap::use_parallel_gc_threads() && CMSConcurrentMTEnabled) {
+  if (CMSConcurrentMTEnabled) {
     if (FLAG_IS_DEFAULT(ConcGCThreads)) {
       // just for now
       FLAG_SET_DEFAULT(ConcGCThreads, (ParallelGCThreads + 3)/4);
@@ -1689,6 +1691,8 @@ void CMSCollector::request_full_gc(unsigned int full_gc_count) {
     MutexLockerEx y(CGC_lock, Mutex::_no_safepoint_check_flag);
     _full_gc_requested = true;
     CGC_lock->notify();   // nudge CMS thread
+  } else {
+    assert(gc_count > full_gc_count, "Error: causal loop");
   }
 }
 
@@ -1988,17 +1992,16 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) {
   // Temporarily widen the span of the weak reference processing to
   // the entire heap.
   MemRegion new_span(GenCollectedHeap::heap()->reserved_region());
-  ReferenceProcessorSpanMutator x(ref_processor(), new_span);
-
+  ReferenceProcessorSpanMutator rp_mut_span(ref_processor(), new_span);
   // Temporarily, clear the "is_alive_non_header" field of the
   // reference processor.
-  ReferenceProcessorIsAliveMutator y(ref_processor(), NULL);
-
+  ReferenceProcessorIsAliveMutator rp_mut_closure(ref_processor(), NULL);
   // Temporarily make reference _processing_ single threaded (non-MT).
-  ReferenceProcessorMTProcMutator z(ref_processor(), false);
-
+  ReferenceProcessorMTProcMutator rp_mut_mt_processing(ref_processor(), false);
   // Temporarily make refs discovery atomic
-  ReferenceProcessorAtomicMutator w(ref_processor(), true);
+  ReferenceProcessorAtomicMutator rp_mut_atomic(ref_processor(), true);
+  // Temporarily make reference _discovery_ single threaded (non-MT)
+  ReferenceProcessorMTDiscoveryMutator rp_mut_discovery(ref_processor(), false);
 
   ref_processor()->set_enqueuing_is_done(false);
   ref_processor()->enable_discovery();
@@ -4263,9 +4266,7 @@ bool CMSCollector::do_marking_mt(bool asynch) {
 
   // Refs discovery is already non-atomic.
   assert(!ref_processor()->discovery_is_atomic(), "Should be non-atomic");
-  // Mutate the Refs discovery so it is MT during the
-  // multi-threaded marking phase.
-  ReferenceProcessorMTMutator mt(ref_processor(), num_workers > 1);
+  assert(ref_processor()->discovery_is_mt(), "Discovery should be MT");
   DEBUG_ONLY(RememberKlassesChecker cmx(should_unload_classes());)
   conc_workers()->start_task(&tsk);
   while (tsk.yielded()) {
@@ -4318,6 +4319,8 @@ bool CMSCollector::do_marking_st(bool asynch) {
   ResourceMark rm;
   HandleMark   hm;
 
+  // Temporarily make refs discovery single threaded (non-MT)
+  ReferenceProcessorMTDiscoveryMutator rp_mut_discovery(ref_processor(), false);
   MarkFromRootsClosure markFromRootsClosure(this, _span, &_markBitMap,
     &_markStack, &_revisitStack, CMSYield && asynch);
   // the last argument to iterate indicates whether the iteration
@@ -4356,10 +4359,6 @@ void CMSCollector::preclean() {
   verify_overflow_empty();
   _abort_preclean = false;
   if (CMSPrecleaningEnabled) {
-    // Precleaning is currently not MT but the reference processor
-    // may be set for MT.  Disable it temporarily here.
-    ReferenceProcessor* rp = ref_processor();
-    ReferenceProcessorMTProcMutator z(rp, false);
     _eden_chunk_index = 0;
     size_t used = get_eden_used();
     size_t capacity = get_eden_capacity();
@@ -4502,11 +4501,16 @@ size_t CMSCollector::preclean_work(bool clean_refs, bool clean_survivor) {
          _collectorState == AbortablePreclean, "incorrect state");
   ResourceMark rm;
   HandleMark   hm;
+
+  // Precleaning is currently not MT but the reference processor
+  // may be set for MT.  Disable it temporarily here.
+  ReferenceProcessor* rp = ref_processor();
+  ReferenceProcessorMTDiscoveryMutator rp_mut_discovery(rp, false);
+
   // Do one pass of scrubbing the discovered reference lists
   // to remove any reference objects with strongly-reachable
   // referents.
   if (clean_refs) {
-    ReferenceProcessor* rp = ref_processor();
     CMSPrecleanRefsYieldClosure yield_cl(this);
     assert(rp->span().equals(_span), "Spans should be equal");
     CMSKeepAliveClosure keep_alive(this, _span, &_markBitMap,
@@ -5576,8 +5580,10 @@ void CMSCollector::do_remark_parallel() {
   // in the multi-threaded case, but we special-case n=1 here to get
   // repeatable measurements of the 1-thread overhead of the parallel code.
   if (n_workers > 1) {
-    // Make refs discovery MT-safe
-    ReferenceProcessorMTMutator mt(ref_processor(), true);
+    // Make refs discovery MT-safe, if it isn't already: it may not
+    // necessarily be so, since it's possible that we are doing
+    // ST marking.
+    ReferenceProcessorMTDiscoveryMutator mt(ref_processor(), true);
     GenCollectedHeap::StrongRootsScope srs(gch);
     workers->run_task(&tsk);
   } else {
@@ -5703,14 +5709,19 @@ public:
                       CMSBitMap*       mark_bit_map,
                       AbstractWorkGang* workers,
                       OopTaskQueueSet* task_queues):
+    // XXX Should superclass AGTWOQ also know about AWG since it knows
+    // about the task_queues used by the AWG? Then it could initialize
+    // the terminator() object. See 6984287. The set_for_termination()
+    // below is a temporary band-aid for the regression in 6984287.
     AbstractGangTaskWOopQueues("Process referents by policy in parallel",
       task_queues),
     _task(task),
     _collector(collector), _span(span), _mark_bit_map(mark_bit_map)
-    {
-      assert(_collector->_span.equals(_span) && !_span.is_empty(),
-             "Inconsistency in _span");
-    }
+  {
+    assert(_collector->_span.equals(_span) && !_span.is_empty(),
+           "Inconsistency in _span");
+    set_for_termination(workers->active_workers());
+  }
 
   OopTaskQueueSet* task_queues() { return queues(); }
 
@@ -5872,8 +5883,7 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) {
       // That is OK as long as the Reference lists are balanced (see
       // balance_all_queues() and balance_queues()).
 
-
-      rp->set_mt_degree(ParallelGCThreads);
+      rp->set_active_mt_degree(ParallelGCThreads);
       CMSRefProcTaskExecutor task_executor(*this);
       rp->process_discovered_references(&_is_alive_closure,
                                         &cmsKeepAliveClosure,
@@ -5920,14 +5930,18 @@ void CMSCollector::refProcessingWork(bool asynch, bool clear_all_soft_refs) {
     }
 
     {
-      TraceTime t("scrub symbol & string tables", PrintGCDetails, false, gclog_or_tty);
-      // Now clean up stale oops in StringTable
-      StringTable::unlink(&_is_alive_closure);
+      TraceTime t("scrub symbol table", PrintGCDetails, false, gclog_or_tty);
       // Clean up unreferenced symbols in symbol table.
       SymbolTable::unlink();
     }
   }
 
+  if (should_unload_classes() || !JavaObjectsInPerm) {
+    TraceTime t("scrub string table", PrintGCDetails, false, gclog_or_tty);
+    // Now clean up stale oops in StringTable
+    StringTable::unlink(&_is_alive_closure);
+  }
+
   verify_work_stacks_empty();
   // Restore any preserved marks as a result of mark stack or
   // work queue overflow
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp
index a54f5eff702..1838fd73951 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1133,7 +1133,7 @@ class ConcurrentMarkSweepGeneration: public CardGeneration {
     // rare that the cost of the CAS's involved is in the
     // noise. That's a measurement that should be done, and
     // the code simplified if that turns out to be the case.
-    return false;
+    return ConcGCThreads > 1;
   }
 
   // Override
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp
index c69af2c14be..78ca0cb57b5 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@ int  ConcurrentMarkSweepThread::_CMS_flag         = CMS_nil;
 volatile jint ConcurrentMarkSweepThread::_pending_yields      = 0;
 volatile jint ConcurrentMarkSweepThread::_pending_decrements  = 0;
 
-volatile bool ConcurrentMarkSweepThread::_icms_enabled   = false;
+volatile jint ConcurrentMarkSweepThread::_icms_disabled   = 0;
 volatile bool ConcurrentMarkSweepThread::_should_run     = false;
 // When icms is enabled, the icms thread is stopped until explicitly
 // started.
@@ -84,7 +84,7 @@ ConcurrentMarkSweepThread::ConcurrentMarkSweepThread(CMSCollector* collector)
     }
   }
   _sltMonitor = SLT_lock;
-  set_icms_enabled(CMSIncrementalMode);
+  assert(!CMSIncrementalMode || icms_is_enabled(), "Error");
 }
 
 void ConcurrentMarkSweepThread::run() {
@@ -341,11 +341,11 @@ void ConcurrentMarkSweepThread::stop_icms() {
 
 void ConcurrentMarkSweepThread::icms_wait() {
   assert(UseConcMarkSweepGC && CMSIncrementalMode, "just checking");
-  if (_should_stop && icms_enabled()) {
+  if (_should_stop && icms_is_enabled()) {
     MutexLockerEx x(iCMS_lock, Mutex::_no_safepoint_check_flag);
     trace_state("pause_icms");
     _collector->stats().stop_cms_timer();
-    while(!_should_run && icms_enabled()) {
+    while(!_should_run && icms_is_enabled()) {
       iCMS_lock->wait(Mutex::_no_safepoint_check_flag);
     }
     _collector->stats().start_cms_timer();
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp
index f47901d361c..a299c32e267 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
 class ConcurrentMarkSweepGeneration;
 class CMSCollector;
 
-// The Concurrent Mark Sweep GC Thread (could be several in the future).
+// The Concurrent Mark Sweep GC Thread
 class ConcurrentMarkSweepThread: public ConcurrentGCThread {
   friend class VMStructs;
   friend class ConcurrentMarkSweepGeneration;   // XXX should remove friendship
@@ -55,8 +55,6 @@ class ConcurrentMarkSweepThread: public ConcurrentGCThread {
   static SurrogateLockerThread::SLT_msg_type _sltBuffer;
   static Monitor*                       _sltMonitor;
 
-  ConcurrentMarkSweepThread*            _next;
-
   static bool _should_terminate;
 
   enum CMS_flag_type {
@@ -84,7 +82,7 @@ class ConcurrentMarkSweepThread: public ConcurrentGCThread {
   // Tracing messages, enabled by CMSTraceThreadState.
   static inline void trace_state(const char* desc);
 
-  static volatile bool _icms_enabled;   // iCMS enabled?
+  static volatile int _icms_disabled;   // a counter to track #iCMS disable & enable
   static volatile bool _should_run;     // iCMS may run
   static volatile bool _should_stop;    // iCMS should stop
 
@@ -214,10 +212,25 @@ class ConcurrentMarkSweepThread: public ConcurrentGCThread {
 
   // Incremental mode is enabled globally by the flag CMSIncrementalMode.  It
   // must also be enabled/disabled dynamically to allow foreground collections.
-  static inline void enable_icms()              { _icms_enabled = true; }
-  static inline void disable_icms()             { _icms_enabled = false; }
-  static inline void set_icms_enabled(bool val) { _icms_enabled = val; }
-  static inline bool icms_enabled()             { return _icms_enabled; }
+#define ICMS_ENABLING_ASSERT                                                      \
+          assert((CMSIncrementalMode  && _icms_disabled >= 0) ||                  \
+                 (!CMSIncrementalMode && _icms_disabled <= 0), "Error")
+
+  static inline void enable_icms() {
+    ICMS_ENABLING_ASSERT;
+    Atomic::dec(&_icms_disabled);
+  }
+  static inline void disable_icms() {
+   ICMS_ENABLING_ASSERT;
+   Atomic::inc(&_icms_disabled);
+  }
+  static inline bool icms_is_disabled() {
+   ICMS_ENABLING_ASSERT;
+   return _icms_disabled > 0;
+  }
+  static inline bool icms_is_enabled() {
+   return !icms_is_disabled();
+  }
 };
 
 inline void ConcurrentMarkSweepThread::trace_state(const char* desc) {
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp
index 12c86b44d02..0ceec0bb98d 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -192,14 +192,18 @@ void VM_GenCollectFullConcurrent::doit() {
          "total_collections() should be monotonically increasing");
 
   MutexLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
+  assert(_full_gc_count_before <= gch->total_full_collections(), "Error");
   if (gch->total_full_collections() == _full_gc_count_before) {
-    // Disable iCMS until the full collection is done.
+    // Disable iCMS until the full collection is done, and
+    // remember that we did so.
     CMSCollector::disable_icms();
+    _disabled_icms = true;
     // In case CMS thread was in icms_wait(), wake it up.
     CMSCollector::start_icms();
     // Nudge the CMS thread to start a concurrent collection.
     CMSCollector::request_full_gc(_full_gc_count_before);
   } else {
+    assert(_full_gc_count_before < gch->total_full_collections(), "Error");
     FullGCCount_lock->notify_all();  // Inform the Java thread its work is done
   }
 }
@@ -259,6 +263,8 @@ void VM_GenCollectFullConcurrent::doit_epilogue() {
       FullGCCount_lock->wait(Mutex::_no_safepoint_check_flag);
     }
   }
-  // Enable iCMS back.
-  CMSCollector::enable_icms();
+  // Enable iCMS back if we disabled it earlier.
+  if (_disabled_icms) {
+    CMSCollector::enable_icms();
+  }
 }
diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp
index 51d6e208875..982f7c1036d 100644
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp
@@ -128,11 +128,14 @@ class VM_CMS_Final_Remark: public VM_CMS_Operation {
 // VM operation to invoke a concurrent collection of the heap as a
 // GenCollectedHeap heap.
 class VM_GenCollectFullConcurrent: public VM_GC_Operation {
+  bool _disabled_icms;
  public:
   VM_GenCollectFullConcurrent(unsigned int gc_count_before,
                               unsigned int full_gc_count_before,
                               GCCause::Cause gc_cause)
-    : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */) {
+    : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */),
+      _disabled_icms(false)
+  {
     assert(FullGCCount_lock != NULL, "Error");
     assert(UseAsyncConcMarkSweepGC, "Else will hang caller");
   }
diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp
index c0d968aa8f4..09279048e90 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.cpp
@@ -373,7 +373,7 @@ void ConcurrentG1Refine::clean_up_cache(int worker_i,
             // RSet updating while within an evacuation pause.
             // In this case worker_i should be the id of a GC worker thread
             assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
-            assert(worker_i < (int) DirtyCardQueueSet::num_par_ids(), "incorrect worker id");
+            assert(worker_i < (int) (ParallelGCThreads == 0 ? 1 : ParallelGCThreads), "incorrect worker id");
             into_cset_dcq->enqueue(entry);
           }
         }
diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
index 3f72bc84dc5..e453b91c35a 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
@@ -1828,7 +1828,7 @@ void ConcurrentMark::completeCleanup() {
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
 
   _cleanup_list.verify_optional();
-  FreeRegionList local_free_list("Local Cleanup List");
+  FreeRegionList tmp_free_list("Tmp Free List");
 
   if (G1ConcRegionFreeingVerbose) {
     gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
@@ -1842,7 +1842,7 @@ void ConcurrentMark::completeCleanup() {
     HeapRegion* hr = _cleanup_list.remove_head();
     assert(hr != NULL, "the list was not empty");
     hr->rem_set()->clear();
-    local_free_list.add_as_tail(hr);
+    tmp_free_list.add_as_tail(hr);
 
     // Instead of adding one region at a time to the secondary_free_list,
     // we accumulate them in the local list and move them a few at a
@@ -1850,20 +1850,20 @@ void ConcurrentMark::completeCleanup() {
     // we do during this process. We'll also append the local list when
     // _cleanup_list is empty (which means we just removed the last
     // region from the _cleanup_list).
-    if ((local_free_list.length() % G1SecondaryFreeListAppendLength == 0) ||
+    if ((tmp_free_list.length() % G1SecondaryFreeListAppendLength == 0) ||
         _cleanup_list.is_empty()) {
       if (G1ConcRegionFreeingVerbose) {
         gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
                                "appending "SIZE_FORMAT" entries to the "
                                "secondary_free_list, clean list still has "
                                SIZE_FORMAT" entries",
-                               local_free_list.length(),
+                               tmp_free_list.length(),
                                _cleanup_list.length());
       }
 
       {
         MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
-        g1h->secondary_free_list_add_as_tail(&local_free_list);
+        g1h->secondary_free_list_add_as_tail(&tmp_free_list);
         SecondaryFreeList_lock->notify_all();
       }
 
@@ -1874,7 +1874,7 @@ void ConcurrentMark::completeCleanup() {
       }
     }
   }
-  assert(local_free_list.is_empty(), "post-condition");
+  assert(tmp_free_list.is_empty(), "post-condition");
 }
 
 // Support closures for reference procssing in G1
@@ -2141,21 +2141,22 @@ void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) {
   G1CMKeepAliveClosure g1_keep_alive(g1h, this, nextMarkBitMap());
   G1CMDrainMarkingStackClosure
     g1_drain_mark_stack(nextMarkBitMap(), &_markStack, &g1_keep_alive);
-
   // We use the work gang from the G1CollectedHeap and we utilize all
   // the worker threads.
-  int active_workers = MAX2(MIN2(g1h->workers()->total_workers(), (int)_max_task_num), 1);
+  int active_workers = g1h->workers() ? g1h->workers()->total_workers() : 1;
+  active_workers = MAX2(MIN2(active_workers, (int)_max_task_num), 1);
 
   G1RefProcTaskExecutor par_task_executor(g1h, this, nextMarkBitMap(),
                                           g1h->workers(), active_workers);
 
+
   if (rp->processing_is_mt()) {
     // Set the degree of MT here.  If the discovery is done MT, there
     // may have been a different number of threads doing the discovery
     // and a different number of discovered lists may have Ref objects.
     // That is OK as long as the Reference lists are balanced (see
     // balance_all_queues() and balance_queues()).
-    rp->set_mt_degree(active_workers);
+    rp->set_active_mt_degree(active_workers);
 
     rp->process_discovered_references(&g1_is_alive,
                                       &g1_keep_alive,
@@ -3182,7 +3183,7 @@ public:
 
   template <class T> void do_oop_work(T* p) {
     assert( _g1h->is_in_g1_reserved((HeapWord*) p), "invariant");
-    assert(!_g1h->is_on_free_list(
+    assert(!_g1h->is_on_master_free_list(
                     _g1h->heap_region_containing((HeapWord*) p)), "invariant");
 
     oop obj = oopDesc::load_decode_heap_oop(p);
@@ -3403,7 +3404,7 @@ void CMTask::deal_with_reference(oop obj) {
 void CMTask::push(oop obj) {
   HeapWord* objAddr = (HeapWord*) obj;
   assert(_g1h->is_in_g1_reserved(objAddr), "invariant");
-  assert(!_g1h->is_on_free_list(
+  assert(!_g1h->is_on_master_free_list(
               _g1h->heap_region_containing((HeapWord*) objAddr)), "invariant");
   assert(!_g1h->is_obj_ill(obj), "invariant");
   assert(_nextMarkBitMap->isMarked(objAddr), "invariant");
@@ -3649,7 +3650,7 @@ void CMTask::drain_local_queue(bool partially) {
                                (void*) obj);
 
       assert(_g1h->is_in_g1_reserved((HeapWord*) obj), "invariant" );
-      assert(!_g1h->is_on_free_list(
+      assert(!_g1h->is_on_master_free_list(
                   _g1h->heap_region_containing((HeapWord*) obj)), "invariant");
 
       scan_object(obj);
diff --git a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp
index 5ff79ac6122..9fbf20fb10a 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp
@@ -237,9 +237,9 @@ void ConcurrentMarkThread::run() {
         // The following will finish freeing up any regions that we
         // found to be empty during cleanup. We'll do this part
         // without joining the suspendible set. If an evacuation pause
-        // takes places, then we would carry on freeing regions in
+        // takes place, then we would carry on freeing regions in
         // case they are needed by the pause. If a Full GC takes
-        // places, it would wait for us to process the regions
+        // place, it would wait for us to process the regions
         // reclaimed by cleanup.
 
         double cleanup_start_sec = os::elapsedTime();
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
index e34d7270e71..f82eec43b6c 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
@@ -479,7 +479,7 @@ G1CollectedHeap* G1CollectedHeap::_g1h;
 // Private methods.
 
 HeapRegion*
-G1CollectedHeap::new_region_try_secondary_free_list(size_t word_size) {
+G1CollectedHeap::new_region_try_secondary_free_list() {
   MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
   while (!_secondary_free_list.is_empty() || free_regions_coming()) {
     if (!_secondary_free_list.is_empty()) {
@@ -531,7 +531,7 @@ HeapRegion* G1CollectedHeap::new_region_work(size_t word_size,
         gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : "
                                "forced to look at the secondary_free_list");
       }
-      res = new_region_try_secondary_free_list(word_size);
+      res = new_region_try_secondary_free_list();
       if (res != NULL) {
         return res;
       }
@@ -543,7 +543,7 @@ HeapRegion* G1CollectedHeap::new_region_work(size_t word_size,
       gclog_or_tty->print_cr("G1ConcRegionFreeing [region alloc] : "
                              "res == NULL, trying the secondary_free_list");
     }
-    res = new_region_try_secondary_free_list(word_size);
+    res = new_region_try_secondary_free_list();
   }
   if (res == NULL && do_expand) {
     if (expand(word_size * HeapWordSize)) {
@@ -579,6 +579,9 @@ HeapRegion* G1CollectedHeap::new_gc_alloc_region(int purpose,
 
 int G1CollectedHeap::humongous_obj_allocate_find_first(size_t num_regions,
                                                        size_t word_size) {
+  assert(isHumongous(word_size), "word_size should be humongous");
+  assert(num_regions * HeapRegion::GrainWords >= word_size, "pre-condition");
+
   int first = -1;
   if (num_regions == 1) {
     // Only one region to allocate, no need to go through the slower
@@ -600,7 +603,7 @@ int G1CollectedHeap::humongous_obj_allocate_find_first(size_t num_regions,
     // request. If we are only allocating one region we use the common
     // region allocation code (see above).
     wait_while_free_regions_coming();
-    append_secondary_free_list_if_not_empty();
+    append_secondary_free_list_if_not_empty_with_lock();
 
     if (free_regions() >= num_regions) {
       first = _hrs->find_contiguous(num_regions);
@@ -608,7 +611,7 @@ int G1CollectedHeap::humongous_obj_allocate_find_first(size_t num_regions,
         for (int i = first; i < first + (int) num_regions; ++i) {
           HeapRegion* hr = _hrs->at(i);
           assert(hr->is_empty(), "sanity");
-          assert(is_on_free_list(hr), "sanity");
+          assert(is_on_master_free_list(hr), "sanity");
           hr->set_pending_removal(true);
         }
         _free_list.remove_all_pending(num_regions);
@@ -618,6 +621,126 @@ int G1CollectedHeap::humongous_obj_allocate_find_first(size_t num_regions,
   return first;
 }
 
+HeapWord*
+G1CollectedHeap::humongous_obj_allocate_initialize_regions(int first,
+                                                           size_t num_regions,
+                                                           size_t word_size) {
+  assert(first != -1, "pre-condition");
+  assert(isHumongous(word_size), "word_size should be humongous");
+  assert(num_regions * HeapRegion::GrainWords >= word_size, "pre-condition");
+
+  // Index of last region in the series + 1.
+  int last = first + (int) num_regions;
+
+  // We need to initialize the region(s) we just discovered. This is
+  // a bit tricky given that it can happen concurrently with
+  // refinement threads refining cards on these regions and
+  // potentially wanting to refine the BOT as they are scanning
+  // those cards (this can happen shortly after a cleanup; see CR
+  // 6991377). So we have to set up the region(s) carefully and in
+  // a specific order.
+
+  // The word size sum of all the regions we will allocate.
+  size_t word_size_sum = num_regions * HeapRegion::GrainWords;
+  assert(word_size <= word_size_sum, "sanity");
+
+  // This will be the "starts humongous" region.
+  HeapRegion* first_hr = _hrs->at(first);
+  // The header of the new object will be placed at the bottom of
+  // the first region.
+  HeapWord* new_obj = first_hr->bottom();
+  // This will be the new end of the first region in the series that
+  // should also match the end of the last region in the seriers.
+  HeapWord* new_end = new_obj + word_size_sum;
+  // This will be the new top of the first region that will reflect
+  // this allocation.
+  HeapWord* new_top = new_obj + word_size;
+
+  // First, we need to zero the header of the space that we will be
+  // allocating. When we update top further down, some refinement
+  // threads might try to scan the region. By zeroing the header we
+  // ensure that any thread that will try to scan the region will
+  // come across the zero klass word and bail out.
+  //
+  // NOTE: It would not have been correct to have used
+  // CollectedHeap::fill_with_object() and make the space look like
+  // an int array. The thread that is doing the allocation will
+  // later update the object header to a potentially different array
+  // type and, for a very short period of time, the klass and length
+  // fields will be inconsistent. This could cause a refinement
+  // thread to calculate the object size incorrectly.
+  Copy::fill_to_words(new_obj, oopDesc::header_size(), 0);
+
+  // We will set up the first region as "starts humongous". This
+  // will also update the BOT covering all the regions to reflect
+  // that there is a single object that starts at the bottom of the
+  // first region.
+  first_hr->set_startsHumongous(new_top, new_end);
+
+  // Then, if there are any, we will set up the "continues
+  // humongous" regions.
+  HeapRegion* hr = NULL;
+  for (int i = first + 1; i < last; ++i) {
+    hr = _hrs->at(i);
+    hr->set_continuesHumongous(first_hr);
+  }
+  // If we have "continues humongous" regions (hr != NULL), then the
+  // end of the last one should match new_end.
+  assert(hr == NULL || hr->end() == new_end, "sanity");
+
+  // Up to this point no concurrent thread would have been able to
+  // do any scanning on any region in this series. All the top
+  // fields still point to bottom, so the intersection between
+  // [bottom,top] and [card_start,card_end] will be empty. Before we
+  // update the top fields, we'll do a storestore to make sure that
+  // no thread sees the update to top before the zeroing of the
+  // object header and the BOT initialization.
+  OrderAccess::storestore();
+
+  // Now that the BOT and the object header have been initialized,
+  // we can update top of the "starts humongous" region.
+  assert(first_hr->bottom() < new_top && new_top <= first_hr->end(),
+         "new_top should be in this region");
+  first_hr->set_top(new_top);
+
+  // Now, we will update the top fields of the "continues humongous"
+  // regions. The reason we need to do this is that, otherwise,
+  // these regions would look empty and this will confuse parts of
+  // G1. For example, the code that looks for a consecutive number
+  // of empty regions will consider them empty and try to
+  // re-allocate them. We can extend is_empty() to also include
+  // !continuesHumongous(), but it is easier to just update the top
+  // fields here. The way we set top for all regions (i.e., top ==
+  // end for all regions but the last one, top == new_top for the
+  // last one) is actually used when we will free up the humongous
+  // region in free_humongous_region().
+  hr = NULL;
+  for (int i = first + 1; i < last; ++i) {
+    hr = _hrs->at(i);
+    if ((i + 1) == last) {
+      // last continues humongous region
+      assert(hr->bottom() < new_top && new_top <= hr->end(),
+             "new_top should fall on this region");
+      hr->set_top(new_top);
+    } else {
+      // not last one
+      assert(new_top > hr->end(), "new_top should be above this region");
+      hr->set_top(hr->end());
+    }
+  }
+  // If we have continues humongous regions (hr != NULL), then the
+  // end of the last one should match new_end and its top should
+  // match new_top.
+  assert(hr == NULL ||
+         (hr->end() == new_end && hr->top() == new_top), "sanity");
+
+  assert(first_hr->used() == word_size * HeapWordSize, "invariant");
+  _summary_bytes_used += first_hr->used();
+  _humongous_set.add(first_hr);
+
+  return new_obj;
+}
+
 // If could fit into free regions w/o expansion, try.
 // Otherwise, if can expand, do so.
 // Otherwise, if using ex regions might help, try with ex given back.
@@ -653,121 +776,16 @@ HeapWord* G1CollectedHeap::humongous_obj_allocate(size_t word_size) {
     }
   }
 
+  HeapWord* result = NULL;
   if (first != -1) {
-    // Index of last region in the series + 1.
-    int last = first + (int) num_regions;
-
-    // We need to initialize the region(s) we just discovered. This is
-    // a bit tricky given that it can happen concurrently with
-    // refinement threads refining cards on these regions and
-    // potentially wanting to refine the BOT as they are scanning
-    // those cards (this can happen shortly after a cleanup; see CR
-    // 6991377). So we have to set up the region(s) carefully and in
-    // a specific order.
-
-    // The word size sum of all the regions we will allocate.
-    size_t word_size_sum = num_regions * HeapRegion::GrainWords;
-    assert(word_size <= word_size_sum, "sanity");
-
-    // This will be the "starts humongous" region.
-    HeapRegion* first_hr = _hrs->at(first);
-    // The header of the new object will be placed at the bottom of
-    // the first region.
-    HeapWord* new_obj = first_hr->bottom();
-    // This will be the new end of the first region in the series that
-    // should also match the end of the last region in the seriers.
-    HeapWord* new_end = new_obj + word_size_sum;
-    // This will be the new top of the first region that will reflect
-    // this allocation.
-    HeapWord* new_top = new_obj + word_size;
-
-    // First, we need to zero the header of the space that we will be
-    // allocating. When we update top further down, some refinement
-    // threads might try to scan the region. By zeroing the header we
-    // ensure that any thread that will try to scan the region will
-    // come across the zero klass word and bail out.
-    //
-    // NOTE: It would not have been correct to have used
-    // CollectedHeap::fill_with_object() and make the space look like
-    // an int array. The thread that is doing the allocation will
-    // later update the object header to a potentially different array
-    // type and, for a very short period of time, the klass and length
-    // fields will be inconsistent. This could cause a refinement
-    // thread to calculate the object size incorrectly.
-    Copy::fill_to_words(new_obj, oopDesc::header_size(), 0);
-
-    // We will set up the first region as "starts humongous". This
-    // will also update the BOT covering all the regions to reflect
-    // that there is a single object that starts at the bottom of the
-    // first region.
-    first_hr->set_startsHumongous(new_top, new_end);
-
-    // Then, if there are any, we will set up the "continues
-    // humongous" regions.
-    HeapRegion* hr = NULL;
-    for (int i = first + 1; i < last; ++i) {
-      hr = _hrs->at(i);
-      hr->set_continuesHumongous(first_hr);
-    }
-    // If we have "continues humongous" regions (hr != NULL), then the
-    // end of the last one should match new_end.
-    assert(hr == NULL || hr->end() == new_end, "sanity");
-
-    // Up to this point no concurrent thread would have been able to
-    // do any scanning on any region in this series. All the top
-    // fields still point to bottom, so the intersection between
-    // [bottom,top] and [card_start,card_end] will be empty. Before we
-    // update the top fields, we'll do a storestore to make sure that
-    // no thread sees the update to top before the zeroing of the
-    // object header and the BOT initialization.
-    OrderAccess::storestore();
-
-    // Now that the BOT and the object header have been initialized,
-    // we can update top of the "starts humongous" region.
-    assert(first_hr->bottom() < new_top && new_top <= first_hr->end(),
-           "new_top should be in this region");
-    first_hr->set_top(new_top);
-
-    // Now, we will update the top fields of the "continues humongous"
-    // regions. The reason we need to do this is that, otherwise,
-    // these regions would look empty and this will confuse parts of
-    // G1. For example, the code that looks for a consecutive number
-    // of empty regions will consider them empty and try to
-    // re-allocate them. We can extend is_empty() to also include
-    // !continuesHumongous(), but it is easier to just update the top
-    // fields here. The way we set top for all regions (i.e., top ==
-    // end for all regions but the last one, top == new_top for the
-    // last one) is actually used when we will free up the humongous
-    // region in free_humongous_region().
-    hr = NULL;
-    for (int i = first + 1; i < last; ++i) {
-      hr = _hrs->at(i);
-      if ((i + 1) == last) {
-        // last continues humongous region
-        assert(hr->bottom() < new_top && new_top <= hr->end(),
-               "new_top should fall on this region");
-        hr->set_top(new_top);
-      } else {
-        // not last one
-        assert(new_top > hr->end(), "new_top should be above this region");
-        hr->set_top(hr->end());
-      }
-    }
-    // If we have continues humongous regions (hr != NULL), then the
-    // end of the last one should match new_end and its top should
-    // match new_top.
-    assert(hr == NULL ||
-           (hr->end() == new_end && hr->top() == new_top), "sanity");
-
-    assert(first_hr->used() == word_size * HeapWordSize, "invariant");
-    _summary_bytes_used += first_hr->used();
-    _humongous_set.add(first_hr);
-
-    return new_obj;
+    result =
+      humongous_obj_allocate_initialize_regions(first, num_regions, word_size);
+    assert(result != NULL, "it should always return a valid result");
   }
 
   verify_region_sets_optional();
-  return NULL;
+
+  return result;
 }
 
 void
@@ -1389,7 +1407,7 @@ bool G1CollectedHeap::do_collection(bool explicit_gc,
     g1_policy()->record_full_collection_start();
 
     wait_while_free_regions_coming();
-    append_secondary_free_list_if_not_empty();
+    append_secondary_free_list_if_not_empty_with_lock();
 
     gc_prologue(true);
     increment_total_collections(true /* full gc */);
@@ -1444,7 +1462,7 @@ bool G1CollectedHeap::do_collection(bool explicit_gc,
     // how reference processing currently works in G1.
 
     // Temporarily make reference _discovery_ single threaded (non-MT).
-    ReferenceProcessorMTMutator rp_disc_ser(ref_processor(), false);
+    ReferenceProcessorMTDiscoveryMutator rp_disc_ser(ref_processor(), false);
 
     // Temporarily make refs discovery atomic
     ReferenceProcessorAtomicMutator rp_disc_atomic(ref_processor(), true);
@@ -2201,16 +2219,16 @@ void G1CollectedHeap::ref_processing_init() {
 
   SharedHeap::ref_processing_init();
   MemRegion mr = reserved_region();
-  _ref_processor = ReferenceProcessor::create_ref_processor(
-                                         mr,    // span
-                                         false, // Reference discovery is not atomic
-                                         true,  // mt_discovery
-                                         &_is_alive_closure, // is alive closure
-                                                             // for efficiency
-                                         ParallelGCThreads,
-                                         ParallelRefProcEnabled,
-                                         true); // Setting next fields of discovered
-                                                // lists requires a barrier.
+  _ref_processor =
+    new ReferenceProcessor(mr,    // span
+                           ParallelRefProcEnabled && (ParallelGCThreads > 1),    // mt processing
+                           (int) ParallelGCThreads,   // degree of mt processing
+                           ParallelGCThreads > 1 || ConcGCThreads > 1,  // mt discovery
+                           (int) MAX2(ParallelGCThreads, ConcGCThreads), // degree of mt discovery
+                           false,                     // Reference discovery is not atomic
+                           &_is_alive_closure,        // is alive closure for efficiency
+                           true);                     // Setting next fields of discovered
+                                                      // lists requires a barrier.
 }
 
 size_t G1CollectedHeap::capacity() const {
@@ -3377,15 +3395,14 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
 
     TraceMemoryManagerStats tms(false /* fullGC */);
 
-    // If there are any free regions available on the secondary_free_list
-    // make sure we append them to the free_list. However, we don't
-    // have to wait for the rest of the cleanup operation to
-    // finish. If it's still going on that's OK. If we run out of
-    // regions, the region allocation code will check the
-    // secondary_free_list and potentially wait if more free regions
-    // are coming (see new_region_try_secondary_free_list()).
+    // If the secondary_free_list is not empty, append it to the
+    // free_list. No need to wait for the cleanup operation to finish;
+    // the region allocation code will check the secondary_free_list
+    // and wait if necessary. If the G1StressConcRegionFreeing flag is
+    // set, skip this step so that the region allocation code has to
+    // get entries from the secondary_free_list.
     if (!G1StressConcRegionFreeing) {
-      append_secondary_free_list_if_not_empty();
+      append_secondary_free_list_if_not_empty_with_lock();
     }
 
     increment_gc_time_stamp();
@@ -5199,7 +5216,7 @@ void G1CollectedHeap::free_collection_set(HeapRegion* cs_head) {
   size_t rs_lengths = 0;
 
   while (cur != NULL) {
-    assert(!is_on_free_list(cur), "sanity");
+    assert(!is_on_master_free_list(cur), "sanity");
 
     if (non_young) {
       if (cur->is_young()) {
@@ -5543,13 +5560,10 @@ void G1CollectedHeap::verify_region_sets() {
     return;
   }
 
-  {
-    MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
-    // Make sure we append the secondary_free_list on the free_list so
-    // that all free regions we will come across can be safely
-    // attributed to the free_list.
-    append_secondary_free_list();
-  }
+  // Make sure we append the secondary_free_list on the free_list so
+  // that all free regions we will come across can be safely
+  // attributed to the free_list.
+  append_secondary_free_list_if_not_empty_with_lock();
 
   // Finally, make sure that the region accounting in the lists is
   // consistent with what we see in the heap.
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
index 93b26c0eb1d..5863e7c9860 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp
@@ -56,7 +56,6 @@ class HeapRegionRemSetIterator;
 class ConcurrentMark;
 class ConcurrentMarkThread;
 class ConcurrentG1Refine;
-class ConcurrentZFThread;
 
 typedef OverflowTaskQueue<StarTask>         RefToScanQueue;
 typedef GenericTaskQueueSet<RefToScanQueue> RefToScanQueueSet;
@@ -64,12 +63,6 @@ typedef GenericTaskQueueSet<RefToScanQueue> RefToScanQueueSet;
 typedef int RegionIdx_t;   // needs to hold [ 0..max_regions() )
 typedef int CardIdx_t;     // needs to hold [ 0..CardsPerRegion )
 
-enum G1GCThreadGroups {
-  G1CRGroup = 0,
-  G1ZFGroup = 1,
-  G1CMGroup = 2
-};
-
 enum GCAllocPurpose {
   GCAllocForTenured,
   GCAllocForSurvived,
@@ -294,9 +287,9 @@ private:
   // These are macros so that, if the assert fires, we get the correct
   // line number, file, etc.
 
-#define heap_locking_asserts_err_msg(__extra_message)                         \
+#define heap_locking_asserts_err_msg(_extra_message_)                         \
   err_msg("%s : Heap_lock locked: %s, at safepoint: %s, is VM thread: %s",    \
-          (__extra_message),                                                  \
+          (_extra_message_),                                                  \
           BOOL_TO_STR(Heap_lock->owned_by_self()),                            \
           BOOL_TO_STR(SafepointSynchronize::is_at_safepoint()),               \
           BOOL_TO_STR(Thread::current()->is_VM_thread()))
@@ -307,11 +300,11 @@ private:
            heap_locking_asserts_err_msg("should be holding the Heap_lock"));  \
   } while (0)
 
-#define assert_heap_locked_or_at_safepoint(__should_be_vm_thread)             \
+#define assert_heap_locked_or_at_safepoint(_should_be_vm_thread_)             \
   do {                                                                        \
     assert(Heap_lock->owned_by_self() ||                                      \
            (SafepointSynchronize::is_at_safepoint() &&                        \
-             ((__should_be_vm_thread) == Thread::current()->is_VM_thread())), \
+             ((_should_be_vm_thread_) == Thread::current()->is_VM_thread())), \
            heap_locking_asserts_err_msg("should be holding the Heap_lock or " \
                                         "should be at a safepoint"));         \
   } while (0)
@@ -338,10 +331,10 @@ private:
                                    "should not be at a safepoint"));          \
   } while (0)
 
-#define assert_at_safepoint(__should_be_vm_thread)                            \
+#define assert_at_safepoint(_should_be_vm_thread_)                            \
   do {                                                                        \
     assert(SafepointSynchronize::is_at_safepoint() &&                         \
-              ((__should_be_vm_thread) == Thread::current()->is_VM_thread()), \
+              ((_should_be_vm_thread_) == Thread::current()->is_VM_thread()), \
            heap_locking_asserts_err_msg("should be at a safepoint"));         \
   } while (0)
 
@@ -371,35 +364,40 @@ protected:
   // will check whether there's anything available in the
   // secondary_free_list and/or wait for more regions to appear in that
   // list, if _free_regions_coming is set.
-  HeapRegion* new_region_try_secondary_free_list(size_t word_size);
+  HeapRegion* new_region_try_secondary_free_list();
 
-  // It will try to allocate a single non-humongous HeapRegion
-  // sufficient for an allocation of the given word_size.  If
-  // do_expand is true, it will attempt to expand the heap if
-  // necessary to satisfy the allocation request. Note that word_size
-  // is only used to make sure that we expand sufficiently but, given
-  // that the allocation request is assumed not to be humongous,
-  // having word_size is not strictly necessary (expanding by a single
-  // region will always be sufficient). But let's keep that parameter
-  // in case we need it in the future.
+  // Try to allocate a single non-humongous HeapRegion sufficient for
+  // an allocation of the given word_size. If do_expand is true,
+  // attempt to expand the heap if necessary to satisfy the allocation
+  // request.
   HeapRegion* new_region_work(size_t word_size, bool do_expand);
 
-  // It will try to allocate a new region to be used for allocation by
-  // mutator threads. It will not try to expand the heap if not region
-  // is available.
+  // Try to allocate a new region to be used for allocation by a
+  // mutator thread. Attempt to expand the heap if no region is
+  // available.
   HeapRegion* new_alloc_region(size_t word_size) {
     return new_region_work(word_size, false /* do_expand */);
   }
 
-  // It will try to allocate a new region to be used for allocation by
-  // a GC thread. It will try to expand the heap if no region is
-  // available.
+  // Try to allocate a new region to be used for allocation by a GC
+  // thread. Attempt to expand the heap if no region is available.
   HeapRegion* new_gc_alloc_region(int purpose, size_t word_size);
 
+  // Attempt to satisfy a humongous allocation request of the given
+  // size by finding a contiguous set of free regions of num_regions
+  // length and remove them from the master free list. Return the
+  // index of the first region or -1 if the search was unsuccessful.
   int humongous_obj_allocate_find_first(size_t num_regions, size_t word_size);
 
-  // Attempt to allocate an object of the given (very large) "word_size".
-  // Returns "NULL" on failure.
+  // Initialize a contiguous set of free regions of length num_regions
+  // and starting at index first so that they appear as a single
+  // humongous region.
+  HeapWord* humongous_obj_allocate_initialize_regions(int first,
+                                                      size_t num_regions,
+                                                      size_t word_size);
+
+  // Attempt to allocate a humongous object of the given size. Return
+  // NULL if unsuccessful.
   HeapWord* humongous_obj_allocate(size_t word_size);
 
   // The following two methods, allocate_new_tlab() and
@@ -776,7 +774,7 @@ protected:
   // Invoke "save_marks" on all heap regions.
   void save_marks();
 
-  // It frees a non-humongous region by initializing its contents and
+  // Frees a non-humongous region by initializing its contents and
   // adding it to the free list that's passed as a parameter (this is
   // usually a local list which will be appended to the master free
   // list later). The used bytes of freed regions are accumulated in
@@ -787,13 +785,13 @@ protected:
                    FreeRegionList* free_list,
                    bool par);
 
-  // It frees a humongous region by collapsing it into individual
-  // regions and calling free_region() for each of them. The freed
-  // regions will be added to the free list that's passed as a parameter
-  // (this is usually a local list which will be appended to the
-  // master free list later). The used bytes of freed regions are
-  // accumulated in pre_used. If par is true, the region's RSet will
-  // not be freed up. The assumption is that this will be done later.
+  // Frees a humongous region by collapsing it into individual regions
+  // and calling free_region() for each of them. The freed regions
+  // will be added to the free list that's passed as a parameter (this
+  // is usually a local list which will be appended to the master free
+  // list later). The used bytes of freed regions are accumulated in
+  // pre_used. If par is true, the region's RSet will not be freed
+  // up. The assumption is that this will be done later.
   void free_humongous_region(HeapRegion* hr,
                              size_t* pre_used,
                              FreeRegionList* free_list,
@@ -1046,13 +1044,13 @@ public:
 #endif // HEAP_REGION_SET_FORCE_VERIFY
 
 #ifdef ASSERT
-  bool is_on_free_list(HeapRegion* hr) {
+  bool is_on_master_free_list(HeapRegion* hr) {
     return hr->containing_set() == &_free_list;
   }
 
-  bool is_on_humongous_set(HeapRegion* hr) {
+  bool is_in_humongous_set(HeapRegion* hr) {
     return hr->containing_set() == &_humongous_set;
-}
+  }
 #endif // ASSERT
 
   // Wrapper for the region list operations that can be called from
@@ -1066,7 +1064,9 @@ public:
     _free_list.add_as_tail(&_secondary_free_list);
   }
 
-  void append_secondary_free_list_if_not_empty() {
+  void append_secondary_free_list_if_not_empty_with_lock() {
+    // If the secondary free list looks empty there's no reason to
+    // take the lock and then try to append it.
     if (!_secondary_free_list.is_empty()) {
       MutexLockerEx x(SecondaryFreeList_lock, Mutex::_no_safepoint_check_flag);
       append_secondary_free_list();
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
index ff3c55acc4b..18f11076996 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp
@@ -81,6 +81,57 @@ static double non_young_other_cost_per_region_ms_defaults[] = {
 
 // </NEW PREDICTION>
 
+// Help class for avoiding interleaved logging
+class LineBuffer: public StackObj {
+
+private:
+  static const int BUFFER_LEN = 1024;
+  static const int INDENT_CHARS = 3;
+  char _buffer[BUFFER_LEN];
+  int _indent_level;
+  int _cur;
+
+  void vappend(const char* format, va_list ap) {
+    int res = vsnprintf(&_buffer[_cur], BUFFER_LEN - _cur, format, ap);
+    if (res != -1) {
+      _cur += res;
+    } else {
+      DEBUG_ONLY(warning("buffer too small in LineBuffer");)
+      _buffer[BUFFER_LEN -1] = 0;
+      _cur = BUFFER_LEN; // vsnprintf above should not add to _buffer if we are called again
+    }
+  }
+
+public:
+  explicit LineBuffer(int indent_level): _indent_level(indent_level), _cur(0) {
+    for (; (_cur < BUFFER_LEN && _cur < (_indent_level * INDENT_CHARS)); _cur++) {
+      _buffer[_cur] = ' ';
+    }
+  }
+
+#ifndef PRODUCT
+  ~LineBuffer() {
+    assert(_cur == _indent_level * INDENT_CHARS, "pending data in buffer - append_and_print_cr() not called?");
+  }
+#endif
+
+  void append(const char* format, ...) {
+    va_list ap;
+    va_start(ap, format);
+    vappend(format, ap);
+    va_end(ap);
+  }
+
+  void append_and_print_cr(const char* format, ...) {
+    va_list ap;
+    va_start(ap, format);
+    vappend(format, ap);
+    va_end(ap);
+    gclog_or_tty->print_cr("%s", _buffer);
+    _cur = _indent_level * INDENT_CHARS;
+  }
+};
+
 G1CollectorPolicy::G1CollectorPolicy() :
   _parallel_gc_threads(G1CollectedHeap::use_parallel_gc_threads()
     ? ParallelGCThreads : 1),
@@ -1016,10 +1067,8 @@ void G1CollectorPolicy::print_par_stats(int level,
                                          bool summary) {
   double min = data[0], max = data[0];
   double total = 0.0;
-  int j;
-  for (j = 0; j < level; ++j)
-    gclog_or_tty->print("   ");
-  gclog_or_tty->print("[%s (ms):", str);
+  LineBuffer buf(level);
+  buf.append("[%s (ms):", str);
   for (uint i = 0; i < ParallelGCThreads; ++i) {
     double val = data[i];
     if (val < min)
@@ -1027,18 +1076,16 @@ void G1CollectorPolicy::print_par_stats(int level,
     if (val > max)
       max = val;
     total += val;
-    gclog_or_tty->print("  %3.1lf", val);
+    buf.append("  %3.1lf", val);
   }
   if (summary) {
-    gclog_or_tty->print_cr("");
+    buf.append_and_print_cr("");
     double avg = total / (double) ParallelGCThreads;
-    gclog_or_tty->print(" ");
-    for (j = 0; j < level; ++j)
-      gclog_or_tty->print("   ");
-    gclog_or_tty->print("Avg: %5.1lf, Min: %5.1lf, Max: %5.1lf",
+    buf.append(" ");
+    buf.append("Avg: %5.1lf, Min: %5.1lf, Max: %5.1lf",
                         avg, min, max);
   }
-  gclog_or_tty->print_cr("]");
+  buf.append_and_print_cr("]");
 }
 
 void G1CollectorPolicy::print_par_sizes(int level,
@@ -1047,10 +1094,8 @@ void G1CollectorPolicy::print_par_sizes(int level,
                                         bool summary) {
   double min = data[0], max = data[0];
   double total = 0.0;
-  int j;
-  for (j = 0; j < level; ++j)
-    gclog_or_tty->print("   ");
-  gclog_or_tty->print("[%s :", str);
+  LineBuffer buf(level);
+  buf.append("[%s :", str);
   for (uint i = 0; i < ParallelGCThreads; ++i) {
     double val = data[i];
     if (val < min)
@@ -1058,34 +1103,28 @@ void G1CollectorPolicy::print_par_sizes(int level,
     if (val > max)
       max = val;
     total += val;
-    gclog_or_tty->print(" %d", (int) val);
+    buf.append(" %d", (int) val);
   }
   if (summary) {
-    gclog_or_tty->print_cr("");
+    buf.append_and_print_cr("");
     double avg = total / (double) ParallelGCThreads;
-    gclog_or_tty->print(" ");
-    for (j = 0; j < level; ++j)
-      gclog_or_tty->print("   ");
-    gclog_or_tty->print("Sum: %d, Avg: %d, Min: %d, Max: %d",
+    buf.append(" ");
+    buf.append("Sum: %d, Avg: %d, Min: %d, Max: %d",
                (int)total, (int)avg, (int)min, (int)max);
   }
-  gclog_or_tty->print_cr("]");
+  buf.append_and_print_cr("]");
 }
 
 void G1CollectorPolicy::print_stats (int level,
                                      const char* str,
                                      double value) {
-  for (int j = 0; j < level; ++j)
-    gclog_or_tty->print("   ");
-  gclog_or_tty->print_cr("[%s: %5.1lf ms]", str, value);
+  LineBuffer(level).append_and_print_cr("[%s: %5.1lf ms]", str, value);
 }
 
 void G1CollectorPolicy::print_stats (int level,
                                      const char* str,
                                      int value) {
-  for (int j = 0; j < level; ++j)
-    gclog_or_tty->print("   ");
-  gclog_or_tty->print_cr("[%s: %d]", str, value);
+  LineBuffer(level).append_and_print_cr("[%s: %d]", str, value);
 }
 
 double G1CollectorPolicy::avg_value (double* data) {
@@ -2060,17 +2099,11 @@ void G1CollectorPolicy::count_CS_bytes_used() {
   _g1->collection_set_iterate(&cs_closure);
 }
 
-static void print_indent(int level) {
-  for (int j = 0; j < level+1; ++j)
-    gclog_or_tty->print("   ");
-}
-
 void G1CollectorPolicy::print_summary (int level,
                                        const char* str,
                                        NumberSeq* seq) const {
   double sum = seq->sum();
-  print_indent(level);
-  gclog_or_tty->print_cr("%-24s = %8.2lf s (avg = %8.2lf ms)",
+  LineBuffer(level + 1).append_and_print_cr("%-24s = %8.2lf s (avg = %8.2lf ms)",
                 str, sum / 1000.0, seq->avg());
 }
 
@@ -2078,8 +2111,7 @@ void G1CollectorPolicy::print_summary_sd (int level,
                                           const char* str,
                                           NumberSeq* seq) const {
   print_summary(level, str, seq);
-  print_indent(level + 5);
-  gclog_or_tty->print_cr("(num = %5d, std dev = %8.2lf ms, max = %8.2lf ms)",
+  LineBuffer(level + 6).append_and_print_cr("(num = %5d, std dev = %8.2lf ms, max = %8.2lf ms)",
                 seq->num(), seq->sd(), seq->maximum());
 }
 
@@ -2087,6 +2119,7 @@ void G1CollectorPolicy::check_other_times(int level,
                                         NumberSeq* other_times_ms,
                                         NumberSeq* calc_other_times_ms) const {
   bool should_print = false;
+  LineBuffer buf(level + 2);
 
   double max_sum = MAX2(fabs(other_times_ms->sum()),
                         fabs(calc_other_times_ms->sum()));
@@ -2095,8 +2128,7 @@ void G1CollectorPolicy::check_other_times(int level,
   double sum_ratio = max_sum / min_sum;
   if (sum_ratio > 1.1) {
     should_print = true;
-    print_indent(level + 1);
-    gclog_or_tty->print_cr("## CALCULATED OTHER SUM DOESN'T MATCH RECORDED ###");
+    buf.append_and_print_cr("## CALCULATED OTHER SUM DOESN'T MATCH RECORDED ###");
   }
 
   double max_avg = MAX2(fabs(other_times_ms->avg()),
@@ -2106,30 +2138,25 @@ void G1CollectorPolicy::check_other_times(int level,
   double avg_ratio = max_avg / min_avg;
   if (avg_ratio > 1.1) {
     should_print = true;
-    print_indent(level + 1);
-    gclog_or_tty->print_cr("## CALCULATED OTHER AVG DOESN'T MATCH RECORDED ###");
+    buf.append_and_print_cr("## CALCULATED OTHER AVG DOESN'T MATCH RECORDED ###");
   }
 
   if (other_times_ms->sum() < -0.01) {
-    print_indent(level + 1);
-    gclog_or_tty->print_cr("## RECORDED OTHER SUM IS NEGATIVE ###");
+    buf.append_and_print_cr("## RECORDED OTHER SUM IS NEGATIVE ###");
   }
 
   if (other_times_ms->avg() < -0.01) {
-    print_indent(level + 1);
-    gclog_or_tty->print_cr("## RECORDED OTHER AVG IS NEGATIVE ###");
+    buf.append_and_print_cr("## RECORDED OTHER AVG IS NEGATIVE ###");
   }
 
   if (calc_other_times_ms->sum() < -0.01) {
     should_print = true;
-    print_indent(level + 1);
-    gclog_or_tty->print_cr("## CALCULATED OTHER SUM IS NEGATIVE ###");
+    buf.append_and_print_cr("## CALCULATED OTHER SUM IS NEGATIVE ###");
   }
 
   if (calc_other_times_ms->avg() < -0.01) {
     should_print = true;
-    print_indent(level + 1);
-    gclog_or_tty->print_cr("## CALCULATED OTHER AVG IS NEGATIVE ###");
+    buf.append_and_print_cr("## CALCULATED OTHER AVG IS NEGATIVE ###");
   }
 
   if (should_print)
@@ -2210,10 +2237,9 @@ void G1CollectorPolicy::print_summary(PauseSummary* summary) const {
       }
     }
   } else {
-    print_indent(0);
-    gclog_or_tty->print_cr("none");
+    LineBuffer(1).append_and_print_cr("none");
   }
-  gclog_or_tty->print_cr("");
+  LineBuffer(0).append_and_print_cr("");
 }
 
 void G1CollectorPolicy::print_tracing_info() const {
@@ -2532,7 +2558,7 @@ public:
     jint regions_added = parKnownGarbageCl.marked_regions_added();
     _hrSorted->incNumMarkedHeapRegions(regions_added);
     if (G1PrintParCleanupStats) {
-      gclog_or_tty->print("     Thread %d called %d times, added %d regions to list.\n",
+      gclog_or_tty->print_cr("     Thread %d called %d times, added %d regions to list.",
                  i, parKnownGarbageCl.invokes(), regions_added);
     }
   }
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp
index 68d5d84f2d4..4c93507a3ad 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp
@@ -185,22 +185,22 @@ class G1PrepareCompactClosure: public HeapRegionClosure {
   G1CollectedHeap* _g1h;
   ModRefBarrierSet* _mrbs;
   CompactPoint _cp;
-  size_t _pre_used;
-  FreeRegionList _free_list;
   HumongousRegionSet _humongous_proxy_set;
 
   void free_humongous_region(HeapRegion* hr) {
     HeapWord* end = hr->end();
+    size_t dummy_pre_used;
+    FreeRegionList dummy_free_list("Dummy Free List for G1MarkSweep");
+
     assert(hr->startsHumongous(),
            "Only the start of a humongous region should be freed.");
-    _g1h->free_humongous_region(hr, &_pre_used, &_free_list,
+    _g1h->free_humongous_region(hr, &dummy_pre_used, &dummy_free_list,
                                 &_humongous_proxy_set, false /* par */);
-    // Do we also need to do this for the continues humongous regions
-    // we just collapsed?
     hr->prepare_for_compaction(&_cp);
     // Also clear the part of the card table that will be unused after
     // compaction.
     _mrbs->clear(MemRegion(hr->compaction_top(), end));
+    dummy_free_list.remove_all();
   }
 
 public:
@@ -208,8 +208,6 @@ public:
   : _g1h(G1CollectedHeap::heap()),
     _mrbs(G1CollectedHeap::heap()->mr_bs()),
     _cp(NULL, cs, cs->initialize_threshold()),
-    _pre_used(0),
-    _free_list("Local Free List for G1MarkSweep"),
     _humongous_proxy_set("G1MarkSweep Humongous Proxy Set") { }
 
   void update_sets() {
@@ -219,7 +217,6 @@ public:
                                             NULL, /* free_list */
                                             &_humongous_proxy_set,
                                             false /* par */);
-    _free_list.remove_all();
   }
 
   bool doHeapRegion(HeapRegion* hr) {
diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp
index 48d3dbd100c..7d8c604f287 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1RemSet.cpp
@@ -86,28 +86,6 @@ public:
   bool idempotent() { return true; }
 };
 
-class IntoCSRegionClosure: public HeapRegionClosure {
-  IntoCSOopClosure _blk;
-  G1CollectedHeap* _g1;
-public:
-  IntoCSRegionClosure(G1CollectedHeap* g1, OopsInHeapRegionClosure* blk) :
-    _g1(g1), _blk(g1, blk) {}
-  bool doHeapRegion(HeapRegion* r) {
-    if (!r->in_collection_set()) {
-      _blk.set_region(r);
-      if (r->isHumongous()) {
-        if (r->startsHumongous()) {
-          oop obj = oop(r->bottom());
-          obj->oop_iterate(&_blk);
-        }
-      } else {
-        r->oop_before_save_marks_iterate(&_blk);
-      }
-    }
-    return false;
-  }
-};
-
 class VerifyRSCleanCardOopClosure: public OopClosure {
   G1CollectedHeap* _g1;
 public:
@@ -329,7 +307,7 @@ public:
     // is during RSet updating within an evacuation pause.
     // In this case worker_i should be the id of a GC worker thread.
     assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause");
-    assert(worker_i < (int) DirtyCardQueueSet::num_par_ids(), "should be a GC worker");
+    assert(worker_i < (int) (ParallelGCThreads == 0 ? 1 : ParallelGCThreads), "should be a GC worker");
 
     if (_g1rs->concurrentRefineOneCard(card_ptr, worker_i, true)) {
       // 'card_ptr' contains references that point into the collection
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp
index e764ad4349c..2d7385ef9b7 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegion.hpp
@@ -53,8 +53,8 @@ class HeapRegion;
 class HeapRegionSetBase;
 
 #define HR_FORMAT "%d:["PTR_FORMAT","PTR_FORMAT","PTR_FORMAT"]"
-#define HR_FORMAT_PARAMS(__hr) (__hr)->hrs_index(), (__hr)->bottom(), \
-                               (__hr)->top(), (__hr)->end()
+#define HR_FORMAT_PARAMS(_hr_) (_hr_)->hrs_index(), (_hr_)->bottom(), \
+                               (_hr_)->top(), (_hr_)->end()
 
 // A dirty card to oop closure for heap regions. It
 // knows how to get the G1 heap and how to use the bitmap
@@ -518,13 +518,13 @@ class HeapRegion: public G1OffsetTableContigSpace {
                    containing_set, _containing_set));
 
     _containing_set = containing_set;
-}
+  }
 
   HeapRegionSetBase* containing_set() { return _containing_set; }
 #else // ASSERT
   void set_containing_set(HeapRegionSetBase* containing_set) { }
 
-  // containing_set() is only used in asserts so there's not reason
+  // containing_set() is only used in asserts so there's no reason
   // to provide a dummy version of it.
 #endif // ASSERT
 
@@ -535,14 +535,15 @@ class HeapRegion: public G1OffsetTableContigSpace {
   bool pending_removal() { return _pending_removal; }
 
   void set_pending_removal(bool pending_removal) {
-    // We can only set pending_removal to true, if it's false and the
-    // region belongs to a set.
-    assert(!pending_removal ||
-           (!_pending_removal && containing_set() != NULL), "pre-condition");
-    // We can only set pending_removal to false, if it's true and the
-    // region does not belong to a set.
-    assert( pending_removal ||
-           ( _pending_removal && containing_set() == NULL), "pre-condition");
+    if (pending_removal) {
+      assert(!_pending_removal && containing_set() != NULL,
+             "can only set pending removal to true if it's false and "
+             "the region belongs to a region set");
+    } else {
+      assert( _pending_removal && containing_set() == NULL,
+              "can only set pending removal to false if it's true and "
+              "the region does not belong to a region set");
+    }
 
     _pending_removal = pending_removal;
   }
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp
index 2e15190c526..764c9ebb0ad 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.cpp
@@ -165,7 +165,7 @@ int HeapRegionSeq::find_contiguous_from(int from, size_t num) {
 
   assert(num_so_far <= num, "post-condition");
   if (num_so_far == num) {
-    // we find enough space for the humongous object
+    // we found enough space for the humongous object
     assert(from <= first && first < _regions.length(), "post-condition");
     assert(first < curr && (curr - first) == (int) num, "post-condition");
     for (int i = first; i < first + (int) num; ++i) {
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp
index 932b0cb9572..167cd65931e 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSeq.hpp
@@ -76,7 +76,8 @@ class HeapRegionSeq: public CHeapObj {
   // that are available for allocation.
   size_t free_suffix();
 
-  // Finds a contiguous set of empty regions of length num.
+  // Find a contiguous set of empty regions of length num and return
+  // the index of the first region or -1 if the search was unsuccessful.
   int find_contiguous(size_t num);
 
   // Apply the "doHeapRegion" method of "blk" to all regions in "this",
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp
index 29fff5d8cf3..be80cd2201a 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.cpp
@@ -42,7 +42,7 @@ size_t HeapRegionSetBase::calculate_region_num(HeapRegion* hr) {
   return region_num;
 }
 
-void HeapRegionSetBase::fill_in_ext_msg(hrl_ext_msg* msg, const char* message) {
+void HeapRegionSetBase::fill_in_ext_msg(hrs_ext_msg* msg, const char* message) {
   msg->append("[%s] %s "
               "ln: "SIZE_FORMAT" rn: "SIZE_FORMAT" "
               "cy: "SIZE_FORMAT" ud: "SIZE_FORMAT,
@@ -109,30 +109,30 @@ void HeapRegionSetBase::verify() {
   // for the verification calls. If we do verification without the
   // appropriate locks and the set changes underneath our feet
   // verification might fail and send us on a wild goose chase.
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
 
   guarantee(( is_empty() && length() == 0 && region_num() == 0 &&
               total_used_bytes() == 0 && total_capacity_bytes() == 0) ||
             (!is_empty() && length() >= 0 && region_num() >= 0 &&
               total_used_bytes() >= 0 && total_capacity_bytes() >= 0),
-            hrl_ext_msg(this, "invariant"));
+            hrs_ext_msg(this, "invariant"));
 
   guarantee((!regions_humongous() && region_num() == length()) ||
             ( regions_humongous() && region_num() >= length()),
-            hrl_ext_msg(this, "invariant"));
+            hrs_ext_msg(this, "invariant"));
 
   guarantee(!regions_empty() || total_used_bytes() == 0,
-            hrl_ext_msg(this, "invariant"));
+            hrs_ext_msg(this, "invariant"));
 
   guarantee(total_used_bytes() <= total_capacity_bytes(),
-            hrl_ext_msg(this, "invariant"));
+            hrs_ext_msg(this, "invariant"));
 }
 
 void HeapRegionSetBase::verify_start() {
   // See comment in verify() about MT safety and verification.
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
   assert(!_verify_in_progress,
-         hrl_ext_msg(this, "verification should not be in progress"));
+         hrs_ext_msg(this, "verification should not be in progress"));
 
   // Do the basic verification first before we do the checks over the regions.
   HeapRegionSetBase::verify();
@@ -146,11 +146,11 @@ void HeapRegionSetBase::verify_start() {
 
 void HeapRegionSetBase::verify_next_region(HeapRegion* hr) {
   // See comment in verify() about MT safety and verification.
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
   assert(_verify_in_progress,
-         hrl_ext_msg(this, "verification should be in progress"));
+         hrs_ext_msg(this, "verification should be in progress"));
 
-  guarantee(verify_region(hr, this), hrl_ext_msg(this, "region verification"));
+  guarantee(verify_region(hr, this), hrs_ext_msg(this, "region verification"));
 
   _calc_length               += 1;
   if (!hr->isHumongous()) {
@@ -164,28 +164,28 @@ void HeapRegionSetBase::verify_next_region(HeapRegion* hr) {
 
 void HeapRegionSetBase::verify_end() {
   // See comment in verify() about MT safety and verification.
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
   assert(_verify_in_progress,
-         hrl_ext_msg(this, "verification should be in progress"));
+         hrs_ext_msg(this, "verification should be in progress"));
 
   guarantee(length() == _calc_length,
-            hrl_err_msg("[%s] length: "SIZE_FORMAT" should be == "
+            hrs_err_msg("[%s] length: "SIZE_FORMAT" should be == "
                         "calc length: "SIZE_FORMAT,
                         name(), length(), _calc_length));
 
   guarantee(region_num() == _calc_region_num,
-            hrl_err_msg("[%s] region num: "SIZE_FORMAT" should be == "
+            hrs_err_msg("[%s] region num: "SIZE_FORMAT" should be == "
                         "calc region num: "SIZE_FORMAT,
                         name(), region_num(), _calc_region_num));
 
   guarantee(total_capacity_bytes() == _calc_total_capacity_bytes,
-            hrl_err_msg("[%s] capacity bytes: "SIZE_FORMAT" should be == "
+            hrs_err_msg("[%s] capacity bytes: "SIZE_FORMAT" should be == "
                         "calc capacity bytes: "SIZE_FORMAT,
                         name(),
                         total_capacity_bytes(), _calc_total_capacity_bytes));
 
   guarantee(total_used_bytes() == _calc_total_used_bytes,
-            hrl_err_msg("[%s] used bytes: "SIZE_FORMAT" should be == "
+            hrs_err_msg("[%s] used bytes: "SIZE_FORMAT" should be == "
                         "calc used bytes: "SIZE_FORMAT,
                         name(), total_used_bytes(), _calc_total_used_bytes));
 
@@ -221,9 +221,9 @@ HeapRegionSetBase::HeapRegionSetBase(const char* name)
 //////////////////// HeapRegionSet ////////////////////
 
 void HeapRegionSet::update_from_proxy(HeapRegionSet* proxy_set) {
-  hrl_assert_mt_safety_ok(this);
-  hrl_assert_mt_safety_ok(proxy_set);
-  hrl_assert_sets_match(this, proxy_set);
+  hrs_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(proxy_set);
+  hrs_assert_sets_match(this, proxy_set);
 
   verify_optional();
   proxy_set->verify_optional();
@@ -231,19 +231,19 @@ void HeapRegionSet::update_from_proxy(HeapRegionSet* proxy_set) {
   if (proxy_set->is_empty()) return;
 
   assert(proxy_set->length() <= _length,
-         hrl_err_msg("[%s] proxy set length: "SIZE_FORMAT" "
+         hrs_err_msg("[%s] proxy set length: "SIZE_FORMAT" "
                      "should be <= length: "SIZE_FORMAT,
                      name(), proxy_set->length(), _length));
   _length -= proxy_set->length();
 
   assert(proxy_set->region_num() <= _region_num,
-         hrl_err_msg("[%s] proxy set region num: "SIZE_FORMAT" "
+         hrs_err_msg("[%s] proxy set region num: "SIZE_FORMAT" "
                      "should be <= region num: "SIZE_FORMAT,
                      name(), proxy_set->region_num(), _region_num));
   _region_num -= proxy_set->region_num();
 
   assert(proxy_set->total_used_bytes() <= _total_used_bytes,
-         hrl_err_msg("[%s] proxy set used bytes: "SIZE_FORMAT" "
+         hrs_err_msg("[%s] proxy set used bytes: "SIZE_FORMAT" "
                      "should be <= used bytes: "SIZE_FORMAT,
                      name(), proxy_set->total_used_bytes(),
                      _total_used_bytes));
@@ -257,13 +257,13 @@ void HeapRegionSet::update_from_proxy(HeapRegionSet* proxy_set) {
 
 //////////////////// HeapRegionLinkedList ////////////////////
 
-void HeapRegionLinkedList::fill_in_ext_msg_extra(hrl_ext_msg* msg) {
+void HeapRegionLinkedList::fill_in_ext_msg_extra(hrs_ext_msg* msg) {
   msg->append(" hd: "PTR_FORMAT" tl: "PTR_FORMAT, head(), tail());
 }
 
 void HeapRegionLinkedList::add_as_tail(HeapRegionLinkedList* from_list) {
-  hrl_assert_mt_safety_ok(this);
-  hrl_assert_mt_safety_ok(from_list);
+  hrs_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(from_list);
 
   verify_optional();
   from_list->verify_optional();
@@ -283,10 +283,10 @@ void HeapRegionLinkedList::add_as_tail(HeapRegionLinkedList* from_list) {
 #endif // ASSERT
 
   if (_tail != NULL) {
-    assert(length() >  0 && _head != NULL, hrl_ext_msg(this, "invariant"));
+    assert(length() >  0 && _head != NULL, hrs_ext_msg(this, "invariant"));
     _tail->set_next(from_list->_head);
   } else {
-    assert(length() == 0 && _head == NULL, hrl_ext_msg(this, "invariant"));
+    assert(length() == 0 && _head == NULL, hrs_ext_msg(this, "invariant"));
     _head = from_list->_head;
   }
   _tail = from_list->_tail;
@@ -301,12 +301,12 @@ void HeapRegionLinkedList::add_as_tail(HeapRegionLinkedList* from_list) {
 }
 
 void HeapRegionLinkedList::remove_all() {
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
   verify_optional();
 
   HeapRegion* curr = _head;
   while (curr != NULL) {
-    hrl_assert_region_ok(this, curr, this);
+    hrs_assert_region_ok(this, curr, this);
 
     HeapRegion* next = curr->next();
     curr->set_next(NULL);
@@ -319,9 +319,9 @@ void HeapRegionLinkedList::remove_all() {
 }
 
 void HeapRegionLinkedList::remove_all_pending(size_t target_count) {
-  hrl_assert_mt_safety_ok(this);
-  assert(target_count > 1, hrl_ext_msg(this, "pre-condition"));
-  assert(!is_empty(), hrl_ext_msg(this, "pre-condition"));
+  hrs_assert_mt_safety_ok(this);
+  assert(target_count > 1, hrs_ext_msg(this, "pre-condition"));
+  assert(!is_empty(), hrs_ext_msg(this, "pre-condition"));
 
   verify_optional();
   DEBUG_ONLY(size_t old_length = length();)
@@ -330,27 +330,27 @@ void HeapRegionLinkedList::remove_all_pending(size_t target_count) {
   HeapRegion* prev = NULL;
   size_t count = 0;
   while (curr != NULL) {
-    hrl_assert_region_ok(this, curr, this);
+    hrs_assert_region_ok(this, curr, this);
     HeapRegion* next = curr->next();
 
     if (curr->pending_removal()) {
       assert(count < target_count,
-             hrl_err_msg("[%s] should not come across more regions "
+             hrs_err_msg("[%s] should not come across more regions "
                          "pending for removal than target_count: "SIZE_FORMAT,
                          name(), target_count));
 
       if (prev == NULL) {
-        assert(_head == curr, hrl_ext_msg(this, "invariant"));
+        assert(_head == curr, hrs_ext_msg(this, "invariant"));
         _head = next;
       } else {
-        assert(_head != curr, hrl_ext_msg(this, "invariant"));
+        assert(_head != curr, hrs_ext_msg(this, "invariant"));
         prev->set_next(next);
       }
       if (next == NULL) {
-        assert(_tail == curr, hrl_ext_msg(this, "invariant"));
+        assert(_tail == curr, hrs_ext_msg(this, "invariant"));
         _tail = prev;
       } else {
-        assert(_tail != curr, hrl_ext_msg(this, "invariant"));
+        assert(_tail != curr, hrs_ext_msg(this, "invariant"));
       }
 
       curr->set_next(NULL);
@@ -371,10 +371,10 @@ void HeapRegionLinkedList::remove_all_pending(size_t target_count) {
   }
 
   assert(count == target_count,
-         hrl_err_msg("[%s] count: "SIZE_FORMAT" should be == "
+         hrs_err_msg("[%s] count: "SIZE_FORMAT" should be == "
                      "target_count: "SIZE_FORMAT, name(), count, target_count));
   assert(length() + target_count == old_length,
-         hrl_err_msg("[%s] new length should be consistent "
+         hrs_err_msg("[%s] new length should be consistent "
                      "new length: "SIZE_FORMAT" old length: "SIZE_FORMAT" "
                      "target_count: "SIZE_FORMAT,
                      name(), length(), old_length, target_count));
@@ -385,7 +385,7 @@ void HeapRegionLinkedList::remove_all_pending(size_t target_count) {
 void HeapRegionLinkedList::verify() {
   // See comment in HeapRegionSetBase::verify() about MT safety and
   // verification.
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
 
   // This will also do the basic verification too.
   verify_start();
@@ -399,7 +399,7 @@ void HeapRegionLinkedList::verify() {
 
     count += 1;
     guarantee(count < _unrealistically_long_length,
-              hrl_err_msg("[%s] the calculated length: "SIZE_FORMAT" "
+              hrs_err_msg("[%s] the calculated length: "SIZE_FORMAT" "
                           "seems very long, is there maybe a cycle? "
                           "curr: "PTR_FORMAT" prev0: "PTR_FORMAT" "
                           "prev1: "PTR_FORMAT" length: "SIZE_FORMAT,
@@ -410,7 +410,7 @@ void HeapRegionLinkedList::verify() {
     curr  = curr->next();
   }
 
-  guarantee(_tail == prev0, hrl_ext_msg(this, "post-condition"));
+  guarantee(_tail == prev0, hrs_ext_msg(this, "post-condition"));
 
   verify_end();
 }
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.hpp
index a973676ae78..5d53068ca88 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.hpp
@@ -28,8 +28,8 @@
 #include "gc_implementation/g1/heapRegion.hpp"
 
 // Large buffer for some cases where the output might be larger than normal.
-#define HRL_ERR_MSG_BUFSZ 512
-typedef FormatBuffer<HRL_ERR_MSG_BUFSZ> hrl_err_msg;
+#define HRS_ERR_MSG_BUFSZ 512
+typedef FormatBuffer<HRS_ERR_MSG_BUFSZ> hrs_err_msg;
 
 // Set verification will be forced either if someone defines
 // HEAP_REGION_SET_FORCE_VERIFY to be 1, or in builds in which
@@ -45,10 +45,10 @@ typedef FormatBuffer<HRL_ERR_MSG_BUFSZ> hrl_err_msg;
 // (e.g., length, region num, used bytes sum) plus any shared
 // functionality (e.g., verification).
 
-class hrl_ext_msg;
+class hrs_ext_msg;
 
 class HeapRegionSetBase VALUE_OBJ_CLASS_SPEC {
-  friend class hrl_ext_msg;
+  friend class hrs_ext_msg;
 
 protected:
   static size_t calculate_region_num(HeapRegion* hr);
@@ -104,10 +104,10 @@ protected:
   virtual bool check_mt_safety() { return true; }
 
   // fill_in_ext_msg() writes the the values of the set's attributes
-  // in the custom err_msg (hrl_ext_msg). fill_in_ext_msg_extra()
+  // in the custom err_msg (hrs_ext_msg). fill_in_ext_msg_extra()
   // allows subclasses to append further information.
-  virtual void fill_in_ext_msg_extra(hrl_ext_msg* msg) { }
-  void fill_in_ext_msg(hrl_ext_msg* msg, const char* message);
+  virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg) { }
+  void fill_in_ext_msg(hrs_ext_msg* msg, const char* message);
 
   // It updates the fields of the set to reflect hr being added to
   // the set.
@@ -170,9 +170,9 @@ public:
 // the fields of the associated set. This can be very helpful in
 // diagnosing failures.
 
-class hrl_ext_msg : public hrl_err_msg {
+class hrs_ext_msg : public hrs_err_msg {
 public:
-  hrl_ext_msg(HeapRegionSetBase* set, const char* message) : hrl_err_msg("") {
+  hrs_ext_msg(HeapRegionSetBase* set, const char* message) : hrs_err_msg("") {
     set->fill_in_ext_msg(this, message);
   }
 };
@@ -180,25 +180,25 @@ public:
 // These two macros are provided for convenience, to keep the uses of
 // these two asserts a bit more concise.
 
-#define hrl_assert_mt_safety_ok(_set_)                                        \
+#define hrs_assert_mt_safety_ok(_set_)                                        \
   do {                                                                        \
-    assert((_set_)->check_mt_safety(), hrl_ext_msg((_set_), "MT safety"));    \
+    assert((_set_)->check_mt_safety(), hrs_ext_msg((_set_), "MT safety"));    \
   } while (0)
 
-#define hrl_assert_region_ok(_set_, _hr_, _expected_)                         \
+#define hrs_assert_region_ok(_set_, _hr_, _expected_)                         \
   do {                                                                        \
     assert((_set_)->verify_region((_hr_), (_expected_)),                      \
-           hrl_ext_msg((_set_), "region verification"));                      \
+           hrs_ext_msg((_set_), "region verification"));                      \
   } while (0)
 
 //////////////////// HeapRegionSet ////////////////////
 
-#define hrl_assert_sets_match(_set1_, _set2_)                                 \
+#define hrs_assert_sets_match(_set1_, _set2_)                                 \
   do {                                                                        \
     assert(((_set1_)->regions_humongous() ==                                  \
                                             (_set2_)->regions_humongous()) && \
            ((_set1_)->regions_empty() == (_set2_)->regions_empty()),          \
-           hrl_err_msg("the contents of set %s and set %s should match",      \
+           hrs_err_msg("the contents of set %s and set %s should match",      \
                        (_set1_)->name(), (_set2_)->name()));                  \
   } while (0)
 
@@ -267,7 +267,7 @@ private:
   HeapRegion* tail() { return _tail; }
 
 protected:
-  virtual void fill_in_ext_msg_extra(hrl_ext_msg* msg);
+  virtual void fill_in_ext_msg_extra(hrs_ext_msg* msg);
 
   // See the comment for HeapRegionSetBase::clear()
   virtual void clear();
@@ -309,10 +309,10 @@ public:
   virtual void print_on(outputStream* out, bool print_contents = false);
 };
 
-//////////////////// HeapRegionLinkedList ////////////////////
+//////////////////// HeapRegionLinkedListIterator ////////////////////
 
-// Iterator class that provides a convenient way to iterator over the
-// regions in a HeapRegionLinkedList instance.
+// Iterator class that provides a convenient way to iterate over the
+// regions of a HeapRegionLinkedList instance.
 
 class HeapRegionLinkedListIterator : public StackObj {
 private:
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp
index 44f7335f48f..501f5a7aef8 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp
@@ -42,8 +42,8 @@ inline void HeapRegionSetBase::update_for_addition(HeapRegion* hr) {
 }
 
 inline void HeapRegionSetBase::add_internal(HeapRegion* hr) {
-  hrl_assert_region_ok(this, hr, NULL);
-  assert(hr->next() == NULL, hrl_ext_msg(this, "should not already be linked"));
+  hrs_assert_region_ok(this, hr, NULL);
+  assert(hr->next() == NULL, hrs_ext_msg(this, "should not already be linked"));
 
   update_for_addition(hr);
   hr->set_containing_set(this);
@@ -51,7 +51,7 @@ inline void HeapRegionSetBase::add_internal(HeapRegion* hr) {
 
 inline void HeapRegionSetBase::update_for_removal(HeapRegion* hr) {
   // Assumes the caller has already verified the region.
-  assert(_length > 0, hrl_ext_msg(this, "pre-condition"));
+  assert(_length > 0, hrs_ext_msg(this, "pre-condition"));
   _length -= 1;
 
   size_t region_num_diff;
@@ -61,22 +61,22 @@ inline void HeapRegionSetBase::update_for_removal(HeapRegion* hr) {
     region_num_diff = calculate_region_num(hr);
   }
   assert(region_num_diff <= _region_num,
-         hrl_err_msg("[%s] region's region num: "SIZE_FORMAT" "
+         hrs_err_msg("[%s] region's region num: "SIZE_FORMAT" "
                      "should be <= region num: "SIZE_FORMAT,
                      name(), region_num_diff, _region_num));
   _region_num -= region_num_diff;
 
   size_t used_bytes = hr->used();
   assert(used_bytes <= _total_used_bytes,
-         hrl_err_msg("[%s] region's used bytes: "SIZE_FORMAT" "
+         hrs_err_msg("[%s] region's used bytes: "SIZE_FORMAT" "
                      "should be <= used bytes: "SIZE_FORMAT,
                      name(), used_bytes, _total_used_bytes));
   _total_used_bytes -= used_bytes;
 }
 
 inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) {
-  hrl_assert_region_ok(this, hr, this);
-  assert(hr->next() == NULL, hrl_ext_msg(this, "should already be unlinked"));
+  hrs_assert_region_ok(this, hr, this);
+  assert(hr->next() == NULL, hrs_ext_msg(this, "should already be unlinked"));
 
   hr->set_containing_set(NULL);
   update_for_removal(hr);
@@ -85,13 +85,13 @@ inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) {
 //////////////////// HeapRegionSet ////////////////////
 
 inline void HeapRegionSet::add(HeapRegion* hr) {
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
   // add_internal() will verify the region.
   add_internal(hr);
 }
 
 inline void HeapRegionSet::remove(HeapRegion* hr) {
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
   // remove_internal() will verify the region.
   remove_internal(hr);
 }
@@ -101,8 +101,8 @@ inline void HeapRegionSet::remove_with_proxy(HeapRegion* hr,
   // No need to fo the MT safety check here given that this method
   // does not update the contents of the set but instead accumulates
   // the changes in proxy_set which is assumed to be thread-local.
-  hrl_assert_sets_match(this, proxy_set);
-  hrl_assert_region_ok(this, hr, this);
+  hrs_assert_sets_match(this, proxy_set);
+  hrs_assert_region_ok(this, hr, this);
 
   hr->set_containing_set(NULL);
   proxy_set->update_for_addition(hr);
@@ -111,10 +111,10 @@ inline void HeapRegionSet::remove_with_proxy(HeapRegion* hr,
 //////////////////// HeapRegionLinkedList ////////////////////
 
 inline void HeapRegionLinkedList::add_as_tail(HeapRegion* hr) {
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
   assert((length() == 0 && _head == NULL && _tail == NULL) ||
          (length() >  0 && _head != NULL && _tail != NULL),
-         hrl_ext_msg(this, "invariant"));
+         hrs_ext_msg(this, "invariant"));
   // add_internal() will verify the region.
   add_internal(hr);
 
@@ -128,10 +128,10 @@ inline void HeapRegionLinkedList::add_as_tail(HeapRegion* hr) {
 }
 
 inline HeapRegion* HeapRegionLinkedList::remove_head() {
-  hrl_assert_mt_safety_ok(this);
-  assert(!is_empty(), hrl_ext_msg(this, "the list should not be empty"));
+  hrs_assert_mt_safety_ok(this);
+  assert(!is_empty(), hrs_ext_msg(this, "the list should not be empty"));
   assert(length() > 0 && _head != NULL && _tail != NULL,
-         hrl_ext_msg(this, "invariant"));
+         hrs_ext_msg(this, "invariant"));
 
   // We need to unlink it first.
   HeapRegion* hr = _head;
@@ -147,7 +147,7 @@ inline HeapRegion* HeapRegionLinkedList::remove_head() {
 }
 
 inline HeapRegion* HeapRegionLinkedList::remove_head_or_null() {
-  hrl_assert_mt_safety_ok(this);
+  hrs_assert_mt_safety_ok(this);
 
   if (!is_empty()) {
     return remove_head();
diff --git a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSets.cpp b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSets.cpp
index c5f58cb87af..24f25eae325 100644
--- a/hotspot/src/share/vm/gc_implementation/g1/heapRegionSets.cpp
+++ b/hotspot/src/share/vm/gc_implementation/g1/heapRegionSets.cpp
@@ -52,7 +52,7 @@ bool MasterFreeRegionList::check_mt_safety() {
                                             FreeList_lock->owned_by_self())) ||
             (!SafepointSynchronize::is_at_safepoint() &&
                                                 Heap_lock->owned_by_self()),
-            hrl_ext_msg(this, "master free list MT safety protocol"));
+            hrs_ext_msg(this, "master free list MT safety protocol"));
 
   return FreeRegionList::check_mt_safety();
 }
@@ -65,7 +65,7 @@ bool SecondaryFreeRegionList::check_mt_safety() {
   // while holding the SecondaryFreeList_lock.
 
   guarantee(SecondaryFreeList_lock->owned_by_self(),
-            hrl_ext_msg(this, "secondary free list MT safety protocol"));
+            hrs_ext_msg(this, "secondary free list MT safety protocol"));
 
   return FreeRegionList::check_mt_safety();
 }
@@ -81,7 +81,7 @@ const char* HumongousRegionSet::verify_region_extra(HeapRegion* hr) {
   return HeapRegionSet::verify_region_extra(hr);
 }
 
-//////////////////// HumongousRegionSet ////////////////////
+//////////////////// MasterHumongousRegionSet ////////////////////
 
 bool MasterHumongousRegionSet::check_mt_safety() {
   // Master Humongous Set MT safety protocol:
@@ -97,6 +97,6 @@ bool MasterHumongousRegionSet::check_mt_safety() {
                                              OldSets_lock->owned_by_self())) ||
             (!SafepointSynchronize::is_at_safepoint() &&
                                                  Heap_lock->owned_by_self()),
-            hrl_ext_msg(this, "master humongous set MT safety protocol"));
+            hrs_ext_msg(this, "master humongous set MT safety protocol"));
   return HumongousRegionSet::check_mt_safety();
 }
diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp
index d8d1ae9b4bf..578a4e0a8dc 100644
--- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp
+++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1530,13 +1530,15 @@ void ParNewGeneration::ref_processor_init()
 {
   if (_ref_processor == NULL) {
     // Allocate and initialize a reference processor
-    _ref_processor = ReferenceProcessor::create_ref_processor(
-        _reserved,                  // span
-        refs_discovery_is_atomic(), // atomic_discovery
-        refs_discovery_is_mt(),     // mt_discovery
-        NULL,                       // is_alive_non_header
-        ParallelGCThreads,
-        ParallelRefProcEnabled);
+    _ref_processor =
+      new ReferenceProcessor(_reserved,                  // span
+                             ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
+                             (int) ParallelGCThreads,    // mt processing degree
+                             refs_discovery_is_mt(),     // mt discovery
+                             (int) ParallelGCThreads,    // mt discovery degree
+                             refs_discovery_is_atomic(), // atomic_discovery
+                             NULL,                       // is_alive_non_header
+                             false);                     // write barrier for next field updates
   }
 }
 
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp
index d39999aaaaa..3d657b3dece 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -58,9 +58,7 @@ CollectorCounters*  PSMarkSweep::_counters = NULL;
 
 void PSMarkSweep::initialize() {
   MemRegion mr = Universe::heap()->reserved_region();
-  _ref_processor = new ReferenceProcessor(mr,
-                                          true,    // atomic_discovery
-                                          false);  // mt_discovery
+  _ref_processor = new ReferenceProcessor(mr);     // a vanilla ref proc
   _counters = new CollectorCounters("PSMarkSweep", 1);
 }
 
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
index 2a77d277f52..5f7504ded06 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -827,13 +827,15 @@ void PSParallelCompact::post_initialize() {
   assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
 
   MemRegion mr = heap->reserved_region();
-  _ref_processor = ReferenceProcessor::create_ref_processor(
-    mr,                         // span
-    true,                       // atomic_discovery
-    true,                       // mt_discovery
-    &_is_alive_closure,
-    ParallelGCThreads,
-    ParallelRefProcEnabled);
+  _ref_processor =
+    new ReferenceProcessor(mr,            // span
+                           ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
+                           (int) ParallelGCThreads, // mt processing degree
+                           true,          // mt discovery
+                           (int) ParallelGCThreads, // mt discovery degree
+                           true,          // atomic_discovery
+                           &_is_alive_closure, // non-header is alive closure
+                           false);        // write barrier for next field updates
   _counters = new CollectorCounters("PSParallelCompact", 1);
 
   // Initialize static fields in ParCompactionManager.
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp
index 8379004f636..39f7f6a3e12 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp
@@ -411,7 +411,7 @@ oop PSPromotionManager::copy_to_survivor_space(oop o) {
 template <class T> void PSPromotionManager::process_array_chunk_work(
                                                  oop obj,
                                                  int start, int end) {
-  assert(start < end, "invariant");
+  assert(start <= end, "invariant");
   T* const base      = (T*)objArrayOop(obj)->base();
   T* p               = base + start;
   T* const chunk_end = base + end;
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp
index f87db47e7cb..419ed6ad7bb 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
  */
 
 #include "precompiled.hpp"
+#include "classfile/symbolTable.hpp"
 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
 #include "gc_implementation/parallelScavenge/gcTaskManager.hpp"
 #include "gc_implementation/parallelScavenge/generationSizer.hpp"
@@ -439,6 +440,14 @@ bool PSScavenge::invoke_no_policy() {
       reference_processor()->enqueue_discovered_references(NULL);
     }
 
+    if (!JavaObjectsInPerm) {
+      // Unlink any dead interned Strings
+      StringTable::unlink(&_is_alive_closure);
+      // Process the remaining live ones
+      PSScavengeRootsClosure root_closure(promotion_manager);
+      StringTable::oops_do(&root_closure);
+    }
+
     // Finally, flush the promotion_manager's labs, and deallocate its stacks.
     PSPromotionManager::post_scavenge();
 
@@ -796,13 +805,15 @@ void PSScavenge::initialize() {
 
   // Initialize ref handling object for scavenging.
   MemRegion mr = young_gen->reserved();
-  _ref_processor = ReferenceProcessor::create_ref_processor(
-    mr,                         // span
-    true,                       // atomic_discovery
-    true,                       // mt_discovery
-    NULL,                       // is_alive_non_header
-    ParallelGCThreads,
-    ParallelRefProcEnabled);
+  _ref_processor =
+    new ReferenceProcessor(mr,                         // span
+                           ParallelRefProcEnabled && (ParallelGCThreads > 1), // mt processing
+                           (int) ParallelGCThreads,    // mt processing degree
+                           true,                       // mt discovery
+                           (int) ParallelGCThreads,    // mt discovery degree
+                           true,                       // atomic_discovery
+                           NULL,                       // header provides liveness info
+                           false);                     // next field updates do not need write barrier
 
   // Cache the cardtable
   BarrierSet* bs = Universe::heap()->barrier_set();
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp
index 5e67cf061ea..1848a1db281 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp
@@ -86,4 +86,21 @@ inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm,
   }
 }
 
+class PSScavengeRootsClosure: public OopClosure {
+ private:
+  PSPromotionManager* _promotion_manager;
+
+ protected:
+  template <class T> void do_oop_work(T *p) {
+    if (PSScavenge::should_scavenge(p)) {
+      // We never card mark roots, maybe call a func without test?
+      PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p);
+    }
+  }
+ public:
+  PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
+  void do_oop(oop* p)       { PSScavengeRootsClosure::do_oop_work(p); }
+  void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); }
+};
+
 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp
index 5b38abb59f3..de44096c1f3 100644
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psTasks.cpp
@@ -30,7 +30,7 @@
 #include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
-#include "gc_implementation/parallelScavenge/psScavenge.hpp"
+#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
 #include "gc_implementation/parallelScavenge/psTasks.hpp"
 #include "memory/iterator.hpp"
 #include "memory/universe.hpp"
@@ -46,24 +46,6 @@
 // ScavengeRootsTask
 //
 
-// Define before use
-class PSScavengeRootsClosure: public OopClosure {
- private:
-  PSPromotionManager* _promotion_manager;
-
- protected:
-  template <class T> void do_oop_work(T *p) {
-    if (PSScavenge::should_scavenge(p)) {
-      // We never card mark roots, maybe call a func without test?
-      PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p);
-    }
-  }
- public:
-  PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
-  void do_oop(oop* p)       { PSScavengeRootsClosure::do_oop_work(p); }
-  void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); }
-};
-
 void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) {
   assert(Universe::heap()->is_gc_active(), "called outside gc");
 
diff --git a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp
index 2dd19992785..a1908a2c928 100644
--- a/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp
+++ b/hotspot/src/share/vm/interpreter/abstractInterpreter.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,7 +96,7 @@ class AbstractInterpreter: AllStatic {
     empty,                                                      // empty method (code: _return)
     accessor,                                                   // accessor method (code: _aload_0, _getfield, _(a|i)return)
     abstract,                                                   // abstract method (throws an AbstractMethodException)
-    method_handle,                                              // java.dyn.MethodHandles::invoke
+    method_handle,                                              // java.lang.invoke.MethodHandles::invoke
     java_lang_math_sin,                                         // implementation of java.lang.Math.sin   (x)
     java_lang_math_cos,                                         // implementation of java.lang.Math.cos   (x)
     java_lang_math_tan,                                         // implementation of java.lang.Math.tan   (x)
diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
index a5512f14176..6713e014387 100644
--- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
+++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp
@@ -656,7 +656,7 @@ BytecodeInterpreter::run(interpreterState istate) {
           // oop rcvr = locals[0].j.r;
           oop rcvr;
           if (METHOD->is_static()) {
-            rcvr = METHOD->constants()->pool_holder()->klass_part()->java_mirror();
+            rcvr = METHOD->constants()->pool_holder()->java_mirror();
           } else {
             rcvr = LOCALS_OBJECT(0);
             VERIFY_OOP(rcvr);
@@ -2111,8 +2111,8 @@ run:
             break;
 
           case JVM_CONSTANT_Class:
-            VERIFY_OOP(constants->resolved_klass_at(index)->klass_part()->java_mirror());
-            SET_STACK_OBJECT(constants->resolved_klass_at(index)->klass_part()->java_mirror(), 0);
+            VERIFY_OOP(constants->resolved_klass_at(index)->java_mirror());
+            SET_STACK_OBJECT(constants->resolved_klass_at(index)->java_mirror(), 0);
             break;
 
           case JVM_CONSTANT_UnresolvedString:
diff --git a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
index a5e92ee13c8..66cb27edf1f 100644
--- a/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
+++ b/hotspot/src/share/vm/interpreter/interpreterRuntime.cpp
@@ -118,7 +118,7 @@ IRT_ENTRY(void, InterpreterRuntime::ldc(JavaThread* thread, bool wide))
 
   if (tag.is_unresolved_klass() || tag.is_klass()) {
     klassOop klass = pool->klass_at(index, CHECK);
-    oop java_class = klass->klass_part()->java_mirror();
+    oop java_class = klass->java_mirror();
     thread->set_vm_result(java_class);
   } else {
 #ifdef ASSERT
@@ -369,7 +369,10 @@ IRT_ENTRY(void, InterpreterRuntime::throw_WrongMethodTypeException(JavaThread* t
   }
 
   // create exception
-  THROW_MSG(vmSymbols::java_dyn_WrongMethodTypeException(), message);
+  Symbol* java_lang_invoke_WrongMethodTypeException = vmSymbols::java_lang_invoke_WrongMethodTypeException();
+  if (AllowTransitionalJSR292)
+    java_lang_invoke_WrongMethodTypeException = SystemDictionaryHandles::WrongMethodTypeException_klass()->name();
+  THROW_MSG(java_lang_invoke_WrongMethodTypeException, message);
 }
 IRT_END
 
@@ -794,7 +797,7 @@ IRT_ENTRY(void, InterpreterRuntime::resolve_invokedynamic(JavaThread* thread)) {
   Handle info;  // optional argument(s) in JVM_CONSTANT_InvokeDynamic
   Handle bootm = SystemDictionary::find_bootstrap_method(caller_method, caller_bci,
                                                          main_index, info, CHECK);
-  if (!java_dyn_MethodHandle::is_instance(bootm())) {
+  if (!java_lang_invoke_MethodHandle::is_instance(bootm())) {
     THROW_MSG(vmSymbols::java_lang_IllegalStateException(),
               "no bootstrap method found for invokedynamic");
   }
@@ -980,7 +983,8 @@ IRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread *thread, oopDes
 ConstantPoolCacheEntry *cp_entry))
 
   // check the access_flags for the field in the klass
-  instanceKlass* ik = instanceKlass::cast((klassOop)cp_entry->f1());
+
+  instanceKlass* ik = instanceKlass::cast(java_lang_Class::as_klassOop(cp_entry->f1()));
   typeArrayOop fields = ik->fields();
   int index = cp_entry->field_index();
   assert(index < fields->length(), "holders field index is out of range");
@@ -1006,7 +1010,7 @@ ConstantPoolCacheEntry *cp_entry))
     // non-static field accessors have an object, but we need a handle
     h_obj = Handle(thread, obj);
   }
-  instanceKlassHandle h_cp_entry_f1(thread, (klassOop)cp_entry->f1());
+  instanceKlassHandle h_cp_entry_f1(thread, java_lang_Class::as_klassOop(cp_entry->f1()));
   jfieldID fid = jfieldIDWorkaround::to_jfieldID(h_cp_entry_f1, cp_entry->f2(), is_static);
   JvmtiExport::post_field_access(thread, method(thread), bcp(thread), h_cp_entry_f1, h_obj, fid);
 IRT_END
@@ -1014,7 +1018,7 @@ IRT_END
 IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread,
   oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value))
 
-  klassOop k = (klassOop)cp_entry->f1();
+  klassOop k = java_lang_Class::as_klassOop(cp_entry->f1());
 
   // check the access_flags for the field in the klass
   instanceKlass* ik = instanceKlass::cast(k);
diff --git a/hotspot/src/share/vm/interpreter/linkResolver.cpp b/hotspot/src/share/vm/interpreter/linkResolver.cpp
index 71f2c7598f6..4ed4ac17f11 100644
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -217,11 +217,13 @@ void LinkResolver::lookup_implicit_method(methodHandle& result,
   if (EnableMethodHandles &&
       klass() == SystemDictionary::MethodHandle_klass() &&
       methodOopDesc::is_method_handle_invoke_name(name)) {
-    if (!MethodHandles::enabled()) {
+    if (!THREAD->is_Compiler_thread() && !MethodHandles::enabled()) {
       // Make sure the Java part of the runtime has been booted up.
       klassOop natives = SystemDictionary::MethodHandleNatives_klass();
       if (natives == NULL || instanceKlass::cast(natives)->is_not_initialized()) {
-        SystemDictionary::resolve_or_fail(vmSymbols::sun_dyn_MethodHandleNatives(),
+        Symbol* natives_name = vmSymbols::java_lang_invoke_MethodHandleNatives();
+        if (natives != NULL && AllowTransitionalJSR292)  natives_name = Klass::cast(natives)->name();
+        SystemDictionary::resolve_or_fail(natives_name,
                                           Handle(),
                                           Handle(),
                                           true,
@@ -298,7 +300,7 @@ void LinkResolver::resolve_method(methodHandle& resolved_method, KlassHandle& re
 }
 
 void LinkResolver::resolve_dynamic_method(methodHandle& resolved_method, KlassHandle& resolved_klass, constantPoolHandle pool, int index, TRAPS) {
-  // The class is java.dyn.MethodHandle
+  // The class is java.lang.invoke.MethodHandle
   resolved_klass = SystemDictionaryHandles::MethodHandle_klass();
 
   Symbol* method_name = vmSymbols::invokeExact_name();
diff --git a/hotspot/src/share/vm/memory/collectorPolicy.cpp b/hotspot/src/share/vm/memory/collectorPolicy.cpp
index c609da68fec..61efdd80f7d 100644
--- a/hotspot/src/share/vm/memory/collectorPolicy.cpp
+++ b/hotspot/src/share/vm/memory/collectorPolicy.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -293,10 +293,11 @@ void GenCollectorPolicy::initialize_size_info() {
   // Determine maximum size of gen0
 
   size_t max_new_size = 0;
-  if (FLAG_IS_CMDLINE(MaxNewSize)) {
+  if (FLAG_IS_CMDLINE(MaxNewSize) || FLAG_IS_ERGO(MaxNewSize)) {
     if (MaxNewSize < min_alignment()) {
       max_new_size = min_alignment();
-    } else if (MaxNewSize >= max_heap_byte_size()) {
+    }
+    if (MaxNewSize >= max_heap_byte_size()) {
       max_new_size = align_size_down(max_heap_byte_size() - min_alignment(),
                                      min_alignment());
       warning("MaxNewSize (" SIZE_FORMAT "k) is equal to or "
@@ -333,7 +334,7 @@ void GenCollectorPolicy::initialize_size_info() {
   assert(max_new_size > 0, "All paths should set max_new_size");
 
   // Given the maximum gen0 size, determine the initial and
-  // minimum sizes.
+  // minimum gen0 sizes.
 
   if (max_heap_byte_size() == min_heap_byte_size()) {
     // The maximum and minimum heap sizes are the same so
@@ -396,7 +397,7 @@ void GenCollectorPolicy::initialize_size_info() {
   }
 
   if (PrintGCDetails && Verbose) {
-    gclog_or_tty->print_cr("Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
+    gclog_or_tty->print_cr("1: Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
       SIZE_FORMAT "  Maximum gen0 " SIZE_FORMAT,
       min_gen0_size(), initial_gen0_size(), max_gen0_size());
   }
@@ -448,7 +449,7 @@ void TwoGenerationCollectorPolicy::initialize_size_info() {
   // At this point the minimum, initial and maximum sizes
   // of the overall heap and of gen0 have been determined.
   // The maximum gen1 size can be determined from the maximum gen0
-  // and maximum heap size since not explicit flags exits
+  // and maximum heap size since no explicit flags exits
   // for setting the gen1 maximum.
   _max_gen1_size = max_heap_byte_size() - _max_gen0_size;
   _max_gen1_size =
@@ -494,13 +495,13 @@ void TwoGenerationCollectorPolicy::initialize_size_info() {
           "generation sizes: using maximum heap = " SIZE_FORMAT
           " -XX:OldSize flag is being ignored",
           max_heap_byte_size());
-  }
+    }
     // If there is an inconsistency between the OldSize and the minimum and/or
     // initial size of gen0, since OldSize was explicitly set, OldSize wins.
     if (adjust_gen0_sizes(&_min_gen0_size, &_min_gen1_size,
                           min_heap_byte_size(), OldSize)) {
       if (PrintGCDetails && Verbose) {
-        gclog_or_tty->print_cr("Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
+        gclog_or_tty->print_cr("2: Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
               SIZE_FORMAT "  Maximum gen0 " SIZE_FORMAT,
               min_gen0_size(), initial_gen0_size(), max_gen0_size());
       }
@@ -509,7 +510,7 @@ void TwoGenerationCollectorPolicy::initialize_size_info() {
     if (adjust_gen0_sizes(&_initial_gen0_size, &_initial_gen1_size,
                          initial_heap_byte_size(), OldSize)) {
       if (PrintGCDetails && Verbose) {
-        gclog_or_tty->print_cr("Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
+        gclog_or_tty->print_cr("3: Minimum gen0 " SIZE_FORMAT "  Initial gen0 "
           SIZE_FORMAT "  Maximum gen0 " SIZE_FORMAT,
           min_gen0_size(), initial_gen0_size(), max_gen0_size());
       }
diff --git a/hotspot/src/share/vm/memory/compactingPermGenGen.hpp b/hotspot/src/share/vm/memory/compactingPermGenGen.hpp
index cf1ffe17530..e3428d72f18 100644
--- a/hotspot/src/share/vm/memory/compactingPermGenGen.hpp
+++ b/hotspot/src/share/vm/memory/compactingPermGenGen.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -105,7 +105,7 @@ private:
 public:
 
   enum {
-    vtbl_list_size = 16, // number of entries in the shared space vtable list.
+    vtbl_list_size = 17, // number of entries in the shared space vtable list.
     num_virtuals = 200   // number of virtual methods in Klass (or
                          // subclass) objects, or greater.
   };
diff --git a/hotspot/src/share/vm/memory/dump.cpp b/hotspot/src/share/vm/memory/dump.cpp
index e987d96d968..3e34118fc91 100644
--- a/hotspot/src/share/vm/memory/dump.cpp
+++ b/hotspot/src/share/vm/memory/dump.cpp
@@ -1561,6 +1561,7 @@ void GenCollectedHeap::preload_and_dump(TRAPS) {
     // thread because it requires object allocation.
     LinkClassesClosure lcc(Thread::current());
     object_iterate(&lcc);
+    ensure_parsability(false); // arg is actually don't care
     tty->print_cr("done. ");
 
     // Create and dump the shared spaces.
diff --git a/hotspot/src/share/vm/memory/generation.cpp b/hotspot/src/share/vm/memory/generation.cpp
index fe194871c5c..75a373285d9 100644
--- a/hotspot/src/share/vm/memory/generation.cpp
+++ b/hotspot/src/share/vm/memory/generation.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -83,14 +83,11 @@ void Generation::print_heap_change(size_t prev_used) const {
 }
 
 // By default we get a single threaded default reference processor;
-// generations needing multi-threaded refs discovery override this method.
+// generations needing multi-threaded refs processing or discovery override this method.
 void Generation::ref_processor_init() {
   assert(_ref_processor == NULL, "a reference processor already exists");
   assert(!_reserved.is_empty(), "empty generation?");
-  _ref_processor =
-    new ReferenceProcessor(_reserved,                  // span
-                           refs_discovery_is_atomic(), // atomic_discovery
-                           refs_discovery_is_mt());    // mt_discovery
+  _ref_processor = new ReferenceProcessor(_reserved);    // a vanilla reference processor
   if (_ref_processor == NULL) {
     vm_exit_during_initialization("Could not allocate ReferenceProcessor object");
   }
diff --git a/hotspot/src/share/vm/memory/heap.cpp b/hotspot/src/share/vm/memory/heap.cpp
index 94676f78dcc..2d46b611241 100644
--- a/hotspot/src/share/vm/memory/heap.cpp
+++ b/hotspot/src/share/vm/memory/heap.cpp
@@ -316,12 +316,19 @@ size_t CodeHeap::allocated_capacity() const {
 }
 
 size_t CodeHeap::largest_free_block() const {
+  // First check unused space excluding free blocks.
+  size_t free_sz = size(_free_segments);
+  size_t unused  = max_capacity() - allocated_capacity() - free_sz;
+  if (unused >= free_sz)
+    return unused;
+
+  // Now check largest free block.
   size_t len = 0;
   for (FreeBlock* b = _freelist; b != NULL; b = b->link()) {
     if (b->length() > len)
       len = b->length();
   }
-  return size(len);
+  return MAX2(unused, size(len));
 }
 
 // Free list management
diff --git a/hotspot/src/share/vm/memory/oopFactory.cpp b/hotspot/src/share/vm/memory/oopFactory.cpp
index c8b45b68a04..08f9825b34f 100644
--- a/hotspot/src/share/vm/memory/oopFactory.cpp
+++ b/hotspot/src/share/vm/memory/oopFactory.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -117,12 +117,12 @@ constantPoolCacheOop oopFactory::new_constantPoolCache(int length,
 }
 
 
-klassOop oopFactory::new_instanceKlass(int vtable_len, int itable_len,
+klassOop oopFactory::new_instanceKlass(Symbol* name, int vtable_len, int itable_len,
                                        int static_field_size,
                                        unsigned int nonstatic_oop_map_count,
                                        ReferenceType rt, TRAPS) {
   instanceKlassKlass* ikk = instanceKlassKlass::cast(Universe::instanceKlassKlassObj());
-  return ikk->allocate_instance_klass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_count, rt, CHECK_NULL);
+  return ikk->allocate_instance_klass(name, vtable_len, itable_len, static_field_size, nonstatic_oop_map_count, rt, CHECK_NULL);
 }
 
 
diff --git a/hotspot/src/share/vm/memory/oopFactory.hpp b/hotspot/src/share/vm/memory/oopFactory.hpp
index 49b89bc3b17..32e50fb4072 100644
--- a/hotspot/src/share/vm/memory/oopFactory.hpp
+++ b/hotspot/src/share/vm/memory/oopFactory.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,7 +72,8 @@ class oopFactory: AllStatic {
                                                     TRAPS);
 
   // Instance classes
-  static klassOop        new_instanceKlass(int vtable_len, int itable_len,
+  static klassOop        new_instanceKlass(Symbol* name,
+                                           int vtable_len, int itable_len,
                                            int static_field_size,
                                            unsigned int nonstatic_oop_map_count,
                                            ReferenceType rt, TRAPS);
diff --git a/hotspot/src/share/vm/memory/referenceProcessor.cpp b/hotspot/src/share/vm/memory/referenceProcessor.cpp
index dc71a93f314..8a4da9a3602 100644
--- a/hotspot/src/share/vm/memory/referenceProcessor.cpp
+++ b/hotspot/src/share/vm/memory/referenceProcessor.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -102,40 +102,17 @@ void ReferenceProcessor::init_statics() {
             "Unrecongnized RefDiscoveryPolicy");
 }
 
-ReferenceProcessor*
-ReferenceProcessor::create_ref_processor(MemRegion          span,
-                                         bool               atomic_discovery,
-                                         bool               mt_discovery,
-                                         BoolObjectClosure* is_alive_non_header,
-                                         int                parallel_gc_threads,
-                                         bool               mt_processing,
-                                         bool               dl_needs_barrier) {
-  int mt_degree = 1;
-  if (parallel_gc_threads > 1) {
-    mt_degree = parallel_gc_threads;
-  }
-  ReferenceProcessor* rp =
-    new ReferenceProcessor(span, atomic_discovery,
-                           mt_discovery, mt_degree,
-                           mt_processing && (parallel_gc_threads > 0),
-                           dl_needs_barrier);
-  if (rp == NULL) {
-    vm_exit_during_initialization("Could not allocate ReferenceProcessor object");
-  }
-  rp->set_is_alive_non_header(is_alive_non_header);
-  rp->setup_policy(false /* default soft ref policy */);
-  return rp;
-}
-
 ReferenceProcessor::ReferenceProcessor(MemRegion span,
-                                       bool      atomic_discovery,
-                                       bool      mt_discovery,
-                                       int       mt_degree,
                                        bool      mt_processing,
+                                       int       mt_processing_degree,
+                                       bool      mt_discovery,
+                                       int       mt_discovery_degree,
+                                       bool      atomic_discovery,
+                                       BoolObjectClosure* is_alive_non_header,
                                        bool      discovered_list_needs_barrier)  :
   _discovering_refs(false),
   _enqueuing_is_done(false),
-  _is_alive_non_header(NULL),
+  _is_alive_non_header(is_alive_non_header),
   _discovered_list_needs_barrier(discovered_list_needs_barrier),
   _bs(NULL),
   _processing_is_mt(mt_processing),
@@ -144,8 +121,8 @@ ReferenceProcessor::ReferenceProcessor(MemRegion span,
   _span = span;
   _discovery_is_atomic = atomic_discovery;
   _discovery_is_mt     = mt_discovery;
-  _num_q               = mt_degree;
-  _max_num_q           = mt_degree;
+  _num_q               = MAX2(1, mt_processing_degree);
+  _max_num_q           = MAX2(_num_q, mt_discovery_degree);
   _discoveredSoftRefs  = NEW_C_HEAP_ARRAY(DiscoveredList, _max_num_q * subclasses_of_ref);
   if (_discoveredSoftRefs == NULL) {
     vm_exit_during_initialization("Could not allocated RefProc Array");
@@ -163,6 +140,7 @@ ReferenceProcessor::ReferenceProcessor(MemRegion span,
   if (discovered_list_needs_barrier) {
     _bs = Universe::heap()->barrier_set();
   }
+  setup_policy(false /* default soft ref policy */);
 }
 
 #ifndef PRODUCT
@@ -405,15 +383,14 @@ public:
   { }
 
   virtual void work(unsigned int work_id) {
-    assert(work_id < (unsigned int)_ref_processor.num_q(), "Index out-of-bounds");
+    assert(work_id < (unsigned int)_ref_processor.max_num_q(), "Index out-of-bounds");
     // Simplest first cut: static partitioning.
     int index = work_id;
     // The increment on "index" must correspond to the maximum number of queues
     // (n_queues) with which that ReferenceProcessor was created.  That
     // is because of the "clever" way the discovered references lists were
-    // allocated and are indexed into.  That number is ParallelGCThreads
-    // currently.  Assert that.
-    assert(_n_queues == (int) ParallelGCThreads, "Different number not expected");
+    // allocated and are indexed into.
+    assert(_n_queues == (int) _ref_processor.max_num_q(), "Different number not expected");
     for (int j = 0;
          j < subclasses_of_ref;
          j++, index += _n_queues) {
@@ -672,7 +649,7 @@ ReferenceProcessor::pp2_work(DiscoveredList&    refs_list,
     }
   }
   NOT_PRODUCT(
-    if (PrintGCDetails && TraceReferenceGC) {
+    if (PrintGCDetails && TraceReferenceGC && (iter.processed() > 0)) {
       gclog_or_tty->print_cr(" Dropped %d active Refs out of %d "
         "Refs in discovered list " INTPTR_FORMAT,
         iter.removed(), iter.processed(), (address)refs_list.head());
@@ -711,7 +688,7 @@ ReferenceProcessor::pp2_work_concurrent_discovery(DiscoveredList&    refs_list,
   // Now close the newly reachable set
   complete_gc->do_void();
   NOT_PRODUCT(
-    if (PrintGCDetails && TraceReferenceGC) {
+    if (PrintGCDetails && TraceReferenceGC && (iter.processed() > 0)) {
       gclog_or_tty->print_cr(" Dropped %d active Refs out of %d "
         "Refs in discovered list " INTPTR_FORMAT,
         iter.removed(), iter.processed(), (address)refs_list.head());
@@ -951,7 +928,7 @@ ReferenceProcessor::process_discovered_reflist(
   }
   if (PrintReferenceGC && PrintGCDetails) {
     size_t total = 0;
-    for (int i = 0; i < _num_q; ++i) {
+    for (int i = 0; i < _max_num_q; ++i) {
       total += refs_lists[i].length();
     }
     gclog_or_tty->print(", %u refs", total);
@@ -967,7 +944,7 @@ ReferenceProcessor::process_discovered_reflist(
       RefProcPhase1Task phase1(*this, refs_lists, policy, true /*marks_oops_alive*/);
       task_executor->execute(phase1);
     } else {
-      for (int i = 0; i < _num_q; i++) {
+      for (int i = 0; i < _max_num_q; i++) {
         process_phase1(refs_lists[i], policy,
                        is_alive, keep_alive, complete_gc);
       }
@@ -983,7 +960,7 @@ ReferenceProcessor::process_discovered_reflist(
     RefProcPhase2Task phase2(*this, refs_lists, !discovery_is_atomic() /*marks_oops_alive*/);
     task_executor->execute(phase2);
   } else {
-    for (int i = 0; i < _num_q; i++) {
+    for (int i = 0; i < _max_num_q; i++) {
       process_phase2(refs_lists[i], is_alive, keep_alive, complete_gc);
     }
   }
@@ -994,7 +971,7 @@ ReferenceProcessor::process_discovered_reflist(
     RefProcPhase3Task phase3(*this, refs_lists, clear_referent, true /*marks_oops_alive*/);
     task_executor->execute(phase3);
   } else {
-    for (int i = 0; i < _num_q; i++) {
+    for (int i = 0; i < _max_num_q; i++) {
       process_phase3(refs_lists[i], clear_referent,
                      is_alive, keep_alive, complete_gc);
     }
@@ -1008,7 +985,7 @@ void ReferenceProcessor::clean_up_discovered_references() {
   //   for (int j = 0; j < _num_q; j++) {
   //     int index = i * _max_num_q + j;
   for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
-    if (TraceReferenceGC && PrintGCDetails && ((i % _num_q) == 0)) {
+    if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) {
       gclog_or_tty->print_cr(
         "\nScrubbing %s discovered list of Null referents",
         list_name(i));
@@ -1350,7 +1327,7 @@ void ReferenceProcessor::preclean_discovered_references(
   {
     TraceTime tt("Preclean WeakReferences", PrintGCDetails && PrintReferenceGC,
               false, gclog_or_tty);
-    for (int i = 0; i < _num_q; i++) {
+    for (int i = 0; i < _max_num_q; i++) {
       if (yield->should_return()) {
         return;
       }
@@ -1363,7 +1340,7 @@ void ReferenceProcessor::preclean_discovered_references(
   {
     TraceTime tt("Preclean FinalReferences", PrintGCDetails && PrintReferenceGC,
               false, gclog_or_tty);
-    for (int i = 0; i < _num_q; i++) {
+    for (int i = 0; i < _max_num_q; i++) {
       if (yield->should_return()) {
         return;
       }
@@ -1376,7 +1353,7 @@ void ReferenceProcessor::preclean_discovered_references(
   {
     TraceTime tt("Preclean PhantomReferences", PrintGCDetails && PrintReferenceGC,
               false, gclog_or_tty);
-    for (int i = 0; i < _num_q; i++) {
+    for (int i = 0; i < _max_num_q; i++) {
       if (yield->should_return()) {
         return;
       }
@@ -1433,7 +1410,7 @@ ReferenceProcessor::preclean_discovered_reflist(DiscoveredList&    refs_list,
   complete_gc->do_void();
 
   NOT_PRODUCT(
-    if (PrintGCDetails && PrintReferenceGC) {
+    if (PrintGCDetails && PrintReferenceGC && (iter.processed() > 0)) {
       gclog_or_tty->print_cr(" Dropped %d Refs out of %d "
         "Refs in discovered list " INTPTR_FORMAT,
         iter.removed(), iter.processed(), (address)refs_list.head());
diff --git a/hotspot/src/share/vm/memory/referenceProcessor.hpp b/hotspot/src/share/vm/memory/referenceProcessor.hpp
index db2a26d5d55..fceb4c4ec1e 100644
--- a/hotspot/src/share/vm/memory/referenceProcessor.hpp
+++ b/hotspot/src/share/vm/memory/referenceProcessor.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -71,7 +71,7 @@ class ReferenceProcessor : public CHeapObj {
   bool        _enqueuing_is_done;     // true if all weak references enqueued
   bool        _processing_is_mt;      // true during phases when
                                       // reference processing is MT.
-  int         _next_id;               // round-robin counter in
+  int         _next_id;               // round-robin mod _num_q counter in
                                       // support of work distribution
 
   // For collectors that do not keep GC marking information
@@ -103,7 +103,8 @@ class ReferenceProcessor : public CHeapObj {
 
  public:
   int num_q()                            { return _num_q; }
-  void set_mt_degree(int v)              { _num_q = v; }
+  int max_num_q()                        { return _max_num_q; }
+  void set_active_mt_degree(int v)       { _num_q = v; }
   DiscoveredList* discovered_soft_refs() { return _discoveredSoftRefs; }
   static oop  sentinel_ref()             { return _sentinelRef; }
   static oop* adr_sentinel_ref()         { return &_sentinelRef; }
@@ -216,6 +217,7 @@ class ReferenceProcessor : public CHeapObj {
                                    VoidClosure*       complete_gc,
                                    YieldClosure*      yield);
 
+  // round-robin mod _num_q (not: _not_ mode _max_num_q)
   int next_id() {
     int id = _next_id;
     if (++_next_id == _num_q) {
@@ -256,24 +258,16 @@ class ReferenceProcessor : public CHeapObj {
     _max_num_q(0),
     _processing_is_mt(false),
     _next_id(0)
-  {}
+  { }
 
-  ReferenceProcessor(MemRegion span, bool atomic_discovery,
-                     bool mt_discovery,
-                     int mt_degree = 1,
-                     bool mt_processing = false,
+  // Default parameters give you a vanilla reference processor.
+  ReferenceProcessor(MemRegion span,
+                     bool mt_processing = false, int mt_processing_degree = 1,
+                     bool mt_discovery  = false, int mt_discovery_degree  = 1,
+                     bool atomic_discovery = true,
+                     BoolObjectClosure* is_alive_non_header = NULL,
                      bool discovered_list_needs_barrier = false);
 
-  // Allocates and initializes a reference processor.
-  static ReferenceProcessor* create_ref_processor(
-    MemRegion          span,
-    bool               atomic_discovery,
-    bool               mt_discovery,
-    BoolObjectClosure* is_alive_non_header = NULL,
-    int                parallel_gc_threads = 1,
-    bool               mt_processing = false,
-    bool               discovered_list_needs_barrier = false);
-
   // RefDiscoveryPolicy values
   enum DiscoveryPolicy {
     ReferenceBasedDiscovery = 0,
@@ -397,20 +391,20 @@ class ReferenceProcessorSpanMutator: StackObj {
 // A utility class to temporarily change the MT'ness of
 // reference discovery for the given ReferenceProcessor
 // in the scope that contains it.
-class ReferenceProcessorMTMutator: StackObj {
+class ReferenceProcessorMTDiscoveryMutator: StackObj {
  private:
   ReferenceProcessor* _rp;
   bool                _saved_mt;
 
  public:
-  ReferenceProcessorMTMutator(ReferenceProcessor* rp,
-                              bool mt):
+  ReferenceProcessorMTDiscoveryMutator(ReferenceProcessor* rp,
+                                       bool mt):
     _rp(rp) {
     _saved_mt = _rp->discovery_is_mt();
     _rp->set_mt_discovery(mt);
   }
 
-  ~ReferenceProcessorMTMutator() {
+  ~ReferenceProcessorMTDiscoveryMutator() {
     _rp->set_mt_discovery(_saved_mt);
   }
 };
diff --git a/hotspot/src/share/vm/memory/sharedHeap.cpp b/hotspot/src/share/vm/memory/sharedHeap.cpp
index e42ecc18dc9..c346995f71b 100644
--- a/hotspot/src/share/vm/memory/sharedHeap.cpp
+++ b/hotspot/src/share/vm/memory/sharedHeap.cpp
@@ -171,11 +171,13 @@ void SharedHeap::process_strong_roots(bool activate_scope,
   }
 
   if (!_process_strong_tasks->is_task_claimed(SH_PS_StringTable_oops_do)) {
-     if (so & SO_Strings) {
-       StringTable::oops_do(roots);
-     }
-    // Verify if the string table contents are in the perm gen
-    NOT_PRODUCT(StringTable::oops_do(&assert_is_perm_closure));
+    if (so & SO_Strings || (!collecting_perm_gen && !JavaObjectsInPerm)) {
+      StringTable::oops_do(roots);
+    }
+    if (JavaObjectsInPerm) {
+      // Verify the string table contents are in the perm gen
+      NOT_PRODUCT(StringTable::oops_do(&assert_is_perm_closure));
+    }
   }
 
   if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) {
diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp
index 6ea6c32cd50..9499d6bacd8 100644
--- a/hotspot/src/share/vm/memory/universe.cpp
+++ b/hotspot/src/share/vm/memory/universe.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,7 @@
 #include "oops/cpCacheKlass.hpp"
 #include "oops/cpCacheOop.hpp"
 #include "oops/instanceKlass.hpp"
+#include "oops/instanceMirrorKlass.hpp"
 #include "oops/instanceKlassKlass.hpp"
 #include "oops/instanceRefKlass.hpp"
 #include "oops/klassKlass.hpp"
@@ -521,6 +522,7 @@ void Universe::init_self_patching_vtbl_list(void** list, int count) {
   { objArrayKlassKlass o;     add_vtable(list, &n, &o, count); }
   { instanceKlassKlass o;     add_vtable(list, &n, &o, count); }
   { instanceKlass o;          add_vtable(list, &n, &o, count); }
+  { instanceMirrorKlass o;    add_vtable(list, &n, &o, count); }
   { instanceRefKlass o;       add_vtable(list, &n, &o, count); }
   { typeArrayKlassKlass o;    add_vtable(list, &n, &o, count); }
   { typeArrayKlass o;         add_vtable(list, &n, &o, count); }
@@ -547,7 +549,7 @@ class FixupMirrorClosure: public ObjectClosure {
       KlassHandle k(THREAD, klassOop(obj));
       // We will never reach the CATCH below since Exceptions::_throw will cause
       // the VM to exit if an exception is thrown during initialization
-      java_lang_Class::create_mirror(k, CATCH);
+      java_lang_Class::fixup_mirror(k, CATCH);
       // This call unconditionally creates a new mirror for k,
       // and links in k's component_mirror field if k is an array.
       // If k is an objArray, k's element type must already have
@@ -605,6 +607,10 @@ void Universe::fixup_mirrors(TRAPS) {
   // walk over permanent objects created so far (mostly classes) and fixup their mirrors. Note
   // that the number of objects allocated at this point is very small.
   assert(SystemDictionary::Class_klass_loaded(), "java.lang.Class should be loaded");
+
+  // Cache the start of the static fields
+  instanceMirrorKlass::init_offset_of_static_fields();
+
   FixupMirrorClosure blk;
   Universe::heap()->permanent_object_iterate(&blk);
 }
@@ -1313,6 +1319,8 @@ void Universe::verify(bool allow_dirty, bool silent, bool option) {
   JNIHandles::verify();
   if (!silent) gclog_or_tty->print("C-heap ");
   os::check_heap();
+  if (!silent) gclog_or_tty->print("code cache ");
+  CodeCache::verify_oops();
   if (!silent) gclog_or_tty->print_cr("]");
 
   _verify_in_progress = false;
diff --git a/hotspot/src/share/vm/oops/arrayKlassKlass.cpp b/hotspot/src/share/vm/oops/arrayKlassKlass.cpp
index 5215d146ce2..0123e85a38e 100644
--- a/hotspot/src/share/vm/oops/arrayKlassKlass.cpp
+++ b/hotspot/src/share/vm/oops/arrayKlassKlass.cpp
@@ -28,6 +28,13 @@
 #include "oops/arrayKlassKlass.hpp"
 #include "oops/oop.inline.hpp"
 #include "runtime/handles.inline.hpp"
+#ifndef SERIALGC
+#include "gc_implementation/parNew/parOopClosures.inline.hpp"
+#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
+#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
+#include "memory/cardTableRS.hpp"
+#include "oops/oop.pcgc.inline.hpp"
+#endif
 
 
 klassOop arrayKlassKlass::create_klass(TRAPS) {
@@ -104,9 +111,12 @@ int arrayKlassKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
 int arrayKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
   assert(obj->is_klass(), "must be klass");
   arrayKlass* ak = arrayKlass::cast(klassOop(obj));
-  blk->do_oop(ak->adr_component_mirror());
-  blk->do_oop(ak->adr_lower_dimension());
-  blk->do_oop(ak->adr_higher_dimension());
+  oop* addr = ak->adr_component_mirror();
+  if (mr.contains(addr)) blk->do_oop(addr);
+  addr = ak->adr_lower_dimension();
+  if (mr.contains(addr)) blk->do_oop(addr);
+  addr = ak->adr_higher_dimension();
+  if (mr.contains(addr)) blk->do_oop(addr);
   ak->vtable()->oop_oop_iterate_m(blk, mr);
   return klassKlass::oop_oop_iterate_m(obj, blk, mr);
 }
@@ -114,6 +124,12 @@ int arrayKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
 #ifndef SERIALGC
 void arrayKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
   assert(obj->blueprint()->oop_is_arrayKlass(),"must be an array klass");
+  arrayKlass* ak = arrayKlass::cast(klassOop(obj));
+  oop* p = ak->adr_component_mirror();
+  if (PSScavenge::should_scavenge(p)) {
+    pm->claim_or_forward_depth(p);
+  }
+  klassKlass::oop_push_contents(pm, obj);
 }
 
 int arrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
diff --git a/hotspot/src/share/vm/oops/constantPoolKlass.cpp b/hotspot/src/share/vm/oops/constantPoolKlass.cpp
index ad1d7329551..367530717d6 100644
--- a/hotspot/src/share/vm/oops/constantPoolKlass.cpp
+++ b/hotspot/src/share/vm/oops/constantPoolKlass.cpp
@@ -285,10 +285,11 @@ int constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
 void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
   assert(obj->is_constantPool(), "should be constant pool");
   constantPoolOop cp = (constantPoolOop) obj;
-  if (AnonymousClasses && cp->has_pseudo_string() && cp->tags() != NULL) {
-    oop* base = (oop*)cp->base();
-    for (int i = 0; i < cp->length(); ++i, ++base) {
+  if (cp->tags() != NULL &&
+      (!JavaObjectsInPerm || (AnonymousClasses && cp->has_pseudo_string()))) {
+    for (int i = 1; i < cp->length(); ++i) {
       if (cp->tag_at(i).is_string()) {
+        oop* base = cp->obj_at_addr_raw(i);
         if (PSScavenge::should_scavenge(base)) {
           pm->claim_or_forward_depth(base);
         }
@@ -460,7 +461,8 @@ void constantPoolKlass::oop_verify_on(oop obj, outputStream* st) {
       if (cp->tag_at(i).is_string()) {
         if (!cp->has_pseudo_string()) {
           if (entry.is_oop()) {
-            guarantee(entry.get_oop()->is_perm(),   "should be in permspace");
+            guarantee(!JavaObjectsInPerm || entry.get_oop()->is_perm(),
+                      "should be in permspace");
             guarantee(entry.get_oop()->is_instance(), "should be instance");
           }
         } else {
diff --git a/hotspot/src/share/vm/oops/constantPoolOop.cpp b/hotspot/src/share/vm/oops/constantPoolOop.cpp
index 605d33329d2..91ab822d096 100644
--- a/hotspot/src/share/vm/oops/constantPoolOop.cpp
+++ b/hotspot/src/share/vm/oops/constantPoolOop.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -481,7 +481,7 @@ oop constantPoolOopDesc::resolve_constant_at_impl(constantPoolHandle this_oop, i
     {
       klassOop resolved = klass_at_impl(this_oop, index, CHECK_NULL);
       // ldc wants the java mirror.
-      result_oop = resolved->klass_part()->java_mirror();
+      result_oop = resolved->java_mirror();
       break;
     }
 
@@ -1175,8 +1175,15 @@ void constantPoolOopDesc::copy_entry_to(constantPoolHandle from_cp, int from_i,
 
   case JVM_CONSTANT_UnresolvedClass:
   {
-    Symbol* k = from_cp->unresolved_klass_at(from_i);
-    to_cp->unresolved_klass_at_put(to_i, k);
+    // Can be resolved after checking tag, so check the slot first.
+    CPSlot entry = from_cp->slot_at(from_i);
+    if (entry.is_oop()) {
+      assert(entry.get_oop()->is_klass(), "must be");
+      // Already resolved
+      to_cp->klass_at_put(to_i, (klassOop)entry.get_oop());
+    } else {
+      to_cp->unresolved_klass_at_put(to_i, entry.get_symbol());
+    }
   } break;
 
   case JVM_CONSTANT_UnresolvedClassInError:
@@ -1189,8 +1196,14 @@ void constantPoolOopDesc::copy_entry_to(constantPoolHandle from_cp, int from_i,
 
   case JVM_CONSTANT_UnresolvedString:
   {
-    Symbol* s = from_cp->unresolved_string_at(from_i);
-    to_cp->unresolved_string_at_put(to_i, s);
+    // Can be resolved after checking tag, so check the slot first.
+    CPSlot entry = from_cp->slot_at(from_i);
+    if (entry.is_oop()) {
+      // Already resolved (either string or pseudo-string)
+      to_cp->string_at_put(to_i, entry.get_oop());
+    } else {
+      to_cp->unresolved_string_at_put(to_i, entry.get_symbol());
+    }
   } break;
 
   case JVM_CONSTANT_Utf8:
diff --git a/hotspot/src/share/vm/oops/cpCacheKlass.cpp b/hotspot/src/share/vm/oops/cpCacheKlass.cpp
index 233c7e64464..86d9dc083b7 100644
--- a/hotspot/src/share/vm/oops/cpCacheKlass.cpp
+++ b/hotspot/src/share/vm/oops/cpCacheKlass.cpp
@@ -168,22 +168,18 @@ int constantPoolCacheKlass::oop_adjust_pointers(oop obj) {
 void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm,
                                                oop obj) {
   assert(obj->is_constantPoolCache(), "should be constant pool");
-  if (EnableInvokeDynamic) {
+  if (ScavengeRootsInCode) {
     constantPoolCacheOop cache = (constantPoolCacheOop)obj;
     // during a scavenge, it is safe to inspect my pool, since it is perm
     constantPoolOop pool = cache->constant_pool();
     assert(pool->is_constantPool(), "should be constant pool");
-    if (pool->has_invokedynamic()) {
-      for (int i = 0; i < cache->length(); i++) {
-        ConstantPoolCacheEntry* e = cache->entry_at(i);
-        oop* p = (oop*)&e->_f1;
-        if (e->is_secondary_entry()) {
-          if (PSScavenge::should_scavenge(p))
-            pm->claim_or_forward_depth(p);
-          assert(!(e->is_vfinal() && PSScavenge::should_scavenge((oop*)&e->_f2)),
-                 "no live oops here");
-        }
-      }
+    for (int i = 0; i < cache->length(); i++) {
+      ConstantPoolCacheEntry* e = cache->entry_at(i);
+      oop* p = (oop*)&e->_f1;
+      if (PSScavenge::should_scavenge(p))
+        pm->claim_or_forward_depth(p);
+      assert(!(e->is_vfinal() && PSScavenge::should_scavenge((oop*)&e->_f2)),
+             "no live oops here");
     }
   }
 }
diff --git a/hotspot/src/share/vm/oops/cpCacheOop.cpp b/hotspot/src/share/vm/oops/cpCacheOop.cpp
index 7dff5d6f497..24855ce75cf 100644
--- a/hotspot/src/share/vm/oops/cpCacheOop.cpp
+++ b/hotspot/src/share/vm/oops/cpCacheOop.cpp
@@ -133,7 +133,7 @@ void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code,
                                        TosState field_type,
                                        bool is_final,
                                        bool is_volatile) {
-  set_f1(field_holder());
+  set_f1(field_holder()->java_mirror());
   set_f2(field_offset);
   // The field index is used by jvm/ti and is the index into fields() array
   // in holder instanceKlass.  This is scaled by instanceKlass::next_offset.
diff --git a/hotspot/src/share/vm/oops/cpCacheOop.hpp b/hotspot/src/share/vm/oops/cpCacheOop.hpp
index e59c4952182..75573ab62cf 100644
--- a/hotspot/src/share/vm/oops/cpCacheOop.hpp
+++ b/hotspot/src/share/vm/oops/cpCacheOop.hpp
@@ -190,7 +190,7 @@ class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC {
   );
 
   void set_dynamic_call(
-    Handle call_site,                            // Resolved java.dyn.CallSite (f1)
+    Handle call_site,                            // Resolved java.lang.invoke.CallSite (f1)
     methodHandle signature_invoker               // determines signature information
   );
 
diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp
index 73f4d97dfcb..840ae03d09e 100644
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp
@@ -37,6 +37,7 @@
 #include "memory/oopFactory.hpp"
 #include "memory/permGen.hpp"
 #include "oops/instanceKlass.hpp"
+#include "oops/instanceMirrorKlass.hpp"
 #include "oops/instanceOop.hpp"
 #include "oops/methodOop.hpp"
 #include "oops/objArrayKlassKlass.hpp"
@@ -649,6 +650,7 @@ instanceOop instanceKlass::register_finalizer(instanceOop i, TRAPS) {
 }
 
 instanceOop instanceKlass::allocate_instance(TRAPS) {
+  assert(!oop_is_instanceMirror(), "wrong allocation path");
   bool has_finalizer_flag = has_finalizer(); // Query before possible GC
   int size = size_helper();  // Query before forming handle.
 
@@ -669,6 +671,7 @@ instanceOop instanceKlass::allocate_permanent_instance(TRAPS) {
   // instances so simply disallow finalizable perm objects.  This can
   // be relaxed if a need for it is found.
   assert(!has_finalizer(), "perm objects not allowed to have finalizers");
+  assert(!oop_is_instanceMirror(), "wrong allocation path");
   int size = size_helper();  // Query before forming handle.
   KlassHandle h_k(THREAD, as_klassOop());
   instanceOop i = (instanceOop)
@@ -735,7 +738,12 @@ void instanceKlass::call_class_initializer(TRAPS) {
 static int call_class_initializer_impl_counter = 0;   // for debugging
 
 methodOop instanceKlass::class_initializer() {
-  return find_method(vmSymbols::class_initializer_name(), vmSymbols::void_method_signature());
+  methodOop clinit = find_method(
+      vmSymbols::class_initializer_name(), vmSymbols::void_method_signature());
+  if (clinit != NULL && clinit->has_valid_initializer_flags()) {
+    return clinit;
+  }
+  return NULL;
 }
 
 void instanceKlass::call_class_initializer_impl(instanceKlassHandle this_oop, TRAPS) {
@@ -893,6 +901,7 @@ void instanceKlass::methods_do(void f(methodOop method)) {
   }
 }
 
+
 void instanceKlass::do_local_static_fields(FieldClosure* cl) {
   fieldDescriptor fd;
   int length = fields()->length();
@@ -1604,36 +1613,6 @@ template <class T> void assert_nothing(T *p) {}
 // The following macros call specialized macros, passing either oop or
 // narrowOop as the specialization type.  These test the UseCompressedOops
 // flag.
-#define InstanceKlass_OOP_ITERATE(start_p, count,    \
-                                  do_oop, assert_fn) \
-{                                                    \
-  if (UseCompressedOops) {                           \
-    InstanceKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
-      start_p, count,                                \
-      do_oop, assert_fn)                             \
-  } else {                                           \
-    InstanceKlass_SPECIALIZED_OOP_ITERATE(oop,       \
-      start_p, count,                                \
-      do_oop, assert_fn)                             \
-  }                                                  \
-}
-
-#define InstanceKlass_BOUNDED_OOP_ITERATE(start_p, count, low, high,    \
-                                          do_oop, assert_fn) \
-{                                                            \
-  if (UseCompressedOops) {                                   \
-    InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop, \
-      start_p, count,                                        \
-      low, high,                                             \
-      do_oop, assert_fn)                                     \
-  } else {                                                   \
-    InstanceKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop,       \
-      start_p, count,                                        \
-      low, high,                                             \
-      do_oop, assert_fn)                                     \
-  }                                                          \
-}
-
 #define InstanceKlass_OOP_MAP_ITERATE(obj, do_oop, assert_fn)            \
 {                                                                        \
   /* Compute oopmap block range. The common case                         \
@@ -1706,38 +1685,6 @@ template <class T> void assert_nothing(T *p) {}
   }                                                                      \
 }
 
-void instanceKlass::follow_static_fields() {
-  InstanceKlass_OOP_ITERATE( \
-    start_of_static_fields(), static_oop_field_size(), \
-    MarkSweep::mark_and_push(p), \
-    assert_is_in_closed_subset)
-}
-
-#ifndef SERIALGC
-void instanceKlass::follow_static_fields(ParCompactionManager* cm) {
-  InstanceKlass_OOP_ITERATE( \
-    start_of_static_fields(), static_oop_field_size(), \
-    PSParallelCompact::mark_and_push(cm, p), \
-    assert_is_in)
-}
-#endif // SERIALGC
-
-void instanceKlass::adjust_static_fields() {
-  InstanceKlass_OOP_ITERATE( \
-    start_of_static_fields(), static_oop_field_size(), \
-    MarkSweep::adjust_pointer(p), \
-    assert_nothing)
-}
-
-#ifndef SERIALGC
-void instanceKlass::update_static_fields() {
-  InstanceKlass_OOP_ITERATE( \
-    start_of_static_fields(), static_oop_field_size(), \
-    PSParallelCompact::adjust_pointer(p), \
-    assert_nothing)
-}
-#endif // SERIALGC
-
 void instanceKlass::oop_follow_contents(oop obj) {
   assert(obj != NULL, "can't follow the content of NULL object");
   obj->follow_header();
@@ -1824,22 +1771,6 @@ ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
 ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
 #endif // !SERIALGC
 
-void instanceKlass::iterate_static_fields(OopClosure* closure) {
-    InstanceKlass_OOP_ITERATE( \
-      start_of_static_fields(), static_oop_field_size(), \
-      closure->do_oop(p), \
-      assert_is_in_reserved)
-}
-
-void instanceKlass::iterate_static_fields(OopClosure* closure,
-                                          MemRegion mr) {
-  InstanceKlass_BOUNDED_OOP_ITERATE( \
-    start_of_static_fields(), static_oop_field_size(), \
-    mr.start(), mr.end(), \
-    (closure)->do_oop_v(p), \
-    assert_is_in_closed_subset)
-}
-
 int instanceKlass::oop_adjust_pointers(oop obj) {
   int size = size_helper();
   InstanceKlass_OOP_MAP_ITERATE( \
@@ -1868,21 +1799,6 @@ int instanceKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
   return size_helper();
 }
 
-void instanceKlass::push_static_fields(PSPromotionManager* pm) {
-  InstanceKlass_OOP_ITERATE( \
-    start_of_static_fields(), static_oop_field_size(), \
-    if (PSScavenge::should_scavenge(p)) { \
-      pm->claim_or_forward_depth(p); \
-    }, \
-    assert_nothing )
-}
-
-void instanceKlass::copy_static_fields(ParCompactionManager* cm) {
-  InstanceKlass_OOP_ITERATE( \
-    start_of_static_fields(), static_oop_field_size(), \
-    PSParallelCompact::adjust_pointer(p), \
-    assert_is_in)
-}
 #endif // SERIALGC
 
 // This klass is alive but the implementor link is not followed/updated.
@@ -1997,6 +1913,11 @@ void instanceKlass::set_source_debug_extension(Symbol* n) {
   if (_source_debug_extension != NULL) _source_debug_extension->increment_refcount();
 }
 
+address instanceKlass::static_field_addr(int offset) {
+  return (address)(offset + instanceMirrorKlass::offset_of_static_fields() + (intptr_t)java_mirror());
+}
+
+
 const char* instanceKlass::signature_name() const {
   const char* src = (const char*) (name()->as_C_string());
   const int src_length = (int)strlen(src);
@@ -2364,7 +2285,7 @@ nmethod* instanceKlass::lookup_osr_nmethod(const methodOop m, int bci, int comp_
 
 void FieldPrinter::do_field(fieldDescriptor* fd) {
   _st->print(BULLET);
-   if (fd->is_static() || (_obj == NULL)) {
+   if (_obj == NULL) {
      fd->print_on(_st);
      _st->cr();
    } else {
@@ -2394,8 +2315,8 @@ void instanceKlass::oop_print_on(oop obj, outputStream* st) {
   }
 
   st->print_cr(BULLET"---- fields (total size %d words):", oop_size(obj));
-  FieldPrinter print_nonstatic_field(st, obj);
-  do_nonstatic_fields(&print_nonstatic_field);
+  FieldPrinter print_field(st, obj);
+  do_nonstatic_fields(&print_field);
 
   if (as_klassOop() == SystemDictionary::Class_klass()) {
     st->print(BULLET"signature: ");
@@ -2413,9 +2334,15 @@ void instanceKlass::oop_print_on(oop obj, outputStream* st) {
     st->print(BULLET"fake entry for array: ");
     array_klass->print_value_on(st);
     st->cr();
+    st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj));
+    st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj));
+    klassOop real_klass = java_lang_Class::as_klassOop(obj);
+    if (real_klass && real_klass->klass_part()->oop_is_instance()) {
+      instanceKlass::cast(real_klass)->do_local_static_fields(&print_field);
+    }
   } else if (as_klassOop() == SystemDictionary::MethodType_klass()) {
     st->print(BULLET"signature: ");
-    java_dyn_MethodType::print_signature(obj, st);
+    java_lang_invoke_MethodType::print_signature(obj, st);
     st->cr();
   }
 }
@@ -2446,7 +2373,7 @@ void instanceKlass::oop_print_value_on(oop obj, outputStream* st) {
     }
   } else if (as_klassOop() == SystemDictionary::MethodType_klass()) {
     st->print(" = ");
-    java_dyn_MethodType::print_signature(obj, st);
+    java_lang_invoke_MethodType::print_signature(obj, st);
   } else if (java_lang_boxing_object::is_instance(obj)) {
     st->print(" = ");
     java_lang_boxing_object::print(obj, st);
@@ -2555,7 +2482,7 @@ void JNIid::deallocate(JNIid* current) {
 
 
 void JNIid::verify(klassOop holder) {
-  int first_field_offset  = instanceKlass::cast(holder)->offset_of_static_fields();
+  int first_field_offset  = instanceMirrorKlass::offset_of_static_fields();
   int end_field_offset;
   end_field_offset = first_field_offset + (instanceKlass::cast(holder)->static_field_size() * wordSize);
 
diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp
index c2f7da14ba6..07acfc358c0 100644
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp
@@ -75,8 +75,6 @@
 //    [Java vtable length         ]
 //    [oop map cache (stack maps) ]
 //    [EMBEDDED Java vtable             ] size in words = vtable_len
-//    [EMBEDDED static oop fields       ] size in words = static_oop_fields_size
-//    [         static non-oop fields   ] size in words = static_field_size - static_oop_fields_size
 //    [EMBEDDED nonstatic oop-map blocks] size in words = nonstatic_oop_map_size
 //
 //    The embedded nonstatic oop-map blocks are short pairs (offset, length) indicating
@@ -193,8 +191,8 @@ class instanceKlass: public Klass {
   typeArrayOop    _inner_classes;
   // Implementors of this interface (not valid if it overflows)
   klassOop        _implementors[implementors_limit];
-  // invokedynamic bootstrap method (a java.dyn.MethodHandle)
-  oop             _bootstrap_method;
+  // invokedynamic bootstrap method (a java.lang.invoke.MethodHandle)
+  oop             _bootstrap_method;  // AllowTransitionalJSR292 ONLY
   // Annotations for this class, or null if none.
   typeArrayOop    _class_annotations;
   // Annotation objects (byte arrays) for fields, or null if no annotations.
@@ -230,7 +228,7 @@ class instanceKlass: public Klass {
   // (including inherited fields but after header_size()).
   int             _nonstatic_field_size;
   int             _static_field_size;    // number words used by static fields (oop and non-oop) in this klass
-  int             _static_oop_field_size;// number of static oop fields in this klass
+  int             _static_oop_field_count;// number of static oop fields in this klass
   int             _nonstatic_oop_map_size;// size in words of nonstatic oop map blocks
   bool            _is_marked_dependent;  // used for marking during flushing and deoptimization
   bool            _rewritten;            // methods rewritten.
@@ -281,8 +279,8 @@ class instanceKlass: public Klass {
   int static_field_size() const            { return _static_field_size; }
   void set_static_field_size(int size)     { _static_field_size = size; }
 
-  int static_oop_field_size() const        { return _static_oop_field_size; }
-  void set_static_oop_field_size(int size) { _static_oop_field_size = size; }
+  int static_oop_field_count() const        { return _static_oop_field_count; }
+  void set_static_oop_field_count(int size) { _static_oop_field_count = size; }
 
   // Java vtable
   int  vtable_length() const               { return _vtable_len; }
@@ -529,7 +527,7 @@ class instanceKlass: public Klass {
                                                         _enclosing_method_method_index = method_index; }
 
   // JSR 292 support
-  oop bootstrap_method() const                        { return _bootstrap_method; }
+  oop bootstrap_method() const                        { return _bootstrap_method; }  // AllowTransitionalJSR292 ONLY
   void set_bootstrap_method(oop mh)                   { oop_store(&_bootstrap_method, mh); }
 
   // jmethodID support
@@ -660,6 +658,7 @@ class instanceKlass: public Klass {
 
   // Casting from klassOop
   static instanceKlass* cast(klassOop k) {
+    assert(k->is_klass(), "must be");
     Klass* kp = k->klass_part();
     assert(kp->null_vtbl() || kp->oop_is_instance_slow(), "cast to instanceKlass");
     return (instanceKlass*) kp;
@@ -667,7 +666,7 @@ class instanceKlass: public Klass {
 
   // Sizing (in words)
   static int header_size()            { return align_object_offset(oopDesc::header_size() + sizeof(instanceKlass)/HeapWordSize); }
-  int object_size() const             { return object_size(align_object_offset(vtable_length()) + align_object_offset(itable_length()) + static_field_size() + nonstatic_oop_map_size()); }
+  int object_size() const             { return object_size(align_object_offset(vtable_length()) + align_object_offset(itable_length()) + nonstatic_oop_map_size()); }
   static int vtable_start_offset()    { return header_size(); }
   static int vtable_length_offset()   { return oopDesc::header_size() + offset_of(instanceKlass, _vtable_len) / HeapWordSize; }
   static int object_size(int extra)   { return align_object_size(header_size() + extra); }
@@ -676,20 +675,12 @@ class instanceKlass: public Klass {
   intptr_t* start_of_itable() const        { return start_of_vtable() + align_object_offset(vtable_length()); }
   int  itable_offset_in_words() const { return start_of_itable() - (intptr_t*)as_klassOop(); }
 
-  // Static field offset is an offset into the Heap, should be converted by
-  // based on UseCompressedOop for traversal
-  HeapWord* start_of_static_fields() const {
-    return (HeapWord*)(start_of_itable() + align_object_offset(itable_length()));
-  }
-
   intptr_t* end_of_itable() const          { return start_of_itable() + itable_length(); }
 
-  int offset_of_static_fields() const {
-    return (intptr_t)start_of_static_fields() - (intptr_t)as_klassOop();
-  }
+  address static_field_addr(int offset);
 
   OopMapBlock* start_of_nonstatic_oop_maps() const {
-    return (OopMapBlock*) (start_of_static_fields() + static_field_size());
+    return (OopMapBlock*)(start_of_itable() + align_object_offset(itable_length()));
   }
 
   // Allocation profiling support
@@ -719,8 +710,6 @@ class instanceKlass: public Klass {
 
   // Garbage collection
   void oop_follow_contents(oop obj);
-  void follow_static_fields();
-  void adjust_static_fields();
   int  oop_adjust_pointers(oop obj);
   bool object_is_parsable() const { return _init_state != unparsable_by_gc; }
        // Value of _init_state must be zero (unparsable_by_gc) when klass field is set.
@@ -732,16 +721,6 @@ class instanceKlass: public Klass {
   // Parallel Scavenge and Parallel Old
   PARALLEL_GC_DECLS
 
-#ifndef SERIALGC
-  // Parallel Scavenge
-  void push_static_fields(PSPromotionManager* pm);
-
-  // Parallel Old
-  void follow_static_fields(ParCompactionManager* cm);
-  void copy_static_fields(ParCompactionManager* cm);
-  void update_static_fields();
-#endif // SERIALGC
-
   // Naming
   const char* signature_name() const;
 
@@ -770,9 +749,6 @@ class instanceKlass: public Klass {
   ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
 #endif // !SERIALGC
 
-  void iterate_static_fields(OopClosure* closure);
-  void iterate_static_fields(OopClosure* closure, MemRegion mr);
-
 private:
   // initialization state
 #ifdef ASSERT
@@ -817,7 +793,7 @@ private:
   oop* adr_signers() const           { return (oop*)&this->_signers;}
   oop* adr_inner_classes() const     { return (oop*)&this->_inner_classes;}
   oop* adr_implementors() const      { return (oop*)&this->_implementors[0];}
-  oop* adr_bootstrap_method() const  { return (oop*)&this->_bootstrap_method;}
+  oop* adr_bootstrap_method() const  { return (oop*)&this->_bootstrap_method;}  // AllowTransitionalJSR292 ONLY
   oop* adr_methods_jmethod_ids() const             { return (oop*)&this->_methods_jmethod_ids;}
   oop* adr_methods_cached_itable_indices() const   { return (oop*)&this->_methods_cached_itable_indices;}
   oop* adr_class_annotations() const   { return (oop*)&this->_class_annotations;}
@@ -926,6 +902,10 @@ class JNIid: public CHeapObj {
   // Identifier lookup
   JNIid* find(int offset);
 
+  bool find_local_field(fieldDescriptor* fd) {
+    return instanceKlass::cast(holder())->find_local_field_from_offset(offset(), true, fd);
+  }
+
   // Garbage collection support
   oop* holder_addr() { return (oop*)&_holder; }
   void oops_do(OopClosure* f);
diff --git a/hotspot/src/share/vm/oops/instanceKlassKlass.cpp b/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
index 150621fa708..897c5157c36 100644
--- a/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
+++ b/hotspot/src/share/vm/oops/instanceKlassKlass.cpp
@@ -31,6 +31,7 @@
 #include "memory/gcLocker.hpp"
 #include "oops/constantPoolOop.hpp"
 #include "oops/instanceKlass.hpp"
+#include "oops/instanceMirrorKlass.hpp"
 #include "oops/instanceKlassKlass.hpp"
 #include "oops/instanceRefKlass.hpp"
 #include "oops/objArrayKlassKlass.hpp"
@@ -86,7 +87,6 @@ void instanceKlassKlass::oop_follow_contents(oop obj) {
   assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass");
 
   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
-  ik->follow_static_fields();
   {
     HandleMark hm;
     ik->vtable()->oop_follow_contents();
@@ -127,7 +127,6 @@ void instanceKlassKlass::oop_follow_contents(ParCompactionManager* cm,
   assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass");
 
   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
-  ik->follow_static_fields(cm);
   ik->vtable()->oop_follow_contents(cm);
   ik->itable()->oop_follow_contents(cm);
 
@@ -168,7 +167,6 @@ int instanceKlassKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
   // Don't call size() or oop_size() since that is a virtual call.
   int size = ik->object_size();
 
-  ik->iterate_static_fields(blk);
   ik->vtable()->oop_oop_iterate(blk);
   ik->itable()->oop_oop_iterate(blk);
 
@@ -209,7 +207,6 @@ int instanceKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk,
   // Don't call size() or oop_size() since that is a virtual call.
   int size = ik->object_size();
 
-  ik->iterate_static_fields(blk, mr);
   ik->vtable()->oop_oop_iterate_m(blk, mr);
   ik->itable()->oop_oop_iterate_m(blk, mr);
 
@@ -266,7 +263,6 @@ int instanceKlassKlass::oop_adjust_pointers(oop obj) {
   assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), "must be instance klass");
 
   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
-  ik->adjust_static_fields();
   ik->vtable()->oop_adjust_pointers();
   ik->itable()->oop_adjust_pointers();
 
@@ -300,7 +296,6 @@ int instanceKlassKlass::oop_adjust_pointers(oop obj) {
 #ifndef SERIALGC
 void instanceKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
-  ik->push_static_fields(pm);
 
   oop* loader_addr = ik->adr_class_loader();
   if (PSScavenge::should_scavenge(loader_addr)) {
@@ -336,7 +331,6 @@ int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
          "must be instance klass");
 
   instanceKlass* ik = instanceKlass::cast(klassOop(obj));
-  ik->update_static_fields();
   ik->vtable()->oop_update_pointers(cm);
   ik->itable()->oop_update_pointers(cm);
 
@@ -356,22 +350,28 @@ int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
 #endif // SERIALGC
 
 klassOop
-instanceKlassKlass::allocate_instance_klass(int vtable_len, int itable_len,
+instanceKlassKlass::allocate_instance_klass(Symbol* name, int vtable_len, int itable_len,
                                             int static_field_size,
                                             unsigned nonstatic_oop_map_count,
                                             ReferenceType rt, TRAPS) {
 
   const int nonstatic_oop_map_size =
     instanceKlass::nonstatic_oop_map_size(nonstatic_oop_map_count);
-  int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + static_field_size + nonstatic_oop_map_size);
+  int size = instanceKlass::object_size(align_object_offset(vtable_len) + align_object_offset(itable_len) + nonstatic_oop_map_size);
 
   // Allocation
   KlassHandle h_this_klass(THREAD, as_klassOop());
   KlassHandle k;
   if (rt == REF_NONE) {
-    // regular klass
-    instanceKlass o;
-    k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
+    if (name != vmSymbols::java_lang_Class()) {
+      // regular klass
+      instanceKlass o;
+      k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
+    } else {
+      // Class
+      instanceMirrorKlass o;
+      k = base_create_klass(h_this_klass, size, o.vtbl_value(), CHECK_NULL);
+    }
   } else {
     // reference klass
     instanceRefKlass o;
@@ -408,7 +408,7 @@ instanceKlassKlass::allocate_instance_klass(int vtable_len, int itable_len,
     ik->set_source_debug_extension(NULL);
     ik->set_array_name(NULL);
     ik->set_inner_classes(NULL);
-    ik->set_static_oop_field_size(0);
+    ik->set_static_oop_field_count(0);
     ik->set_nonstatic_field_size(0);
     ik->set_is_marked_dependent(false);
     ik->set_init_state(instanceKlass::allocated);
@@ -442,9 +442,6 @@ instanceKlassKlass::allocate_instance_klass(int vtable_len, int itable_len,
     // To get verify to work - must be set to partial loaded before first GC point.
     k()->set_partially_loaded();
   }
-
-  // GC can happen here
-  java_lang_Class::create_mirror(k, CHECK_NULL); // Allocate mirror
   return k();
 }
 
@@ -566,13 +563,6 @@ void instanceKlassKlass::oop_print_on(oop obj, outputStream* st) {
   FieldPrinter print_nonstatic_field(st);
   ik->do_nonstatic_fields(&print_nonstatic_field);
 
-  st->print(BULLET"static oop maps:     ");
-  if (ik->static_oop_field_size() > 0) {
-    int first_offset = ik->offset_of_static_fields();
-    st->print("%d-%d", first_offset, first_offset + ik->static_oop_field_size() - 1);
-  }
-  st->cr();
-
   st->print(BULLET"non-static oop maps: ");
   OopMapBlock* map     = ik->start_of_nonstatic_oop_maps();
   OopMapBlock* end_map = map + ik->nonstatic_oop_map_count();
@@ -630,7 +620,6 @@ void instanceKlassKlass::oop_verify_on(oop obj, outputStream* st) {
 
     // Verify static fields
     VerifyFieldClosure blk;
-    ik->iterate_static_fields(&blk);
 
     // Verify vtables
     if (ik->is_linked()) {
diff --git a/hotspot/src/share/vm/oops/instanceKlassKlass.hpp b/hotspot/src/share/vm/oops/instanceKlassKlass.hpp
index 4e0eb1125c1..9cbabe24644 100644
--- a/hotspot/src/share/vm/oops/instanceKlassKlass.hpp
+++ b/hotspot/src/share/vm/oops/instanceKlassKlass.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,8 @@ class instanceKlassKlass : public klassKlass {
   // Allocation
   DEFINE_ALLOCATE_PERMANENT(instanceKlassKlass);
   static klassOop create_klass(TRAPS);
-  klassOop allocate_instance_klass(int vtable_len,
+  klassOop allocate_instance_klass(Symbol* name,
+                                   int vtable_len,
                                    int itable_len,
                                    int static_field_size,
                                    unsigned int nonstatic_oop_map_count,
diff --git a/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp
new file mode 100644
index 00000000000..8f6644139c4
--- /dev/null
+++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.cpp
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#include "precompiled.hpp"
+#include "classfile/javaClasses.hpp"
+#include "classfile/systemDictionary.hpp"
+#include "gc_implementation/shared/markSweep.inline.hpp"
+#include "gc_interface/collectedHeap.inline.hpp"
+#include "memory/genOopClosures.inline.hpp"
+#include "memory/oopFactory.hpp"
+#include "memory/permGen.hpp"
+#include "oops/instanceKlass.hpp"
+#include "oops/instanceMirrorKlass.hpp"
+#include "oops/instanceOop.hpp"
+#include "oops/oop.inline.hpp"
+#include "oops/symbol.hpp"
+#include "runtime/handles.inline.hpp"
+#ifndef SERIALGC
+#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
+#include "gc_implementation/g1/g1OopClosures.inline.hpp"
+#include "gc_implementation/g1/g1RemSet.inline.hpp"
+#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
+#include "gc_implementation/parNew/parOopClosures.inline.hpp"
+#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
+#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
+#include "oops/oop.pcgc.inline.hpp"
+#endif
+
+int instanceMirrorKlass::_offset_of_static_fields = 0;
+
+#ifdef ASSERT
+template <class T> void assert_is_in(T *p) {
+  T heap_oop = oopDesc::load_heap_oop(p);
+  if (!oopDesc::is_null(heap_oop)) {
+    oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
+    assert(Universe::heap()->is_in(o), "should be in heap");
+  }
+}
+template <class T> void assert_is_in_closed_subset(T *p) {
+  T heap_oop = oopDesc::load_heap_oop(p);
+  if (!oopDesc::is_null(heap_oop)) {
+    oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
+    assert(Universe::heap()->is_in_closed_subset(o), "should be in closed");
+  }
+}
+template <class T> void assert_is_in_reserved(T *p) {
+  T heap_oop = oopDesc::load_heap_oop(p);
+  if (!oopDesc::is_null(heap_oop)) {
+    oop o = oopDesc::decode_heap_oop_not_null(heap_oop);
+    assert(Universe::heap()->is_in_reserved(o), "should be in reserved");
+  }
+}
+template <class T> void assert_nothing(T *p) {}
+
+#else
+template <class T> void assert_is_in(T *p) {}
+template <class T> void assert_is_in_closed_subset(T *p) {}
+template <class T> void assert_is_in_reserved(T *p) {}
+template <class T> void assert_nothing(T *p) {}
+#endif // ASSERT
+
+#define InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE( \
+  T, start_p, count, do_oop,                         \
+  assert_fn)                                         \
+{                                                    \
+  T* p         = (T*)(start_p);                      \
+  T* const end = p + (count);                        \
+  while (p < end) {                                  \
+    (assert_fn)(p);                                  \
+    do_oop;                                          \
+    ++p;                                             \
+  }                                                  \
+}
+
+#define InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE( \
+  T, start_p, count, low, high,                              \
+  do_oop, assert_fn)                                         \
+{                                                            \
+  T* const l = (T*)(low);                                    \
+  T* const h = (T*)(high);                                   \
+  assert(mask_bits((intptr_t)l, sizeof(T)-1) == 0 &&         \
+         mask_bits((intptr_t)h, sizeof(T)-1) == 0,           \
+         "bounded region must be properly aligned");         \
+  T* p       = (T*)(start_p);                                \
+  T* end     = p + (count);                                  \
+  if (p < l) p = l;                                          \
+  if (end > h) end = h;                                      \
+  while (p < end) {                                          \
+    (assert_fn)(p);                                          \
+    do_oop;                                                  \
+    ++p;                                                     \
+  }                                                          \
+}
+
+
+#define InstanceMirrorKlass_OOP_ITERATE(start_p, count,    \
+                                  do_oop, assert_fn)       \
+{                                                          \
+  if (UseCompressedOops) {                                 \
+    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE(narrowOop, \
+      start_p, count,                                      \
+      do_oop, assert_fn)                                   \
+  } else {                                                 \
+    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE(oop,       \
+      start_p, count,                                      \
+      do_oop, assert_fn)                                   \
+  }                                                        \
+}
+
+// The following macros call specialized macros, passing either oop or
+// narrowOop as the specialization type.  These test the UseCompressedOops
+// flag.
+#define InstanceMirrorKlass_BOUNDED_OOP_ITERATE(start_p, count, low, high, \
+                                          do_oop, assert_fn)               \
+{                                                                          \
+  if (UseCompressedOops) {                                                 \
+    InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(narrowOop,         \
+      start_p, count,                                                      \
+      low, high,                                                           \
+      do_oop, assert_fn)                                                   \
+  } else {                                                                 \
+    InstanceMirrorKlass_SPECIALIZED_BOUNDED_OOP_ITERATE(oop,               \
+      start_p, count,                                                      \
+      low, high,                                                           \
+      do_oop, assert_fn)                                                   \
+  }                                                                        \
+}
+
+
+void instanceMirrorKlass::oop_follow_contents(oop obj) {
+  instanceKlass::oop_follow_contents(obj);
+  InstanceMirrorKlass_OOP_ITERATE(                                                    \
+    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
+    MarkSweep::mark_and_push(p),                                                      \
+    assert_is_in_closed_subset)
+}
+
+#ifndef SERIALGC
+void instanceMirrorKlass::oop_follow_contents(ParCompactionManager* cm,
+                                              oop obj) {
+  instanceKlass::oop_follow_contents(cm, obj);
+  InstanceMirrorKlass_OOP_ITERATE(                                                    \
+    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
+    PSParallelCompact::mark_and_push(cm, p),                                          \
+    assert_is_in)
+}
+#endif // SERIALGC
+
+int instanceMirrorKlass::oop_adjust_pointers(oop obj) {
+  int size = oop_size(obj);
+  instanceKlass::oop_adjust_pointers(obj);
+  InstanceMirrorKlass_OOP_ITERATE(                                                    \
+    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
+    MarkSweep::adjust_pointer(p),                                                     \
+    assert_nothing)
+  return size;
+}
+
+#define InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(T, nv_suffix)                \
+  InstanceMirrorKlass_OOP_ITERATE(                                                    \
+    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
+      (closure)->do_oop##nv_suffix(p),                                                \
+    assert_is_in_closed_subset)                                                       \
+  return oop_size(obj);                                                               \
+
+#define InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(T, nv_suffix, mr)         \
+  InstanceMirrorKlass_BOUNDED_OOP_ITERATE(                                            \
+    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),        \
+    mr.start(), mr.end(),                                                             \
+      (closure)->do_oop##nv_suffix(p),                                                \
+    assert_is_in_closed_subset)                                                       \
+  return oop_size(obj);                                                               \
+
+
+// Macro to define instanceMirrorKlass::oop_oop_iterate for virtual/nonvirtual for
+// all closures.  Macros calling macros above for each oop size.
+
+#define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN(OopClosureType, nv_suffix)           \
+                                                                                      \
+int instanceMirrorKlass::                                                             \
+oop_oop_iterate##nv_suffix(oop obj, OopClosureType* closure) {                        \
+  /* Get size before changing pointers */                                             \
+  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);      \
+                                                                                      \
+  instanceKlass::oop_oop_iterate##nv_suffix(obj, closure);                            \
+                                                                                      \
+  if (UseCompressedOops) {                                                            \
+    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(narrowOop, nv_suffix);           \
+  } else {                                                                            \
+    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(oop, nv_suffix);                 \
+  }                                                                                   \
+}
+
+#ifndef SERIALGC
+#define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN(OopClosureType, nv_suffix) \
+                                                                                      \
+int instanceMirrorKlass::                                                             \
+oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* closure) {              \
+  /* Get size before changing pointers */                                             \
+  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);      \
+                                                                                      \
+  instanceKlass::oop_oop_iterate_backwards##nv_suffix(obj, closure);                  \
+                                                                                      \
+  if (UseCompressedOops) {                                                            \
+    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(narrowOop, nv_suffix);           \
+  } else {                                                                            \
+    InstanceMirrorKlass_SPECIALIZED_OOP_ITERATE_DEFN(oop, nv_suffix);                 \
+  }                                                                                   \
+}
+#endif // !SERIALGC
+
+
+#define InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m(OopClosureType, nv_suffix)         \
+                                                                                      \
+int instanceMirrorKlass::                                                             \
+oop_oop_iterate##nv_suffix##_m(oop obj,                                               \
+                               OopClosureType* closure,                               \
+                               MemRegion mr) {                                        \
+  SpecializationStats::record_iterate_call##nv_suffix(SpecializationStats::irk);      \
+                                                                                      \
+  instanceKlass::oop_oop_iterate##nv_suffix##_m(obj, closure, mr);                    \
+  if (UseCompressedOops) {                                                            \
+    InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(narrowOop, nv_suffix, mr);    \
+  } else {                                                                            \
+    InstanceMirrorKlass_BOUNDED_SPECIALIZED_OOP_ITERATE(oop, nv_suffix, mr);          \
+  }                                                                                   \
+}
+
+ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN)
+ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN)
+#ifndef SERIALGC
+ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
+ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DEFN)
+#endif // SERIALGC
+ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m)
+ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DEFN_m)
+
+#ifndef SERIALGC
+void instanceMirrorKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
+  instanceKlass::oop_push_contents(pm, obj);
+  InstanceMirrorKlass_OOP_ITERATE(                                            \
+    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\
+    if (PSScavenge::should_scavenge(p)) {                                     \
+      pm->claim_or_forward_depth(p);                                          \
+    },                                                                        \
+    assert_nothing )
+}
+
+int instanceMirrorKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
+  instanceKlass::oop_update_pointers(cm, obj);
+  InstanceMirrorKlass_OOP_ITERATE(                                            \
+    start_of_static_fields(obj), java_lang_Class::static_oop_field_count(obj),\
+    PSParallelCompact::adjust_pointer(p),                                     \
+    assert_nothing)
+  return oop_size(obj);
+}
+#endif // SERIALGC
+
+int instanceMirrorKlass::instance_size(KlassHandle k) {
+  if (k() != NULL && k->oop_is_instance()) {
+    return align_object_size(size_helper() + instanceKlass::cast(k())->static_field_size());
+  }
+  return size_helper();
+}
+
+instanceOop instanceMirrorKlass::allocate_instance(KlassHandle k, TRAPS) {
+  // Query before forming handle.
+  int size = instance_size(k);
+  KlassHandle h_k(THREAD, as_klassOop());
+  instanceOop i;
+
+  if (JavaObjectsInPerm) {
+    i = (instanceOop) CollectedHeap::permanent_obj_allocate(h_k, size, CHECK_NULL);
+  } else {
+    assert(ScavengeRootsInCode > 0, "must be");
+    i = (instanceOop) CollectedHeap::obj_allocate(h_k, size, CHECK_NULL);
+  }
+
+  return i;
+}
+
+int instanceMirrorKlass::oop_size(oop obj) const {
+  return java_lang_Class::oop_size(obj);
+}
+
+int instanceMirrorKlass::compute_static_oop_field_count(oop obj) {
+  klassOop k = java_lang_Class::as_klassOop(obj);
+  if (k != NULL && k->klass_part()->oop_is_instance()) {
+    return instanceKlass::cast(k)->static_oop_field_count();
+  }
+  return 0;
+}
diff --git a/hotspot/src/share/vm/oops/instanceMirrorKlass.hpp b/hotspot/src/share/vm/oops/instanceMirrorKlass.hpp
new file mode 100644
index 00000000000..0556dc5abd4
--- /dev/null
+++ b/hotspot/src/share/vm/oops/instanceMirrorKlass.hpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+#ifndef SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
+#define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
+
+#include "oops/instanceKlass.hpp"
+
+// An instanceMirrorKlass is a specialized instanceKlass for
+// java.lang.Class instances.  These instances are special because
+// they contain the static fields of the class in addition to the
+// normal fields of Class.  This means they are variable sized
+// instances and need special logic for computing their size and for
+// iteration of their oops.
+
+
+class instanceMirrorKlass: public instanceKlass {
+ private:
+  static int _offset_of_static_fields;
+
+ public:
+  // Type testing
+  bool oop_is_instanceMirror() const             { return true; }
+
+  // Casting from klassOop
+  static instanceMirrorKlass* cast(klassOop k) {
+    assert(k->klass_part()->oop_is_instanceMirror(), "cast to instanceMirrorKlass");
+    return (instanceMirrorKlass*) k->klass_part();
+  }
+
+  // Returns the size of the instance including the extra static fields.
+  virtual int oop_size(oop obj) const;
+
+  // Static field offset is an offset into the Heap, should be converted by
+  // based on UseCompressedOop for traversal
+  static HeapWord* start_of_static_fields(oop obj) {
+    return (HeapWord*)((intptr_t)obj + offset_of_static_fields());
+  }
+
+  static void init_offset_of_static_fields() {
+    // Cache the offset of the static fields in the Class instance
+    assert(_offset_of_static_fields == 0, "once");
+    _offset_of_static_fields = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
+  }
+
+  static int offset_of_static_fields() {
+    return _offset_of_static_fields;
+  }
+
+  int compute_static_oop_field_count(oop obj);
+
+  // Given a Klass return the size of the instance
+  int instance_size(KlassHandle k);
+
+  // allocation
+  DEFINE_ALLOCATE_PERMANENT(instanceMirrorKlass);
+  instanceOop allocate_instance(KlassHandle k, TRAPS);
+
+  // Garbage collection
+  int  oop_adjust_pointers(oop obj);
+  void oop_follow_contents(oop obj);
+
+  // Parallel Scavenge and Parallel Old
+  PARALLEL_GC_DECLS
+
+  int oop_oop_iterate(oop obj, OopClosure* blk) {
+    return oop_oop_iterate_v(obj, blk);
+  }
+  int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
+    return oop_oop_iterate_v_m(obj, blk, mr);
+  }
+
+#define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)           \
+  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);                       \
+  int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
+
+  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
+  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
+
+#ifndef SERIALGC
+#define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \
+  int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
+
+  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
+  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
+#endif // !SERIALGC
+};
+
+#endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp
index 4dbff59e490..407b1ef295a 100644
--- a/hotspot/src/share/vm/oops/klass.hpp
+++ b/hotspot/src/share/vm/oops/klass.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -577,6 +577,7 @@ class Klass : public Klass_vtbl {
  public:
   // type testing operations
   virtual bool oop_is_instance_slow()       const { return false; }
+  virtual bool oop_is_instanceMirror()      const { return false; }
   virtual bool oop_is_instanceRef()         const { return false; }
   virtual bool oop_is_array()               const { return false; }
   virtual bool oop_is_objArray_slow()       const { return false; }
@@ -811,4 +812,8 @@ class Klass : public Klass_vtbl {
 #endif
 };
 
+
+inline oop klassOopDesc::java_mirror() const                        { return klass_part()->java_mirror(); }
+
+
 #endif // SHARE_VM_OOPS_KLASS_HPP
diff --git a/hotspot/src/share/vm/oops/klassKlass.cpp b/hotspot/src/share/vm/oops/klassKlass.cpp
index 6411609d73e..06809d526d9 100644
--- a/hotspot/src/share/vm/oops/klassKlass.cpp
+++ b/hotspot/src/share/vm/oops/klassKlass.cpp
@@ -41,6 +41,10 @@
 #include "oops/typeArrayKlass.hpp"
 #include "runtime/handles.inline.hpp"
 #ifndef SERIALGC
+#include "gc_implementation/parNew/parOopClosures.inline.hpp"
+#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
+#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
+#include "memory/cardTableRS.hpp"
 #include "oops/oop.pcgc.inline.hpp"
 #endif
 
@@ -175,6 +179,12 @@ int klassKlass::oop_adjust_pointers(oop obj) {
 
 #ifndef SERIALGC
 void klassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
+  Klass* k = Klass::cast(klassOop(obj));
+
+  oop* p = k->adr_java_mirror();
+  if (PSScavenge::should_scavenge(p)) {
+    pm->claim_or_forward_depth(p);
+  }
 }
 
 int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
@@ -233,7 +243,7 @@ void klassKlass::oop_verify_on(oop obj, outputStream* st) {
 
   if (k->java_mirror() != NULL || (k->oop_is_instance() && instanceKlass::cast(klassOop(obj))->is_loaded())) {
     guarantee(k->java_mirror() != NULL,          "should be allocated");
-    guarantee(k->java_mirror()->is_perm(),       "should be in permspace");
+    guarantee(k->java_mirror()->is_perm() || !JavaObjectsInPerm,       "should be in permspace");
     guarantee(k->java_mirror()->is_instance(),   "should be instance");
   }
 }
diff --git a/hotspot/src/share/vm/oops/klassOop.hpp b/hotspot/src/share/vm/oops/klassOop.hpp
index bc6e2bb3612..7617b8590d1 100644
--- a/hotspot/src/share/vm/oops/klassOop.hpp
+++ b/hotspot/src/share/vm/oops/klassOop.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,73 @@ class klassOopDesc : public oopDesc {
   static int klass_part_offset_in_bytes()        { return sizeof(klassOopDesc); }
 
   // returns the Klass part containing dispatching behavior
-  Klass* klass_part()                            { return (Klass*)((address)this + klass_part_offset_in_bytes()); }
+  Klass* klass_part() const                      { return (Klass*)((address)this + klass_part_offset_in_bytes()); }
+
+  // Convenience wrapper
+  inline oop java_mirror() const;
+
+ private:
+  // These have no implementation since klassOop should never be accessed in this fashion
+  oop obj_field(int offset) const;
+  void obj_field_put(int offset, oop value);
+  void obj_field_raw_put(int offset, oop value);
+
+  jbyte byte_field(int offset) const;
+  void byte_field_put(int offset, jbyte contents);
+
+  jchar char_field(int offset) const;
+  void char_field_put(int offset, jchar contents);
+
+  jboolean bool_field(int offset) const;
+  void bool_field_put(int offset, jboolean contents);
+
+  jint int_field(int offset) const;
+  void int_field_put(int offset, jint contents);
+
+  jshort short_field(int offset) const;
+  void short_field_put(int offset, jshort contents);
+
+  jlong long_field(int offset) const;
+  void long_field_put(int offset, jlong contents);
+
+  jfloat float_field(int offset) const;
+  void float_field_put(int offset, jfloat contents);
+
+  jdouble double_field(int offset) const;
+  void double_field_put(int offset, jdouble contents);
+
+  address address_field(int offset) const;
+  void address_field_put(int offset, address contents);
+
+  oop obj_field_acquire(int offset) const;
+  void release_obj_field_put(int offset, oop value);
+
+  jbyte byte_field_acquire(int offset) const;
+  void release_byte_field_put(int offset, jbyte contents);
+
+  jchar char_field_acquire(int offset) const;
+  void release_char_field_put(int offset, jchar contents);
+
+  jboolean bool_field_acquire(int offset) const;
+  void release_bool_field_put(int offset, jboolean contents);
+
+  jint int_field_acquire(int offset) const;
+  void release_int_field_put(int offset, jint contents);
+
+  jshort short_field_acquire(int offset) const;
+  void release_short_field_put(int offset, jshort contents);
+
+  jlong long_field_acquire(int offset) const;
+  void release_long_field_put(int offset, jlong contents);
+
+  jfloat float_field_acquire(int offset) const;
+  void release_float_field_put(int offset, jfloat contents);
+
+  jdouble double_field_acquire(int offset) const;
+  void release_double_field_put(int offset, jdouble contents);
+
+  address address_field_acquire(int offset) const;
+  void release_address_field_put(int offset, address contents);
 };
 
 #endif // SHARE_VM_OOPS_KLASSOOP_HPP
diff --git a/hotspot/src/share/vm/oops/klassVtable.cpp b/hotspot/src/share/vm/oops/klassVtable.cpp
index f0939cb6919..5436f534348 100644
--- a/hotspot/src/share/vm/oops/klassVtable.cpp
+++ b/hotspot/src/share/vm/oops/klassVtable.cpp
@@ -883,7 +883,7 @@ void klassItable::initialize_itable_for_interface(int method_table_offset, Klass
   int ime_num = 0;
 
   // Skip first methodOop if it is a class initializer
-  int i = ((methodOop)methods()->obj_at(0))->name() != vmSymbols::class_initializer_name() ? 0 : 1;
+  int i = ((methodOop)methods()->obj_at(0))->is_static_initializer() ? 1 : 0;
 
   // m, method_name, method_signature, klass reset each loop so they
   // don't need preserving across check_signature_loaders call
@@ -1095,7 +1095,7 @@ void klassItable::setup_itable_offset_table(instanceKlassHandle klass) {
   itableOffsetEntry* ioe = (itableOffsetEntry*)klass->start_of_itable();
   itableMethodEntry* ime = (itableMethodEntry*)(ioe + nof_interfaces);
   intptr_t* end               = klass->end_of_itable();
-  assert((oop*)(ime + nof_methods) <= (oop*)klass->start_of_static_fields(), "wrong offset calculation (1)");
+  assert((oop*)(ime + nof_methods) <= (oop*)klass->start_of_nonstatic_oop_maps(), "wrong offset calculation (1)");
   assert((oop*)(end) == (oop*)(ime + nof_methods),                      "wrong offset calculation (2)");
 
   // Visit all interfaces and initialize itable offset table
@@ -1121,7 +1121,7 @@ int klassItable::compute_itable_index(methodOop m) {
     assert(index < methods->length(), "should find index for resolve_invoke");
   }
   // Adjust for <clinit>, which is left out of table if first method
-  if (methods->length() > 0 && ((methodOop)methods->obj_at(0))->name() == vmSymbols::class_initializer_name()) {
+  if (methods->length() > 0 && ((methodOop)methods->obj_at(0))->is_static_initializer()) {
     index--;
   }
   return index;
@@ -1135,7 +1135,7 @@ methodOop klassItable::method_for_itable_index(klassOop intf, int itable_index)
 
   int index = itable_index;
   // Adjust for <clinit>, which is left out of table if first method
-  if (methods->length() > 0 && ((methodOop)methods->obj_at(0))->name() == vmSymbols::class_initializer_name()) {
+  if (methods->length() > 0 && ((methodOop)methods->obj_at(0))->is_static_initializer()) {
     index++;
   }
 
diff --git a/hotspot/src/share/vm/oops/methodDataOop.hpp b/hotspot/src/share/vm/oops/methodDataOop.hpp
index 906b18ea86b..6f556747c03 100644
--- a/hotspot/src/share/vm/oops/methodDataOop.hpp
+++ b/hotspot/src/share/vm/oops/methodDataOop.hpp
@@ -228,7 +228,7 @@ public:
     return byte_offset_of(DataLayout, _header._struct._bci);
   }
   static ByteSize cell_offset(int index) {
-    return byte_offset_of(DataLayout, _cells[index]);
+    return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size);
   }
   // Return a value which, when or-ed as a byte into _flags, sets the flag.
   static int flag_number_to_byte_constant(int flag_number) {
diff --git a/hotspot/src/share/vm/oops/methodKlass.cpp b/hotspot/src/share/vm/oops/methodKlass.cpp
index 85ac2c4cb8f..f8d15108e75 100644
--- a/hotspot/src/share/vm/oops/methodKlass.cpp
+++ b/hotspot/src/share/vm/oops/methodKlass.cpp
@@ -103,6 +103,12 @@ methodOop methodKlass::allocate(constMethodHandle xconst,
   m->backedge_counter()->init();
   m->clear_number_of_breakpoints();
 
+#ifdef TIERED
+  m->set_rate(0);
+  m->set_prev_event_count(0);
+  m->set_prev_time(0);
+#endif
+
   assert(m->is_parsable(), "must be parsable here.");
   assert(m->size() == size, "wrong size for object");
   // We should not publish an uprasable object's reference
diff --git a/hotspot/src/share/vm/oops/methodOop.cpp b/hotspot/src/share/vm/oops/methodOop.cpp
index dad734460a9..16d42b0262b 100644
--- a/hotspot/src/share/vm/oops/methodOop.cpp
+++ b/hotspot/src/share/vm/oops/methodOop.cpp
@@ -466,7 +466,20 @@ bool methodOopDesc::is_accessor() const {
 
 
 bool methodOopDesc::is_initializer() const {
-  return name() == vmSymbols::object_initializer_name() || name() == vmSymbols::class_initializer_name();
+  return name() == vmSymbols::object_initializer_name() || is_static_initializer();
+}
+
+bool methodOopDesc::has_valid_initializer_flags() const {
+  return (is_static() ||
+          instanceKlass::cast(method_holder())->major_version() < 51);
+}
+
+bool methodOopDesc::is_static_initializer() const {
+  // For classfiles version 51 or greater, ensure that the clinit method is
+  // static.  Non-static methods with the name "<clinit>" are not static
+  // initializers. (older classfiles exempted for backward compatibility)
+  return name() == vmSymbols::class_initializer_name() &&
+         has_valid_initializer_flags();
 }
 
 
@@ -842,7 +855,7 @@ bool methodOopDesc::is_method_handle_invoke_name(vmSymbols::SID name_sid) {
   case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name):
     return true;
   }
-  if (AllowTransitionalJSR292
+  if ((AllowTransitionalJSR292 || AllowInvokeForInvokeGeneric)
       && name_sid == vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name))
     return true;
   return false;
@@ -852,7 +865,7 @@ bool methodOopDesc::is_method_handle_invoke_name(vmSymbols::SID name_sid) {
 enum {
   _imcp_invoke_name = 1,        // utf8: 'invokeExact' or 'invokeGeneric'
   _imcp_invoke_signature,       // utf8: (variable Symbol*)
-  _imcp_method_type_value,      // string: (variable java/dyn/MethodType, sic)
+  _imcp_method_type_value,      // string: (variable java/lang/invoke/MethodType, sic)
   _imcp_limit
 };
 
@@ -1078,7 +1091,8 @@ void methodOopDesc::init_intrinsic_id() {
   vmSymbols::SID  name_id = vmSymbols::find_sid(name());
   if (name_id == vmSymbols::NO_SID)  return;
   vmSymbols::SID   sig_id = vmSymbols::find_sid(signature());
-  if (klass_id != vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle)
+  if (klass_id != vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_MethodHandle)
+      && !(klass_id == vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle) && AllowTransitionalJSR292)
       && sig_id == vmSymbols::NO_SID)  return;
   jshort flags = access_flags().as_short();
 
@@ -1104,7 +1118,8 @@ void methodOopDesc::init_intrinsic_id() {
     break;
 
   // Signature-polymorphic methods: MethodHandle.invoke*, InvokeDynamic.*.
-  case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle):
+  case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_MethodHandle):  // AllowTransitionalJSR292 ONLY
+  case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_MethodHandle):
     if (is_static() || !is_native())  break;
     switch (name_id) {
     case vmSymbols::VM_SYMBOL_ENUM_NAME(invokeGeneric_name):
@@ -1114,11 +1129,12 @@ void methodOopDesc::init_intrinsic_id() {
       id = vmIntrinsics::_invokeExact;
       break;
     case vmSymbols::VM_SYMBOL_ENUM_NAME(invoke_name):
-      if (AllowTransitionalJSR292)  id = vmIntrinsics::_invokeExact;
+      if (AllowInvokeForInvokeGeneric)   id = vmIntrinsics::_invokeGeneric;
+      else if (AllowTransitionalJSR292)  id = vmIntrinsics::_invokeExact;
       break;
     }
     break;
-  case vmSymbols::VM_SYMBOL_ENUM_NAME(java_dyn_InvokeDynamic):
+  case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_InvokeDynamic):
     if (!is_static() || !is_native())  break;
     id = vmIntrinsics::_invokeDynamic;
     break;
diff --git a/hotspot/src/share/vm/oops/methodOop.hpp b/hotspot/src/share/vm/oops/methodOop.hpp
index 3b2ed335516..bf3f8528e13 100644
--- a/hotspot/src/share/vm/oops/methodOop.hpp
+++ b/hotspot/src/share/vm/oops/methodOop.hpp
@@ -84,6 +84,11 @@
 // | invocation_counter                                   |
 // | backedge_counter                                     |
 // |------------------------------------------------------|
+// |           prev_time (tiered only, 64 bit wide)       |
+// |                                                      |
+// |------------------------------------------------------|
+// |                  rate (tiered)                       |
+// |------------------------------------------------------|
 // | code                           (pointer)             |
 // | i2i                            (pointer)             |
 // | adapter                        (pointer)             |
@@ -124,6 +129,11 @@ class methodOopDesc : public oopDesc {
   InvocationCounter _invocation_counter;         // Incremented before each activation of the method - used to trigger frequency-based optimizations
   InvocationCounter _backedge_counter;           // Incremented before each backedge taken - used to trigger frequencey-based optimizations
 
+#ifdef TIERED
+  jlong             _prev_time;                   // Previous time the rate was acquired
+  float             _rate;                        // Events (invocation and backedge counter increments) per millisecond
+#endif
+
 #ifndef PRODUCT
   int               _compiled_invocation_count;  // Number of nmethod invocations so far (for perf. debugging)
 #endif
@@ -304,6 +314,17 @@ class methodOopDesc : public oopDesc {
   InvocationCounter* invocation_counter() { return &_invocation_counter; }
   InvocationCounter* backedge_counter()   { return &_backedge_counter; }
 
+#ifdef TIERED
+  // We are reusing interpreter_invocation_count as a holder for the previous event count!
+  // We can do that since interpreter_invocation_count is not used in tiered.
+  int prev_event_count() const                   { return _interpreter_invocation_count;  }
+  void set_prev_event_count(int count)           { _interpreter_invocation_count = count; }
+  jlong prev_time() const                        { return _prev_time; }
+  void set_prev_time(jlong time)                 { _prev_time = time; }
+  float rate() const                             { return _rate; }
+  void set_rate(float rate)                      { _rate = rate; }
+#endif
+
   int invocation_count();
   int backedge_count();
 
@@ -497,6 +518,13 @@ class methodOopDesc : public oopDesc {
   // returns true if the method is an initializer (<init> or <clinit>).
   bool is_initializer() const;
 
+  // returns true if the method is static OR if the classfile version < 51
+  bool has_valid_initializer_flags() const;
+
+  // returns true if the method name is <clinit> and the method has
+  // valid static initializer flags.
+  bool is_static_initializer() const;
+
   // compiled code support
   // NOTE: code() is inherently racy as deopt can be clearing code
   // simultaneously. Use with caution.
diff --git a/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
index a21110250a2..dedd3f8829f 100644
--- a/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
+++ b/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp
@@ -31,6 +31,13 @@
 #include "oops/objArrayKlassKlass.hpp"
 #include "oops/oop.inline.hpp"
 #include "oops/oop.inline2.hpp"
+#ifndef SERIALGC
+#include "gc_implementation/parNew/parOopClosures.inline.hpp"
+#include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
+#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
+#include "memory/cardTableRS.hpp"
+#include "oops/oop.pcgc.inline.hpp"
+#endif
 
 klassOop objArrayKlassKlass::create_klass(TRAPS) {
   objArrayKlassKlass o;
@@ -236,12 +243,23 @@ objArrayKlassKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
   addr = oak->bottom_klass_addr();
   if (mr.contains(addr)) blk->do_oop(addr);
 
-  return arrayKlassKlass::oop_oop_iterate(obj, blk);
+  return arrayKlassKlass::oop_oop_iterate_m(obj, blk, mr);
 }
 
 #ifndef SERIALGC
 void objArrayKlassKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
   assert(obj->blueprint()->oop_is_objArrayKlass(),"must be an obj array klass");
+  objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
+  oop* p = oak->element_klass_addr();
+  if (PSScavenge::should_scavenge(p)) {
+    pm->claim_or_forward_depth(p);
+  }
+  p = oak->bottom_klass_addr();
+  if (PSScavenge::should_scavenge(p)) {
+    pm->claim_or_forward_depth(p);
+  }
+
+  arrayKlassKlass::oop_push_contents(pm, obj);
 }
 
 int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
@@ -287,7 +305,7 @@ const char* objArrayKlassKlass::internal_name() const {
 // Verification
 
 void objArrayKlassKlass::oop_verify_on(oop obj, outputStream* st) {
-  klassKlass::oop_verify_on(obj, st);
+  arrayKlassKlass::oop_verify_on(obj, st);
   objArrayKlass* oak = objArrayKlass::cast((klassOop)obj);
   guarantee(oak->element_klass()->is_perm(),  "should be in permspace");
   guarantee(oak->element_klass()->is_klass(), "should be klass");
diff --git a/hotspot/src/share/vm/oops/oop.hpp b/hotspot/src/share/vm/oops/oop.hpp
index 7553ec38ff9..c778f0d7204 100644
--- a/hotspot/src/share/vm/oops/oop.hpp
+++ b/hotspot/src/share/vm/oops/oop.hpp
@@ -129,6 +129,7 @@ class oopDesc {
 
   // type test operations (inlined in oop.inline.h)
   bool is_instance()           const;
+  bool is_instanceMirror()     const;
   bool is_instanceRef()        const;
   bool is_array()              const;
   bool is_objArray()           const;
diff --git a/hotspot/src/share/vm/oops/oop.inline.hpp b/hotspot/src/share/vm/oops/oop.inline.hpp
index afdccfb262b..01f001c391b 100644
--- a/hotspot/src/share/vm/oops/oop.inline.hpp
+++ b/hotspot/src/share/vm/oops/oop.inline.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -141,6 +141,7 @@ inline Klass* oopDesc::blueprint()           const { return klass()->klass_part(
 inline bool oopDesc::is_a(klassOop k)        const { return blueprint()->is_subtype_of(k); }
 
 inline bool oopDesc::is_instance()           const { return blueprint()->oop_is_instance(); }
+inline bool oopDesc::is_instanceMirror()     const { return blueprint()->oop_is_instanceMirror(); }
 inline bool oopDesc::is_instanceRef()        const { return blueprint()->oop_is_instanceRef(); }
 inline bool oopDesc::is_array()              const { return blueprint()->oop_is_array(); }
 inline bool oopDesc::is_objArray()           const { return blueprint()->oop_is_objArray(); }
@@ -399,7 +400,7 @@ inline void oopDesc::release_address_field_put(int offset, address contents) { O
 
 inline int oopDesc::size_given_klass(Klass* klass)  {
   int lh = klass->layout_helper();
-  int s  = lh >> LogHeapWordSize;  // deliver size scaled by wordSize
+  int s;
 
   // lh is now a value computed at class initialization that may hint
   // at the size.  For instances, this is positive and equal to the
@@ -412,7 +413,13 @@ inline int oopDesc::size_given_klass(Klass* klass)  {
   // alive or dead.  So the speed here is equal in importance to the
   // speed of allocation.
 
-  if (lh <= Klass::_lh_neutral_value) {
+  if (lh > Klass::_lh_neutral_value) {
+    if (!Klass::layout_helper_needs_slow_path(lh)) {
+      s = lh >> LogHeapWordSize;  // deliver size scaled by wordSize
+    } else {
+      s = klass->oop_size(this);
+    }
+  } else if (lh <= Klass::_lh_neutral_value) {
     // The most common case is instances; fall through if so.
     if (lh < Klass::_lh_neutral_value) {
       // Second most common case is arrays.  We have to fetch the
diff --git a/hotspot/src/share/vm/oops/oopsHierarchy.hpp b/hotspot/src/share/vm/oops/oopsHierarchy.hpp
index 106fa144ef6..fb10bca74eb 100644
--- a/hotspot/src/share/vm/oops/oopsHierarchy.hpp
+++ b/hotspot/src/share/vm/oops/oopsHierarchy.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -174,6 +174,7 @@ DEF_OOP(compiledICHolder);
 
 class Klass;
 class   instanceKlass;
+class     instanceMirrorKlass;
 class     instanceRefKlass;
 class   methodKlass;
 class   constMethodKlass;
diff --git a/hotspot/src/share/vm/opto/bytecodeInfo.cpp b/hotspot/src/share/vm/opto/bytecodeInfo.cpp
index bb511eb8f44..6443bc16bf9 100644
--- a/hotspot/src/share/vm/opto/bytecodeInfo.cpp
+++ b/hotspot/src/share/vm/opto/bytecodeInfo.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -487,7 +487,7 @@ InlineTree *InlineTree::build_inline_tree_for_callee( ciMethod* callee_method, J
     if (caller_jvms->method()->is_method_handle_adapter())
       new_depth_adjust -= 1;  // don't count actions in MH or indy adapter frames
     else if (callee_method->is_method_handle_invoke()) {
-      new_depth_adjust -= 1;  // don't count method handle calls from java.dyn implem
+      new_depth_adjust -= 1;  // don't count method handle calls from java.lang.invoke implem
     }
     if (new_depth_adjust != 0 && PrintInlining) {
       stringStream nm1; caller_jvms->method()->print_name(&nm1);
diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp
index 159b2805081..033074dadf6 100644
--- a/hotspot/src/share/vm/opto/c2_globals.hpp
+++ b/hotspot/src/share/vm/opto/c2_globals.hpp
@@ -180,6 +180,9 @@
   develop(bool, TraceLoopPredicate, false,                                  \
           "Trace generation of loop predicates")                            \
                                                                             \
+  develop(bool, TraceLoopOpts, false,                                       \
+          "Trace executed loop optimizations")                              \
+                                                                            \
   product(bool, OptimizeFill, false,                                        \
           "convert fill/copy loops into intrinsic")                         \
                                                                             \
diff --git a/hotspot/src/share/vm/opto/callGenerator.cpp b/hotspot/src/share/vm/opto/callGenerator.cpp
index 5b861bfb209..6d201139e80 100644
--- a/hotspot/src/share/vm/opto/callGenerator.cpp
+++ b/hotspot/src/share/vm/opto/callGenerator.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -199,7 +199,7 @@ JVMState* DynamicCallGenerator::generate(JVMState* jvms) {
   Node* call_site = kit.make_load(kit.control(), call_site_adr, TypeInstPtr::BOTTOM, T_OBJECT, Compile::AliasIdxRaw);
 
   // Load the target MethodHandle from the CallSite object.
-  Node* target_mh_adr = kit.basic_plus_adr(call_site, call_site, java_dyn_CallSite::target_offset_in_bytes());
+  Node* target_mh_adr = kit.basic_plus_adr(call_site, call_site, java_lang_invoke_CallSite::target_offset_in_bytes());
   Node* target_mh = kit.make_load(kit.control(), target_mh_adr, TypeInstPtr::BOTTOM, T_OBJECT);
 
   address resolve_stub = SharedRuntime::get_resolve_opt_virtual_call_stub();
@@ -725,7 +725,7 @@ JVMState* PredictedDynamicCallGenerator::generate(JVMState* jvms) {
   Node* call_site     = kit.make_load(kit.control(), call_site_adr, TypeInstPtr::BOTTOM, T_OBJECT, Compile::AliasIdxRaw);
 
   // Load the target MethodHandle from the CallSite object.
-  Node* target_adr = kit.basic_plus_adr(call_site, call_site, java_dyn_CallSite::target_offset_in_bytes());
+  Node* target_adr = kit.basic_plus_adr(call_site, call_site, java_lang_invoke_CallSite::target_offset_in_bytes());
   Node* target_mh  = kit.make_load(kit.control(), target_adr, TypeInstPtr::BOTTOM, T_OBJECT);
 
   // Check if the MethodHandle is still the same.
diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp
index a1d9659af82..c9e04bb7a3e 100644
--- a/hotspot/src/share/vm/opto/compile.cpp
+++ b/hotspot/src/share/vm/opto/compile.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1202,11 +1202,15 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
   // Oop pointers need some flattening
   const TypeInstPtr *to = tj->isa_instptr();
   if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) {
+    ciInstanceKlass *k = to->klass()->as_instance_klass();
     if( ptr == TypePtr::Constant ) {
-      // No constant oop pointers (such as Strings); they alias with
-      // unknown strings.
-      assert(!is_known_inst, "not scalarizable allocation");
-      tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
+      if (to->klass() != ciEnv::current()->Class_klass() ||
+          offset < k->size_helper() * wordSize) {
+        // No constant oop pointers (such as Strings); they alias with
+        // unknown strings.
+        assert(!is_known_inst, "not scalarizable allocation");
+        tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
+      }
     } else if( is_known_inst ) {
       tj = to; // Keep NotNull and klass_is_exact for instance type
     } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
@@ -1216,7 +1220,6 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
       tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
     }
     // Canonicalize the holder of this field
-    ciInstanceKlass *k = to->klass()->as_instance_klass();
     if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) {
       // First handle header references such as a LoadKlassNode, even if the
       // object's klass is unloaded at compile time (4965979).
@@ -1224,9 +1227,13 @@ const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
         tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset);
       }
     } else if (offset < 0 || offset >= k->size_helper() * wordSize) {
-      to = NULL;
-      tj = TypeOopPtr::BOTTOM;
-      offset = tj->offset();
+      // Static fields are in the space above the normal instance
+      // fields in the java.lang.Class instance.
+      if (to->klass() != ciEnv::current()->Class_klass()) {
+        to = NULL;
+        tj = TypeOopPtr::BOTTOM;
+        offset = tj->offset();
+      }
     } else {
       ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset);
       if (!k->equals(canonical_holder) || tj->offset() != offset) {
@@ -1399,7 +1406,7 @@ void Compile::grow_alias_types() {
 
 
 //--------------------------------find_alias_type------------------------------
-Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create) {
+Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_create, ciField* original_field) {
   if (_AliasLevel == 0)
     return alias_type(AliasIdxBot);
 
@@ -1464,22 +1471,28 @@ Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_cr
     // but the base pointer type is not distinctive enough to identify
     // references into JavaThread.)
 
-    // Check for final instance fields.
+    // Check for final fields.
     const TypeInstPtr* tinst = flat->isa_instptr();
     if (tinst && tinst->offset() >= instanceOopDesc::base_offset_in_bytes()) {
-      ciInstanceKlass *k = tinst->klass()->as_instance_klass();
-      ciField* field = k->get_field_by_offset(tinst->offset(), false);
+      ciField* field;
+      if (tinst->const_oop() != NULL &&
+          tinst->klass() == ciEnv::current()->Class_klass() &&
+          tinst->offset() >= (tinst->klass()->as_instance_klass()->size_helper() * wordSize)) {
+        // static field
+        ciInstanceKlass* k = tinst->const_oop()->as_instance()->java_lang_Class_klass()->as_instance_klass();
+        field = k->get_field_by_offset(tinst->offset(), true);
+      } else {
+        ciInstanceKlass *k = tinst->klass()->as_instance_klass();
+        field = k->get_field_by_offset(tinst->offset(), false);
+      }
+      assert(field == NULL ||
+             original_field == NULL ||
+             (field->holder() == original_field->holder() &&
+              field->offset() == original_field->offset() &&
+              field->is_static() == original_field->is_static()), "wrong field?");
       // Set field() and is_rewritable() attributes.
       if (field != NULL)  alias_type(idx)->set_field(field);
     }
-    const TypeKlassPtr* tklass = flat->isa_klassptr();
-    // Check for final static fields.
-    if (tklass && tklass->klass()->is_instance_klass()) {
-      ciInstanceKlass *k = tklass->klass()->as_instance_klass();
-      ciField* field = k->get_field_by_offset(tklass->offset(), true);
-      // Set field() and is_rewritable() attributes.
-      if (field != NULL)   alias_type(idx)->set_field(field);
-    }
   }
 
   // Fill the cache for next time.
@@ -1502,10 +1515,10 @@ Compile::AliasType* Compile::find_alias_type(const TypePtr* adr_type, bool no_cr
 Compile::AliasType* Compile::alias_type(ciField* field) {
   const TypeOopPtr* t;
   if (field->is_static())
-    t = TypeKlassPtr::make(field->holder());
+    t = TypeInstPtr::make(field->holder()->java_mirror());
   else
     t = TypeOopPtr::make_from_klass_raw(field->holder());
-  AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()));
+  AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()), field);
   assert(field->is_final() == !atp->is_rewritable(), "must get the rewritable bits correct");
   return atp;
 }
@@ -1522,7 +1535,7 @@ bool Compile::have_alias_type(const TypePtr* adr_type) {
   if (adr_type == NULL)             return true;
   if (adr_type == TypePtr::BOTTOM)  return true;
 
-  return find_alias_type(adr_type, true) != NULL;
+  return find_alias_type(adr_type, true, NULL) != NULL;
 }
 
 //-----------------------------must_alias--------------------------------------
diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp
index 36d09aca48b..5b562ecee44 100644
--- a/hotspot/src/share/vm/opto/compile.hpp
+++ b/hotspot/src/share/vm/opto/compile.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -596,7 +596,7 @@ class Compile : public Phase {
   }
 
   AliasType*        alias_type(int                idx)  { assert(idx < num_alias_types(), "oob"); return _alias_types[idx]; }
-  AliasType*        alias_type(const TypePtr* adr_type) { return find_alias_type(adr_type, false); }
+  AliasType*        alias_type(const TypePtr* adr_type, ciField* field = NULL) { return find_alias_type(adr_type, false, field); }
   bool         have_alias_type(const TypePtr* adr_type);
   AliasType*        alias_type(ciField*         field);
 
@@ -835,7 +835,7 @@ class Compile : public Phase {
   void grow_alias_types();
   AliasCacheEntry* probe_alias_cache(const TypePtr* adr_type);
   const TypePtr *flatten_alias_type(const TypePtr* adr_type) const;
-  AliasType* find_alias_type(const TypePtr* adr_type, bool no_create);
+  AliasType* find_alias_type(const TypePtr* adr_type, bool no_create, ciField* field);
 
   void verify_top(Node*) const PRODUCT_RETURN;
 
diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp
index 80101d2da40..b20513e67c1 100644
--- a/hotspot/src/share/vm/opto/graphKit.cpp
+++ b/hotspot/src/share/vm/opto/graphKit.cpp
@@ -3338,6 +3338,49 @@ InitializeNode* AllocateNode::initialization() {
   return NULL;
 }
 
+//----------------------------- loop predicates ---------------------------
+
+//------------------------------add_predicate_impl----------------------------
+void GraphKit::add_predicate_impl(Deoptimization::DeoptReason reason, int nargs) {
+  // Too many traps seen?
+  if (too_many_traps(reason)) {
+#ifdef ASSERT
+    if (TraceLoopPredicate) {
+      int tc = C->trap_count(reason);
+      tty->print("too many traps=%s tcount=%d in ",
+                    Deoptimization::trap_reason_name(reason), tc);
+      method()->print(); // which method has too many predicate traps
+      tty->cr();
+    }
+#endif
+    // We cannot afford to take more traps here,
+    // do not generate predicate.
+    return;
+  }
+
+  Node *cont    = _gvn.intcon(1);
+  Node* opq     = _gvn.transform(new (C, 2) Opaque1Node(C, cont));
+  Node *bol     = _gvn.transform(new (C, 2) Conv2BNode(opq));
+  IfNode* iff   = create_and_map_if(control(), bol, PROB_MAX, COUNT_UNKNOWN);
+  Node* iffalse = _gvn.transform(new (C, 1) IfFalseNode(iff));
+  C->add_predicate_opaq(opq);
+  {
+    PreserveJVMState pjvms(this);
+    set_control(iffalse);
+    _sp += nargs;
+    uncommon_trap(reason, Deoptimization::Action_maybe_recompile);
+  }
+  Node* iftrue = _gvn.transform(new (C, 1) IfTrueNode(iff));
+  set_control(iftrue);
+}
+
+//------------------------------add_predicate---------------------------------
+void GraphKit::add_predicate(int nargs) {
+  if (UseLoopPredicate) {
+    add_predicate_impl(Deoptimization::Reason_predicate, nargs);
+  }
+}
+
 //----------------------------- store barriers ----------------------------
 #define __ ideal.
 
diff --git a/hotspot/src/share/vm/opto/graphKit.hpp b/hotspot/src/share/vm/opto/graphKit.hpp
index 721bd864038..2f7a7d5ab05 100644
--- a/hotspot/src/share/vm/opto/graphKit.hpp
+++ b/hotspot/src/share/vm/opto/graphKit.hpp
@@ -793,6 +793,10 @@ class GraphKit : public Phase {
     if (!tst->is_Con())  record_for_igvn(iff);     // Range-check and Null-check removal is later
     return iff;
   }
+
+  // Insert a loop predicate into the graph
+  void add_predicate(int nargs = 0);
+  void add_predicate_impl(Deoptimization::DeoptReason reason, int nargs);
 };
 
 // Helper class to support building of control flow branches. Upon
diff --git a/hotspot/src/share/vm/opto/idealKit.cpp b/hotspot/src/share/vm/opto/idealKit.cpp
index 5cd6f9bdeaa..bc7aaaa6a9a 100644
--- a/hotspot/src/share/vm/opto/idealKit.cpp
+++ b/hotspot/src/share/vm/opto/idealKit.cpp
@@ -154,8 +154,18 @@ void IdealKit::end_if() {
 //
 // Pushes the loop top cvstate first, then the else (loop exit) cvstate
 // onto the stack.
-void IdealKit::loop(IdealVariable& iv, Node* init, BoolTest::mask relop, Node* limit, float prob, float cnt) {
+void IdealKit::loop(GraphKit* gkit, int nargs, IdealVariable& iv, Node* init, BoolTest::mask relop, Node* limit, float prob, float cnt) {
   assert((state() & (BlockS|LoopS|IfThenS|ElseS)), "bad state for new loop");
+
+  // Sync IdealKit and graphKit.
+  gkit->set_all_memory(this->merged_memory());
+  gkit->set_control(this->ctrl());
+  // Add loop predicate.
+  gkit->add_predicate(nargs);
+  // Update IdealKit memory.
+  this->set_all_memory(gkit->merged_memory());
+  this->set_ctrl(gkit->control());
+
   set(iv, init);
   Node* head = make_label(1);
   bind(head);
diff --git a/hotspot/src/share/vm/opto/idealKit.hpp b/hotspot/src/share/vm/opto/idealKit.hpp
index b5d894ca27c..8192a446288 100644
--- a/hotspot/src/share/vm/opto/idealKit.hpp
+++ b/hotspot/src/share/vm/opto/idealKit.hpp
@@ -29,6 +29,7 @@
 #include "opto/cfgnode.hpp"
 #include "opto/connode.hpp"
 #include "opto/divnode.hpp"
+#include "opto/graphKit.hpp"
 #include "opto/mulnode.hpp"
 #include "opto/phaseX.hpp"
 #include "opto/subnode.hpp"
@@ -160,7 +161,7 @@ class IdealKit: public StackObj {
                bool push_new_state = true);
   void else_();
   void end_if();
-  void loop(IdealVariable& iv, Node* init, BoolTest::mask cmp, Node* limit,
+  void loop(GraphKit* gkit, int nargs, IdealVariable& iv, Node* init, BoolTest::mask cmp, Node* limit,
             float prob = PROB_LIKELY(0.9), float cnt = COUNT_UNKNOWN);
   void end_loop();
   Node* make_label(int goto_ct);
diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp
index 6a6ca27fef7..024955215e6 100644
--- a/hotspot/src/share/vm/opto/library_call.cpp
+++ b/hotspot/src/share/vm/opto/library_call.cpp
@@ -1101,6 +1101,8 @@ Node* LibraryCallKit::string_indexOf(Node* string_object, ciTypeArray* target_ar
   float likely   = PROB_LIKELY(0.9);
   float unlikely = PROB_UNLIKELY(0.9);
 
+  const int nargs = 2; // number of arguments to push back for uncommon trap in predicate
+
   const int value_offset  = java_lang_String::value_offset_in_bytes();
   const int count_offset  = java_lang_String::count_offset_in_bytes();
   const int offset_offset = java_lang_String::offset_offset_in_bytes();
@@ -1116,7 +1118,7 @@ Node* LibraryCallKit::string_indexOf(Node* string_object, ciTypeArray* target_ar
   Node* sourcea       = basic_plus_adr(string_object, string_object, value_offset);
   Node* source        = make_load(no_ctrl, sourcea, source_type, T_OBJECT, string_type->add_offset(value_offset));
 
-  Node* target = _gvn.transform( makecon(TypeOopPtr::make_from_constant(target_array)) );
+  Node* target = _gvn.transform( makecon(TypeOopPtr::make_from_constant(target_array, true)) );
   jint target_length = target_array->length();
   const TypeAry* target_array_type = TypeAry::make(TypeInt::CHAR, TypeInt::make(0, target_length, Type::WidenMin));
   const TypeAryPtr* target_type = TypeAryPtr::make(TypePtr::BotPTR, target_array_type, target_array->klass(), true, Type::OffsetBot);
@@ -1138,12 +1140,12 @@ Node* LibraryCallKit::string_indexOf(Node* string_object, ciTypeArray* target_ar
   Node* return_    = __ make_label(1);
 
   __ set(rtn,__ ConI(-1));
-  __ loop(i, sourceOffset, BoolTest::lt, sourceEnd); {
+  __ loop(this, nargs, i, sourceOffset, BoolTest::lt, sourceEnd); {
        Node* i2  = __ AddI(__ value(i), targetCountLess1);
        // pin to prohibit loading of "next iteration" value which may SEGV (rare)
        Node* src = load_array_element(__ ctrl(), source, i2, TypeAryPtr::CHARS);
        __ if_then(src, BoolTest::eq, lastChar, unlikely); {
-         __ loop(j, zero, BoolTest::lt, targetCountLess1); {
+         __ loop(this, nargs, j, zero, BoolTest::lt, targetCountLess1); {
               Node* tpj = __ AddI(targetOffset, __ value(j));
               Node* targ = load_array_element(no_ctrl, target, tpj, target_type);
               Node* ipj  = __ AddI(__ value(i), __ value(j));
diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp
index 9de938d2579..dfccee43d48 100644
--- a/hotspot/src/share/vm/opto/loopTransform.cpp
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp
@@ -205,6 +205,8 @@ Node* IdealLoopTree::reassociate_add_sub(Node* n1, PhaseIdealLoop *phase) {
   }
   phase->register_new_node(addx, phase->get_ctrl(x));
   phase->_igvn.replace_node(n1, addx);
+  assert(phase->get_loop(phase->get_ctrl(n1)) == this, "");
+  _body.yank(n1);
   return addx;
 }
 
@@ -307,15 +309,21 @@ void PhaseIdealLoop::do_peeling( IdealLoopTree *loop, Node_List &old_new ) {
   // iterations adjusted.  Therefore, we need to declare this loop as
   // no longer a 'main' loop; it will need new pre and post loops before
   // we can do further RCE.
+#ifndef PRODUCT
+  if (TraceLoopOpts) {
+    tty->print("Peel         ");
+    loop->dump_head();
+  }
+#endif
   Node *h = loop->_head;
-  if( h->is_CountedLoop() ) {
+  if (h->is_CountedLoop()) {
     CountedLoopNode *cl = h->as_CountedLoop();
     assert(cl->trip_count() > 0, "peeling a fully unrolled loop");
     cl->set_trip_count(cl->trip_count() - 1);
-    if( cl->is_main_loop() ) {
+    if (cl->is_main_loop()) {
       cl->set_normal_loop();
 #ifndef PRODUCT
-      if( PrintOpto && VerifyLoopOptimizations ) {
+      if (PrintOpto && VerifyLoopOptimizations) {
         tty->print("Peeling a 'main' loop; resetting to 'normal' ");
         loop->dump_head();
       }
@@ -645,6 +653,15 @@ Node *PhaseIdealLoop::clone_up_backedge_goo( Node *back_ctrl, Node *preheader_ct
 // alignment.  Useful to unroll loops that do no array accesses.
 void PhaseIdealLoop::insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_new, bool peel_only ) {
 
+#ifndef PRODUCT
+  if (TraceLoopOpts) {
+    if (peel_only)
+      tty->print("PeelMainPost ");
+    else
+      tty->print("PreMainPost  ");
+    loop->dump_head();
+  }
+#endif
   C->set_major_progress();
 
   // Find common pieces of the loop being guarded with pre & post loops
@@ -897,16 +914,19 @@ bool IdealLoopTree::is_invariant(Node* n) const {
 //------------------------------do_unroll--------------------------------------
 // Unroll the loop body one step - make each trip do 2 iterations.
 void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool adjust_min_trip ) {
-  assert( LoopUnrollLimit, "" );
+  assert(LoopUnrollLimit, "");
+  CountedLoopNode *loop_head = loop->_head->as_CountedLoop();
+  CountedLoopEndNode *loop_end = loop_head->loopexit();
+  assert(loop_end, "");
 #ifndef PRODUCT
-  if( PrintOpto && VerifyLoopOptimizations ) {
+  if (PrintOpto && VerifyLoopOptimizations) {
     tty->print("Unrolling ");
     loop->dump_head();
+  } else if (TraceLoopOpts) {
+    tty->print("Unroll     %d ", loop_head->unrolled_count()*2);
+    loop->dump_head();
   }
 #endif
-  CountedLoopNode *loop_head = loop->_head->as_CountedLoop();
-  CountedLoopEndNode *loop_end = loop_head->loopexit();
-  assert( loop_end, "" );
 
   // Remember loop node count before unrolling to detect
   // if rounds of unroll,optimize are making progress
@@ -915,7 +935,7 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad
   Node *ctrl  = loop_head->in(LoopNode::EntryControl);
   Node *limit = loop_head->limit();
   Node *init  = loop_head->init_trip();
-  Node *strid = loop_head->stride();
+  Node *stride = loop_head->stride();
 
   Node *opaq = NULL;
   if( adjust_min_trip ) {       // If not maximally unrolling, need adjustment
@@ -955,13 +975,13 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad
   // odd iteration: (trip_cnt & ~1).  Then back compute a new limit.
   Node *span = new (C, 3) SubINode( limit, init );
   register_new_node( span, ctrl );
-  Node *trip = new (C, 3) DivINode( 0, span, strid );
+  Node *trip = new (C, 3) DivINode( 0, span, stride );
   register_new_node( trip, ctrl );
   Node *mtwo = _igvn.intcon(-2);
   set_ctrl(mtwo, C->root());
   Node *rond = new (C, 3) AndINode( trip, mtwo );
   register_new_node( rond, ctrl );
-  Node *spn2 = new (C, 3) MulINode( rond, strid );
+  Node *spn2 = new (C, 3) MulINode( rond, stride );
   register_new_node( spn2, ctrl );
   Node *lim2 = new (C, 3) AddINode( spn2, init );
   register_new_node( lim2, ctrl );
@@ -1040,17 +1060,23 @@ void PhaseIdealLoop::do_unroll( IdealLoopTree *loop, Node_List &old_new, bool ad
 
 void PhaseIdealLoop::do_maximally_unroll( IdealLoopTree *loop, Node_List &old_new ) {
   CountedLoopNode *cl = loop->_head->as_CountedLoop();
-  assert( cl->trip_count() > 0, "");
+  assert(cl->trip_count() > 0, "");
+#ifndef PRODUCT
+  if (TraceLoopOpts) {
+    tty->print("MaxUnroll  %d ", cl->trip_count());
+    loop->dump_head();
+  }
+#endif
 
   // If loop is tripping an odd number of times, peel odd iteration
-  if( (cl->trip_count() & 1) == 1 ) {
-    do_peeling( loop, old_new );
+  if ((cl->trip_count() & 1) == 1) {
+    do_peeling(loop, old_new);
   }
 
   // Now its tripping an even number of times remaining.  Double loop body.
   // Do not adjust pre-guards; they are not needed and do not exist.
-  if( cl->trip_count() > 0 ) {
-    do_unroll( loop, old_new, false );
+  if (cl->trip_count() > 0) {
+    do_unroll(loop, old_new, false);
   }
 }
 
@@ -1227,35 +1253,55 @@ bool PhaseIdealLoop::is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale,
 // Eliminate range-checks and other trip-counter vs loop-invariant tests.
 void PhaseIdealLoop::do_range_check( IdealLoopTree *loop, Node_List &old_new ) {
 #ifndef PRODUCT
-  if( PrintOpto && VerifyLoopOptimizations ) {
+  if (PrintOpto && VerifyLoopOptimizations) {
     tty->print("Range Check Elimination ");
     loop->dump_head();
+  } else if (TraceLoopOpts) {
+    tty->print("RangeCheck   ");
+    loop->dump_head();
   }
 #endif
-  assert( RangeCheckElimination, "" );
+  assert(RangeCheckElimination, "");
   CountedLoopNode *cl = loop->_head->as_CountedLoop();
-  assert( cl->is_main_loop(), "" );
+  assert(cl->is_main_loop(), "");
+
+  // protect against stride not being a constant
+  if (!cl->stride_is_con())
+    return;
 
   // Find the trip counter; we are iteration splitting based on it
   Node *trip_counter = cl->phi();
   // Find the main loop limit; we will trim it's iterations
   // to not ever trip end tests
   Node *main_limit = cl->limit();
+
+  // Need to find the main-loop zero-trip guard
+  Node *ctrl  = cl->in(LoopNode::EntryControl);
+  assert(ctrl->Opcode() == Op_IfTrue || ctrl->Opcode() == Op_IfFalse, "");
+  Node *iffm = ctrl->in(0);
+  assert(iffm->Opcode() == Op_If, "");
+  Node *bolzm = iffm->in(1);
+  assert(bolzm->Opcode() == Op_Bool, "");
+  Node *cmpzm = bolzm->in(1);
+  assert(cmpzm->is_Cmp(), "");
+  Node *opqzm = cmpzm->in(2);
+  // Can not optimize a loop if pre-loop Opaque1 node is optimized
+  // away and then another round of loop opts attempted.
+  if (opqzm->Opcode() != Op_Opaque1)
+    return;
+  assert(opqzm->in(1) == main_limit, "do not understand situation");
+
   // Find the pre-loop limit; we will expand it's iterations to
   // not ever trip low tests.
-  Node *ctrl  = cl->in(LoopNode::EntryControl);
-  assert( ctrl->Opcode() == Op_IfTrue || ctrl->Opcode() == Op_IfFalse, "" );
-  Node *iffm = ctrl->in(0);
-  assert( iffm->Opcode() == Op_If, "" );
   Node *p_f = iffm->in(0);
-  assert( p_f->Opcode() == Op_IfFalse, "" );
+  assert(p_f->Opcode() == Op_IfFalse, "");
   CountedLoopEndNode *pre_end = p_f->in(0)->as_CountedLoopEnd();
-  assert( pre_end->loopnode()->is_pre_loop(), "" );
+  assert(pre_end->loopnode()->is_pre_loop(), "");
   Node *pre_opaq1 = pre_end->limit();
   // Occasionally it's possible for a pre-loop Opaque1 node to be
   // optimized away and then another round of loop opts attempted.
   // We can not optimize this particular loop in that case.
-  if( pre_opaq1->Opcode() != Op_Opaque1 )
+  if (pre_opaq1->Opcode() != Op_Opaque1)
     return;
   Opaque1Node *pre_opaq = (Opaque1Node*)pre_opaq1;
   Node *pre_limit = pre_opaq->in(1);
@@ -1266,25 +1312,11 @@ void PhaseIdealLoop::do_range_check( IdealLoopTree *loop, Node_List &old_new ) {
   // Ensure the original loop limit is available from the
   // pre-loop Opaque1 node.
   Node *orig_limit = pre_opaq->original_loop_limit();
-  if( orig_limit == NULL || _igvn.type(orig_limit) == Type::TOP )
+  if (orig_limit == NULL || _igvn.type(orig_limit) == Type::TOP)
     return;
 
-  // Need to find the main-loop zero-trip guard
-  Node *bolzm = iffm->in(1);
-  assert( bolzm->Opcode() == Op_Bool, "" );
-  Node *cmpzm = bolzm->in(1);
-  assert( cmpzm->is_Cmp(), "" );
-  Node *opqzm = cmpzm->in(2);
-  if( opqzm->Opcode() != Op_Opaque1 )
-    return;
-  assert( opqzm->in(1) == main_limit, "do not understand situation" );
-
   // Must know if its a count-up or count-down loop
 
-  // protect against stride not being a constant
-  if ( !cl->stride_is_con() ) {
-    return;
-  }
   int stride_con = cl->stride_con();
   Node *zero = _igvn.intcon(0);
   Node *one  = _igvn.intcon(1);
@@ -1566,16 +1598,24 @@ void IdealLoopTree::adjust_loop_exit_prob( PhaseIdealLoop *phase ) {
 // have on the last iteration.  This will break the loop.
 bool IdealLoopTree::policy_do_remove_empty_loop( PhaseIdealLoop *phase ) {
   // Minimum size must be empty loop
-  if( _body.size() > 7/*number of nodes in an empty loop*/ ) return false;
+  if (_body.size() > 7/*number of nodes in an empty loop*/)
+    return false;
 
-  if( !_head->is_CountedLoop() ) return false;     // Dead loop
+  if (!_head->is_CountedLoop())
+    return false;     // Dead loop
   CountedLoopNode *cl = _head->as_CountedLoop();
-  if( !cl->loopexit() ) return false; // Malformed loop
-  if( !phase->is_member(this,phase->get_ctrl(cl->loopexit()->in(CountedLoopEndNode::TestValue)) ) )
+  if (!cl->loopexit())
+    return false; // Malformed loop
+  if (!phase->is_member(this, phase->get_ctrl(cl->loopexit()->in(CountedLoopEndNode::TestValue))))
     return false;             // Infinite loop
 #ifndef PRODUCT
-  if( PrintOpto )
-    tty->print_cr("Removing empty loop");
+  if (PrintOpto) {
+    tty->print("Removing empty loop");
+    this->dump_head();
+  } else if (TraceLoopOpts) {
+    tty->print("Empty        ");
+    this->dump_head();
+  }
 #endif
 #ifdef ASSERT
   // Ensure only one phi which is the iv.
@@ -1720,7 +1760,7 @@ bool IdealLoopTree::iteration_split_impl( PhaseIdealLoop *phase, Node_List &old_
 //------------------------------iteration_split--------------------------------
 bool IdealLoopTree::iteration_split( PhaseIdealLoop *phase, Node_List &old_new ) {
   // Recursively iteration split nested loops
-  if( _child && !_child->iteration_split( phase, old_new ))
+  if (_child && !_child->iteration_split(phase, old_new))
     return false;
 
   // Clean out prior deadwood
@@ -1729,21 +1769,20 @@ bool IdealLoopTree::iteration_split( PhaseIdealLoop *phase, Node_List &old_new )
 
   // Look for loop-exit tests with my 50/50 guesses from the Parsing stage.
   // Replace with a 1-in-10 exit guess.
-  if( _parent /*not the root loop*/ &&
+  if (_parent /*not the root loop*/ &&
       !_irreducible &&
       // Also ignore the occasional dead backedge
-      !tail()->is_top() ) {
+      !tail()->is_top()) {
     adjust_loop_exit_prob(phase);
   }
 
-
   // Gate unrolling, RCE and peeling efforts.
-  if( !_child &&                // If not an inner loop, do not split
+  if (!_child &&                // If not an inner loop, do not split
       !_irreducible &&
       _allow_optimizations &&
-      !tail()->is_top() ) {     // Also ignore the occasional dead backedge
+      !tail()->is_top()) {     // Also ignore the occasional dead backedge
     if (!_has_call) {
-        if (!iteration_split_impl( phase, old_new )) {
+        if (!iteration_split_impl(phase, old_new)) {
           return false;
         }
     } else if (policy_unswitching(phase)) {
@@ -1752,16 +1791,17 @@ bool IdealLoopTree::iteration_split( PhaseIdealLoop *phase, Node_List &old_new )
   }
 
   // Minor offset re-organization to remove loop-fallout uses of
-  // trip counter.
-  if( _head->is_CountedLoop() ) phase->reorg_offsets( this );
-  if( _next && !_next->iteration_split( phase, old_new ))
+  // trip counter when there was no major reshaping.
+  phase->reorg_offsets(this);
+
+  if (_next && !_next->iteration_split(phase, old_new))
     return false;
   return true;
 }
 
 //-------------------------------is_uncommon_trap_proj----------------------------
 // Return true if proj is the form of "proj->[region->..]call_uct"
-bool PhaseIdealLoop::is_uncommon_trap_proj(ProjNode* proj, bool must_reason_predicate) {
+bool PhaseIdealLoop::is_uncommon_trap_proj(ProjNode* proj, Deoptimization::DeoptReason reason) {
   int path_limit = 10;
   assert(proj, "invalid argument");
   Node* out = proj;
@@ -1772,8 +1812,8 @@ bool PhaseIdealLoop::is_uncommon_trap_proj(ProjNode* proj, bool must_reason_pred
     if (out->is_CallStaticJava()) {
       int req = out->as_CallStaticJava()->uncommon_trap_request();
       if (req != 0) {
-        Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(req);
-        if (!must_reason_predicate || reason == Deoptimization::Reason_predicate){
+        Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
+        if (trap_reason == reason || reason == Deoptimization::Reason_none) {
            return true;
         }
       }
@@ -1790,15 +1830,15 @@ bool PhaseIdealLoop::is_uncommon_trap_proj(ProjNode* proj, bool must_reason_pred
 //                      other_proj->[region->..]call_uct"
 //
 // "must_reason_predicate" means the uct reason must be Reason_predicate
-bool PhaseIdealLoop::is_uncommon_trap_if_pattern(ProjNode *proj, bool must_reason_predicate) {
+bool PhaseIdealLoop::is_uncommon_trap_if_pattern(ProjNode *proj, Deoptimization::DeoptReason reason) {
   Node *in0 = proj->in(0);
   if (!in0->is_If()) return false;
   // Variation of a dead If node.
   if (in0->outcnt() < 2)  return false;
   IfNode* iff = in0->as_If();
 
-  // we need "If(Conv2B(Opaque1(...)))" pattern for must_reason_predicate
-  if (must_reason_predicate) {
+  // we need "If(Conv2B(Opaque1(...)))" pattern for reason_predicate
+  if (reason != Deoptimization::Reason_none) {
     if (iff->in(1)->Opcode() != Op_Conv2B ||
        iff->in(1)->in(1)->Opcode() != Op_Opaque1) {
       return false;
@@ -1806,7 +1846,19 @@ bool PhaseIdealLoop::is_uncommon_trap_if_pattern(ProjNode *proj, bool must_reaso
   }
 
   ProjNode* other_proj = iff->proj_out(1-proj->_con)->as_Proj();
-  return is_uncommon_trap_proj(other_proj, must_reason_predicate);
+  return is_uncommon_trap_proj(other_proj, reason);
+}
+
+//-------------------------------register_control-------------------------
+void PhaseIdealLoop::register_control(Node* n, IdealLoopTree *loop, Node* pred) {
+  assert(n->is_CFG(), "must be control node");
+  _igvn.register_new_node_with_optimizer(n);
+  loop->_body.push(n);
+  set_loop(n, loop);
+  // When called from beautify_loops() idom is not constructed yet.
+  if (_idom != NULL) {
+    set_idom(n, pred, dom_depth(pred));
+  }
 }
 
 //------------------------------create_new_if_for_predicate------------------------
@@ -1843,8 +1895,10 @@ bool PhaseIdealLoop::is_uncommon_trap_if_pattern(ProjNode *proj, bool must_reaso
 //
 // We will create a region to guard the uct call if there is no one there.
 // The true projecttion (if_cont) of the new_iff is returned.
-ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj) {
-  assert(is_uncommon_trap_if_pattern(cont_proj, true), "must be a uct if pattern!");
+// This code is also used to clone predicates to clonned loops.
+ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry,
+                                                      Deoptimization::DeoptReason reason) {
+  assert(is_uncommon_trap_if_pattern(cont_proj, reason), "must be a uct if pattern!");
   IfNode* iff = cont_proj->in(0)->as_If();
 
   ProjNode *uncommon_proj = iff->proj_out(1 - cont_proj->_con);
@@ -1854,57 +1908,84 @@ ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj) {
   if (!rgn->is_Region()) { // create a region to guard the call
     assert(rgn->is_Call(), "must be call uct");
     CallNode* call = rgn->as_Call();
+    IdealLoopTree* loop = get_loop(call);
     rgn = new (C, 1) RegionNode(1);
-    _igvn.set_type(rgn, rgn->bottom_type());
     rgn->add_req(uncommon_proj);
-    set_idom(rgn, idom(uncommon_proj), dom_depth(uncommon_proj)+1);
+    register_control(rgn, loop, uncommon_proj);
     _igvn.hash_delete(call);
     call->set_req(0, rgn);
+    // When called from beautify_loops() idom is not constructed yet.
+    if (_idom != NULL) {
+      set_idom(call, rgn, dom_depth(rgn));
+    }
   }
 
+  Node* entry = iff->in(0);
+  if (new_entry != NULL) {
+    // Clonning the predicate to new location.
+    entry = new_entry;
+  }
   // Create new_iff
-  uint  iffdd  = dom_depth(iff);
-  IdealLoopTree* lp = get_loop(iff);
-  IfNode *new_iff = new (C, 2) IfNode(iff->in(0), NULL, iff->_prob, iff->_fcnt);
-  register_node(new_iff, lp, idom(iff), iffdd);
+  IdealLoopTree* lp = get_loop(entry);
+  IfNode *new_iff = new (C, 2) IfNode(entry, NULL, iff->_prob, iff->_fcnt);
+  register_control(new_iff, lp, entry);
   Node *if_cont = new (C, 1) IfTrueNode(new_iff);
   Node *if_uct  = new (C, 1) IfFalseNode(new_iff);
   if (cont_proj->is_IfFalse()) {
     // Swap
     Node* tmp = if_uct; if_uct = if_cont; if_cont = tmp;
   }
-  register_node(if_cont, lp, new_iff, iffdd);
-  register_node(if_uct, get_loop(rgn), new_iff, iffdd);
-
-  // if_cont to iff
-  _igvn.hash_delete(iff);
-  iff->set_req(0, if_cont);
-  set_idom(iff, if_cont, dom_depth(iff));
+  register_control(if_cont, lp, new_iff);
+  register_control(if_uct, get_loop(rgn), new_iff);
 
   // if_uct to rgn
   _igvn.hash_delete(rgn);
   rgn->add_req(if_uct);
-  Node* ridom = idom(rgn);
-  Node* nrdom = dom_lca(ridom, new_iff);
-  set_idom(rgn, nrdom, dom_depth(rgn));
-
+  // When called from beautify_loops() idom is not constructed yet.
+  if (_idom != NULL) {
+    Node* ridom = idom(rgn);
+    Node* nrdom = dom_lca(ridom, new_iff);
+    set_idom(rgn, nrdom, dom_depth(rgn));
+  }
   // rgn must have no phis
   assert(!rgn->as_Region()->has_phi(), "region must have no phis");
 
+  if (new_entry == NULL) {
+    // Attach if_cont to iff
+    _igvn.hash_delete(iff);
+    iff->set_req(0, if_cont);
+    if (_idom != NULL) {
+      set_idom(iff, if_cont, dom_depth(iff));
+    }
+  }
   return if_cont->as_Proj();
 }
 
-//------------------------------find_predicate_insertion_point--------------------------
+//--------------------------find_predicate_insertion_point-------------------
 // Find a good location to insert a predicate
-ProjNode* PhaseIdealLoop::find_predicate_insertion_point(Node* start_c) {
-  if (start_c == C->root() || !start_c->is_Proj())
+ProjNode* PhaseIdealLoop::find_predicate_insertion_point(Node* start_c, Deoptimization::DeoptReason reason) {
+  if (start_c == NULL || !start_c->is_Proj())
     return NULL;
-  if (is_uncommon_trap_if_pattern(start_c->as_Proj(), true/*Reason_Predicate*/)) {
+  if (is_uncommon_trap_if_pattern(start_c->as_Proj(), reason)) {
     return start_c->as_Proj();
   }
   return NULL;
 }
 
+//--------------------------find_predicate------------------------------------
+// Find a predicate
+Node* PhaseIdealLoop::find_predicate(Node* entry) {
+  Node* predicate = NULL;
+  if (UseLoopPredicate) {
+    predicate = find_predicate_insertion_point(entry, Deoptimization::Reason_predicate);
+    if (predicate != NULL) { // right pattern that can be used by loop predication
+      assert(entry->in(0)->in(1)->in(1)->Opcode()==Op_Opaque1, "must be");
+      return entry;
+    }
+  }
+  return NULL;
+}
+
 //------------------------------Invariance-----------------------------------
 // Helper class for loop_predication_impl to compute invariance on the fly and
 // clone invariants.
@@ -2151,6 +2232,11 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
     return false;
   }
 
+  if (loop->_head->unique_ctrl_out()->Opcode() == Op_NeverBranch) {
+    // do nothing for infinite loops
+    return false;
+  }
+
   CountedLoopNode *cl = NULL;
   if (loop->_head->is_CountedLoop()) {
     cl = loop->_head->as_CountedLoop();
@@ -2158,40 +2244,22 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
     if (!cl->is_normal_loop()) return false;
   }
 
-  // Too many traps seen?
-  bool tmt = C->too_many_traps(C->method(), 0, Deoptimization::Reason_predicate);
-  int tc = C->trap_count(Deoptimization::Reason_predicate);
-  if (tmt || tc > 0) {
-    if (TraceLoopPredicate) {
-      tty->print_cr("too many predicate traps: %d", tc);
-      C->method()->print(); // which method has too many predicate traps
-      tty->print_cr("");
-    }
-    return false;
-  }
-
   LoopNode *lpn  = loop->_head->as_Loop();
   Node* entry = lpn->in(LoopNode::EntryControl);
 
-  ProjNode *predicate_proj = find_predicate_insertion_point(entry);
-  if (!predicate_proj){
+  ProjNode *predicate_proj = find_predicate_insertion_point(entry, Deoptimization::Reason_predicate);
+  if (!predicate_proj) {
 #ifndef PRODUCT
     if (TraceLoopPredicate) {
       tty->print("missing predicate:");
       loop->dump_head();
+      lpn->dump(1);
     }
 #endif
     return false;
   }
-
   ConNode* zero = _igvn.intcon(0);
   set_ctrl(zero, C->root());
-  Node *cond_false = new (C, 2) Conv2BNode(zero);
-  register_new_node(cond_false, C->root());
-  ConNode* one = _igvn.intcon(1);
-  set_ctrl(one, C->root());
-  Node *cond_true = new (C, 2) Conv2BNode(one);
-  register_new_node(cond_true, C->root());
 
   ResourceArea *area = Thread::current()->resource_area();
   Invariance invar(area, loop);
@@ -2218,7 +2286,7 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
     ProjNode* proj = if_proj_list.pop()->as_Proj();
     IfNode*   iff  = proj->in(0)->as_If();
 
-    if (!is_uncommon_trap_if_pattern(proj)) {
+    if (!is_uncommon_trap_if_pattern(proj, Deoptimization::Reason_none)) {
       if (loop->is_loop_exit(iff)) {
         // stop processing the remaining projs in the list because the execution of them
         // depends on the condition of "iff" (iff->in(1)).
@@ -2242,7 +2310,8 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
     BoolNode* bol = test->as_Bool();
     if (invar.is_invariant(bol)) {
       // Invariant test
-      new_predicate_proj = create_new_if_for_predicate(predicate_proj);
+      new_predicate_proj = create_new_if_for_predicate(predicate_proj, NULL,
+                                                       Deoptimization::Reason_predicate);
       Node* ctrl = new_predicate_proj->in(0)->as_If()->in(0);
       BoolNode* new_predicate_bol = invar.clone(bol, ctrl)->as_Bool();
 
@@ -2256,8 +2325,15 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
       IfNode* new_predicate_iff = new_predicate_proj->in(0)->as_If();
       _igvn.hash_delete(new_predicate_iff);
       new_predicate_iff->set_req(1, new_predicate_bol);
-      if (TraceLoopPredicate) tty->print_cr("invariant if%s: %d", negated ? " negated" : "", new_predicate_iff->_idx);
-
+#ifndef PRODUCT
+      if (TraceLoopPredicate) {
+        tty->print("Predicate invariant if%s: %d ", negated ? " negated" : "", new_predicate_iff->_idx);
+        loop->dump_head();
+      } else if (TraceLoopOpts) {
+        tty->print("Predicate IC ");
+        loop->dump_head();
+      }
+#endif
     } else if (cl != NULL && loop->is_range_check_if(iff, this, invar)) {
       assert(proj->_con == predicate_proj->_con, "must match");
 
@@ -2281,8 +2357,8 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
       // lower_bound test will dominate the upper bound test and all
       // cloned or created nodes will use the lower bound test as
       // their declared control.
-      ProjNode* lower_bound_proj = create_new_if_for_predicate(predicate_proj);
-      ProjNode* upper_bound_proj = create_new_if_for_predicate(predicate_proj);
+      ProjNode* lower_bound_proj = create_new_if_for_predicate(predicate_proj, NULL, Deoptimization::Reason_predicate);
+      ProjNode* upper_bound_proj = create_new_if_for_predicate(predicate_proj, NULL, Deoptimization::Reason_predicate);
       assert(upper_bound_proj->in(0)->as_If()->in(0) == lower_bound_proj, "should dominate");
       Node *ctrl = lower_bound_proj->in(0)->as_If()->in(0);
 
@@ -2311,41 +2387,24 @@ bool PhaseIdealLoop::loop_predication_impl(IdealLoopTree *loop) {
       // Fall through into rest of the clean up code which will move
       // any dependent nodes onto the upper bound test.
       new_predicate_proj = upper_bound_proj;
+
+#ifndef PRODUCT
+      if (TraceLoopOpts && !TraceLoopPredicate) {
+        tty->print("Predicate RC ");
+        loop->dump_head();
+      }
+#endif
     } else {
-      // The other proj of the "iff" is a uncommon trap projection, and we can assume
-      // the other proj will not be executed ("executed" means uct raised).
+      // Loop variant check (for example, range check in non-counted loop)
+      // with uncommon trap.
       continue;
     }
-
+    assert(new_predicate_proj != NULL, "sanity");
     // Success - attach condition (new_predicate_bol) to predicate if
     invar.map_ctrl(proj, new_predicate_proj); // so that invariance test can be appropriate
 
-    // Eliminate the old if in the loop body
-    _igvn.hash_delete(iff);
-    iff->set_req(1, proj->is_IfFalse() ? cond_false : cond_true);
-
-    Node* ctrl = new_predicate_proj; // new control
-    ProjNode* dp = proj;     // old control
-    assert(get_loop(dp) == loop, "guaranteed at the time of collecting proj");
-    // Find nodes (depends only on the test) off the surviving projection;
-    // move them outside the loop with the control of proj_clone
-    for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) {
-      Node* cd = dp->fast_out(i); // Control-dependent node
-      if (cd->depends_only_on_test()) {
-        assert(cd->in(0) == dp, "");
-        _igvn.hash_delete(cd);
-        cd->set_req(0, ctrl); // ctrl, not NULL
-        set_early_ctrl(cd);
-        _igvn._worklist.push(cd);
-        IdealLoopTree *new_loop = get_loop(get_ctrl(cd));
-        if (new_loop != loop) {
-          if (!loop->_child) loop->_body.yank(cd);
-          if (!new_loop->_child ) new_loop->_body.push(cd);
-        }
-        --i;
-        --imax;
-      }
-    }
+    // Eliminate the old If in the loop body
+    dominated_by( new_predicate_proj, iff, proj->_con != new_predicate_proj->_con );
 
     hoisted = true;
     C->set_major_progress();
diff --git a/hotspot/src/share/vm/opto/loopUnswitch.cpp b/hotspot/src/share/vm/opto/loopUnswitch.cpp
index 8cfd5fb6b1f..fa8e58a44c8 100644
--- a/hotspot/src/share/vm/opto/loopUnswitch.cpp
+++ b/hotspot/src/share/vm/opto/loopUnswitch.cpp
@@ -110,6 +110,13 @@ void PhaseIdealLoop::do_unswitching (IdealLoopTree *loop, Node_List &old_new) {
   IfNode* unswitch_iff = find_unswitching_candidate((const IdealLoopTree *)loop);
   assert(unswitch_iff != NULL, "should be at least one");
 
+#ifndef PRODUCT
+  if (TraceLoopOpts) {
+    tty->print("Unswitch   %d ", head->unswitch_count()+1);
+    loop->dump_head();
+  }
+#endif
+
   // Need to revert back to normal loop
   if (head->is_CountedLoop() && !head->as_CountedLoop()->is_normal_loop()) {
     head->as_CountedLoop()->set_normal_loop();
diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp
index 204eeea65b8..cfcea4c6f09 100644
--- a/hotspot/src/share/vm/opto/loopnode.cpp
+++ b/hotspot/src/share/vm/opto/loopnode.cpp
@@ -56,12 +56,32 @@ const Node* Node::is_loop_iv() const {
 // Dump special per-node info
 #ifndef PRODUCT
 void LoopNode::dump_spec(outputStream *st) const {
-  if( is_inner_loop () ) st->print( "inner " );
-  if( is_partial_peel_loop () ) st->print( "partial_peel " );
-  if( partial_peel_has_failed () ) st->print( "partial_peel_failed " );
+  if (is_inner_loop()) st->print( "inner " );
+  if (is_partial_peel_loop()) st->print( "partial_peel " );
+  if (partial_peel_has_failed()) st->print( "partial_peel_failed " );
 }
 #endif
 
+//------------------------------is_valid_counted_loop-------------------------
+bool LoopNode::is_valid_counted_loop() const {
+  if (is_CountedLoop()) {
+    CountedLoopNode*    l  = as_CountedLoop();
+    CountedLoopEndNode* le = l->loopexit();
+    if (le != NULL &&
+        le->proj_out(1 /* true */) == l->in(LoopNode::LoopBackControl)) {
+      Node* phi  = l->phi();
+      Node* exit = le->proj_out(0 /* false */);
+      if (exit != NULL && exit->Opcode() == Op_IfFalse &&
+          phi != NULL && phi->is_Phi() &&
+          phi->in(LoopNode::LoopBackControl) == l->incr() &&
+          le->loopnode() == l && le->stride_is_con()) {
+        return true;
+      }
+    }
+  }
+  return false;
+}
+
 //------------------------------get_early_ctrl---------------------------------
 // Compute earliest legal control
 Node *PhaseIdealLoop::get_early_ctrl( Node *n ) {
@@ -142,43 +162,44 @@ void PhaseIdealLoop::set_subtree_ctrl( Node *n ) {
 }
 
 //------------------------------is_counted_loop--------------------------------
-Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
+bool PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
   PhaseGVN *gvn = &_igvn;
 
   // Counted loop head must be a good RegionNode with only 3 not NULL
   // control input edges: Self, Entry, LoopBack.
-  if ( x->in(LoopNode::Self) == NULL || x->req() != 3 )
-    return NULL;
+  if (x->in(LoopNode::Self) == NULL || x->req() != 3)
+    return false;
 
   Node *init_control = x->in(LoopNode::EntryControl);
   Node *back_control = x->in(LoopNode::LoopBackControl);
-  if( init_control == NULL || back_control == NULL )    // Partially dead
-    return NULL;
+  if (init_control == NULL || back_control == NULL)    // Partially dead
+    return false;
   // Must also check for TOP when looking for a dead loop
-  if( init_control->is_top() || back_control->is_top() )
-    return NULL;
+  if (init_control->is_top() || back_control->is_top())
+    return false;
 
   // Allow funny placement of Safepoint
-  if( back_control->Opcode() == Op_SafePoint )
+  if (back_control->Opcode() == Op_SafePoint)
     back_control = back_control->in(TypeFunc::Control);
 
   // Controlling test for loop
   Node *iftrue = back_control;
   uint iftrue_op = iftrue->Opcode();
-  if( iftrue_op != Op_IfTrue &&
-      iftrue_op != Op_IfFalse )
+  if (iftrue_op != Op_IfTrue &&
+      iftrue_op != Op_IfFalse)
     // I have a weird back-control.  Probably the loop-exit test is in
     // the middle of the loop and I am looking at some trailing control-flow
     // merge point.  To fix this I would have to partially peel the loop.
-    return NULL; // Obscure back-control
+    return false; // Obscure back-control
 
   // Get boolean guarding loop-back test
   Node *iff = iftrue->in(0);
-  if( get_loop(iff) != loop || !iff->in(1)->is_Bool() ) return NULL;
+  if (get_loop(iff) != loop || !iff->in(1)->is_Bool())
+    return false;
   BoolNode *test = iff->in(1)->as_Bool();
   BoolTest::mask bt = test->_test._test;
   float cl_prob = iff->as_If()->_prob;
-  if( iftrue_op == Op_IfFalse ) {
+  if (iftrue_op == Op_IfFalse) {
     bt = BoolTest(bt).negate();
     cl_prob = 1.0 - cl_prob;
   }
@@ -186,7 +207,7 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
   Node *cmp = test->in(1);
   int cmp_op = cmp->Opcode();
   if( cmp_op != Op_CmpI )
-    return NULL;                // Avoid pointer & float compares
+    return false;                // Avoid pointer & float compares
 
   // Find the trip-counter increment & limit.  Limit must be loop invariant.
   Node *incr  = cmp->in(1);
@@ -196,55 +217,64 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
   // need 'loop()' test to tell if limit is loop invariant
   // ---------
 
-  if( !is_member( loop, get_ctrl(incr) ) ) { // Swapped trip counter and limit?
-    Node *tmp = incr;           // Then reverse order into the CmpI
+  if (!is_member(loop, get_ctrl(incr))) { // Swapped trip counter and limit?
+    Node *tmp = incr;            // Then reverse order into the CmpI
     incr = limit;
     limit = tmp;
     bt = BoolTest(bt).commute(); // And commute the exit test
   }
-  if( is_member( loop, get_ctrl(limit) ) ) // Limit must loop-invariant
-    return NULL;
+  if (is_member(loop, get_ctrl(limit))) // Limit must be loop-invariant
+    return false;
+  if (!is_member(loop, get_ctrl(incr))) // Trip counter must be loop-variant
+    return false;
 
+  Node* phi_incr = NULL;
   // Trip-counter increment must be commutative & associative.
-  uint incr_op = incr->Opcode();
-  if( incr_op == Op_Phi && incr->req() == 3 ) {
-    incr = incr->in(2);         // Assume incr is on backedge of Phi
-    incr_op = incr->Opcode();
+  if (incr->is_Phi()) {
+    if (incr->as_Phi()->region() != x || incr->req() != 3)
+      return false; // Not simple trip counter expression
+    phi_incr = incr;
+    incr = phi_incr->in(LoopNode::LoopBackControl); // Assume incr is on backedge of Phi
+    if (!is_member(loop, get_ctrl(incr))) // Trip counter must be loop-variant
+      return false;
   }
+
   Node* trunc1 = NULL;
   Node* trunc2 = NULL;
   const TypeInt* iv_trunc_t = NULL;
   if (!(incr = CountedLoopNode::match_incr_with_optional_truncation(incr, &trunc1, &trunc2, &iv_trunc_t))) {
-    return NULL; // Funny increment opcode
+    return false; // Funny increment opcode
   }
+  assert(incr->Opcode() == Op_AddI, "wrong increment code");
 
   // Get merge point
   Node *xphi = incr->in(1);
   Node *stride = incr->in(2);
-  if( !stride->is_Con() ) {     // Oops, swap these
-    if( !xphi->is_Con() )       // Is the other guy a constant?
-      return NULL;              // Nope, unknown stride, bail out
+  if (!stride->is_Con()) {     // Oops, swap these
+    if (!xphi->is_Con())       // Is the other guy a constant?
+      return false;             // Nope, unknown stride, bail out
     Node *tmp = xphi;           // 'incr' is commutative, so ok to swap
     xphi = stride;
     stride = tmp;
   }
-  //if( loop(xphi) != l) return NULL;// Merge point is in inner loop??
-  if( !xphi->is_Phi() ) return NULL; // Too much math on the trip counter
+  // Stride must be constant
+  int stride_con = stride->get_int();
+  assert(stride_con != 0, "missed some peephole opt");
+
+  if (!xphi->is_Phi())
+    return false; // Too much math on the trip counter
+  if (phi_incr != NULL && phi_incr != xphi)
+    return false;
   PhiNode *phi = xphi->as_Phi();
 
-  // Stride must be constant
-  const Type *stride_t = stride->bottom_type();
-  int stride_con = stride_t->is_int()->get_con();
-  assert( stride_con, "missed some peephole opt" );
-
   // Phi must be of loop header; backedge must wrap to increment
-  if( phi->region() != x ) return NULL;
-  if( trunc1 == NULL && phi->in(LoopNode::LoopBackControl) != incr ||
-      trunc1 != NULL && phi->in(LoopNode::LoopBackControl) != trunc1 ) {
-    return NULL;
+  if (phi->region() != x)
+    return false;
+  if (trunc1 == NULL && phi->in(LoopNode::LoopBackControl) != incr ||
+      trunc1 != NULL && phi->in(LoopNode::LoopBackControl) != trunc1) {
+    return false;
   }
   Node *init_trip = phi->in(LoopNode::EntryControl);
-  //if (!init_trip->is_Con()) return NULL; // avoid rolling over MAXINT/MININT
 
   // If iv trunc type is smaller than int, check for possible wrap.
   if (!TypeInt::INT->higher_equal(iv_trunc_t)) {
@@ -267,12 +297,12 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
     if (stride_con > 0) {
       if (iv_trunc_t->_hi - phi_ft->_hi < stride_con ||
           iv_trunc_t->_lo > phi_ft->_lo) {
-        return NULL;  // truncation may occur
+        return false;  // truncation may occur
       }
     } else if (stride_con < 0) {
       if (iv_trunc_t->_lo - phi_ft->_lo > stride_con ||
           iv_trunc_t->_hi < phi_ft->_hi) {
-        return NULL;  // truncation may occur
+        return false;  // truncation may occur
       }
     }
     // No possibility of wrap so truncation can be discarded
@@ -281,35 +311,45 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
     assert(trunc1 == NULL && trunc2 == NULL, "no truncation for int");
   }
 
+  // If the condition is inverted and we will be rolling
+  // through MININT to MAXINT, then bail out.
+  if (bt == BoolTest::eq || // Bail out, but this loop trips at most twice!
+      // Odd stride
+      bt == BoolTest::ne && stride_con != 1 && stride_con != -1 ||
+      // Count down loop rolls through MAXINT
+      (bt == BoolTest::le || bt == BoolTest::lt) && stride_con < 0 ||
+      // Count up loop rolls through MININT
+      (bt == BoolTest::ge || bt == BoolTest::gt) && stride_con > 0 ) {
+    return false; // Bail out
+  }
+
+  const TypeInt* init_t = gvn->type(init_trip)->is_int();
+  const TypeInt* limit_t = gvn->type(limit)->is_int();
+
+  if (stride_con > 0) {
+    long init_p = (long)init_t->_lo + stride_con;
+    if (init_p > (long)max_jint || init_p > (long)limit_t->_hi)
+      return false; // cyclic loop or this loop trips only once
+  } else {
+    long init_p = (long)init_t->_hi + stride_con;
+    if (init_p < (long)min_jint || init_p < (long)limit_t->_lo)
+      return false; // cyclic loop or this loop trips only once
+  }
+
   // =================================================
   // ---- SUCCESS!   Found A Trip-Counted Loop!  -----
   //
-  // Canonicalize the condition on the test.  If we can exactly determine
-  // the trip-counter exit value, then set limit to that value and use
-  // a '!=' test.  Otherwise use condition '<' for count-up loops and
-  // '>' for count-down loops.  If the condition is inverted and we will
-  // be rolling through MININT to MAXINT, then bail out.
-
+  assert(x->Opcode() == Op_Loop, "regular loops only");
   C->print_method("Before CountedLoop", 3);
 
-  // Check for SafePoint on backedge and remove
-  Node *sfpt = x->in(LoopNode::LoopBackControl);
-  if( sfpt->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt)) {
-    lazy_replace( sfpt, iftrue );
-    loop->_tail = iftrue;
-  }
-
-
   // If compare points to incr, we are ok.  Otherwise the compare
   // can directly point to the phi; in this case adjust the compare so that
   // it points to the incr by adjusting the limit.
-  if( cmp->in(1) == phi || cmp->in(2) == phi )
+  if (cmp->in(1) == phi || cmp->in(2) == phi)
     limit = gvn->transform(new (C, 3) AddINode(limit,stride));
 
   // trip-count for +-tive stride should be: (limit - init_trip + stride - 1)/stride.
   // Final value for iterator should be: trip_count * stride + init_trip.
-  const Type *limit_t = limit->bottom_type();
-  const Type *init_t = init_trip->bottom_type();
   Node *one_p = gvn->intcon( 1);
   Node *one_m = gvn->intcon(-1);
 
@@ -317,15 +357,15 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
   Node *hook = new (C, 6) Node(6);
   switch( bt ) {
   case BoolTest::eq:
-    return NULL;                // Bail out, but this loop trips at most twice!
+    ShouldNotReachHere();
   case BoolTest::ne:            // Ahh, the case we desire
-    if( stride_con == 1 )
+    if (stride_con == 1)
       trip_count = gvn->transform(new (C, 3) SubINode(limit,init_trip));
-    else if( stride_con == -1 )
+    else if (stride_con == -1)
       trip_count = gvn->transform(new (C, 3) SubINode(init_trip,limit));
     else
-      return NULL;              // Odd stride; must prove we hit limit exactly
-    set_subtree_ctrl( trip_count );
+      ShouldNotReachHere();
+    set_subtree_ctrl(trip_count);
     //_loop.map(trip_count->_idx,loop(limit));
     break;
   case BoolTest::le:            // Maybe convert to '<' case
@@ -338,7 +378,8 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
     //_loop.map(limit->_idx,limit_loop);
     // Fall into next case
   case BoolTest::lt: {          // Maybe convert to '!=' case
-    if( stride_con < 0 ) return NULL; // Count down loop rolls through MAXINT
+    if (stride_con < 0) // Count down loop rolls through MAXINT
+      ShouldNotReachHere();
     Node *range = gvn->transform(new (C, 3) SubINode(limit,init_trip));
     set_subtree_ctrl( range );
     hook->init_req(0, range);
@@ -367,7 +408,8 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
     //_loop.map(limit->_idx,limit_loop);
     // Fall into next case
   case BoolTest::gt: {          // Maybe convert to '!=' case
-    if( stride_con > 0 ) return NULL; // count up loop rolls through MININT
+    if (stride_con > 0) // count up loop rolls through MININT
+      ShouldNotReachHere();
     Node *range = gvn->transform(new (C, 3) SubINode(limit,init_trip));
     set_subtree_ctrl( range );
     hook->init_req(0, range);
@@ -385,7 +427,7 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
     hook->init_req(3, trip_count);
     break;
   }
-  }
+  } // switch( bt )
 
   Node *span = gvn->transform(new (C, 3) MulINode(trip_count,stride));
   set_subtree_ctrl( span );
@@ -394,83 +436,82 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
   limit = gvn->transform(new (C, 3) AddINode(span,init_trip));
   set_subtree_ctrl( limit );
 
+  // Check for SafePoint on backedge and remove
+  Node *sfpt = x->in(LoopNode::LoopBackControl);
+  if (sfpt->Opcode() == Op_SafePoint && is_deleteable_safept(sfpt)) {
+    lazy_replace( sfpt, iftrue );
+    loop->_tail = iftrue;
+  }
+
   // Build a canonical trip test.
   // Clone code, as old values may be in use.
+  Node* nphi = PhiNode::make(x, init_trip, TypeInt::INT);
+  nphi = _igvn.register_new_node_with_optimizer(nphi);
+  set_ctrl(nphi, get_ctrl(phi));
+
   incr = incr->clone();
-  incr->set_req(1,phi);
+  incr->set_req(1,nphi);
   incr->set_req(2,stride);
   incr = _igvn.register_new_node_with_optimizer(incr);
   set_early_ctrl( incr );
-  _igvn.hash_delete(phi);
-  phi->set_req_X( LoopNode::LoopBackControl, incr, &_igvn );
 
-  // If phi type is more restrictive than Int, raise to
-  // Int to prevent (almost) infinite recursion in igvn
-  // which can only handle integer types for constants or minint..maxint.
-  if (!TypeInt::INT->higher_equal(phi->bottom_type())) {
-    Node* nphi = PhiNode::make(phi->in(0), phi->in(LoopNode::EntryControl), TypeInt::INT);
-    nphi->set_req(LoopNode::LoopBackControl, phi->in(LoopNode::LoopBackControl));
-    nphi = _igvn.register_new_node_with_optimizer(nphi);
-    set_ctrl(nphi, get_ctrl(phi));
-    _igvn.replace_node(phi, nphi);
-    phi = nphi->as_Phi();
-  }
+  nphi->set_req(LoopNode::LoopBackControl, incr);
+  _igvn.replace_node(phi, nphi);
+  phi = nphi->as_Phi();
+
   cmp = cmp->clone();
   cmp->set_req(1,incr);
   cmp->set_req(2,limit);
   cmp = _igvn.register_new_node_with_optimizer(cmp);
   set_ctrl(cmp, iff->in(0));
 
-  Node *tmp = test->clone();
-  assert( tmp->is_Bool(), "" );
-  test = (BoolNode*)tmp;
-  (*(BoolTest*)&test->_test)._test = bt; //BoolTest::ne;
+  test = test->clone()->as_Bool();
+  (*(BoolTest*)&test->_test)._test = bt;
   test->set_req(1,cmp);
   _igvn.register_new_node_with_optimizer(test);
   set_ctrl(test, iff->in(0));
-  // If the exit test is dead, STOP!
-  if( test == NULL ) return NULL;
-  _igvn.hash_delete(iff);
-  iff->set_req_X( 1, test, &_igvn );
 
   // Replace the old IfNode with a new LoopEndNode
-  Node *lex = _igvn.register_new_node_with_optimizer(new (C, 2) CountedLoopEndNode( iff->in(0), iff->in(1), cl_prob, iff->as_If()->_fcnt ));
+  Node *lex = _igvn.register_new_node_with_optimizer(new (C, 2) CountedLoopEndNode( iff->in(0), test, cl_prob, iff->as_If()->_fcnt ));
   IfNode *le = lex->as_If();
   uint dd = dom_depth(iff);
   set_idom(le, le->in(0), dd); // Update dominance for loop exit
   set_loop(le, loop);
 
   // Get the loop-exit control
-  Node *if_f = iff->as_If()->proj_out(!(iftrue_op == Op_IfTrue));
+  Node *iffalse = iff->as_If()->proj_out(!(iftrue_op == Op_IfTrue));
 
   // Need to swap loop-exit and loop-back control?
-  if( iftrue_op == Op_IfFalse ) {
+  if (iftrue_op == Op_IfFalse) {
     Node *ift2=_igvn.register_new_node_with_optimizer(new (C, 1) IfTrueNode (le));
     Node *iff2=_igvn.register_new_node_with_optimizer(new (C, 1) IfFalseNode(le));
 
     loop->_tail = back_control = ift2;
     set_loop(ift2, loop);
-    set_loop(iff2, get_loop(if_f));
+    set_loop(iff2, get_loop(iffalse));
 
     // Lazy update of 'get_ctrl' mechanism.
-    lazy_replace_proj( if_f  , iff2 );
-    lazy_replace_proj( iftrue, ift2 );
+    lazy_replace_proj( iffalse, iff2 );
+    lazy_replace_proj( iftrue,  ift2 );
 
     // Swap names
-    if_f   = iff2;
-    iftrue = ift2;
+    iffalse = iff2;
+    iftrue  = ift2;
   } else {
-    _igvn.hash_delete(if_f  );
+    _igvn.hash_delete(iffalse);
     _igvn.hash_delete(iftrue);
-    if_f  ->set_req_X( 0, le, &_igvn );
-    iftrue->set_req_X( 0, le, &_igvn );
+    iffalse->set_req_X( 0, le, &_igvn );
+    iftrue ->set_req_X( 0, le, &_igvn );
   }
 
-  set_idom(iftrue, le, dd+1);
-  set_idom(if_f,   le, dd+1);
+  set_idom(iftrue,  le, dd+1);
+  set_idom(iffalse, le, dd+1);
+  assert(iff->outcnt() == 0, "should be dead now");
+  lazy_replace( iff, le ); // fix 'get_ctrl'
 
   // Now setup a new CountedLoopNode to replace the existing LoopNode
   CountedLoopNode *l = new (C, 3) CountedLoopNode(init_control, back_control);
+  l->set_unswitch_count(x->as_Loop()->unswitch_count()); // Preserve
   // The following assert is approximately true, and defines the intention
   // of can_be_counted_loop.  It fails, however, because phase->type
   // is not yet initialized for this loop and its parts.
@@ -491,10 +532,14 @@ Node *PhaseIdealLoop::is_counted_loop( Node *x, IdealLoopTree *loop ) {
   // Free up intermediate goo
   _igvn.remove_dead_node(hook);
 
+#ifdef ASSERT
+  assert(l->is_valid_counted_loop(), "counted loop shape is messed up");
+  assert(l == loop->_head && l->phi() == phi && l->loopexit() == lex, "" );
+#endif
+
   C->print_method("After CountedLoop", 3);
 
-  // Return trip counter
-  return trip_count;
+  return true;
 }
 
 
@@ -1256,17 +1301,98 @@ bool PhaseIdealLoop::is_deleteable_safept(Node* sfpt) {
   return true;
 }
 
+//---------------------------replace_parallel_iv-------------------------------
+// Replace parallel induction variable (parallel to trip counter)
+void PhaseIdealLoop::replace_parallel_iv(IdealLoopTree *loop) {
+  assert(loop->_head->is_CountedLoop(), "");
+  CountedLoopNode *cl = loop->_head->as_CountedLoop();
+  Node *incr = cl->incr();
+  if (incr == NULL)
+    return;         // Dead loop?
+  Node *init = cl->init_trip();
+  Node *phi  = cl->phi();
+  // protect against stride not being a constant
+  if (!cl->stride_is_con())
+    return;
+  int stride_con = cl->stride_con();
+
+  PhaseGVN *gvn = &_igvn;
+
+  // Visit all children, looking for Phis
+  for (DUIterator i = cl->outs(); cl->has_out(i); i++) {
+    Node *out = cl->out(i);
+    // Look for other phis (secondary IVs). Skip dead ones
+    if (!out->is_Phi() || out == phi || !has_node(out))
+      continue;
+    PhiNode* phi2 = out->as_Phi();
+    Node *incr2 = phi2->in( LoopNode::LoopBackControl );
+    // Look for induction variables of the form:  X += constant
+    if (phi2->region() != loop->_head ||
+        incr2->req() != 3 ||
+        incr2->in(1) != phi2 ||
+        incr2 == incr ||
+        incr2->Opcode() != Op_AddI ||
+        !incr2->in(2)->is_Con())
+      continue;
+
+    // Check for parallel induction variable (parallel to trip counter)
+    // via an affine function.  In particular, count-down loops with
+    // count-up array indices are common. We only RCE references off
+    // the trip-counter, so we need to convert all these to trip-counter
+    // expressions.
+    Node *init2 = phi2->in( LoopNode::EntryControl );
+    int stride_con2 = incr2->in(2)->get_int();
+
+    // The general case here gets a little tricky.  We want to find the
+    // GCD of all possible parallel IV's and make a new IV using this
+    // GCD for the loop.  Then all possible IVs are simple multiples of
+    // the GCD.  In practice, this will cover very few extra loops.
+    // Instead we require 'stride_con2' to be a multiple of 'stride_con',
+    // where +/-1 is the common case, but other integer multiples are
+    // also easy to handle.
+    int ratio_con = stride_con2/stride_con;
+
+    if ((ratio_con * stride_con) == stride_con2) { // Check for exact
+      // Convert to using the trip counter.  The parallel induction
+      // variable differs from the trip counter by a loop-invariant
+      // amount, the difference between their respective initial values.
+      // It is scaled by the 'ratio_con'.
+      // Perform local Ideal transformation since in most cases ratio == 1.
+      Node* ratio = _igvn.intcon(ratio_con);
+      set_ctrl(ratio, C->root());
+      Node* hook = new (C, 3) Node(3);
+      Node* ratio_init = gvn->transform(new (C, 3) MulINode(init, ratio));
+      hook->init_req(0, ratio_init);
+      Node* diff = gvn->transform(new (C, 3) SubINode(init2, ratio_init));
+      hook->init_req(1, diff);
+      Node* ratio_idx = gvn->transform(new (C, 3) MulINode(phi, ratio));
+      hook->init_req(2, ratio_idx);
+      Node* add  = gvn->transform(new (C, 3) AddINode(ratio_idx, diff));
+      set_subtree_ctrl(add);
+      _igvn.replace_node( phi2, add );
+      // Free up intermediate goo
+      _igvn.remove_dead_node(hook);
+      // Sometimes an induction variable is unused
+      if (add->outcnt() == 0) {
+        _igvn.remove_dead_node(add);
+      }
+      --i; // deleted this phi; rescan starting with next position
+      continue;
+    }
+  }
+}
+
 //------------------------------counted_loop-----------------------------------
 // Convert to counted loops where possible
 void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) {
 
   // For grins, set the inner-loop flag here
-  if( !_child ) {
-    if( _head->is_Loop() ) _head->as_Loop()->set_inner_loop();
+  if (!_child) {
+    if (_head->is_Loop()) _head->as_Loop()->set_inner_loop();
   }
 
-  if( _head->is_CountedLoop() ||
-      phase->is_counted_loop( _head, this ) ) {
+  if (_head->is_CountedLoop() ||
+      phase->is_counted_loop(_head, this)) {
     _has_sfpt = 1;              // Indicate we do not need a safepoint here
 
     // Look for a safepoint to remove
@@ -1275,79 +1401,9 @@ void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) {
           phase->is_deleteable_safept(n))
         phase->lazy_replace(n,n->in(TypeFunc::Control));
 
-    CountedLoopNode *cl = _head->as_CountedLoop();
-    Node *incr = cl->incr();
-    if( !incr ) return;         // Dead loop?
-    Node *init = cl->init_trip();
-    Node *phi  = cl->phi();
-    // protect against stride not being a constant
-    if( !cl->stride_is_con() ) return;
-    int stride_con = cl->stride_con();
-
     // Look for induction variables
+    phase->replace_parallel_iv(this);
 
-    // Visit all children, looking for Phis
-    for (DUIterator i = cl->outs(); cl->has_out(i); i++) {
-      Node *out = cl->out(i);
-      // Look for other phis (secondary IVs). Skip dead ones
-      if (!out->is_Phi() || out == phi || !phase->has_node(out)) continue;
-      PhiNode* phi2 = out->as_Phi();
-      Node *incr2 = phi2->in( LoopNode::LoopBackControl );
-      // Look for induction variables of the form:  X += constant
-      if( phi2->region() != _head ||
-          incr2->req() != 3 ||
-          incr2->in(1) != phi2 ||
-          incr2 == incr ||
-          incr2->Opcode() != Op_AddI ||
-          !incr2->in(2)->is_Con() )
-        continue;
-
-      // Check for parallel induction variable (parallel to trip counter)
-      // via an affine function.  In particular, count-down loops with
-      // count-up array indices are common. We only RCE references off
-      // the trip-counter, so we need to convert all these to trip-counter
-      // expressions.
-      Node *init2 = phi2->in( LoopNode::EntryControl );
-      int stride_con2 = incr2->in(2)->get_int();
-
-      // The general case here gets a little tricky.  We want to find the
-      // GCD of all possible parallel IV's and make a new IV using this
-      // GCD for the loop.  Then all possible IVs are simple multiples of
-      // the GCD.  In practice, this will cover very few extra loops.
-      // Instead we require 'stride_con2' to be a multiple of 'stride_con',
-      // where +/-1 is the common case, but other integer multiples are
-      // also easy to handle.
-      int ratio_con = stride_con2/stride_con;
-
-      if( ratio_con * stride_con == stride_con2 ) { // Check for exact
-        // Convert to using the trip counter.  The parallel induction
-        // variable differs from the trip counter by a loop-invariant
-        // amount, the difference between their respective initial values.
-        // It is scaled by the 'ratio_con'.
-        Compile* C = phase->C;
-        Node* ratio = phase->_igvn.intcon(ratio_con);
-        phase->set_ctrl(ratio, C->root());
-        Node* ratio_init = new (C, 3) MulINode(init, ratio);
-        phase->_igvn.register_new_node_with_optimizer(ratio_init, init);
-        phase->set_early_ctrl(ratio_init);
-        Node* diff = new (C, 3) SubINode(init2, ratio_init);
-        phase->_igvn.register_new_node_with_optimizer(diff, init2);
-        phase->set_early_ctrl(diff);
-        Node* ratio_idx = new (C, 3) MulINode(phi, ratio);
-        phase->_igvn.register_new_node_with_optimizer(ratio_idx, phi);
-        phase->set_ctrl(ratio_idx, cl);
-        Node* add  = new (C, 3) AddINode(ratio_idx, diff);
-        phase->_igvn.register_new_node_with_optimizer(add);
-        phase->set_ctrl(add, cl);
-        phase->_igvn.replace_node( phi2, add );
-        // Sometimes an induction variable is unused
-        if (add->outcnt() == 0) {
-          phase->_igvn.remove_dead_node(add);
-        }
-        --i; // deleted this phi; rescan starting with next position
-        continue;
-      }
-    }
   } else if (_parent != NULL && !_irreducible) {
     // Not a counted loop.
     // Look for a safepoint on the idom-path to remove, preserving the first one
@@ -1366,24 +1422,31 @@ void IdealLoopTree::counted_loop( PhaseIdealLoop *phase ) {
   }
 
   // Recursively
-  if( _child ) _child->counted_loop( phase );
-  if( _next  ) _next ->counted_loop( phase );
+  if (_child) _child->counted_loop( phase );
+  if (_next)  _next ->counted_loop( phase );
 }
 
 #ifndef PRODUCT
 //------------------------------dump_head--------------------------------------
 // Dump 1 liner for loop header info
 void IdealLoopTree::dump_head( ) const {
-  for( uint i=0; i<_nest; i++ )
+  for (uint i=0; i<_nest; i++)
     tty->print("  ");
   tty->print("Loop: N%d/N%d ",_head->_idx,_tail->_idx);
-  if( _irreducible ) tty->print(" IRREDUCIBLE");
-  if( _head->is_CountedLoop() ) {
+  if (_irreducible) tty->print(" IRREDUCIBLE");
+  if (UseLoopPredicate) {
+    Node* entry = _head->in(LoopNode::EntryControl);
+    if (entry != NULL && entry->is_Proj() &&
+        PhaseIdealLoop::is_uncommon_trap_if_pattern(entry->as_Proj(), Deoptimization::Reason_predicate)) {
+      tty->print(" predicated");
+    }
+  }
+  if (_head->is_CountedLoop()) {
     CountedLoopNode *cl = _head->as_CountedLoop();
     tty->print(" counted");
-    if( cl->is_pre_loop () ) tty->print(" pre" );
-    if( cl->is_main_loop() ) tty->print(" main");
-    if( cl->is_post_loop() ) tty->print(" post");
+    if (cl->is_pre_loop ()) tty->print(" pre" );
+    if (cl->is_main_loop()) tty->print(" main");
+    if (cl->is_post_loop()) tty->print(" post");
   }
   tty->cr();
 }
@@ -1392,8 +1455,8 @@ void IdealLoopTree::dump_head( ) const {
 // Dump loops by loop tree
 void IdealLoopTree::dump( ) const {
   dump_head();
-  if( _child ) _child->dump();
-  if( _next  ) _next ->dump();
+  if (_child) _child->dump();
+  if (_next)  _next ->dump();
 }
 
 #endif
@@ -1439,19 +1502,19 @@ void PhaseIdealLoop::collect_potentially_useful_predicates(
   }
 
   // self (only loops that we can apply loop predication may use their predicates)
-  if (loop->_head->is_Loop()     &&
-      !loop->_irreducible        &&
+  if (loop->_head->is_Loop() &&
+      !loop->_irreducible    &&
       !loop->tail()->is_top()) {
-    LoopNode *lpn  = loop->_head->as_Loop();
+    LoopNode* lpn = loop->_head->as_Loop();
     Node* entry = lpn->in(LoopNode::EntryControl);
-    ProjNode *predicate_proj = find_predicate_insertion_point(entry);
+    Node* predicate_proj = find_predicate(entry);
     if (predicate_proj != NULL ) { // right pattern that can be used by loop predication
-      assert(entry->in(0)->in(1)->in(1)->Opcode()==Op_Opaque1, "must be");
+      assert(entry->in(0)->in(1)->in(1)->Opcode() == Op_Opaque1, "must be");
       useful_predicates.push(entry->in(0)->in(1)->in(1)); // good one
     }
   }
 
-  if ( loop->_next ) { // sibling
+  if (loop->_next) { // sibling
     collect_potentially_useful_predicates(loop->_next, useful_predicates);
   }
 }
@@ -1459,7 +1522,8 @@ void PhaseIdealLoop::collect_potentially_useful_predicates(
 //------------------------eliminate_useless_predicates-----------------------------
 // Eliminate all inserted predicates if they could not be used by loop predication.
 void PhaseIdealLoop::eliminate_useless_predicates() {
-  if (C->predicate_count() == 0) return; // no predicate left
+  if (C->predicate_count() == 0)
+    return; // no predicate left
 
   Unique_Node_List useful_predicates; // to store useful predicates
   if (C->has_loops()) {
@@ -1647,12 +1711,15 @@ void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool do_loop_pred) {
 
 #ifndef PRODUCT
   C->verify_graph_edges();
-  if( _verify_me ) {             // Nested verify pass?
+  if (_verify_me) {             // Nested verify pass?
     // Check to see if the verify mode is broken
     assert(C->unique() == unique, "non-optimize mode made Nodes? ? ?");
     return;
   }
-  if( VerifyLoopOptimizations ) verify();
+  if(VerifyLoopOptimizations) verify();
+  if(TraceLoopOpts && C->has_loops()) {
+    _ltree_root->dump();
+  }
 #endif
 
   if (ReassociateInvariants) {
diff --git a/hotspot/src/share/vm/opto/loopnode.hpp b/hotspot/src/share/vm/opto/loopnode.hpp
index 7f44acccf63..9edcdf2922a 100644
--- a/hotspot/src/share/vm/opto/loopnode.hpp
+++ b/hotspot/src/share/vm/opto/loopnode.hpp
@@ -93,6 +93,7 @@ public:
       in(1) != NULL && phase->type(in(1)) != Type::TOP &&
       in(2) != NULL && phase->type(in(2)) != Type::TOP;
   }
+  bool is_valid_counted_loop() const;
 #ifndef PRODUCT
   virtual void dump_spec(outputStream *st) const;
 #endif
@@ -101,9 +102,8 @@ public:
 //------------------------------Counted Loops----------------------------------
 // Counted loops are all trip-counted loops, with exactly 1 trip-counter exit
 // path (and maybe some other exit paths).  The trip-counter exit is always
-// last in the loop.  The trip-counter does not have to stride by a constant,
-// but it does have to stride by a loop-invariant amount; the exit value is
-// also loop invariant.
+// last in the loop.  The trip-counter have to stride by a constant;
+// the exit value is also loop invariant.
 
 // CountedLoopNodes and CountedLoopEndNodes come in matched pairs.  The
 // CountedLoopNode has the incoming loop control and the loop-back-control
@@ -112,7 +112,7 @@ public:
 // CountedLoopNode if there is control flow in the loop), the post-increment
 // trip-counter value, and the limit.  The trip-counter value is always of
 // the form (Op old-trip-counter stride).  The old-trip-counter is produced
-// by a Phi connected to the CountedLoopNode.  The stride is loop invariant.
+// by a Phi connected to the CountedLoopNode.  The stride is constant.
 // The Op is any commutable opcode, including Add, Mul, Xor.  The
 // CountedLoopEndNode also takes in the loop-invariant limit value.
 
@@ -696,6 +696,9 @@ private:
   // Is safept not required by an outer loop?
   bool is_deleteable_safept(Node* sfpt);
 
+  // Replace parallel induction variable (parallel to trip counter)
+  void replace_parallel_iv(IdealLoopTree *loop);
+
   // Perform verification that the graph is valid.
   PhaseIdealLoop( PhaseIterGVN &igvn) :
     PhaseTransform(Ideal_Loop),
@@ -751,7 +754,7 @@ public:
   // Per-Node transform
   virtual Node *transform( Node *a_node ) { return 0; }
 
-  Node *is_counted_loop( Node *x, IdealLoopTree *loop );
+  bool is_counted_loop( Node *x, IdealLoopTree *loop );
 
   // Return a post-walked LoopNode
   IdealLoopTree *get_loop( Node *n ) const {
@@ -815,16 +818,22 @@ public:
   bool is_scaled_iv_plus_offset(Node* exp, Node* iv, int* p_scale, Node** p_offset, int depth = 0);
 
   // Return true if proj is for "proj->[region->..]call_uct"
-  bool is_uncommon_trap_proj(ProjNode* proj, bool must_reason_predicate = false);
+  // Return true if proj is for "proj->[region->..]call_uct"
+  static bool is_uncommon_trap_proj(ProjNode* proj, Deoptimization::DeoptReason reason);
   // Return true for    "if(test)-> proj -> ...
   //                          |
   //                          V
   //                      other_proj->[region->..]call_uct"
-  bool is_uncommon_trap_if_pattern(ProjNode* proj, bool must_reason_predicate = false);
+  static bool is_uncommon_trap_if_pattern(ProjNode* proj, Deoptimization::DeoptReason reason);
   // Create a new if above the uncommon_trap_if_pattern for the predicate to be promoted
-  ProjNode* create_new_if_for_predicate(ProjNode* cont_proj);
-  // Find a good location to insert a predicate
-  ProjNode* find_predicate_insertion_point(Node* start_c);
+  ProjNode* create_new_if_for_predicate(ProjNode* cont_proj, Node* new_entry,
+                                        Deoptimization::DeoptReason reason);
+  void register_control(Node* n, IdealLoopTree *loop, Node* pred);
+
+   // Find a good location to insert a predicate
+  static ProjNode* find_predicate_insertion_point(Node* start_c, Deoptimization::DeoptReason reason);
+  // Find a predicate
+  static Node* find_predicate(Node* entry);
   // Construct a range check for a predicate if
   BoolNode* rc_predicate(Node* ctrl,
                          int scale, Node* offset,
@@ -936,7 +945,7 @@ public:
   Node *has_local_phi_input( Node *n );
   // Mark an IfNode as being dominated by a prior test,
   // without actually altering the CFG (and hence IDOM info).
-  void dominated_by( Node *prevdom, Node *iff );
+  void dominated_by( Node *prevdom, Node *iff, bool flip = false );
 
   // Split Node 'n' through merge point
   Node *split_thru_region( Node *n, Node *region );
diff --git a/hotspot/src/share/vm/opto/loopopts.cpp b/hotspot/src/share/vm/opto/loopopts.cpp
index 9f56692866e..ae62e609f3f 100644
--- a/hotspot/src/share/vm/opto/loopopts.cpp
+++ b/hotspot/src/share/vm/opto/loopopts.cpp
@@ -42,13 +42,13 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
     return NULL;
   }
   int wins = 0;
-  assert( !n->is_CFG(), "" );
-  assert( region->is_Region(), "" );
+  assert(!n->is_CFG(), "");
+  assert(region->is_Region(), "");
 
   const Type* type = n->bottom_type();
   const TypeOopPtr *t_oop = _igvn.type(n)->isa_oopptr();
   Node *phi;
-  if( t_oop != NULL && t_oop->is_known_instance_field() ) {
+  if (t_oop != NULL && t_oop->is_known_instance_field()) {
     int iid    = t_oop->instance_id();
     int index  = C->get_alias_index(t_oop);
     int offset = t_oop->offset();
@@ -57,20 +57,20 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
     phi = PhiNode::make_blank(region, n);
   }
   uint old_unique = C->unique();
-  for( uint i = 1; i < region->req(); i++ ) {
+  for (uint i = 1; i < region->req(); i++) {
     Node *x;
     Node* the_clone = NULL;
-    if( region->in(i) == C->top() ) {
+    if (region->in(i) == C->top()) {
       x = C->top();             // Dead path?  Use a dead data op
     } else {
       x = n->clone();           // Else clone up the data op
       the_clone = x;            // Remember for possible deletion.
       // Alter data node to use pre-phi inputs
-      if( n->in(0) == region )
+      if (n->in(0) == region)
         x->set_req( 0, region->in(i) );
-      for( uint j = 1; j < n->req(); j++ ) {
+      for (uint j = 1; j < n->req(); j++) {
         Node *in = n->in(j);
-        if( in->is_Phi() && in->in(0) == region )
+        if (in->is_Phi() && in->in(0) == region)
           x->set_req( j, in->in(i) ); // Use pre-Phi input for the clone
       }
     }
@@ -85,7 +85,7 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
     // happen if the singleton occurs on loop entry, as the elimination of
     // the PhiNode may cause the resulting node to migrate back to a previous
     // loop iteration.
-    if( singleton && t == Type::TOP ) {
+    if (singleton && t == Type::TOP) {
       // Is_Loop() == false does not confirm the absence of a loop (e.g., an
       // irreducible loop may not be indicated by an affirmative is_Loop());
       // therefore, the only top we can split thru a phi is on a backedge of
@@ -93,7 +93,7 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
       singleton &= region->is_Loop() && (i != LoopNode::EntryControl);
     }
 
-    if( singleton ) {
+    if (singleton) {
       wins++;
       x = ((PhaseGVN&)_igvn).makecon(t);
     } else {
@@ -108,12 +108,12 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
       // igvn->type(x) is set to x->Value() already.
       x->raise_bottom_type(t);
       Node *y = x->Identity(&_igvn);
-      if( y != x ) {
+      if (y != x) {
         wins++;
         x = y;
       } else {
         y = _igvn.hash_find(x);
-        if( y ) {
+        if (y) {
           wins++;
           x = y;
         } else {
@@ -129,7 +129,7 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
     phi->set_req( i, x );
   }
   // Too few wins?
-  if( wins <= policy ) {
+  if (wins <= policy) {
     _igvn.remove_dead_node(phi);
     return NULL;
   }
@@ -137,7 +137,7 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
   // Record Phi
   register_new_node( phi, region );
 
-  for( uint i2 = 1; i2 < phi->req(); i2++ ) {
+  for (uint i2 = 1; i2 < phi->req(); i2++) {
     Node *x = phi->in(i2);
     // If we commoned up the cloned 'x' with another existing Node,
     // the existing Node picks up a new use.  We need to make the
@@ -145,24 +145,44 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
     Node *old_ctrl;
     IdealLoopTree *old_loop;
 
+    if (x->is_Con()) {
+      // Constant's control is always root.
+      set_ctrl(x, C->root());
+      continue;
+    }
     // The occasional new node
-    if( x->_idx >= old_unique ) {   // Found a new, unplaced node?
-      old_ctrl = x->is_Con() ? C->root() : NULL;
-      old_loop = NULL;              // Not in any prior loop
+    if (x->_idx >= old_unique) {     // Found a new, unplaced node?
+      old_ctrl = NULL;
+      old_loop = NULL;               // Not in any prior loop
     } else {
-      old_ctrl = x->is_Con() ? C->root() : get_ctrl(x);
+      old_ctrl = get_ctrl(x);
       old_loop = get_loop(old_ctrl); // Get prior loop
     }
     // New late point must dominate new use
-    Node *new_ctrl = dom_lca( old_ctrl, region->in(i2) );
+    Node *new_ctrl = dom_lca(old_ctrl, region->in(i2));
+    if (new_ctrl == old_ctrl) // Nothing is changed
+      continue;
+
+    IdealLoopTree *new_loop = get_loop(new_ctrl);
+
+    // Don't move x into a loop if its uses are
+    // outside of loop. Otherwise x will be cloned
+    // for each use outside of this loop.
+    IdealLoopTree *use_loop = get_loop(region);
+    if (!new_loop->is_member(use_loop) &&
+        (old_loop == NULL || !new_loop->is_member(old_loop))) {
+      // Take early control, later control will be recalculated
+      // during next iteration of loop optimizations.
+      new_ctrl = get_early_ctrl(x);
+      new_loop = get_loop(new_ctrl);
+    }
     // Set new location
     set_ctrl(x, new_ctrl);
-    IdealLoopTree *new_loop = get_loop( new_ctrl );
     // If changing loop bodies, see if we need to collect into new body
-    if( old_loop != new_loop ) {
-      if( old_loop && !old_loop->_child )
+    if (old_loop != new_loop) {
+      if (old_loop && !old_loop->_child)
         old_loop->_body.yank(x);
-      if( !new_loop->_child )
+      if (!new_loop->_child)
         new_loop->_body.push(x);  // Collect body info
     }
   }
@@ -174,9 +194,9 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) {
 // Replace the dominated test with an obvious true or false.  Place it on the
 // IGVN worklist for later cleanup.  Move control-dependent data Nodes on the
 // live path up to the dominating control.
-void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff ) {
+void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff, bool flip ) {
 #ifndef PRODUCT
-  if( VerifyLoopOptimizations && PrintOpto ) tty->print_cr("dominating test");
+  if (VerifyLoopOptimizations && PrintOpto) tty->print_cr("dominating test");
 #endif
 
 
@@ -185,6 +205,12 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff ) {
   assert( iff->Opcode() == Op_If || iff->Opcode() == Op_CountedLoopEnd, "Check this code when new subtype is added");
   int pop = prevdom->Opcode();
   assert( pop == Op_IfFalse || pop == Op_IfTrue, "" );
+  if (flip) {
+    if (pop == Op_IfTrue)
+      pop = Op_IfFalse;
+    else
+      pop = Op_IfTrue;
+  }
   // 'con' is set to true or false to kill the dominated test.
   Node *con = _igvn.makecon(pop == Op_IfTrue ? TypeInt::ONE : TypeInt::ZERO);
   set_ctrl(con, C->root()); // Constant gets a new use
@@ -197,7 +223,7 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff ) {
   // I can assume this path reaches an infinite loop.  In this case it's not
   // important to optimize the data Nodes - either the whole compilation will
   // be tossed or this path (and all data Nodes) will go dead.
-  if( iff->outcnt() != 2 ) return;
+  if (iff->outcnt() != 2) return;
 
   // Make control-dependent data Nodes on the live path (path that will remain
   // once the dominated IF is removed) become control-dependent on the
@@ -207,16 +233,16 @@ void PhaseIdealLoop::dominated_by( Node *prevdom, Node *iff ) {
 
   for (DUIterator_Fast imax, i = dp->fast_outs(imax); i < imax; i++) {
     Node* cd = dp->fast_out(i); // Control-dependent node
-    if( cd->depends_only_on_test() ) {
-      assert( cd->in(0) == dp, "" );
-      _igvn.hash_delete( cd );
+    if (cd->depends_only_on_test()) {
+      assert(cd->in(0) == dp, "");
+      _igvn.hash_delete(cd);
       cd->set_req(0, prevdom);
-      set_early_ctrl( cd );
+      set_early_ctrl(cd);
       _igvn._worklist.push(cd);
       IdealLoopTree *new_loop = get_loop(get_ctrl(cd));
-      if( old_loop != new_loop ) {
-        if( !old_loop->_child ) old_loop->_body.yank(cd);
-        if( !new_loop->_child ) new_loop->_body.push(cd);
+      if (old_loop != new_loop) {
+        if (!old_loop->_child) old_loop->_body.yank(cd);
+        if (!new_loop->_child) new_loop->_body.push(cd);
       }
       --i;
       --imax;
@@ -2338,6 +2364,11 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) {
   }
 
 #if !defined(PRODUCT)
+  if (TraceLoopOpts) {
+    tty->print("PartialPeel  ");
+    loop->dump_head();
+  }
+
   if (TracePartialPeeling) {
     tty->print_cr("before partial peel one iteration");
     Node_List wl;
@@ -2481,6 +2512,7 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) {
   // Create new loop head for new phis and to hang
   // the nodes being moved (sinked) from the peel region.
   LoopNode* new_head = new (C, 3) LoopNode(last_peel, last_peel);
+  new_head->set_unswitch_count(head->unswitch_count()); // Preserve
   _igvn.register_new_node_with_optimizer(new_head);
   assert(first_not_peeled->in(0) == last_peel, "last_peel <- first_not_peeled");
   first_not_peeled->set_req(0, new_head);
@@ -2651,24 +2683,23 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) {
 // prevent loop-fallout uses of the pre-incremented trip counter (which are
 // then alive with the post-incremented trip counter forcing an extra
 // register move)
-void PhaseIdealLoop::reorg_offsets( IdealLoopTree *loop ) {
+void PhaseIdealLoop::reorg_offsets(IdealLoopTree *loop) {
+  // Perform it only for canonical counted loops.
+  // Loop's shape could be messed up by iteration_split_impl.
+  if (!loop->_head->is_CountedLoop())
+    return;
+  if (!loop->_head->as_Loop()->is_valid_counted_loop())
+    return;
 
   CountedLoopNode *cl = loop->_head->as_CountedLoop();
   CountedLoopEndNode *cle = cl->loopexit();
-  if( !cle ) return;            // The occasional dead loop
-  // Find loop exit control
   Node *exit = cle->proj_out(false);
-  assert( exit->Opcode() == Op_IfFalse, "" );
+  Node *phi = cl->phi();
 
   // Check for the special case of folks using the pre-incremented
   // trip-counter on the fall-out path (forces the pre-incremented
   // and post-incremented trip counter to be live at the same time).
   // Fix this by adjusting to use the post-increment trip counter.
-  Node *phi = cl->phi();
-  if( !phi ) return;            // Dead infinite loop
-
-  // Shape messed up, probably by iteration_split_impl
-  if (phi->in(LoopNode::LoopBackControl) != cl->incr()) return;
 
   bool progress = true;
   while (progress) {
@@ -2677,21 +2708,19 @@ void PhaseIdealLoop::reorg_offsets( IdealLoopTree *loop ) {
       Node* use = phi->fast_out(i);   // User of trip-counter
       if (!has_ctrl(use))  continue;
       Node *u_ctrl = get_ctrl(use);
-      if( use->is_Phi() ) {
+      if (use->is_Phi()) {
         u_ctrl = NULL;
-        for( uint j = 1; j < use->req(); j++ )
-          if( use->in(j) == phi )
-            u_ctrl = dom_lca( u_ctrl, use->in(0)->in(j) );
+        for (uint j = 1; j < use->req(); j++)
+          if (use->in(j) == phi)
+            u_ctrl = dom_lca(u_ctrl, use->in(0)->in(j));
       }
       IdealLoopTree *u_loop = get_loop(u_ctrl);
       // Look for loop-invariant use
-      if( u_loop == loop ) continue;
-      if( loop->is_member( u_loop ) ) continue;
+      if (u_loop == loop) continue;
+      if (loop->is_member(u_loop)) continue;
       // Check that use is live out the bottom.  Assuming the trip-counter
       // update is right at the bottom, uses of of the loop middle are ok.
-      if( dom_lca( exit, u_ctrl ) != exit ) continue;
-      // protect against stride not being a constant
-      if( !cle->stride_is_con() ) continue;
+      if (dom_lca(exit, u_ctrl) != exit) continue;
       // Hit!  Refactor use to use the post-incremented tripcounter.
       // Compute a post-increment tripcounter.
       Node *opaq = new (C, 2) Opaque2Node( C, cle->incr() );
@@ -2702,9 +2731,10 @@ void PhaseIdealLoop::reorg_offsets( IdealLoopTree *loop ) {
       register_new_node( post, u_ctrl );
       _igvn.hash_delete(use);
       _igvn._worklist.push(use);
-      for( uint j = 1; j < use->req(); j++ )
-        if( use->in(j) == phi )
+      for (uint j = 1; j < use->req(); j++) {
+        if (use->in(j) == phi)
           use->set_req(j, post);
+      }
       // Since DU info changed, rerun loop
       progress = true;
       break;
diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp
index 926a1afd44a..b9ff98ff76d 100644
--- a/hotspot/src/share/vm/opto/memnode.cpp
+++ b/hotspot/src/share/vm/opto/memnode.cpp
@@ -1573,9 +1573,9 @@ const Type *LoadNode::Value( PhaseTransform *phase ) const {
             return TypeInt::make(constant.as_int());
           } else if (constant.basic_type() == T_ARRAY) {
             if (adr->bottom_type()->is_ptr_to_narrowoop()) {
-              return TypeNarrowOop::make_from_constant(constant.as_object());
+              return TypeNarrowOop::make_from_constant(constant.as_object(), true);
             } else {
-              return TypeOopPtr::make_from_constant(constant.as_object());
+              return TypeOopPtr::make_from_constant(constant.as_object(), true);
             }
           }
         }
diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp
index de294231621..a57508b418e 100644
--- a/hotspot/src/share/vm/opto/output.cpp
+++ b/hotspot/src/share/vm/opto/output.cpp
@@ -1028,7 +1028,7 @@ void NonSafepointEmitter::emit_non_safepoint() {
 
 // helper for Fill_buffer bailout logic
 static void turn_off_compiler(Compile* C) {
-  if (CodeCache::unallocated_capacity() >= CodeCacheMinimumFreeSpace*10) {
+  if (CodeCache::largest_free_block() >= CodeCacheMinimumFreeSpace*10) {
     // Do not turn off compilation if a single giant method has
     // blown the code cache size.
     C->record_failure("excessive request to CodeCache");
diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp
index a8d63b55df6..7a57ff79e79 100644
--- a/hotspot/src/share/vm/opto/parse.hpp
+++ b/hotspot/src/share/vm/opto/parse.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -136,6 +136,7 @@ class Parse : public GraphKit {
     uint               _count;          // how many times executed?  Currently only set by _goto's
     bool               _is_parsed;      // has this block been parsed yet?
     bool               _is_handler;     // is this block an exception handler?
+    bool               _has_merged_backedge; // does this block have merged backedge?
     SafePointNode*     _start_map;      // all values flowing into this block
     MethodLivenessResult _live_locals;  // lazily initialized liveness bitmap
 
@@ -168,6 +169,18 @@ class Parse : public GraphKit {
     // True after any predecessor flows control into this block
     bool is_merged() const                 { return _start_map != NULL; }
 
+#ifdef ASSERT
+    // True after backedge predecessor flows control into this block
+    bool has_merged_backedge() const       { return _has_merged_backedge; }
+    void mark_merged_backedge(Block* pred) {
+      assert(is_SEL_head(), "should be loop head");
+      if (pred != NULL && is_SEL_backedge(pred)) {
+        assert(is_parsed(), "block should be parsed before merging backedges");
+        _has_merged_backedge = true;
+      }
+    }
+#endif
+
     // True when all non-exception predecessors have been parsed.
     bool is_ready() const                  { return preds_parsed() == pred_count(); }
 
@@ -441,11 +454,6 @@ class Parse : public GraphKit {
     }
   }
 
-  // Return true if the parser should add a loop predicate
-  bool should_add_predicate(int target_bci);
-  // Insert a loop predicate into the graph
-  void add_predicate();
-
   // Note:  Intrinsic generation routines may be found in library_call.cpp.
 
   // Helper function to setup Ideal Call nodes
@@ -483,8 +491,8 @@ class Parse : public GraphKit {
   bool static_field_ok_in_clinit(ciField *field, ciMethod *method);
 
   // common code for actually performing the load or store
-  void do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field);
-  void do_put_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field);
+  void do_get_xxx(Node* obj, ciField* field, bool is_field);
+  void do_put_xxx(Node* obj, ciField* field, bool is_field);
 
   // loading from a constant field or the constant pool
   // returns false if push failed (non-perm field constants only, not ldcs)
diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp
index 3729c38b42c..589a541048e 100644
--- a/hotspot/src/share/vm/opto/parse1.cpp
+++ b/hotspot/src/share/vm/opto/parse1.cpp
@@ -637,6 +637,25 @@ void Parse::do_all_blocks() {
         // (Note that dead locals do not get phis built, ever.)
         ensure_phis_everywhere();
 
+        if (block->is_SEL_head() &&
+            UseLoopPredicate) {
+          // Add predicate to single entry (not irreducible) loop head.
+          assert(!block->has_merged_backedge(), "only entry paths should be merged for now");
+          // Need correct bci for predicate.
+          // It is fine to set it here since do_one_block() will set it anyway.
+          set_parse_bci(block->start());
+          add_predicate();
+          // Add new region for back branches.
+          int edges = block->pred_count() - block->preds_parsed() + 1; // +1 for original region
+          RegionNode *r = new (C, edges+1) RegionNode(edges+1);
+          _gvn.set_type(r, Type::CONTROL);
+          record_for_igvn(r);
+          r->init_req(edges, control());
+          set_control(r);
+          // Add new phis.
+          ensure_phis_everywhere();
+        }
+
         // Leave behind an undisturbed copy of the map, for future merges.
         set_map(clone_map());
       }
@@ -1113,7 +1132,7 @@ void Parse::Block::init_node(Parse* outer, int rpo) {
   _preds_parsed = 0;
   _count = 0;
   assert(pred_count() == 0 && preds_parsed() == 0, "sanity");
-  assert(!(is_merged() || is_parsed() || is_handler()), "sanity");
+  assert(!(is_merged() || is_parsed() || is_handler() || has_merged_backedge()), "sanity");
   assert(_live_locals.size() == 0, "sanity");
 
   // entry point has additional predecessor
@@ -1350,10 +1369,6 @@ void Parse::do_one_block() {
     set_parse_bci(iter().cur_bci());
 
     if (bci() == block()->limit()) {
-      // insert a predicate if it falls through to a loop head block
-      if (should_add_predicate(bci())){
-        add_predicate();
-      }
       // Do not walk into the next block until directed by do_all_blocks.
       merge(bci());
       break;
@@ -1498,17 +1513,29 @@ void Parse::merge_common(Parse::Block* target, int pnum) {
         || target->is_handler()       // These have unpredictable inputs.
         || target->is_loop_head()     // Known multiple inputs
         || control()->is_Region()) {  // We must hide this guy.
+
+      int current_bci = bci();
+      set_parse_bci(target->start()); // Set target bci
+      if (target->is_SEL_head()) {
+        DEBUG_ONLY( target->mark_merged_backedge(block()); )
+        if (target->start() == 0) {
+          // Add loop predicate for the special case when
+          // there are backbranches to the method entry.
+          add_predicate();
+        }
+      }
       // Add a Region to start the new basic block.  Phis will be added
       // later lazily.
       int edges = target->pred_count();
       if (edges < pnum)  edges = pnum;  // might be a new path!
-      Node *r = new (C, edges+1) RegionNode(edges+1);
+      RegionNode *r = new (C, edges+1) RegionNode(edges+1);
       gvn().set_type(r, Type::CONTROL);
       record_for_igvn(r);
       // zap all inputs to NULL for debugging (done in Node(uint) constructor)
       // for (int j = 1; j < edges+1; j++) { r->init_req(j, NULL); }
       r->init_req(pnum, control());
       set_control(r);
+      set_parse_bci(current_bci); // Restore bci
     }
 
     // Convert the existing Parser mapping into a mapping at this bci.
@@ -1517,7 +1544,11 @@ void Parse::merge_common(Parse::Block* target, int pnum) {
 
   } else {                      // Prior mapping at this bci
     if (TraceOptoParse) {  tty->print(" with previous state"); }
-
+#ifdef ASSERT
+    if (target->is_SEL_head()) {
+      target->mark_merged_backedge(block());
+    }
+#endif
     // We must not manufacture more phis if the target is already parsed.
     bool nophi = target->is_parsed();
 
@@ -2054,37 +2085,6 @@ void Parse::add_safepoint() {
   }
 }
 
-//------------------------------should_add_predicate--------------------------
-bool Parse::should_add_predicate(int target_bci) {
-  if (!UseLoopPredicate) return false;
-  Block* target = successor_for_bci(target_bci);
-  if (target != NULL          &&
-      target->is_loop_head()  &&
-      block()->rpo() < target->rpo()) {
-    return true;
-  }
-  return false;
-}
-
-//------------------------------add_predicate---------------------------------
-void Parse::add_predicate() {
-  assert(UseLoopPredicate,"use only for loop predicate");
-  Node *cont    = _gvn.intcon(1);
-  Node* opq     = _gvn.transform(new (C, 2) Opaque1Node(C, cont));
-  Node *bol     = _gvn.transform(new (C, 2) Conv2BNode(opq));
-  IfNode* iff   = create_and_map_if(control(), bol, PROB_MAX, COUNT_UNKNOWN);
-  Node* iffalse = _gvn.transform(new (C, 1) IfFalseNode(iff));
-  C->add_predicate_opaq(opq);
-  {
-    PreserveJVMState pjvms(this);
-    set_control(iffalse);
-    uncommon_trap(Deoptimization::Reason_predicate,
-                  Deoptimization::Action_maybe_recompile);
-  }
-  Node* iftrue = _gvn.transform(new (C, 1) IfTrueNode(iff));
-  set_control(iftrue);
-}
-
 #ifndef PRODUCT
 //------------------------show_parse_info--------------------------------------
 void Parse::show_parse_info() {
diff --git a/hotspot/src/share/vm/opto/parse2.cpp b/hotspot/src/share/vm/opto/parse2.cpp
index a9f42eb7a08..162878e6aa8 100644
--- a/hotspot/src/share/vm/opto/parse2.cpp
+++ b/hotspot/src/share/vm/opto/parse2.cpp
@@ -293,11 +293,6 @@ void Parse::do_tableswitch() {
   if (len < 1) {
     // If this is a backward branch, add safepoint
     maybe_add_safepoint(default_dest);
-    if (should_add_predicate(default_dest)){
-      _sp += 1; // set original stack for use by uncommon_trap
-      add_predicate();
-      _sp -= 1;
-    }
     merge(default_dest);
     return;
   }
@@ -344,11 +339,6 @@ void Parse::do_lookupswitch() {
 
   if (len < 1) {    // If this is a backward branch, add safepoint
     maybe_add_safepoint(default_dest);
-    if (should_add_predicate(default_dest)){
-      _sp += 1; // set original stack for use by uncommon_trap
-      add_predicate();
-      _sp -= 1;
-    }
     merge(default_dest);
     return;
   }
@@ -756,9 +746,6 @@ void Parse::do_jsr() {
   push(_gvn.makecon(ret_addr));
 
   // Flow to the jsr.
-  if (should_add_predicate(jsr_bci)){
-    add_predicate();
-  }
   merge(jsr_bci);
 }
 
@@ -1040,11 +1027,6 @@ void Parse::do_ifnull(BoolTest::mask btest, Node *c) {
       profile_taken_branch(target_bci);
       adjust_map_after_if(btest, c, prob, branch_block, next_block);
       if (!stopped()) {
-        if (should_add_predicate(target_bci)){ // add a predicate if it branches to a loop
-          int nargs = repush_if_args(); // set original stack for uncommon_trap
-          add_predicate();
-          _sp -= nargs;
-        }
         merge(target_bci);
       }
     }
@@ -1168,11 +1150,6 @@ void Parse::do_if(BoolTest::mask btest, Node* c) {
       profile_taken_branch(target_bci);
       adjust_map_after_if(taken_btest, c, prob, branch_block, next_block);
       if (!stopped()) {
-        if (should_add_predicate(target_bci)){ // add a predicate if it branches to a loop
-          int nargs = repush_if_args(); // set original stack for the uncommon_trap
-          add_predicate();
-          _sp -= nargs;
-        }
         merge(target_bci);
       }
     }
@@ -2166,10 +2143,6 @@ void Parse::do_one_bytecode() {
     // Update method data
     profile_taken_branch(target_bci);
 
-    // Add loop predicate if it goes to a loop
-    if (should_add_predicate(target_bci)){
-      add_predicate();
-    }
     // Merge the current control into the target basic block
     merge(target_bci);
 
diff --git a/hotspot/src/share/vm/opto/parse3.cpp b/hotspot/src/share/vm/opto/parse3.cpp
index 82763367017..eec5131e1a9 100644
--- a/hotspot/src/share/vm/opto/parse3.cpp
+++ b/hotspot/src/share/vm/opto/parse3.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,29 +112,31 @@ void Parse::do_field_access(bool is_get, bool is_field) {
     // Compile-time detect of null-exception?
     if (stopped())  return;
 
+#ifdef ASSERT
     const TypeInstPtr *tjp = TypeInstPtr::make(TypePtr::NotNull, iter().get_declared_field_holder());
     assert(_gvn.type(obj)->higher_equal(tjp), "cast_up is no longer needed");
+#endif
 
     if (is_get) {
       --_sp;  // pop receiver before getting
-      do_get_xxx(tjp, obj, field, is_field);
+      do_get_xxx(obj, field, is_field);
     } else {
-      do_put_xxx(tjp, obj, field, is_field);
+      do_put_xxx(obj, field, is_field);
       --_sp;  // pop receiver after putting
     }
   } else {
-    const TypeKlassPtr* tkp = TypeKlassPtr::make(field_holder);
-    obj = _gvn.makecon(tkp);
+    const TypeInstPtr* tip = TypeInstPtr::make(field_holder->java_mirror());
+    obj = _gvn.makecon(tip);
     if (is_get) {
-      do_get_xxx(tkp, obj, field, is_field);
+      do_get_xxx(obj, field, is_field);
     } else {
-      do_put_xxx(tkp, obj, field, is_field);
+      do_put_xxx(obj, field, is_field);
     }
   }
 }
 
 
-void Parse::do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
+void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
   // Does this field have a constant value?  If so, just push the value.
   if (field->is_constant()) {
     if (field->is_static()) {
@@ -143,8 +145,8 @@ void Parse::do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool
         return;
     }
     else {
-      // final non-static field of a trusted class ({java,sun}.dyn
-      // classes).
+      // final non-static field of a trusted class (classes in
+      // java.lang.invoke and sun.invoke packages and subpackages).
       if (obj->is_Con()) {
         const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr();
         ciObject* constant_oop = oop_ptr->const_oop();
@@ -231,7 +233,7 @@ void Parse::do_get_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool
   }
 }
 
-void Parse::do_put_xxx(const TypePtr* obj_type, Node* obj, ciField* field, bool is_field) {
+void Parse::do_put_xxx(Node* obj, ciField* field, bool is_field) {
   bool is_vol = field->is_volatile();
   // If reference is volatile, prevent following memory ops from
   // floating down past the volatile write.  Also prevents commoning
diff --git a/hotspot/src/share/vm/opto/stringopts.cpp b/hotspot/src/share/vm/opto/stringopts.cpp
index 658fc05b11c..c039480118f 100644
--- a/hotspot/src/share/vm/opto/stringopts.cpp
+++ b/hotspot/src/share/vm/opto/stringopts.cpp
@@ -910,7 +910,7 @@ Node* PhaseStringOpts::fetch_static_field(GraphKit& kit, ciField* field) {
       ciObject* con = field->constant_value().as_object();
       // Do not "join" in the previous type; it doesn't add value,
       // and may yield a vacuous result if the field is of interface type.
-      type = TypeOopPtr::make_from_constant(con)->isa_oopptr();
+      type = TypeOopPtr::make_from_constant(con, true)->isa_oopptr();
       assert(type != NULL, "field singleton type must be consistent");
     } else {
       type = TypeOopPtr::make_from_klass(field_klass->as_klass());
@@ -969,6 +969,10 @@ Node* PhaseStringOpts::int_stringSize(GraphKit& kit, Node* arg) {
     // for (int i=0; ; i++)
     //   if (x <= sizeTable[i])
     //     return i+1;
+
+    // Add loop predicate first.
+    kit.add_predicate();
+
     RegionNode *loop = new (C, 3) RegionNode(3);
     loop->init_req(1, kit.control());
     kit.gvn().set_type(loop, Type::CONTROL);
@@ -1086,6 +1090,9 @@ void PhaseStringOpts::int_getChars(GraphKit& kit, Node* arg, Node* char_array, N
   // }
 
   {
+    // Add loop predicate first.
+    kit.add_predicate();
+
     RegionNode *head = new (C, 3) RegionNode(3);
     head->init_req(1, kit.control());
     kit.gvn().set_type(head, Type::CONTROL);
diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp
index 5f6550a6795..af118139e2b 100644
--- a/hotspot/src/share/vm/opto/type.cpp
+++ b/hotspot/src/share/vm/opto/type.cpp
@@ -32,6 +32,7 @@
 #include "memory/oopFactory.hpp"
 #include "memory/resourceArea.hpp"
 #include "oops/instanceKlass.hpp"
+#include "oops/instanceMirrorKlass.hpp"
 #include "oops/klassKlass.hpp"
 #include "oops/objArrayKlass.hpp"
 #include "oops/typeArrayKlass.hpp"
@@ -2241,43 +2242,49 @@ TypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int
     } else if (this->isa_aryptr()) {
       _is_ptr_to_narrowoop = (klass()->is_obj_array_klass() &&
                              _offset != arrayOopDesc::length_offset_in_bytes());
-    } else if (klass() == ciEnv::current()->Class_klass() &&
-               (_offset == java_lang_Class::klass_offset_in_bytes() ||
-                _offset == java_lang_Class::array_klass_offset_in_bytes())) {
-      // Special hidden fields from the Class.
-      assert(this->isa_instptr(), "must be an instance ptr.");
-      _is_ptr_to_narrowoop = true;
     } else if (klass()->is_instance_klass()) {
       ciInstanceKlass* ik = klass()->as_instance_klass();
       ciField* field = NULL;
       if (this->isa_klassptr()) {
-        // Perm objects don't use compressed references, except for
-        // static fields which are currently compressed.
-        field = ik->get_field_by_offset(_offset, true);
-        if (field != NULL) {
-          BasicType basic_elem_type = field->layout_type();
-          _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
-                                  basic_elem_type == T_ARRAY);
-        }
+        // Perm objects don't use compressed references
       } else if (_offset == OffsetBot || _offset == OffsetTop) {
         // unsafe access
         _is_ptr_to_narrowoop = true;
       } else { // exclude unsafe ops
         assert(this->isa_instptr(), "must be an instance ptr.");
-        // Field which contains a compressed oop references.
-        field = ik->get_field_by_offset(_offset, false);
-        if (field != NULL) {
+
+        if (klass() == ciEnv::current()->Class_klass() &&
+            (_offset == java_lang_Class::klass_offset_in_bytes() ||
+             _offset == java_lang_Class::array_klass_offset_in_bytes())) {
+          // Special hidden fields from the Class.
+          assert(this->isa_instptr(), "must be an instance ptr.");
+          _is_ptr_to_narrowoop = true;
+        } else if (klass() == ciEnv::current()->Class_klass() &&
+                   _offset >= instanceMirrorKlass::offset_of_static_fields()) {
+          // Static fields
+          assert(o != NULL, "must be constant");
+          ciInstanceKlass* k = o->as_instance()->java_lang_Class_klass()->as_instance_klass();
+          ciField* field = k->get_field_by_offset(_offset, true);
+          assert(field != NULL, "missing field");
           BasicType basic_elem_type = field->layout_type();
           _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
                                   basic_elem_type == T_ARRAY);
-        } else if (klass()->equals(ciEnv::current()->Object_klass())) {
-          // Compile::find_alias_type() cast exactness on all types to verify
-          // that it does not affect alias type.
-          _is_ptr_to_narrowoop = true;
         } else {
-          // Type for the copy start in LibraryCallKit::inline_native_clone().
-          assert(!klass_is_exact(), "only non-exact klass");
-          _is_ptr_to_narrowoop = true;
+          // Instance fields which contains a compressed oop references.
+          field = ik->get_field_by_offset(_offset, false);
+          if (field != NULL) {
+            BasicType basic_elem_type = field->layout_type();
+            _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT ||
+                                    basic_elem_type == T_ARRAY);
+          } else if (klass()->equals(ciEnv::current()->Object_klass())) {
+            // Compile::find_alias_type() cast exactness on all types to verify
+            // that it does not affect alias type.
+            _is_ptr_to_narrowoop = true;
+          } else {
+            // Type for the copy start in LibraryCallKit::inline_native_clone().
+            assert(!klass_is_exact(), "only non-exact klass");
+            _is_ptr_to_narrowoop = true;
+          }
         }
       }
     }
@@ -3386,7 +3393,22 @@ const Type *TypeAryPtr::xmeet( const Type *t ) const {
         instance_id = InstanceBot;
         tary = TypeAry::make(Type::BOTTOM, tary->_size);
       }
+    } else // Non integral arrays.
+    // Must fall to bottom if exact klasses in upper lattice
+    // are not equal or super klass is exact.
+    if ( above_centerline(ptr) && klass() != tap->klass() &&
+         // meet with top[] and bottom[] are processed further down:
+         tap ->_klass != NULL  && this->_klass != NULL   &&
+         // both are exact and not equal:
+        ((tap ->_klass_is_exact && this->_klass_is_exact) ||
+         // 'tap'  is exact and super or unrelated:
+         (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) ||
+         // 'this' is exact and super or unrelated:
+         (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) {
+      tary = TypeAry::make(Type::BOTTOM, tary->_size);
+      return make( NotNull, NULL, tary, lazy_klass, false, off, InstanceBot );
     }
+
     bool xk = false;
     switch (tap->ptr()) {
     case AnyNull:
@@ -3766,7 +3788,7 @@ ciKlass* TypeAryPtr::klass() const {
   // Oops, need to compute _klass and cache it
   ciKlass* k_ary = compute_klass();
 
-  if( this != TypeAryPtr::OOPS ) {
+  if( this != TypeAryPtr::OOPS && this->dual() != TypeAryPtr::OOPS ) {
     // The _klass field acts as a cache of the underlying
     // ciKlass for this array type.  In order to set the field,
     // we need to cast away const-ness.
diff --git a/hotspot/src/share/vm/opto/type.hpp b/hotspot/src/share/vm/opto/type.hpp
index d1c647fd1d2..56ea820a734 100644
--- a/hotspot/src/share/vm/opto/type.hpp
+++ b/hotspot/src/share/vm/opto/type.hpp
@@ -988,8 +988,8 @@ public:
 
   static const TypeNarrowOop *make( const TypePtr* type);
 
-  static const TypeNarrowOop* make_from_constant(ciObject* con) {
-    return make(TypeOopPtr::make_from_constant(con));
+  static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
+    return make(TypeOopPtr::make_from_constant(con, require_constant));
   }
 
   // returns the equivalent ptr type for this compressed pointer
diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp
index a4b7a4dfdb4..d77c7ce9e24 100644
--- a/hotspot/src/share/vm/prims/jni.cpp
+++ b/hotspot/src/share/vm/prims/jni.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1858,7 +1858,7 @@ JNI_ENTRY(jobject, jni_ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldI
     // Static field. The fieldID a JNIid specifying the field holder and the offset within the klassOop.
     JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID);
     assert(id->is_static_field_id(), "invalid static field id");
-    found = instanceKlass::cast(id->holder())->find_local_field_from_offset(id->offset(), true, &fd);
+    found = id->find_local_field(&fd);
   } else {
     // Non-static field. The fieldID is really the offset of the field within the instanceOop.
     int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID);
@@ -1906,9 +1906,7 @@ JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz,
   JNIid* id = instanceKlass::cast(fd.field_holder())->jni_id_for(fd.offset());
   debug_only(id->set_is_static_field_id();)
 
-  debug_only(int first_offset = instanceKlass::cast(fd.field_holder())->offset_of_static_fields();)
-  debug_only(int end_offset = first_offset + (instanceKlass::cast(fd.field_holder())->static_field_size() * wordSize);)
-  assert(id->offset() >= first_offset && id->offset() < end_offset, "invalid static field offset");
+  debug_only(id->verify(fd.field_holder()));
 
   ret = jfieldIDWorkaround::to_static_jfieldID(id);
   return ret;
@@ -1928,7 +1926,7 @@ JNI_ENTRY(jobject, jni_GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID
   if (JvmtiExport::should_post_field_access()) {
     JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true);
   }
-  jobject ret = JNIHandles::make_local(id->holder()->obj_field(id->offset()));
+  jobject ret = JNIHandles::make_local(id->holder()->java_mirror()->obj_field(id->offset()));
   DTRACE_PROBE1(hotspot_jni, GetStaticObjectField__return, ret);
   return ret;
 JNI_END
@@ -1950,7 +1948,7 @@ JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfield
   if (JvmtiExport::should_post_field_access()) { \
     JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \
   } \
-  ret = id->holder()-> Fieldname##_field (id->offset()); \
+  ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \
   return ret;\
 JNI_END
 
@@ -1976,7 +1974,7 @@ JNI_ENTRY(void, jni_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fie
     field_value.l = value;
     JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value);
   }
-  id->holder()->obj_field_put(id->offset(), JNIHandles::resolve(value));
+  id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value));
   DTRACE_PROBE(hotspot_jni, SetStaticObjectField__return);
 JNI_END
 
@@ -1999,7 +1997,7 @@ JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID
     field_value.unionType = value; \
     JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \
   } \
-  id->holder()-> Fieldname##_field_put (id->offset(), value); \
+  id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \
   DTRACE_PROBE(hotspot_jni, SetStatic##Result##Field__return);\
 JNI_END
 
diff --git a/hotspot/src/share/vm/prims/jniCheck.cpp b/hotspot/src/share/vm/prims/jniCheck.cpp
index 6301c9865cb..63281dc2730 100644
--- a/hotspot/src/share/vm/prims/jniCheck.cpp
+++ b/hotspot/src/share/vm/prims/jniCheck.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -224,8 +224,7 @@ checkStaticFieldID(JavaThread* thr, jfieldID fid, jclass cls, int ftype)
     ReportJNIFatalError(thr, fatal_wrong_static_field);
 
   /* check for proper field type */
-  if (!instanceKlass::cast(f_oop)->find_local_field_from_offset(
-          id->offset(), true, &fd))
+  if (!id->find_local_field(&fd))
     ReportJNIFatalError(thr, fatal_static_field_not_found);
   if ((fd.field_type() != ftype) &&
       !(fd.field_type() == T_ARRAY && ftype == T_OBJECT)) {
diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp
index 417052502cc..4ee600f94bf 100644
--- a/hotspot/src/share/vm/prims/jvm.cpp
+++ b/hotspot/src/share/vm/prims/jvm.cpp
@@ -1808,7 +1808,7 @@ JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAt(JNIEnv *env, jobject unused, jobjec
     THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), "Wrong type at constant pool index");
   }
   klassOop k = cp->klass_at(index, CHECK_NULL);
-  return (jclass) JNIHandles::make_local(k->klass_part()->java_mirror());
+  return (jclass) JNIHandles::make_local(k->java_mirror());
 }
 JVM_END
 
@@ -1824,7 +1824,7 @@ JVM_ENTRY(jclass, JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv *env, jobject unused
   }
   klassOop k = constantPoolOopDesc::klass_at_if_loaded(cp, index);
   if (k == NULL) return NULL;
-  return (jclass) JNIHandles::make_local(k->klass_part()->java_mirror());
+  return (jclass) JNIHandles::make_local(k->java_mirror());
 }
 JVM_END
 
diff --git a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
index 43c12537c54..30903a63226 100644
--- a/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -616,9 +616,7 @@ JvmtiEnvBase::get_field_descriptor(klassOop k, jfieldID field, fieldDescriptor*
   bool found = false;
   if (jfieldIDWorkaround::is_static_jfieldID(field)) {
     JNIid* id = jfieldIDWorkaround::from_static_jfieldID(field);
-    int offset = id->offset();
-    klassOop holder = id->holder();
-    found = instanceKlass::cast(holder)->find_local_field_from_offset(offset, true, fd);
+    found = id->find_local_field(fd);
   } else {
     // Non-static field. The fieldID is really the offset of the field within the object.
     int offset = jfieldIDWorkaround::from_instance_jfieldID(k, field);
diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp
index c821c8ed376..5bb68f7ab88 100644
--- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp
@@ -919,15 +919,24 @@ JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_load_event(
     nmethod* nm) {
   JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_LOAD);
   event._event_data.compiled_method_load = nm;
-  nmethodLocker::lock_nmethod(nm); // will be unlocked when posted
+  // Keep the nmethod alive until the ServiceThread can process
+  // this deferred event.
+  nmethodLocker::lock_nmethod(nm);
   return event;
 }
 
 JvmtiDeferredEvent JvmtiDeferredEvent::compiled_method_unload_event(
-    jmethodID id, const void* code) {
+    nmethod* nm, jmethodID id, const void* code) {
   JvmtiDeferredEvent event = JvmtiDeferredEvent(TYPE_COMPILED_METHOD_UNLOAD);
+  event._event_data.compiled_method_unload.nm = nm;
   event._event_data.compiled_method_unload.method_id = id;
   event._event_data.compiled_method_unload.code_begin = code;
+  // Keep the nmethod alive until the ServiceThread can process
+  // this deferred event. This will keep the memory for the
+  // generated code from being reused too early. We pass
+  // zombie_ok == true here so that our nmethod that was just
+  // made into a zombie can be locked.
+  nmethodLocker::lock_nmethod(nm, true /* zombie_ok */);
   return event;
 }
 JvmtiDeferredEvent JvmtiDeferredEvent::dynamic_code_generated_event(
@@ -946,14 +955,19 @@ void JvmtiDeferredEvent::post() {
     case TYPE_COMPILED_METHOD_LOAD: {
       nmethod* nm = _event_data.compiled_method_load;
       JvmtiExport::post_compiled_method_load(nm);
+      // done with the deferred event so unlock the nmethod
       nmethodLocker::unlock_nmethod(nm);
       break;
     }
-    case TYPE_COMPILED_METHOD_UNLOAD:
+    case TYPE_COMPILED_METHOD_UNLOAD: {
+      nmethod* nm = _event_data.compiled_method_unload.nm;
       JvmtiExport::post_compiled_method_unload(
         _event_data.compiled_method_unload.method_id,
         _event_data.compiled_method_unload.code_begin);
+      // done with the deferred event so unlock the nmethod
+      nmethodLocker::unlock_nmethod(nm);
       break;
+    }
     case TYPE_DYNAMIC_CODE_GENERATED:
       JvmtiExport::post_dynamic_code_generated_internal(
         _event_data.dynamic_code_generated.name,
diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.hpp b/hotspot/src/share/vm/prims/jvmtiImpl.hpp
index b7bc0fd68a4..704d287a8f3 100644
--- a/hotspot/src/share/vm/prims/jvmtiImpl.hpp
+++ b/hotspot/src/share/vm/prims/jvmtiImpl.hpp
@@ -458,6 +458,7 @@ class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC {
   union {
     nmethod* compiled_method_load;
     struct {
+      nmethod* nm;
       jmethodID method_id;
       const void* code_begin;
     } compiled_method_unload;
@@ -477,7 +478,7 @@ class JvmtiDeferredEvent VALUE_OBJ_CLASS_SPEC {
   // Factory methods
   static JvmtiDeferredEvent compiled_method_load_event(nmethod* nm)
     KERNEL_RETURN_(JvmtiDeferredEvent());
-  static JvmtiDeferredEvent compiled_method_unload_event(
+  static JvmtiDeferredEvent compiled_method_unload_event(nmethod* nm,
       jmethodID id, const void* code) KERNEL_RETURN_(JvmtiDeferredEvent());
   static JvmtiDeferredEvent dynamic_code_generated_event(
       const char* name, const void* begin, const void* end)
diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
index 26e9e5bc857..353494844d3 100644
--- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp
@@ -1084,7 +1084,10 @@ bool VM_RedefineClasses::merge_constant_pools(constantPoolHandle old_cp,
       jbyte old_tag = old_cp->tag_at(old_i).value();
       switch (old_tag) {
       case JVM_CONSTANT_Class:
+      case JVM_CONSTANT_UnresolvedClass:
         // revert the copy to JVM_CONSTANT_UnresolvedClass
+        // May be resolving while calling this so do the same for
+        // JVM_CONSTANT_UnresolvedClass (klass_name_at() deals with transition)
         (*merge_cp_p)->unresolved_klass_at_put(old_i,
           old_cp->klass_name_at(old_i));
         break;
@@ -3347,11 +3350,12 @@ void VM_RedefineClasses::increment_class_counter(instanceKlass *ik, TRAPS) {
 
   for (Klass *subk = ik->subklass(); subk != NULL;
        subk = subk->next_sibling()) {
-    klassOop sub = subk->as_klassOop();
-    instanceKlass *subik = (instanceKlass *)sub->klass_part();
-
-    // recursively do subclasses of the current subclass
-    increment_class_counter(subik, THREAD);
+    if (subk->oop_is_instance()) {
+      // Only update instanceKlasses
+      instanceKlass *subik = (instanceKlass*)subk;
+      // recursively do subclasses of the current subclass
+      increment_class_counter(subik, THREAD);
+    }
   }
 }
 
diff --git a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
index ec3a4256361..de5803b69ee 100644
--- a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
+++ b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
+#include "oops/instanceMirrorKlass.hpp"
 #include "oops/objArrayKlass.hpp"
 #include "oops/oop.inline2.hpp"
 #include "prims/jvmtiEventController.hpp"
@@ -2594,6 +2595,11 @@ class SimpleRootsClosure : public OopClosure {
     if (o->is_klass()) {
       klassOop k = (klassOop)o;
       o = Klass::cast(k)->java_mirror();
+      if (o == NULL) {
+        // Classes without mirrors don't correspond to real Java
+        // classes so just ignore them.
+        return;
+      }
     } else {
 
       // SystemDictionary::always_strong_oops_do reports the application
@@ -2834,10 +2840,10 @@ inline bool VM_HeapWalkOperation::iterate_over_type_array(oop o) {
 
 // verify that a static oop field is in range
 static inline bool verify_static_oop(instanceKlass* ik,
-                                     klassOop k, int offset) {
-  address obj_p = (address)k + offset;
-  address start = (address)ik->start_of_static_fields();
-  address end = start + (ik->static_oop_field_size() * heapOopSize);
+                                     oop mirror, int offset) {
+  address obj_p = (address)mirror + offset;
+  address start = (address)instanceMirrorKlass::start_of_static_fields(mirror);
+  address end = start + (java_lang_Class::static_oop_field_count(mirror) * heapOopSize);
   assert(end >= start, "sanity check");
 
   if (obj_p >= start && obj_p < end) {
@@ -2938,8 +2944,8 @@ inline bool VM_HeapWalkOperation::iterate_over_class(klassOop k) {
       ClassFieldDescriptor* field = field_map->field_at(i);
       char type = field->field_type();
       if (!is_primitive_field_type(type)) {
-        oop fld_o = k->obj_field(field->field_offset());
-        assert(verify_static_oop(ik, k, field->field_offset()), "sanity check");
+        oop fld_o = mirror->obj_field(field->field_offset());
+        assert(verify_static_oop(ik, mirror, field->field_offset()), "sanity check");
         if (fld_o != NULL) {
           int slot = field->field_index();
           if (!CallbackInvoker::report_static_field_reference(mirror, fld_o, slot)) {
@@ -2949,7 +2955,7 @@ inline bool VM_HeapWalkOperation::iterate_over_class(klassOop k) {
         }
       } else {
          if (is_reporting_primitive_fields()) {
-           address addr = (address)k + field->field_offset();
+           address addr = (address)mirror + field->field_offset();
            int slot = field->field_index();
            if (!CallbackInvoker::report_primitive_static_field(mirror, slot, addr, type)) {
              delete field_map;
diff --git a/hotspot/src/share/vm/prims/methodHandleWalk.cpp b/hotspot/src/share/vm/prims/methodHandleWalk.cpp
index 61a7eeb4f70..915cf35995c 100644
--- a/hotspot/src/share/vm/prims/methodHandleWalk.cpp
+++ b/hotspot/src/share/vm/prims/methodHandleWalk.cpp
@@ -36,7 +36,7 @@
 // MethodHandleChain
 
 void MethodHandleChain::set_method_handle(Handle mh, TRAPS) {
-  if (!java_dyn_MethodHandle::is_instance(mh()))  lose("bad method handle", CHECK);
+  if (!java_lang_invoke_MethodHandle::is_instance(mh()))  lose("bad method handle", CHECK);
 
   // set current method handle and unpack partially
   _method_handle = mh;
@@ -47,21 +47,21 @@ void MethodHandleChain::set_method_handle(Handle mh, TRAPS) {
   _conversion    = -1;
   _last_invoke   = Bytecodes::_nop;  //arbitrary non-garbage
 
-  if (sun_dyn_DirectMethodHandle::is_instance(mh())) {
+  if (java_lang_invoke_DirectMethodHandle::is_instance(mh())) {
     set_last_method(mh(), THREAD);
     return;
   }
-  if (sun_dyn_AdapterMethodHandle::is_instance(mh())) {
+  if (java_lang_invoke_AdapterMethodHandle::is_instance(mh())) {
     _conversion = AdapterMethodHandle_conversion();
     assert(_conversion != -1, "bad conv value");
-    assert(sun_dyn_BoundMethodHandle::is_instance(mh()), "also BMH");
+    assert(java_lang_invoke_BoundMethodHandle::is_instance(mh()), "also BMH");
   }
-  if (sun_dyn_BoundMethodHandle::is_instance(mh())) {
+  if (java_lang_invoke_BoundMethodHandle::is_instance(mh())) {
     if (!is_adapter())          // keep AMH and BMH separate in this model
       _is_bound = true;
     _arg_slot = BoundMethodHandle_vmargslot();
     oop target = MethodHandle_vmtarget_oop();
-    if (!is_bound() || java_dyn_MethodHandle::is_instance(target)) {
+    if (!is_bound() || java_lang_invoke_MethodHandle::is_instance(target)) {
       _arg_type = compute_bound_arg_type(target, NULL, _arg_slot, CHECK);
     } else if (target != NULL && target->is_method()) {
       methodOop m = (methodOop) target;
@@ -100,13 +100,12 @@ void MethodHandleChain::set_last_method(oop target, TRAPS) {
 BasicType MethodHandleChain::compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS) {
   // There is no direct indication of whether the argument is primitive or not.
   // It is implied by the _vmentry code, and by the MethodType of the target.
-  // FIXME: Make it explicit MethodHandleImpl refactors out from MethodHandle
   BasicType arg_type = T_VOID;
   if (target != NULL) {
-    oop mtype = java_dyn_MethodHandle::type(target);
+    oop mtype = java_lang_invoke_MethodHandle::type(target);
     int arg_num = MethodHandles::argument_slot_to_argnum(mtype, arg_slot);
     if (arg_num >= 0) {
-      oop ptype = java_dyn_MethodType::ptype(mtype, arg_num);
+      oop ptype = java_lang_invoke_MethodType::ptype(mtype, arg_num);
       arg_type = java_lang_Class::as_BasicType(ptype);
     }
   } else if (m != NULL) {
@@ -205,28 +204,28 @@ MethodHandleWalker::walk(TRAPS) {
       int arg_slot = chain().adapter_arg_slot();
       SlotState* arg_state = slot_state(arg_slot);
       if (arg_state == NULL
-          && conv_op > sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW) {
+          && conv_op > java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW) {
         lose("bad argument index", CHECK_(empty));
       }
 
       // perform the adapter action
       switch (chain().adapter_conversion_op()) {
-      case sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY:
+      case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY:
         // No changes to arguments; pass the bits through.
         break;
 
-      case sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW: {
+      case java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW: {
         // To keep the verifier happy, emit bitwise ("raw") conversions as needed.
         // See MethodHandles::same_basic_type_for_arguments for allowed conversions.
         Handle incoming_mtype(THREAD, chain().method_type_oop());
         oop outgoing_mh_oop = chain().vmtarget_oop();
-        if (!java_dyn_MethodHandle::is_instance(outgoing_mh_oop))
+        if (!java_lang_invoke_MethodHandle::is_instance(outgoing_mh_oop))
           lose("outgoing target not a MethodHandle", CHECK_(empty));
-        Handle outgoing_mtype(THREAD, java_dyn_MethodHandle::type(outgoing_mh_oop));
+        Handle outgoing_mtype(THREAD, java_lang_invoke_MethodHandle::type(outgoing_mh_oop));
         outgoing_mh_oop = NULL;  // GC safety
 
-        int nptypes = java_dyn_MethodType::ptype_count(outgoing_mtype());
-        if (nptypes != java_dyn_MethodType::ptype_count(incoming_mtype()))
+        int nptypes = java_lang_invoke_MethodType::ptype_count(outgoing_mtype());
+        if (nptypes != java_lang_invoke_MethodType::ptype_count(incoming_mtype()))
           lose("incoming and outgoing parameter count do not agree", CHECK_(empty));
 
         for (int i = 0, slot = _outgoing.length() - 1; slot >= 0; slot--) {
@@ -236,8 +235,8 @@ MethodHandleWalker::walk(TRAPS) {
 
           klassOop  in_klass  = NULL;
           klassOop  out_klass = NULL;
-          BasicType inpbt  = java_lang_Class::as_BasicType(java_dyn_MethodType::ptype(incoming_mtype(), i), &in_klass);
-          BasicType outpbt = java_lang_Class::as_BasicType(java_dyn_MethodType::ptype(outgoing_mtype(), i), &out_klass);
+          BasicType inpbt  = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::ptype(incoming_mtype(), i), &in_klass);
+          BasicType outpbt = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::ptype(outgoing_mtype(), i), &out_klass);
           assert(inpbt == arg.basic_type(), "sanity");
 
           if (inpbt != outpbt) {
@@ -255,8 +254,8 @@ MethodHandleWalker::walk(TRAPS) {
           i++;  // We need to skip void slots at the top of the loop.
         }
 
-        BasicType inrbt  = java_lang_Class::as_BasicType(java_dyn_MethodType::rtype(incoming_mtype()));
-        BasicType outrbt = java_lang_Class::as_BasicType(java_dyn_MethodType::rtype(outgoing_mtype()));
+        BasicType inrbt  = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(incoming_mtype()));
+        BasicType outrbt = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(outgoing_mtype()));
         if (inrbt != outrbt) {
           if (inrbt == T_INT && outrbt == T_VOID) {
             // See comments in MethodHandles::same_basic_type_for_arguments.
@@ -268,7 +267,7 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_CHECK_CAST: {
+      case java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST: {
         // checkcast the Nth outgoing argument in place
         klassOop dest_klass = NULL;
         BasicType dest = java_lang_Class::as_BasicType(chain().adapter_arg_oop(), &dest_klass);
@@ -281,7 +280,7 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM: {
+      case java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM: {
         // i2l, etc., on the Nth outgoing argument in place
         BasicType src = chain().adapter_conversion_src_type(),
                   dest = chain().adapter_conversion_dest_type();
@@ -306,7 +305,7 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM: {
+      case java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM: {
         // checkcast to wrapper type & call intValue, etc.
         BasicType dest = chain().adapter_conversion_dest_type();
         ArgToken arg = arg_state->_arg;
@@ -324,7 +323,7 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_PRIM_TO_REF: {
+      case java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF: {
         // call wrapper type.valueOf
         BasicType src = chain().adapter_conversion_src_type();
         ArgToken arg = arg_state->_arg;
@@ -340,7 +339,7 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS: {
+      case java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS: {
         int dest_arg_slot = chain().adapter_conversion_vminfo();
         if (!slot_has_argument(dest_arg_slot)) {
           lose("bad swap index", CHECK_(empty));
@@ -353,7 +352,7 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_ROT_ARGS: {
+      case java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS: {
         int dest_arg_slot = chain().adapter_conversion_vminfo();
         if (!slot_has_argument(dest_arg_slot) || arg_slot == dest_arg_slot) {
           lose("bad rotate index", CHECK_(empty));
@@ -379,7 +378,7 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_DUP_ARGS: {
+      case java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS: {
         int dup_slots = chain().adapter_conversion_stack_pushes();
         if (dup_slots <= 0) {
           lose("bad dup count", CHECK_(empty));
@@ -393,7 +392,7 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_DROP_ARGS: {
+      case java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS: {
         int drop_slots = -chain().adapter_conversion_stack_pushes();
         if (drop_slots <= 0) {
           lose("bad drop count", CHECK_(empty));
@@ -407,12 +406,12 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_COLLECT_ARGS: { //NYI, may GC
+      case java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS: { //NYI, may GC
         lose("unimplemented", CHECK_(empty));
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS: {
+      case java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS: {
         klassOop array_klass_oop = NULL;
         BasicType array_type = java_lang_Class::as_BasicType(chain().adapter_arg_oop(),
                                                              &array_klass_oop);
@@ -470,8 +469,8 @@ MethodHandleWalker::walk(TRAPS) {
         break;
       }
 
-      case sun_dyn_AdapterMethodHandle::OP_FLYBY: //NYI, runs Java code
-      case sun_dyn_AdapterMethodHandle::OP_RICOCHET: //NYI, runs Java code
+      case java_lang_invoke_AdapterMethodHandle::OP_FLYBY: //NYI, runs Java code
+      case java_lang_invoke_AdapterMethodHandle::OP_RICOCHET: //NYI, runs Java code
         lose("unimplemented", CHECK_(empty));
         break;
 
@@ -533,7 +532,7 @@ MethodHandleWalker::walk(TRAPS) {
 //
 void MethodHandleWalker::walk_incoming_state(TRAPS) {
   Handle mtype(THREAD, chain().method_type_oop());
-  int nptypes = java_dyn_MethodType::ptype_count(mtype());
+  int nptypes = java_lang_invoke_MethodType::ptype_count(mtype());
   _outgoing_argc = nptypes;
   int argp = nptypes - 1;
   if (argp >= 0) {
@@ -542,7 +541,7 @@ void MethodHandleWalker::walk_incoming_state(TRAPS) {
   for (int i = 0; i < nptypes; i++) {
     klassOop  arg_type_klass = NULL;
     BasicType arg_type = java_lang_Class::as_BasicType(
-                java_dyn_MethodType::ptype(mtype(), i), &arg_type_klass);
+                java_lang_invoke_MethodType::ptype(mtype(), i), &arg_type_klass);
     int index = new_local_index(arg_type);
     ArgToken arg = make_parameter(arg_type, arg_type_klass, index, CHECK);
     debug_only(arg_type_klass = (klassOop) NULL);
@@ -556,7 +555,7 @@ void MethodHandleWalker::walk_incoming_state(TRAPS) {
   // call make_parameter at the end of the list for the return type
   klassOop  ret_type_klass = NULL;
   BasicType ret_type = java_lang_Class::as_BasicType(
-              java_dyn_MethodType::rtype(mtype()), &ret_type_klass);
+              java_lang_invoke_MethodType::rtype(mtype()), &ret_type_klass);
   ArgToken  ret = make_parameter(ret_type, ret_type_klass, -1, CHECK);
   // ignore ret; client can catch it if needed
 }
@@ -631,7 +630,7 @@ MethodHandleCompiler::MethodHandleCompiler(Handle root, methodHandle callee, boo
   // Get return type klass.
   Handle first_mtype(THREAD, chain().method_type_oop());
   // _rklass is NULL for primitives.
-  _rtype = java_lang_Class::as_BasicType(java_dyn_MethodType::rtype(first_mtype()), &_rklass);
+  _rtype = java_lang_Class::as_BasicType(java_lang_invoke_MethodType::rtype(first_mtype()), &_rklass);
   if (_rtype == T_ARRAY)  _rtype = T_OBJECT;
 
   int params = _callee->size_of_parameters();  // Incoming arguments plus receiver.
@@ -960,6 +959,16 @@ MethodHandleCompiler::make_invoke(methodOop m, vmIntrinsics::ID iid,
   if (m == NULL) {
     // Get the intrinsic methodOop.
     m = vmIntrinsics::method_for(iid);
+    if (m == NULL && iid == vmIntrinsics::_checkSpreadArgument && AllowTransitionalJSR292) {
+      m = vmIntrinsics::method_for(vmIntrinsics::_checkSpreadArgument_TRANS);
+      if (m == NULL)
+        // sun.dyn.MethodHandleImpl not found, look for java.dyn.MethodHandleNatives:
+        m = vmIntrinsics::method_for(vmIntrinsics::_checkSpreadArgument_TRANS2);
+    }
+    if (m == NULL) {
+      ArgToken zero;
+      lose(vmIntrinsics::name_at(iid), CHECK_(zero));
+    }
   }
 
   klassOop  klass   = m->method_holder();
@@ -1396,7 +1405,7 @@ extern "C"
 void print_method_handle(oop mh) {
   if (!mh->is_oop()) {
     tty->print_cr("*** not a method handle: "INTPTR_FORMAT, (intptr_t)mh);
-  } else if (java_dyn_MethodHandle::is_instance(mh)) {
+  } else if (java_lang_invoke_MethodHandle::is_instance(mh)) {
     //MethodHandlePrinter::print(mh);
   } else {
     tty->print("*** not a method handle: ");
diff --git a/hotspot/src/share/vm/prims/methodHandleWalk.hpp b/hotspot/src/share/vm/prims/methodHandleWalk.hpp
index aad0edb2058..cc4eed30f73 100644
--- a/hotspot/src/share/vm/prims/methodHandleWalk.hpp
+++ b/hotspot/src/share/vm/prims/methodHandleWalk.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,13 +48,13 @@ private:
   void set_last_method(oop target, TRAPS);
   static BasicType compute_bound_arg_type(oop target, methodOop m, int arg_slot, TRAPS);
 
-  oop MethodHandle_type_oop()     { return java_dyn_MethodHandle::type(method_handle_oop()); }
-  oop MethodHandle_vmtarget_oop() { return java_dyn_MethodHandle::vmtarget(method_handle_oop()); }
-  int MethodHandle_vmslots()      { return java_dyn_MethodHandle::vmslots(method_handle_oop()); }
-  int DirectMethodHandle_vmindex()     { return sun_dyn_DirectMethodHandle::vmindex(method_handle_oop()); }
-  oop BoundMethodHandle_argument_oop() { return sun_dyn_BoundMethodHandle::argument(method_handle_oop()); }
-  int BoundMethodHandle_vmargslot()    { return sun_dyn_BoundMethodHandle::vmargslot(method_handle_oop()); }
-  int AdapterMethodHandle_conversion() { return sun_dyn_AdapterMethodHandle::conversion(method_handle_oop()); }
+  oop MethodHandle_type_oop()          { return java_lang_invoke_MethodHandle::type(method_handle_oop()); }
+  oop MethodHandle_vmtarget_oop()      { return java_lang_invoke_MethodHandle::vmtarget(method_handle_oop()); }
+  int MethodHandle_vmslots()           { return java_lang_invoke_MethodHandle::vmslots(method_handle_oop()); }
+  int DirectMethodHandle_vmindex()     { return java_lang_invoke_DirectMethodHandle::vmindex(method_handle_oop()); }
+  oop BoundMethodHandle_argument_oop() { return java_lang_invoke_BoundMethodHandle::argument(method_handle_oop()); }
+  int BoundMethodHandle_vmargslot()    { return java_lang_invoke_BoundMethodHandle::vmargslot(method_handle_oop()); }
+  int AdapterMethodHandle_conversion() { return java_lang_invoke_AdapterMethodHandle::conversion(method_handle_oop()); }
 
 public:
   MethodHandleChain(Handle root, TRAPS)
diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp
index 2f191632181..6da4b969615 100644
--- a/hotspot/src/share/vm/prims/methodHandles.cpp
+++ b/hotspot/src/share/vm/prims/methodHandles.cpp
@@ -163,9 +163,9 @@ methodOop MethodHandles::decode_vmtarget(oop vmtarget, int vmindex, oop mtype,
     // or it may use the klass/index form; both forms mean the same thing.
     methodOop m = decode_methodOop(methodOop(vmtarget), decode_flags_result);
     if ((decode_flags_result & _dmf_has_receiver) != 0
-        && java_dyn_MethodType::is_instance(mtype)) {
+        && java_lang_invoke_MethodType::is_instance(mtype)) {
       // Extract receiver type restriction from mtype.ptypes[0].
-      objArrayOop ptypes = java_dyn_MethodType::ptypes(mtype);
+      objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(mtype);
       oop ptype0 = (ptypes == NULL || ptypes->length() < 1) ? oop(NULL) : ptypes->obj_at(0);
       if (java_lang_Class::is_instance(ptype0))
         receiver_limit_result = java_lang_Class::as_klassOop(ptype0);
@@ -199,18 +199,18 @@ methodOop MethodHandles::decode_vmtarget(oop vmtarget, int vmindex, oop mtype,
 // (MemberName is the non-operational name used for queries and setup.)
 
 methodOop MethodHandles::decode_DirectMethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result) {
-  oop vmtarget = sun_dyn_DirectMethodHandle::vmtarget(mh);
-  int vmindex  = sun_dyn_DirectMethodHandle::vmindex(mh);
-  oop mtype    = sun_dyn_DirectMethodHandle::type(mh);
+  oop vmtarget = java_lang_invoke_DirectMethodHandle::vmtarget(mh);
+  int vmindex  = java_lang_invoke_DirectMethodHandle::vmindex(mh);
+  oop mtype    = java_lang_invoke_DirectMethodHandle::type(mh);
   return decode_vmtarget(vmtarget, vmindex, mtype, receiver_limit_result, decode_flags_result);
 }
 
 methodOop MethodHandles::decode_BoundMethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result) {
-  assert(sun_dyn_BoundMethodHandle::is_instance(mh), "");
+  assert(java_lang_invoke_BoundMethodHandle::is_instance(mh), "");
   assert(mh->klass() != SystemDictionary::AdapterMethodHandle_klass(), "");
   for (oop bmh = mh;;) {
     // Bound MHs can be stacked to bind several arguments.
-    oop target = java_dyn_MethodHandle::vmtarget(bmh);
+    oop target = java_lang_invoke_MethodHandle::vmtarget(bmh);
     if (target == NULL)  return NULL;
     decode_flags_result |= MethodHandles::_dmf_binds_argument;
     klassOop tk = target->klass();
@@ -218,7 +218,7 @@ methodOop MethodHandles::decode_BoundMethodHandle(oop mh, klassOop& receiver_lim
       bmh = target;
       continue;
     } else {
-      if (java_dyn_MethodHandle::is_subclass(tk)) {
+      if (java_lang_invoke_MethodHandle::is_subclass(tk)) {
         //assert(tk == SystemDictionary::DirectMethodHandle_klass(), "end of BMH chain must be DMH");
         return decode_MethodHandle(target, receiver_limit_result, decode_flags_result);
       } else {
@@ -240,9 +240,9 @@ methodOop MethodHandles::decode_AdapterMethodHandle(oop mh, klassOop& receiver_l
   assert(mh->klass() == SystemDictionary::AdapterMethodHandle_klass(), "");
   for (oop amh = mh;;) {
     // Adapter MHs can be stacked to convert several arguments.
-    int conv_op = adapter_conversion_op(sun_dyn_AdapterMethodHandle::conversion(amh));
+    int conv_op = adapter_conversion_op(java_lang_invoke_AdapterMethodHandle::conversion(amh));
     decode_flags_result |= (_dmf_adapter_lsb << conv_op) & _DMF_ADAPTER_MASK;
-    oop target = java_dyn_MethodHandle::vmtarget(amh);
+    oop target = java_lang_invoke_MethodHandle::vmtarget(amh);
     if (target == NULL)  return NULL;
     klassOop tk = target->klass();
     if (tk == SystemDictionary::AdapterMethodHandle_klass()) {
@@ -258,14 +258,14 @@ methodOop MethodHandles::decode_AdapterMethodHandle(oop mh, klassOop& receiver_l
 methodOop MethodHandles::decode_MethodHandle(oop mh, klassOop& receiver_limit_result, int& decode_flags_result) {
   if (mh == NULL)  return NULL;
   klassOop mhk = mh->klass();
-  assert(java_dyn_MethodHandle::is_subclass(mhk), "must be a MethodHandle");
+  assert(java_lang_invoke_MethodHandle::is_subclass(mhk), "must be a MethodHandle");
   if (mhk == SystemDictionary::DirectMethodHandle_klass()) {
     return decode_DirectMethodHandle(mh, receiver_limit_result, decode_flags_result);
   } else if (mhk == SystemDictionary::BoundMethodHandle_klass()) {
     return decode_BoundMethodHandle(mh, receiver_limit_result, decode_flags_result);
   } else if (mhk == SystemDictionary::AdapterMethodHandle_klass()) {
     return decode_AdapterMethodHandle(mh, receiver_limit_result, decode_flags_result);
-  } else if (sun_dyn_BoundMethodHandle::is_subclass(mhk)) {
+  } else if (java_lang_invoke_BoundMethodHandle::is_subclass(mhk)) {
     // could be a JavaMethodHandle (but not an adapter MH)
     return decode_BoundMethodHandle(mh, receiver_limit_result, decode_flags_result);
   } else {
@@ -308,7 +308,7 @@ methodOop MethodHandles::decode_method(oop x, klassOop& receiver_limit_result, i
   } else if (xk == SystemDictionary::MemberName_klass()) {
     // Note: This only works if the MemberName has already been resolved.
     return decode_MemberName(x, receiver_limit_result, decode_flags_result);
-  } else if (java_dyn_MethodHandle::is_subclass(xk)) {
+  } else if (java_lang_invoke_MethodHandle::is_subclass(xk)) {
     return decode_MethodHandle(x, receiver_limit_result, decode_flags_result);
   } else if (xk == SystemDictionary::reflect_Method_klass()) {
     oop clazz  = java_lang_reflect_Method::clazz(x);
@@ -327,7 +327,7 @@ methodOop MethodHandles::decode_method(oop x, klassOop& receiver_limit_result, i
   } else {
     // unrecognized object
     assert(!x->is_method(), "already checked");
-    assert(!sun_dyn_MemberName::is_instance(x), "already checked");
+    assert(!java_lang_invoke_MemberName::is_instance(x), "already checked");
   }
   return NULL;
 }
@@ -336,15 +336,15 @@ methodOop MethodHandles::decode_method(oop x, klassOop& receiver_limit_result, i
 int MethodHandles::decode_MethodHandle_stack_pushes(oop mh) {
   if (mh->klass() == SystemDictionary::DirectMethodHandle_klass())
     return 0;                   // no push/pop
-  int this_vmslots = java_dyn_MethodHandle::vmslots(mh);
+  int this_vmslots = java_lang_invoke_MethodHandle::vmslots(mh);
   int last_vmslots = 0;
   oop last_mh = mh;
   for (;;) {
-    oop target = java_dyn_MethodHandle::vmtarget(last_mh);
+    oop target = java_lang_invoke_MethodHandle::vmtarget(last_mh);
     if (target->klass() == SystemDictionary::DirectMethodHandle_klass()) {
-      last_vmslots = java_dyn_MethodHandle::vmslots(target);
+      last_vmslots = java_lang_invoke_MethodHandle::vmslots(target);
       break;
-    } else if (!java_dyn_MethodHandle::is_instance(target)) {
+    } else if (!java_lang_invoke_MethodHandle::is_instance(target)) {
       // might be klass or method
       assert(target->is_method(), "must get here with a direct ref to method");
       last_vmslots = methodOop(target)->size_of_parameters();
@@ -361,16 +361,16 @@ int MethodHandles::decode_MethodHandle_stack_pushes(oop mh) {
 
 // MemberName support
 
-// import sun_dyn_MemberName.*
+// import java_lang_invoke_MemberName.*
 enum {
-  IS_METHOD      = sun_dyn_MemberName::MN_IS_METHOD,
-  IS_CONSTRUCTOR = sun_dyn_MemberName::MN_IS_CONSTRUCTOR,
-  IS_FIELD       = sun_dyn_MemberName::MN_IS_FIELD,
-  IS_TYPE        = sun_dyn_MemberName::MN_IS_TYPE,
-  SEARCH_SUPERCLASSES = sun_dyn_MemberName::MN_SEARCH_SUPERCLASSES,
-  SEARCH_INTERFACES   = sun_dyn_MemberName::MN_SEARCH_INTERFACES,
+  IS_METHOD      = java_lang_invoke_MemberName::MN_IS_METHOD,
+  IS_CONSTRUCTOR = java_lang_invoke_MemberName::MN_IS_CONSTRUCTOR,
+  IS_FIELD       = java_lang_invoke_MemberName::MN_IS_FIELD,
+  IS_TYPE        = java_lang_invoke_MemberName::MN_IS_TYPE,
+  SEARCH_SUPERCLASSES = java_lang_invoke_MemberName::MN_SEARCH_SUPERCLASSES,
+  SEARCH_INTERFACES   = java_lang_invoke_MemberName::MN_SEARCH_INTERFACES,
   ALL_KINDS      = IS_METHOD | IS_CONSTRUCTOR | IS_FIELD | IS_TYPE,
-  VM_INDEX_UNINITIALIZED = sun_dyn_MemberName::VM_INDEX_UNINITIALIZED
+  VM_INDEX_UNINITIALIZED = java_lang_invoke_MemberName::VM_INDEX_UNINITIALIZED
 };
 
 Handle MethodHandles::new_MemberName(TRAPS) {
@@ -405,10 +405,10 @@ void MethodHandles::init_MemberName(oop mname_oop, methodOop m, bool do_dispatch
   if (!do_dispatch || (flags & IS_CONSTRUCTOR) || m->can_be_statically_bound())
     vmindex = methodOopDesc::nonvirtual_vtable_index; // implies never any dispatch
   assert(vmindex != VM_INDEX_UNINITIALIZED, "Java sentinel value");
-  sun_dyn_MemberName::set_vmtarget(mname_oop, vmtarget);
-  sun_dyn_MemberName::set_vmindex(mname_oop,  vmindex);
-  sun_dyn_MemberName::set_flags(mname_oop,    flags);
-  sun_dyn_MemberName::set_clazz(mname_oop,    Klass::cast(m->method_holder())->java_mirror());
+  java_lang_invoke_MemberName::set_vmtarget(mname_oop, vmtarget);
+  java_lang_invoke_MemberName::set_vmindex(mname_oop,  vmindex);
+  java_lang_invoke_MemberName::set_flags(mname_oop,    flags);
+  java_lang_invoke_MemberName::set_clazz(mname_oop,    Klass::cast(m->method_holder())->java_mirror());
 }
 
 void MethodHandles::init_MemberName(oop mname_oop, klassOop field_holder, AccessFlags mods, int offset) {
@@ -416,21 +416,21 @@ void MethodHandles::init_MemberName(oop mname_oop, klassOop field_holder, Access
   oop vmtarget = field_holder;
   int vmindex  = offset;  // determines the field uniquely when combined with static bit
   assert(vmindex != VM_INDEX_UNINITIALIZED, "bad alias on vmindex");
-  sun_dyn_MemberName::set_vmtarget(mname_oop, vmtarget);
-  sun_dyn_MemberName::set_vmindex(mname_oop,  vmindex);
-  sun_dyn_MemberName::set_flags(mname_oop,    flags);
-  sun_dyn_MemberName::set_clazz(mname_oop,    Klass::cast(field_holder)->java_mirror());
+  java_lang_invoke_MemberName::set_vmtarget(mname_oop, vmtarget);
+  java_lang_invoke_MemberName::set_vmindex(mname_oop,  vmindex);
+  java_lang_invoke_MemberName::set_flags(mname_oop,    flags);
+  java_lang_invoke_MemberName::set_clazz(mname_oop,    Klass::cast(field_holder)->java_mirror());
 }
 
 
 methodOop MethodHandles::decode_MemberName(oop mname, klassOop& receiver_limit_result, int& decode_flags_result) {
-  int flags  = sun_dyn_MemberName::flags(mname);
+  int flags  = java_lang_invoke_MemberName::flags(mname);
   if ((flags & (IS_METHOD | IS_CONSTRUCTOR)) == 0)  return NULL;  // not invocable
-  oop vmtarget = sun_dyn_MemberName::vmtarget(mname);
-  int vmindex  = sun_dyn_MemberName::vmindex(mname);
+  oop vmtarget = java_lang_invoke_MemberName::vmtarget(mname);
+  int vmindex  = java_lang_invoke_MemberName::vmindex(mname);
   if (vmindex == VM_INDEX_UNINITIALIZED)  return NULL; // not resolved
   methodOop m = decode_vmtarget(vmtarget, vmindex, NULL, receiver_limit_result, decode_flags_result);
-  oop clazz = sun_dyn_MemberName::clazz(mname);
+  oop clazz = java_lang_invoke_MemberName::clazz(mname);
   if (clazz != NULL && java_lang_Class::is_instance(clazz)) {
     klassOop klass = java_lang_Class::as_klassOop(clazz);
     if (klass != NULL)  receiver_limit_result = klass;
@@ -442,8 +442,8 @@ methodOop MethodHandles::decode_MemberName(oop mname, klassOop& receiver_limit_r
 Symbol* MethodHandles::convert_to_signature(oop type_str,
                                             bool polymorphic,
                                             TRAPS) {
-  if (java_dyn_MethodType::is_instance(type_str)) {
-    return java_dyn_MethodType::as_signature(type_str, polymorphic, CHECK_NULL);
+  if (java_lang_invoke_MethodType::is_instance(type_str)) {
+    return java_lang_invoke_MethodType::as_signature(type_str, polymorphic, CHECK_NULL);
   } else if (java_lang_Class::is_instance(type_str)) {
     return java_lang_Class::as_signature(type_str, false, CHECK_NULL);
   } else if (java_lang_String::is_instance(type_str)) {
@@ -461,7 +461,7 @@ Symbol* MethodHandles::convert_to_signature(oop type_str,
 // Resolving it plants a vmtarget/vmindex in it,
 // which refers dirctly to JVM internals.
 void MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
-  assert(sun_dyn_MemberName::is_instance(mname()), "");
+  assert(java_lang_invoke_MemberName::is_instance(mname()), "");
 #ifdef ASSERT
   // If this assert throws, renegotiate the sentinel value used by the Java code,
   // so that it is distinct from any valid vtable index value, and any special
@@ -472,12 +472,12 @@ void MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
   const int sentinel_limit = methodOopDesc::highest_unused_vtable_index_value - sentinel_slop;
   assert(VM_INDEX_UNINITIALIZED < sentinel_limit, "Java sentinel != JVM sentinels");
 #endif
-  if (sun_dyn_MemberName::vmindex(mname()) != VM_INDEX_UNINITIALIZED)
+  if (java_lang_invoke_MemberName::vmindex(mname()) != VM_INDEX_UNINITIALIZED)
     return;  // already resolved
-  oop defc_oop = sun_dyn_MemberName::clazz(mname());
-  oop name_str = sun_dyn_MemberName::name(mname());
-  oop type_str = sun_dyn_MemberName::type(mname());
-  int flags    = sun_dyn_MemberName::flags(mname());
+  oop defc_oop = java_lang_invoke_MemberName::clazz(mname());
+  oop name_str = java_lang_invoke_MemberName::name(mname());
+  oop type_str = java_lang_invoke_MemberName::type(mname());
+  int flags    = java_lang_invoke_MemberName::flags(mname());
 
   if (defc_oop == NULL || name_str == NULL || type_str == NULL) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "nothing to resolve");
@@ -510,7 +510,7 @@ void MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
 
   // convert the external string or reflective type to an internal signature
   TempNewSymbol type = convert_to_signature(type_str, polymorphic_signature, CHECK);
-  if (java_dyn_MethodType::is_instance(type_str) && polymorphic_signature) {
+  if (java_lang_invoke_MethodType::is_instance(type_str) && polymorphic_signature) {
     polymorphic_method_type = Handle(THREAD, type_str);  //preserve exactly
   }
 
@@ -557,9 +557,9 @@ void MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
         vmtarget = result.resolved_klass()->as_klassOop();
       }
       int mods = (m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS);
-      sun_dyn_MemberName::set_vmtarget(mname(), vmtarget);
-      sun_dyn_MemberName::set_vmindex(mname(),  vmindex);
-      sun_dyn_MemberName::set_modifiers(mname(), mods);
+      java_lang_invoke_MemberName::set_vmtarget(mname(), vmtarget);
+      java_lang_invoke_MemberName::set_vmindex(mname(),  vmindex);
+      java_lang_invoke_MemberName::set_modifiers(mname(), mods);
       DEBUG_ONLY(int junk; klassOop junk2);
       assert(decode_MemberName(mname(), junk2, junk) == result.resolved_method()(),
              "properly stored for later decoding");
@@ -586,9 +586,9 @@ void MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
       oop vmtarget = m();
       int vmindex  = methodOopDesc::nonvirtual_vtable_index;
       int mods     = (m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS);
-      sun_dyn_MemberName::set_vmtarget(mname(), vmtarget);
-      sun_dyn_MemberName::set_vmindex(mname(),  vmindex);
-      sun_dyn_MemberName::set_modifiers(mname(), mods);
+      java_lang_invoke_MemberName::set_vmtarget(mname(), vmtarget);
+      java_lang_invoke_MemberName::set_vmindex(mname(),  vmindex);
+      java_lang_invoke_MemberName::set_modifiers(mname(), mods);
       DEBUG_ONLY(int junk; klassOop junk2);
       assert(decode_MemberName(mname(), junk2, junk) == result.resolved_method()(),
              "properly stored for later decoding");
@@ -605,9 +605,9 @@ void MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
       int vmindex  = fd.offset();
       int mods     = (fd.access_flags().as_short() & JVM_RECOGNIZED_FIELD_MODIFIERS);
       if (vmindex == VM_INDEX_UNINITIALIZED)  break;  // should not happen
-      sun_dyn_MemberName::set_vmtarget(mname(),  vmtarget);
-      sun_dyn_MemberName::set_vmindex(mname(),   vmindex);
-      sun_dyn_MemberName::set_modifiers(mname(), mods);
+      java_lang_invoke_MemberName::set_vmtarget(mname(),  vmtarget);
+      java_lang_invoke_MemberName::set_vmindex(mname(),   vmindex);
+      java_lang_invoke_MemberName::set_modifiers(mname(), mods);
       return;
     }
   default:
@@ -618,11 +618,11 @@ void MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
   if (polymorphic_method_type.not_null()) {
     // Look on a non-null class loader.
     Handle cur_class_loader;
-    const int nptypes = java_dyn_MethodType::ptype_count(polymorphic_method_type());
+    const int nptypes = java_lang_invoke_MethodType::ptype_count(polymorphic_method_type());
     for (int i = 0; i <= nptypes; i++) {
       oop type_mirror;
-      if (i < nptypes)  type_mirror = java_dyn_MethodType::ptype(polymorphic_method_type(), i);
-      else              type_mirror = java_dyn_MethodType::rtype(polymorphic_method_type());
+      if (i < nptypes)  type_mirror = java_lang_invoke_MethodType::ptype(polymorphic_method_type(), i);
+      else              type_mirror = java_lang_invoke_MethodType::rtype(polymorphic_method_type());
       klassOop example_type = java_lang_Class::as_klassOop(type_mirror);
       if (example_type == NULL)  continue;
       oop class_loader = Klass::cast(example_type)->class_loader();
@@ -639,9 +639,9 @@ void MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
       }
       if (m != NULL) {
         int mods = (m->access_flags().as_short() & JVM_RECOGNIZED_METHOD_MODIFIERS);
-        sun_dyn_MemberName::set_vmtarget(mname(),  m);
-        sun_dyn_MemberName::set_vmindex(mname(),   m->vtable_index());
-        sun_dyn_MemberName::set_modifiers(mname(), mods);
+        java_lang_invoke_MemberName::set_vmtarget(mname(),  m);
+        java_lang_invoke_MemberName::set_vmindex(mname(),   m->vtable_index());
+        java_lang_invoke_MemberName::set_modifiers(mname(), mods);
         return;
       }
     }
@@ -653,17 +653,17 @@ void MethodHandles::resolve_MemberName(Handle mname, TRAPS) {
 // Resolving it plants a vmtarget/vmindex in it,
 // which refers directly to JVM internals.
 void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) {
-  assert(sun_dyn_MemberName::is_instance(mname()), "");
-  oop vmtarget = sun_dyn_MemberName::vmtarget(mname());
-  int vmindex  = sun_dyn_MemberName::vmindex(mname());
+  assert(java_lang_invoke_MemberName::is_instance(mname()), "");
+  oop vmtarget = java_lang_invoke_MemberName::vmtarget(mname());
+  int vmindex  = java_lang_invoke_MemberName::vmindex(mname());
   if (vmtarget == NULL || vmindex == VM_INDEX_UNINITIALIZED) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "nothing to expand");
   }
 
-  bool have_defc = (sun_dyn_MemberName::clazz(mname()) != NULL);
-  bool have_name = (sun_dyn_MemberName::name(mname()) != NULL);
-  bool have_type = (sun_dyn_MemberName::type(mname()) != NULL);
-  int flags      = sun_dyn_MemberName::flags(mname());
+  bool have_defc = (java_lang_invoke_MemberName::clazz(mname()) != NULL);
+  bool have_name = (java_lang_invoke_MemberName::name(mname()) != NULL);
+  bool have_type = (java_lang_invoke_MemberName::type(mname()) != NULL);
+  int flags      = java_lang_invoke_MemberName::flags(mname());
 
   if (suppress != 0) {
     if (suppress & _suppress_defc)  have_defc = true;
@@ -687,16 +687,16 @@ void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) {
         if (receiver_limit != NULL && receiver_limit != defc
             && Klass::cast(receiver_limit)->is_subtype_of(defc))
           defc = receiver_limit;
-        sun_dyn_MemberName::set_clazz(mname(), Klass::cast(defc)->java_mirror());
+        java_lang_invoke_MemberName::set_clazz(mname(), Klass::cast(defc)->java_mirror());
       }
       if (!have_name) {
         //not java_lang_String::create_from_symbol; let's intern member names
         Handle name = StringTable::intern(m->name(), CHECK);
-        sun_dyn_MemberName::set_name(mname(), name());
+        java_lang_invoke_MemberName::set_name(mname(), name());
       }
       if (!have_type) {
         Handle type = java_lang_String::create_from_symbol(m->signature(), CHECK);
-        sun_dyn_MemberName::set_type(mname(), type());
+        java_lang_invoke_MemberName::set_type(mname(), type());
       }
       return;
     }
@@ -711,16 +711,16 @@ void MethodHandles::expand_MemberName(Handle mname, int suppress, TRAPS) {
       if (!defc->find_field_from_offset(vmindex, is_static, &fd))
         break;                  // cannot expand
       if (!have_defc) {
-        sun_dyn_MemberName::set_clazz(mname(), defc->java_mirror());
+        java_lang_invoke_MemberName::set_clazz(mname(), defc->java_mirror());
       }
       if (!have_name) {
         //not java_lang_String::create_from_symbol; let's intern member names
         Handle name = StringTable::intern(fd.name(), CHECK);
-        sun_dyn_MemberName::set_name(mname(), name());
+        java_lang_invoke_MemberName::set_name(mname(), name());
       }
       if (!have_type) {
         Handle type = java_lang_String::create_from_symbol(fd.signature(), CHECK);
-        sun_dyn_MemberName::set_type(mname(), type());
+        java_lang_invoke_MemberName::set_type(mname(), type());
       }
       return;
     }
@@ -775,7 +775,7 @@ int MethodHandles::find_MemberNames(klassOop k,
         --rskip;
       } else if (rfill < rlimit) {
         oop result = results->obj_at(rfill++);
-        if (!sun_dyn_MemberName::is_instance(result))
+        if (!java_lang_invoke_MemberName::is_instance(result))
           return -99;  // caller bug!
         MethodHandles::init_MemberName(result, st.klass()->as_klassOop(), st.access_flags(), st.offset());
       } else if (++overflow >= overflow_limit) {
@@ -823,7 +823,7 @@ int MethodHandles::find_MemberNames(klassOop k,
         --rskip;
       } else if (rfill < rlimit) {
         oop result = results->obj_at(rfill++);
-        if (!sun_dyn_MemberName::is_instance(result))
+        if (!java_lang_invoke_MemberName::is_instance(result))
           return -99;  // caller bug!
         MethodHandles::init_MemberName(result, m, true);
       } else if (++overflow >= overflow_limit) {
@@ -857,9 +857,9 @@ instanceKlassHandle MethodHandles::resolve_instance_klass(oop java_mirror_oop, T
 // Sanitize out methodOops, klassOops, and any other non-Java data.
 // This is for debugging and reflection.
 oop MethodHandles::encode_target(Handle mh, int format, TRAPS) {
-  assert(java_dyn_MethodHandle::is_instance(mh()), "must be a MH");
+  assert(java_lang_invoke_MethodHandle::is_instance(mh()), "must be a MH");
   if (format == ETF_HANDLE_OR_METHOD_NAME) {
-    oop target = java_dyn_MethodHandle::vmtarget(mh());
+    oop target = java_lang_invoke_MethodHandle::vmtarget(mh());
     if (target == NULL) {
       return NULL;                // unformed MH
     }
@@ -874,10 +874,10 @@ oop MethodHandles::encode_target(Handle mh, int format, TRAPS) {
       if (target->klass() == SystemDictionary::DirectMethodHandle_klass()) {
         return target;
       }
-      if (!java_dyn_MethodHandle::is_instance(target)){
+      if (!java_lang_invoke_MethodHandle::is_instance(target)){
         return NULL;                // unformed MH
       }
-      target = java_dyn_MethodHandle::vmtarget(target);
+      target = java_lang_invoke_MethodHandle::vmtarget(target);
     }
   }
   // cases of metadata in MH.vmtarget:
@@ -904,7 +904,7 @@ oop MethodHandles::encode_target(Handle mh, int format, TRAPS) {
       instanceKlassHandle mname_klass(THREAD, SystemDictionary::MemberName_klass());
       mname_klass->initialize(CHECK_NULL);
       Handle mname = mname_klass->allocate_instance_handle(CHECK_NULL);
-      sun_dyn_MemberName::set_vmindex(mname(), VM_INDEX_UNINITIALIZED);
+      java_lang_invoke_MemberName::set_vmindex(mname(), VM_INDEX_UNINITIALIZED);
       bool do_dispatch = ((decode_flags & MethodHandles::_dmf_does_dispatch) != 0);
       init_MemberName(mname(), m, do_dispatch);
       expand_MemberName(mname, 0, CHECK_NULL);
@@ -923,6 +923,7 @@ static const char* always_null_names[] = {
   "java/lang/Null",
   //"java/lang/Nothing",
   "sun/dyn/empty/Empty",
+  "sun/invoke/empty/Empty",
   NULL
 };
 
@@ -1025,7 +1026,7 @@ void MethodHandles::verify_method_signature(methodHandle m,
                                             int first_ptype_pos,
                                             KlassHandle insert_ptype,
                                             TRAPS) {
-  objArrayHandle ptypes(THREAD, java_dyn_MethodType::ptypes(mtype()));
+  objArrayHandle ptypes(THREAD, java_lang_invoke_MethodType::ptypes(mtype()));
   int pnum = first_ptype_pos;
   int pmax = ptypes->length();
   int mnum = 0;                 // method argument
@@ -1036,7 +1037,7 @@ void MethodHandles::verify_method_signature(methodHandle m,
     if (ss.at_return_type()) {
       if (pnum != pmax)
         { err = "too many arguments"; break; }
-      ptype_oop = java_dyn_MethodType::rtype(mtype());
+      ptype_oop = java_lang_invoke_MethodType::rtype(mtype());
     } else {
       if (pnum >= pmax)
         { err = "not enough arguments"; break; }
@@ -1111,7 +1112,7 @@ void MethodHandles::verify_method_type(methodHandle m,
   }
 
   if (m_needs_receiver && err == NULL) {
-    objArrayOop ptypes = java_dyn_MethodType::ptypes(mtype());
+    objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(mtype());
     if (ptypes->length() < first_ptype_pos)
       { err = "receiver argument is missing"; goto die; }
     if (has_bound_recv)
@@ -1131,15 +1132,15 @@ void MethodHandles::verify_method_type(methodHandle m,
 
 void MethodHandles::verify_vmslots(Handle mh, TRAPS) {
   // Verify vmslots.
-  int check_slots = argument_slot_count(java_dyn_MethodHandle::type(mh()));
-  if (java_dyn_MethodHandle::vmslots(mh()) != check_slots) {
+  int check_slots = argument_slot_count(java_lang_invoke_MethodHandle::type(mh()));
+  if (java_lang_invoke_MethodHandle::vmslots(mh()) != check_slots) {
     THROW_MSG(vmSymbols::java_lang_InternalError(), "bad vmslots in BMH");
   }
 }
 
 void MethodHandles::verify_vmargslot(Handle mh, int argnum, int argslot, TRAPS) {
   // Verify that argslot points at the given argnum.
-  int check_slot = argument_slot(java_dyn_MethodHandle::type(mh()), argnum);
+  int check_slot = argument_slot(java_lang_invoke_MethodHandle::type(mh()), argnum);
   if (argslot != check_slot || argslot < 0) {
     const char* fmt = "for argnum of %d, vmargslot is %d, should be %d";
     size_t msglen = strlen(fmt) + 3*11 + 1;
@@ -1160,8 +1161,8 @@ const char* MethodHandles::check_method_type_change(oop src_mtype, int src_beg,
                                                     int delete_argnum,
                                                     oop dst_mtype, int dst_beg, int dst_end,
                                                     bool raw) {
-  objArrayOop src_ptypes = java_dyn_MethodType::ptypes(src_mtype);
-  objArrayOop dst_ptypes = java_dyn_MethodType::ptypes(dst_mtype);
+  objArrayOop src_ptypes = java_lang_invoke_MethodType::ptypes(src_mtype);
+  objArrayOop dst_ptypes = java_lang_invoke_MethodType::ptypes(dst_mtype);
 
   int src_max = src_ptypes->length();
   int dst_max = dst_ptypes->length();
@@ -1224,8 +1225,8 @@ const char* MethodHandles::check_method_type_change(oop src_mtype, int src_beg,
   }
 
   // Now compare return types also.
-  oop src_rtype = java_dyn_MethodType::rtype(src_mtype);
-  oop dst_rtype = java_dyn_MethodType::rtype(dst_mtype);
+  oop src_rtype = java_lang_invoke_MethodType::rtype(src_mtype);
+  oop dst_rtype = java_lang_invoke_MethodType::rtype(dst_mtype);
   if (src_rtype != dst_rtype) {
     err = check_return_type_change(dst_rtype, src_rtype, raw); // note reversal!
     if (err != NULL)  return err;
@@ -1314,7 +1315,7 @@ const char* MethodHandles::check_argument_type_change(BasicType src_type,
 // then return a negative number.  Otherwise, the result
 // is in the range [0..vmslots] inclusive.
 int MethodHandles::argument_slot(oop method_type, int arg) {
-  objArrayOop ptypes = java_dyn_MethodType::ptypes(method_type);
+  objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(method_type);
   int argslot = 0;
   int len = ptypes->length();
   if (arg < -1 || arg >= len)  return -99;
@@ -1328,7 +1329,7 @@ int MethodHandles::argument_slot(oop method_type, int arg) {
 
 // Given a slot number, return the argument number.
 int MethodHandles::argument_slot_to_argnum(oop method_type, int query_argslot) {
-  objArrayOop ptypes = java_dyn_MethodType::ptypes(method_type);
+  objArrayOop ptypes = java_lang_invoke_MethodType::ptypes(method_type);
   int argslot = 0;
   int len = ptypes->length();
   for (int i = len-1; i >= 0; i--) {
@@ -1394,11 +1395,11 @@ methodHandle MethodHandles::dispatch_decoded_method(methodHandle m,
 
 void MethodHandles::verify_DirectMethodHandle(Handle mh, methodHandle m, TRAPS) {
   // Verify type.
-  Handle mtype(THREAD, java_dyn_MethodHandle::type(mh()));
+  Handle mtype(THREAD, java_lang_invoke_MethodHandle::type(mh()));
   verify_method_type(m, mtype, false, KlassHandle(), CHECK);
 
   // Verify vmslots.
-  if (java_dyn_MethodHandle::vmslots(mh()) != m->size_of_parameters()) {
+  if (java_lang_invoke_MethodHandle::vmslots(mh()) != m->size_of_parameters()) {
     THROW_MSG(vmSymbols::java_lang_InternalError(), "bad vmslots in DMH");
   }
 }
@@ -1410,7 +1411,7 @@ void MethodHandles::init_DirectMethodHandle(Handle mh, methodHandle m, bool do_d
     THROW(vmSymbols::java_lang_InternalError());
   }
 
-  java_dyn_MethodHandle::init_vmslots(mh());
+  java_lang_invoke_MethodHandle::init_vmslots(mh());
 
   if (VerifyMethodHandles) {
     // The privileged code which invokes this routine should not make
@@ -1470,8 +1471,8 @@ void MethodHandles::init_DirectMethodHandle(Handle mh, methodHandle m, bool do_d
 
   if (me == NULL) { THROW(vmSymbols::java_lang_InternalError()); }
 
-  sun_dyn_DirectMethodHandle::set_vmtarget(mh(), vmtarget);
-  sun_dyn_DirectMethodHandle::set_vmindex(mh(),  vmindex);
+  java_lang_invoke_DirectMethodHandle::set_vmtarget(mh(), vmtarget);
+  java_lang_invoke_DirectMethodHandle::set_vmindex(mh(),  vmindex);
   DEBUG_ONLY(int flags; klassOop rlimit);
   assert(MethodHandles::decode_method(mh(), rlimit, flags) == m(),
          "properly stored for later decoding");
@@ -1482,15 +1483,15 @@ void MethodHandles::init_DirectMethodHandle(Handle mh, methodHandle m, bool do_d
   assert(decode_MethodHandle_stack_pushes(mh()) == 0, "DMH does not move stack");
 
   // Done!
-  java_dyn_MethodHandle::set_vmentry(mh(), me);
+  java_lang_invoke_MethodHandle::set_vmentry(mh(), me);
 }
 
 void MethodHandles::verify_BoundMethodHandle_with_receiver(Handle mh,
                                                            methodHandle m,
                                                            TRAPS) {
   // Verify type.
-  oop receiver = sun_dyn_BoundMethodHandle::argument(mh());
-  Handle mtype(THREAD, java_dyn_MethodHandle::type(mh()));
+  oop receiver = java_lang_invoke_BoundMethodHandle::argument(mh());
+  Handle mtype(THREAD, java_lang_invoke_MethodHandle::type(mh()));
   KlassHandle bound_recv_type;
   if (receiver != NULL)  bound_recv_type = KlassHandle(THREAD, receiver->klass());
   verify_method_type(m, mtype, true, bound_recv_type, CHECK);
@@ -1498,11 +1499,11 @@ void MethodHandles::verify_BoundMethodHandle_with_receiver(Handle mh,
   int receiver_pos = m->size_of_parameters() - 1;
 
   // Verify MH.vmargslot, which should point at the bound receiver.
-  verify_vmargslot(mh, -1, sun_dyn_BoundMethodHandle::vmargslot(mh()), CHECK);
+  verify_vmargslot(mh, -1, java_lang_invoke_BoundMethodHandle::vmargslot(mh()), CHECK);
   //verify_vmslots(mh, CHECK);
 
   // Verify vmslots.
-  if (java_dyn_MethodHandle::vmslots(mh()) != receiver_pos) {
+  if (java_lang_invoke_MethodHandle::vmslots(mh()) != receiver_pos) {
     THROW_MSG(vmSymbols::java_lang_InternalError(), "bad vmslots in BMH (receiver)");
   }
 }
@@ -1520,7 +1521,7 @@ void MethodHandles::init_BoundMethodHandle_with_receiver(Handle mh,
 
   KlassHandle receiver_klass;
   {
-    oop receiver_oop = sun_dyn_BoundMethodHandle::argument(mh());
+    oop receiver_oop = java_lang_invoke_BoundMethodHandle::argument(mh());
     if (receiver_oop != NULL)
       receiver_klass = KlassHandle(THREAD, receiver_oop->klass());
   }
@@ -1531,31 +1532,31 @@ void MethodHandles::init_BoundMethodHandle_with_receiver(Handle mh,
   if (m.is_null())      { THROW(vmSymbols::java_lang_InternalError()); }
   if (m->is_abstract()) { THROW(vmSymbols::java_lang_AbstractMethodError()); }
 
-  java_dyn_MethodHandle::init_vmslots(mh());
+  java_lang_invoke_MethodHandle::init_vmslots(mh());
 
   if (VerifyMethodHandles) {
     verify_BoundMethodHandle_with_receiver(mh, m, CHECK);
   }
 
-  sun_dyn_BoundMethodHandle::set_vmtarget(mh(), m());
+  java_lang_invoke_BoundMethodHandle::set_vmtarget(mh(), m());
 
   DEBUG_ONLY(int junk; klassOop junk2);
   assert(MethodHandles::decode_method(mh(), junk2, junk) == m(), "properly stored for later decoding");
   assert(decode_MethodHandle_stack_pushes(mh()) == 1, "BMH pushes one stack slot");
 
   // Done!
-  java_dyn_MethodHandle::set_vmentry(mh(), MethodHandles::entry(MethodHandles::_bound_ref_direct_mh));
+  java_lang_invoke_MethodHandle::set_vmentry(mh(), MethodHandles::entry(MethodHandles::_bound_ref_direct_mh));
 }
 
 void MethodHandles::verify_BoundMethodHandle(Handle mh, Handle target, int argnum,
                                              bool direct_to_method, TRAPS) {
   Handle ptype_handle(THREAD,
-                           java_dyn_MethodType::ptype(java_dyn_MethodHandle::type(target()), argnum));
+                           java_lang_invoke_MethodType::ptype(java_lang_invoke_MethodHandle::type(target()), argnum));
   KlassHandle ptype_klass;
   BasicType ptype = java_lang_Class::as_BasicType(ptype_handle(), &ptype_klass);
   int slots_pushed = type2size[ptype];
 
-  oop argument = sun_dyn_BoundMethodHandle::argument(mh());
+  oop argument = java_lang_invoke_BoundMethodHandle::argument(mh());
 
   const char* err = NULL;
 
@@ -1623,9 +1624,9 @@ void MethodHandles::verify_BoundMethodHandle(Handle mh, Handle target, int argnu
 
   if (err == NULL) {
     // Verify the rest of the method type.
-    err = check_method_type_insertion(java_dyn_MethodHandle::type(mh()),
+    err = check_method_type_insertion(java_lang_invoke_MethodHandle::type(mh()),
                                       argnum, ptype_handle(),
-                                      java_dyn_MethodHandle::type(target()));
+                                      java_lang_invoke_MethodHandle::type(target()));
   }
 
   if (err != NULL) {
@@ -1635,20 +1636,20 @@ void MethodHandles::verify_BoundMethodHandle(Handle mh, Handle target, int argnu
 
 void MethodHandles::init_BoundMethodHandle(Handle mh, Handle target, int argnum, TRAPS) {
   // Check arguments.
-  if (mh.is_null() || target.is_null() || !java_dyn_MethodHandle::is_instance(target())) {
+  if (mh.is_null() || target.is_null() || !java_lang_invoke_MethodHandle::is_instance(target())) {
     THROW(vmSymbols::java_lang_InternalError());
   }
 
-  java_dyn_MethodHandle::init_vmslots(mh());
+  java_lang_invoke_MethodHandle::init_vmslots(mh());
 
   if (VerifyMethodHandles) {
     int insert_after = argnum - 1;
-    verify_vmargslot(mh, insert_after, sun_dyn_BoundMethodHandle::vmargslot(mh()), CHECK);
+    verify_vmargslot(mh, insert_after, java_lang_invoke_BoundMethodHandle::vmargslot(mh()), CHECK);
     verify_vmslots(mh, CHECK);
   }
 
   // Get bound type and required slots.
-  oop ptype_oop = java_dyn_MethodType::ptype(java_dyn_MethodHandle::type(target()), argnum);
+  oop ptype_oop = java_lang_invoke_MethodType::ptype(java_lang_invoke_MethodHandle::type(target()), argnum);
   BasicType ptype = java_lang_Class::as_BasicType(ptype_oop);
   int slots_pushed = type2size[ptype];
 
@@ -1659,12 +1660,12 @@ void MethodHandles::init_BoundMethodHandle(Handle mh, Handle target, int argnum,
   bool direct_to_method = false;
   if (OptimizeMethodHandles &&
       target->klass() == SystemDictionary::DirectMethodHandle_klass() &&
-      (argnum == 0 || sun_dyn_DirectMethodHandle::vmindex(target()) < 0)) {
+      (argnum == 0 || java_lang_invoke_DirectMethodHandle::vmindex(target()) < 0)) {
     int decode_flags = 0; klassOop receiver_limit_oop = NULL;
     methodHandle m(THREAD, decode_method(target(), receiver_limit_oop, decode_flags));
     if (m.is_null()) { THROW_MSG(vmSymbols::java_lang_InternalError(), "DMH failed to decode"); }
     DEBUG_ONLY(int m_vmslots = m->size_of_parameters() - slots_pushed); // pos. of 1st arg.
-    assert(sun_dyn_BoundMethodHandle::vmslots(mh()) == m_vmslots, "type w/ m sig");
+    assert(java_lang_invoke_BoundMethodHandle::vmslots(mh()) == m_vmslots, "type w/ m sig");
     if (argnum == 0 && (decode_flags & _dmf_has_receiver) != 0) {
       KlassHandle receiver_limit(THREAD, receiver_limit_oop);
       init_BoundMethodHandle_with_receiver(mh, m,
@@ -1677,11 +1678,11 @@ void MethodHandles::init_BoundMethodHandle(Handle mh, Handle target, int argnum,
     // to bind another argument and still invoke the methodOop directly.
     if (!(decode_flags & _dmf_does_dispatch)) {
       direct_to_method = true;
-      sun_dyn_BoundMethodHandle::set_vmtarget(mh(), m());
+      java_lang_invoke_BoundMethodHandle::set_vmtarget(mh(), m());
     }
   }
   if (!direct_to_method)
-    sun_dyn_BoundMethodHandle::set_vmtarget(mh(), target());
+    java_lang_invoke_BoundMethodHandle::set_vmtarget(mh(), target());
 
   if (VerifyMethodHandles) {
     verify_BoundMethodHandle(mh, target, argnum, direct_to_method, CHECK);
@@ -1703,7 +1704,7 @@ void MethodHandles::init_BoundMethodHandle(Handle mh, Handle target, int argnum,
   }
 
   // Done!
-  java_dyn_MethodHandle::set_vmentry(mh(), me);
+  java_lang_invoke_MethodHandle::set_vmentry(mh(), me);
 }
 
 static void throw_InternalError_for_bad_conversion(int conversion, const char* err, TRAPS) {
@@ -1713,8 +1714,8 @@ static void throw_InternalError_for_bad_conversion(int conversion, const char* e
 }
 
 void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
-  jint conversion = sun_dyn_AdapterMethodHandle::conversion(mh());
-  int  argslot    = sun_dyn_AdapterMethodHandle::vmargslot(mh());
+  jint conversion = java_lang_invoke_AdapterMethodHandle::conversion(mh());
+  int  argslot    = java_lang_invoke_AdapterMethodHandle::vmargslot(mh());
 
   verify_vmargslot(mh, argnum, argslot, CHECK);
   verify_vmslots(mh, CHECK);
@@ -1731,10 +1732,10 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
   BasicType dest = adapter_conversion_dest_type(conversion);
   int vminfo     = adapter_conversion_vminfo(conversion); // should be zero
 
-  Handle argument(THREAD,  sun_dyn_AdapterMethodHandle::argument(mh()));
-  Handle target(THREAD,    sun_dyn_AdapterMethodHandle::vmtarget(mh()));
-  Handle src_mtype(THREAD, java_dyn_MethodHandle::type(mh()));
-  Handle dst_mtype(THREAD, java_dyn_MethodHandle::type(target()));
+  Handle argument(THREAD,  java_lang_invoke_AdapterMethodHandle::argument(mh()));
+  Handle target(THREAD,    java_lang_invoke_AdapterMethodHandle::vmtarget(mh()));
+  Handle src_mtype(THREAD, java_lang_invoke_MethodHandle::type(mh()));
+  Handle dst_mtype(THREAD, java_lang_invoke_MethodHandle::type(target()));
 
   const char* err = NULL;
 
@@ -1760,7 +1761,7 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
       break;
     case _adapter_flyby:
     case _adapter_ricochet:
-      if (!java_dyn_MethodHandle::is_instance(argument()))
+      if (!java_lang_invoke_MethodHandle::is_instance(argument()))
         { err = "MethodHandle adapter argument required"; break; }
       break;
     default:
@@ -1806,9 +1807,9 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
           err = "adapter requires src/dest conversion subfields for swap"; break;
         }
         int swap_size = type2size[src];
-        oop src_mtype  = sun_dyn_AdapterMethodHandle::type(mh());
-        oop dest_mtype = sun_dyn_AdapterMethodHandle::type(target());
-        int slot_limit = sun_dyn_AdapterMethodHandle::vmslots(target());
+        oop src_mtype  = java_lang_invoke_AdapterMethodHandle::type(mh());
+        oop dest_mtype = java_lang_invoke_AdapterMethodHandle::type(target());
+        int slot_limit = java_lang_invoke_AdapterMethodHandle::vmslots(target());
         int src_slot   = argslot;
         int dest_slot  = vminfo;
         bool rotate_up = (src_slot > dest_slot); // upward rotation
@@ -1821,8 +1822,8 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
         } else if (ek == _adapter_swap_args && !(src_slot > dest_slot)) {
           err = "source of swap must be deeper in stack";
         } else if (ek == _adapter_swap_args) {
-          err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype, dest_arg),
-                                           java_dyn_MethodType::ptype(dest_mtype, src_arg),
+          err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype, dest_arg),
+                                           java_lang_invoke_MethodType::ptype(dest_mtype, src_arg),
                                            dest_arg);
         } else if (ek == _adapter_rot_args) {
           if (rotate_up) {
@@ -1830,8 +1831,8 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
             // rotate up: [dest_slot..src_slot-ss] --> [dest_slot+ss..src_slot]
             // that is:   [src_arg+1..dest_arg] --> [src_arg..dest_arg-1]
             for (int i = src_arg+1; i <= dest_arg && err == NULL; i++) {
-              err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype, i),
-                                               java_dyn_MethodType::ptype(dest_mtype, i-1),
+              err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype, i),
+                                               java_lang_invoke_MethodType::ptype(dest_mtype, i-1),
                                                i);
             }
           } else { // rotate down
@@ -1839,15 +1840,15 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
             // rotate down: [src_slot+ss..dest_slot] --> [src_slot..dest_slot-ss]
             // that is:     [dest_arg..src_arg-1] --> [dst_arg+1..src_arg]
             for (int i = dest_arg; i <= src_arg-1 && err == NULL; i++) {
-              err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype, i),
-                                               java_dyn_MethodType::ptype(dest_mtype, i+1),
+              err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype, i),
+                                               java_lang_invoke_MethodType::ptype(dest_mtype, i+1),
                                                i);
             }
           }
         }
         if (err == NULL)
-          err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype, src_arg),
-                                           java_dyn_MethodType::ptype(dest_mtype, dest_arg),
+          err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype, src_arg),
+                                           java_lang_invoke_MethodType::ptype(dest_mtype, dest_arg),
                                            src_arg);
       }
       break;
@@ -1918,8 +1919,8 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
   if (err == NULL) {
     // Make sure this adapter does not push too deeply.
     int slots_pushed = stack_move / stack_move_unit();
-    int this_vmslots = java_dyn_MethodHandle::vmslots(mh());
-    int target_vmslots = java_dyn_MethodHandle::vmslots(target());
+    int this_vmslots = java_lang_invoke_MethodHandle::vmslots(mh());
+    int target_vmslots = java_lang_invoke_MethodHandle::vmslots(target());
     if (slots_pushed != (target_vmslots - this_vmslots)) {
       err = "stack_move inconsistent with previous and current MethodType vmslots";
     } else if (slots_pushed > 0)  {
@@ -1961,7 +1962,7 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
     case _adapter_check_cast:
       {
         // The actual value being checked must be a reference:
-        err = check_argument_type_change(java_dyn_MethodType::ptype(src_mtype(), argnum),
+        err = check_argument_type_change(java_lang_invoke_MethodType::ptype(src_mtype(), argnum),
                                          object_java_mirror(), argnum);
         if (err != NULL)  break;
 
@@ -1985,9 +1986,9 @@ void MethodHandles::verify_AdapterMethodHandle(Handle mh, int argnum, TRAPS) {
 }
 
 void MethodHandles::init_AdapterMethodHandle(Handle mh, Handle target, int argnum, TRAPS) {
-  oop  argument   = sun_dyn_AdapterMethodHandle::argument(mh());
-  int  argslot    = sun_dyn_AdapterMethodHandle::vmargslot(mh());
-  jint conversion = sun_dyn_AdapterMethodHandle::conversion(mh());
+  oop  argument   = java_lang_invoke_AdapterMethodHandle::argument(mh());
+  int  argslot    = java_lang_invoke_AdapterMethodHandle::vmargslot(mh());
+  jint conversion = java_lang_invoke_AdapterMethodHandle::conversion(mh());
   jint conv_op    = adapter_conversion_op(conversion);
 
   // adjust the adapter code to the internal EntryKind enumeration:
@@ -1995,11 +1996,11 @@ void MethodHandles::init_AdapterMethodHandle(Handle mh, Handle target, int argnu
   EntryKind ek_opt  = ek_orig;  // may be optimized
 
   // Finalize the vmtarget field (Java initialized it to null).
-  if (!java_dyn_MethodHandle::is_instance(target())) {
+  if (!java_lang_invoke_MethodHandle::is_instance(target())) {
     throw_InternalError_for_bad_conversion(conversion, "bad target", THREAD);
     return;
   }
-  sun_dyn_AdapterMethodHandle::set_vmtarget(mh(), target());
+  java_lang_invoke_AdapterMethodHandle::set_vmtarget(mh(), target());
 
   if (VerifyMethodHandles) {
     verify_AdapterMethodHandle(mh, argnum, CHECK);
@@ -2083,7 +2084,7 @@ void MethodHandles::init_AdapterMethodHandle(Handle mh, Handle target, int argnu
   case _adapter_rot_args:
     {
       int swap_slots = type2size[src];
-      int slot_limit = sun_dyn_AdapterMethodHandle::vmslots(mh());
+      int slot_limit = java_lang_invoke_AdapterMethodHandle::vmslots(mh());
       int src_slot   = argslot;
       int dest_slot  = vminfo;
       int rotate     = (ek_orig == _adapter_swap_args) ? 0 : (src_slot > dest_slot) ? 1 : -1;
@@ -2147,10 +2148,10 @@ void MethodHandles::init_AdapterMethodHandle(Handle mh, Handle target, int argnu
   jint new_conversion = adapter_conversion(conv_op, src, dest, stack_move, vminfo);
 
   // Finalize the conversion field.  (Note that it is final to Java code.)
-  sun_dyn_AdapterMethodHandle::set_conversion(mh(), new_conversion);
+  java_lang_invoke_AdapterMethodHandle::set_conversion(mh(), new_conversion);
 
   // Done!
-  java_dyn_MethodHandle::set_vmentry(mh(), entry(ek_opt));
+  java_lang_invoke_MethodHandle::set_vmentry(mh(), entry(ek_opt));
 
   // There should be enough memory barriers on exit from native methods
   // to ensure that the MH is fully initialized to all threads before
@@ -2158,7 +2159,7 @@ void MethodHandles::init_AdapterMethodHandle(Handle mh, Handle target, int argnu
 }
 
 //
-// Here are the native methods on sun.dyn.MethodHandleImpl.
+// Here are the native methods on sun.invoke.MethodHandleImpl.
 // They are the private interface between this JVM and the HotSpot-specific
 // Java code that implements JSR 292 method handles.
 //
@@ -2168,7 +2169,7 @@ void MethodHandles::init_AdapterMethodHandle(Handle mh, Handle target, int argnu
 
 // direct method handles for invokestatic or invokespecial
 // void init(DirectMethodHandle self, MemberName ref, boolean doDispatch, Class<?> caller);
-JVM_ENTRY(void, MHI_init_DMH(JNIEnv *env, jobject igcls, jobject mh_jh,
+JVM_ENTRY(void, MHN_init_DMH(JNIEnv *env, jobject igcls, jobject mh_jh,
                              jobject target_jh, jboolean do_dispatch, jobject caller_jh)) {
   ResourceMark rm;              // for error messages
 
@@ -2177,13 +2178,13 @@ JVM_ENTRY(void, MHI_init_DMH(JNIEnv *env, jobject igcls, jobject mh_jh,
   Handle mh(THREAD, JNIHandles::resolve_non_null(mh_jh));
 
   // Early returns out of this method leave the DMH in an unfinished state.
-  assert(java_dyn_MethodHandle::vmentry(mh()) == NULL, "must be safely null");
+  assert(java_lang_invoke_MethodHandle::vmentry(mh()) == NULL, "must be safely null");
 
   // which method are we really talking about?
   if (target_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); }
   oop target_oop = JNIHandles::resolve_non_null(target_jh);
-  if (sun_dyn_MemberName::is_instance(target_oop) &&
-      sun_dyn_MemberName::vmindex(target_oop) == VM_INDEX_UNINITIALIZED) {
+  if (java_lang_invoke_MemberName::is_instance(target_oop) &&
+      java_lang_invoke_MemberName::vmindex(target_oop) == VM_INDEX_UNINITIALIZED) {
     Handle mname(THREAD, target_oop);
     MethodHandles::resolve_MemberName(mname, CHECK);
     target_oop = mname(); // in case of GC
@@ -2232,7 +2233,7 @@ JVM_ENTRY(void, MHI_init_DMH(JNIEnv *env, jobject igcls, jobject mh_jh,
 JVM_END
 
 // bound method handles
-JVM_ENTRY(void, MHI_init_BMH(JNIEnv *env, jobject igcls, jobject mh_jh,
+JVM_ENTRY(void, MHN_init_BMH(JNIEnv *env, jobject igcls, jobject mh_jh,
                              jobject target_jh, int argnum)) {
   ResourceMark rm;              // for error messages
 
@@ -2241,12 +2242,12 @@ JVM_ENTRY(void, MHI_init_BMH(JNIEnv *env, jobject igcls, jobject mh_jh,
   Handle mh(THREAD, JNIHandles::resolve_non_null(mh_jh));
 
   // Early returns out of this method leave the BMH in an unfinished state.
-  assert(java_dyn_MethodHandle::vmentry(mh()) == NULL, "must be safely null");
+  assert(java_lang_invoke_MethodHandle::vmentry(mh()) == NULL, "must be safely null");
 
   if (target_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); }
   Handle target(THREAD, JNIHandles::resolve_non_null(target_jh));
 
-  if (!java_dyn_MethodHandle::is_instance(target())) {
+  if (!java_lang_invoke_MethodHandle::is_instance(target())) {
     // Target object is a reflective method.  (%%% Do we need this alternate path?)
     Untested("init_BMH of non-MH");
     if (argnum != 0) { THROW(vmSymbols::java_lang_InternalError()); }
@@ -2269,7 +2270,7 @@ JVM_ENTRY(void, MHI_init_BMH(JNIEnv *env, jobject igcls, jobject mh_jh,
 JVM_END
 
 // adapter method handles
-JVM_ENTRY(void, MHI_init_AMH(JNIEnv *env, jobject igcls, jobject mh_jh,
+JVM_ENTRY(void, MHN_init_AMH(JNIEnv *env, jobject igcls, jobject mh_jh,
                              jobject target_jh, int argnum)) {
   // This is the guy we are initializing:
   if (mh_jh == NULL || target_jh == NULL) {
@@ -2279,14 +2280,14 @@ JVM_ENTRY(void, MHI_init_AMH(JNIEnv *env, jobject igcls, jobject mh_jh,
   Handle target(THREAD, JNIHandles::resolve_non_null(target_jh));
 
   // Early returns out of this method leave the AMH in an unfinished state.
-  assert(java_dyn_MethodHandle::vmentry(mh()) == NULL, "must be safely null");
+  assert(java_lang_invoke_MethodHandle::vmentry(mh()) == NULL, "must be safely null");
 
   MethodHandles::init_AdapterMethodHandle(mh, target, argnum, CHECK);
 }
 JVM_END
 
 // method type forms
-JVM_ENTRY(void, MHI_init_MT(JNIEnv *env, jobject igcls, jobject erased_jh)) {
+JVM_ENTRY(void, MHN_init_MT(JNIEnv *env, jobject igcls, jobject erased_jh)) {
   if (erased_jh == NULL)  return;
   if (TraceMethodHandles) {
     tty->print("creating MethodType form ");
@@ -2307,9 +2308,9 @@ JVM_ENTRY(void, MHI_init_MT(JNIEnv *env, jobject igcls, jobject erased_jh)) {
 JVM_END
 
 // debugging and reflection
-JVM_ENTRY(jobject, MHI_getTarget(JNIEnv *env, jobject igcls, jobject mh_jh, jint format)) {
+JVM_ENTRY(jobject, MHN_getTarget(JNIEnv *env, jobject igcls, jobject mh_jh, jint format)) {
   Handle mh(THREAD, JNIHandles::resolve(mh_jh));
-  if (!java_dyn_MethodHandle::is_instance(mh())) {
+  if (!java_lang_invoke_MethodHandle::is_instance(mh())) {
     THROW_NULL(vmSymbols::java_lang_IllegalArgumentException());
   }
   oop target = MethodHandles::encode_target(mh, format, CHECK_NULL);
@@ -2317,7 +2318,7 @@ JVM_ENTRY(jobject, MHI_getTarget(JNIEnv *env, jobject igcls, jobject mh_jh, jint
 }
 JVM_END
 
-JVM_ENTRY(jint, MHI_getConstant(JNIEnv *env, jobject igcls, jint which)) {
+JVM_ENTRY(jint, MHN_getConstant(JNIEnv *env, jobject igcls, jint which)) {
   switch (which) {
   case MethodHandles::GC_JVM_PUSH_LIMIT:
     guarantee(MethodHandlePushLimit >= 2 && MethodHandlePushLimit <= 0xFF,
@@ -2341,36 +2342,36 @@ JVM_END
     template(MethodHandles,ETF_DIRECT_HANDLE) \
     template(MethodHandles,ETF_METHOD_NAME) \
     template(MethodHandles,ETF_REFLECT_METHOD) \
-    template(sun_dyn_MemberName,MN_IS_METHOD) \
-    template(sun_dyn_MemberName,MN_IS_CONSTRUCTOR) \
-    template(sun_dyn_MemberName,MN_IS_FIELD) \
-    template(sun_dyn_MemberName,MN_IS_TYPE) \
-    template(sun_dyn_MemberName,MN_SEARCH_SUPERCLASSES) \
-    template(sun_dyn_MemberName,MN_SEARCH_INTERFACES) \
-    template(sun_dyn_MemberName,VM_INDEX_UNINITIALIZED) \
-    template(sun_dyn_AdapterMethodHandle,OP_RETYPE_ONLY) \
-    template(sun_dyn_AdapterMethodHandle,OP_RETYPE_RAW) \
-    template(sun_dyn_AdapterMethodHandle,OP_CHECK_CAST) \
-    template(sun_dyn_AdapterMethodHandle,OP_PRIM_TO_PRIM) \
-    template(sun_dyn_AdapterMethodHandle,OP_REF_TO_PRIM) \
-    template(sun_dyn_AdapterMethodHandle,OP_PRIM_TO_REF) \
-    template(sun_dyn_AdapterMethodHandle,OP_SWAP_ARGS) \
-    template(sun_dyn_AdapterMethodHandle,OP_ROT_ARGS) \
-    template(sun_dyn_AdapterMethodHandle,OP_DUP_ARGS) \
-    template(sun_dyn_AdapterMethodHandle,OP_DROP_ARGS) \
-    template(sun_dyn_AdapterMethodHandle,OP_COLLECT_ARGS) \
-    template(sun_dyn_AdapterMethodHandle,OP_SPREAD_ARGS) \
-    template(sun_dyn_AdapterMethodHandle,OP_FLYBY) \
-    template(sun_dyn_AdapterMethodHandle,OP_RICOCHET) \
-    template(sun_dyn_AdapterMethodHandle,CONV_OP_LIMIT) \
-    template(sun_dyn_AdapterMethodHandle,CONV_OP_MASK) \
-    template(sun_dyn_AdapterMethodHandle,CONV_VMINFO_MASK) \
-    template(sun_dyn_AdapterMethodHandle,CONV_VMINFO_SHIFT) \
-    template(sun_dyn_AdapterMethodHandle,CONV_OP_SHIFT) \
-    template(sun_dyn_AdapterMethodHandle,CONV_DEST_TYPE_SHIFT) \
-    template(sun_dyn_AdapterMethodHandle,CONV_SRC_TYPE_SHIFT) \
-    template(sun_dyn_AdapterMethodHandle,CONV_STACK_MOVE_SHIFT) \
-    template(sun_dyn_AdapterMethodHandle,CONV_STACK_MOVE_MASK) \
+    template(java_lang_invoke_MemberName,MN_IS_METHOD) \
+    template(java_lang_invoke_MemberName,MN_IS_CONSTRUCTOR) \
+    template(java_lang_invoke_MemberName,MN_IS_FIELD) \
+    template(java_lang_invoke_MemberName,MN_IS_TYPE) \
+    template(java_lang_invoke_MemberName,MN_SEARCH_SUPERCLASSES) \
+    template(java_lang_invoke_MemberName,MN_SEARCH_INTERFACES) \
+    template(java_lang_invoke_MemberName,VM_INDEX_UNINITIALIZED) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_RETYPE_ONLY) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_RETYPE_RAW) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_CHECK_CAST) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_PRIM_TO_PRIM) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_REF_TO_PRIM) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_PRIM_TO_REF) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_SWAP_ARGS) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_ROT_ARGS) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_DUP_ARGS) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_DROP_ARGS) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_COLLECT_ARGS) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_SPREAD_ARGS) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_FLYBY) \
+    template(java_lang_invoke_AdapterMethodHandle,OP_RICOCHET) \
+    template(java_lang_invoke_AdapterMethodHandle,CONV_OP_LIMIT) \
+    template(java_lang_invoke_AdapterMethodHandle,CONV_OP_MASK) \
+    template(java_lang_invoke_AdapterMethodHandle,CONV_VMINFO_MASK) \
+    template(java_lang_invoke_AdapterMethodHandle,CONV_VMINFO_SHIFT) \
+    template(java_lang_invoke_AdapterMethodHandle,CONV_OP_SHIFT) \
+    template(java_lang_invoke_AdapterMethodHandle,CONV_DEST_TYPE_SHIFT) \
+    template(java_lang_invoke_AdapterMethodHandle,CONV_SRC_TYPE_SHIFT) \
+    template(java_lang_invoke_AdapterMethodHandle,CONV_STACK_MOVE_SHIFT) \
+    template(java_lang_invoke_AdapterMethodHandle,CONV_STACK_MOVE_MASK) \
     /*end*/
 
 #define ONE_PLUS(scope,value) 1+
@@ -2386,7 +2387,7 @@ static const char con_names[] = { EACH_NAMED_CON(STRING_NULL) };
 #undef EACH_NAMED_CON
 #endif
 
-JVM_ENTRY(jint, MHI_getNamedCon(JNIEnv *env, jobject igcls, jint which, jobjectArray box_jh)) {
+JVM_ENTRY(jint, MHN_getNamedCon(JNIEnv *env, jobject igcls, jint which, jobjectArray box_jh)) {
 #ifndef PRODUCT
   if (which >= 0 && which < con_value_count) {
     int con = con_values[which];
@@ -2406,7 +2407,7 @@ JVM_ENTRY(jint, MHI_getNamedCon(JNIEnv *env, jobject igcls, jint which, jobjectA
 JVM_END
 
 // void init(MemberName self, AccessibleObject ref)
-JVM_ENTRY(void, MHI_init_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jobject target_jh)) {
+JVM_ENTRY(void, MHN_init_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jobject target_jh)) {
   if (mname_jh == NULL || target_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); }
   Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh));
   oop target_oop = JNIHandles::resolve_non_null(target_jh);
@@ -2415,7 +2416,7 @@ JVM_ENTRY(void, MHI_init_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jobje
 JVM_END
 
 // void expand(MemberName self)
-JVM_ENTRY(void, MHI_expand_Mem(JNIEnv *env, jobject igcls, jobject mname_jh)) {
+JVM_ENTRY(void, MHN_expand_Mem(JNIEnv *env, jobject igcls, jobject mname_jh)) {
   if (mname_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); }
   Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh));
   MethodHandles::expand_MemberName(mname, 0, CHECK);
@@ -2423,14 +2424,14 @@ JVM_ENTRY(void, MHI_expand_Mem(JNIEnv *env, jobject igcls, jobject mname_jh)) {
 JVM_END
 
 // void resolve(MemberName self, Class<?> caller)
-JVM_ENTRY(void, MHI_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jclass caller_jh)) {
+JVM_ENTRY(void, MHN_resolve_Mem(JNIEnv *env, jobject igcls, jobject mname_jh, jclass caller_jh)) {
   if (mname_jh == NULL) { THROW(vmSymbols::java_lang_InternalError()); }
   Handle mname(THREAD, JNIHandles::resolve_non_null(mname_jh));
 
   // The trusted Java code that calls this method should already have performed
   // access checks on behalf of the given caller.  But, we can verify this.
   if (VerifyMethodHandles && caller_jh != NULL) {
-    klassOop reference_klass = java_lang_Class::as_klassOop(sun_dyn_MemberName::clazz(mname()));
+    klassOop reference_klass = java_lang_Class::as_klassOop(java_lang_invoke_MemberName::clazz(mname()));
     if (reference_klass != NULL) {
       // Emulate LinkResolver::check_klass_accessability.
       klassOop caller = java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(caller_jh));
@@ -2448,7 +2449,7 @@ JVM_END
 
 //  static native int getMembers(Class<?> defc, String matchName, String matchSig,
 //          int matchFlags, Class<?> caller, int skip, MemberName[] results);
-JVM_ENTRY(jint, MHI_getMembers(JNIEnv *env, jobject igcls,
+JVM_ENTRY(jint, MHN_getMembers(JNIEnv *env, jobject igcls,
                                jclass clazz_jh, jstring name_jh, jstring sig_jh,
                                int mflags, jclass caller_jh, jint skip, jobjectArray results_jh)) {
   if (clazz_jh == NULL || results_jh == NULL)  return -1;
@@ -2487,14 +2488,14 @@ JVM_ENTRY(jint, MHI_getMembers(JNIEnv *env, jobject igcls,
 }
 JVM_END
 
-JVM_ENTRY(void, MHI_registerBootstrap(JNIEnv *env, jobject igcls, jclass caller_jh, jobject bsm_jh)) {
+JVM_ENTRY(void, MHN_registerBootstrap(JNIEnv *env, jobject igcls, jclass caller_jh, jobject bsm_jh)) {
   instanceKlassHandle ik = MethodHandles::resolve_instance_klass(caller_jh, THREAD);
   if (!AllowTransitionalJSR292) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
               "registerBootstrapMethod is only supported in JSR 292 EDR");
   }
   ik->link_class(CHECK);
-  if (!java_dyn_MethodHandle::is_instance(JNIHandles::resolve(bsm_jh))) {
+  if (!java_lang_invoke_MethodHandle::is_instance(JNIHandles::resolve(bsm_jh))) {
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "method handle");
   }
   const char* err = NULL;
@@ -2522,29 +2523,28 @@ JVM_ENTRY(void, MHI_registerBootstrap(JNIEnv *env, jobject igcls, jclass caller_
 }
 JVM_END
 
-JVM_ENTRY(jobject, MHI_getBootstrap(JNIEnv *env, jobject igcls, jclass caller_jh)) {
+JVM_ENTRY(jobject, MHN_getBootstrap(JNIEnv *env, jobject igcls, jclass caller_jh)) {
+  if (!AllowTransitionalJSR292)
+    THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "getBootstrap: transitional only");
   instanceKlassHandle ik = MethodHandles::resolve_instance_klass(caller_jh, THREAD);
   return JNIHandles::make_local(THREAD, ik->bootstrap_method());
 }
 JVM_END
 
-JVM_ENTRY(void, MHI_setCallSiteTarget(JNIEnv *env, jobject igcls, jobject site_jh, jobject target_jh)) {
-  // No special action required, yet.
-  oop site_oop = JNIHandles::resolve(site_jh);
-  if (!java_dyn_CallSite::is_instance(site_oop))
-    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "not a CallSite");
-  java_dyn_CallSite::set_target(site_oop, JNIHandles::resolve(target_jh));
+JVM_ENTRY(void, MHN_setCallSiteTarget(JNIEnv *env, jobject igcls, jobject site_jh, jobject target_jh)) {
+  if (!AllowTransitionalJSR292)
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), "setCallSite: transitional only");
 }
 JVM_END
 
 
 /// JVM_RegisterMethodHandleMethods
 
-#define ADR "J"
-
 #define LANG "Ljava/lang/"
-#define JDYN "Ljava/dyn/"
-#define IDYN "Lsun/dyn/"
+#define JLINV "Ljava/lang/invoke/" /* standard package */
+#define JDYN "Ljava/dyn/" /* alternative package to JLINV if AllowTransitionalJSR292 */
+#define IDYN "Lsun/dyn/"  /* alternative package to JDYN if AllowTransitionalJSR292 */
+// FIXME: After AllowTransitionalJSR292 is removed, replace JDYN and IDYN by JLINV.
 
 #define OBJ   LANG"Object;"
 #define CLS   LANG"Class;"
@@ -2552,7 +2552,6 @@ JVM_END
 #define CST   JDYN"CallSite;"
 #define MT    JDYN"MethodType;"
 #define MH    JDYN"MethodHandle;"
-#define MHI   IDYN"MethodHandleImpl;"
 #define MEM   IDYN"MemberName;"
 #define AMH   IDYN"AdapterMethodHandle;"
 #define BMH   IDYN"BoundMethodHandle;"
@@ -2561,32 +2560,58 @@ JVM_END
 #define CC (char*)  /*cast a literal from (const char*)*/
 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 
-// These are the native methods on sun.dyn.MethodHandleNatives.
+// These are the native methods on sun.invoke.MethodHandleNatives.
 static JNINativeMethod methods[] = {
   // void init(MemberName self, AccessibleObject ref)
-  {CC"init",                    CC"("AMH""MH"I)V",              FN_PTR(MHI_init_AMH)},
-  {CC"init",                    CC"("BMH""OBJ"I)V",             FN_PTR(MHI_init_BMH)},
-  {CC"init",                    CC"("DMH""OBJ"Z"CLS")V",        FN_PTR(MHI_init_DMH)},
-  {CC"init",                    CC"("MT")V",                    FN_PTR(MHI_init_MT)},
-  {CC"init",                    CC"("MEM""OBJ")V",              FN_PTR(MHI_init_Mem)},
-  {CC"expand",                  CC"("MEM")V",                   FN_PTR(MHI_expand_Mem)},
-  {CC"resolve",                 CC"("MEM""CLS")V",              FN_PTR(MHI_resolve_Mem)},
-  {CC"getTarget",               CC"("MH"I)"OBJ,                 FN_PTR(MHI_getTarget)},
-  {CC"getConstant",             CC"(I)I",                       FN_PTR(MHI_getConstant)},
+  {CC"init",                    CC"("AMH""MH"I)V",              FN_PTR(MHN_init_AMH)},
+  {CC"init",                    CC"("BMH""OBJ"I)V",             FN_PTR(MHN_init_BMH)},
+  {CC"init",                    CC"("DMH""OBJ"Z"CLS")V",        FN_PTR(MHN_init_DMH)},
+  {CC"init",                    CC"("MT")V",                    FN_PTR(MHN_init_MT)},
+  {CC"init",                    CC"("MEM""OBJ")V",              FN_PTR(MHN_init_Mem)},
+  {CC"expand",                  CC"("MEM")V",                   FN_PTR(MHN_expand_Mem)},
+  {CC"resolve",                 CC"("MEM""CLS")V",              FN_PTR(MHN_resolve_Mem)},
+  {CC"getTarget",               CC"("MH"I)"OBJ,                 FN_PTR(MHN_getTarget)},
+  {CC"getConstant",             CC"(I)I",                       FN_PTR(MHN_getConstant)},
   //  static native int getNamedCon(int which, Object[] name)
-  {CC"getNamedCon",             CC"(I["OBJ")I",                 FN_PTR(MHI_getNamedCon)},
+  {CC"getNamedCon",             CC"(I["OBJ")I",                 FN_PTR(MHN_getNamedCon)},
   //  static native int getMembers(Class<?> defc, String matchName, String matchSig,
   //          int matchFlags, Class<?> caller, int skip, MemberName[] results);
-  {CC"getMembers",              CC"("CLS""STRG""STRG"I"CLS"I["MEM")I",  FN_PTR(MHI_getMembers)}
+  {CC"getMembers",              CC"("CLS""STRG""STRG"I"CLS"I["MEM")I",  FN_PTR(MHN_getMembers)}
 };
 
 // More entry points specifically for EnableInvokeDynamic.
+// FIXME: Remove methods2 after AllowTransitionalJSR292 is removed.
 static JNINativeMethod methods2[] = {
-  {CC"registerBootstrap",       CC"("CLS MH")V",                FN_PTR(MHI_registerBootstrap)},
-  {CC"getBootstrap",            CC"("CLS")"MH,                  FN_PTR(MHI_getBootstrap)},
-  {CC"setCallSiteTarget",       CC"("CST MH")V",                FN_PTR(MHI_setCallSiteTarget)}
+  {CC"registerBootstrap",       CC"("CLS MH")V",                FN_PTR(MHN_registerBootstrap)},
+  {CC"getBootstrap",            CC"("CLS")"MH,                  FN_PTR(MHN_getBootstrap)},
+  {CC"setCallSiteTarget",       CC"("CST MH")V",                FN_PTR(MHN_setCallSiteTarget)}
 };
 
+static void hack_signatures(JNINativeMethod* methods, jint num_methods, const char* from_sig, const char* to_sig) {
+  for (int i = 0; i < num_methods; i++) {
+    const char* sig = methods[i].signature;
+    if (!strstr(sig, from_sig))  continue;
+    size_t buflen = strlen(sig) + 100;
+    char* buf = NEW_C_HEAP_ARRAY(char, buflen);
+    char* bufp = buf;
+    const char* sigp = sig;
+    size_t from_len = strlen(from_sig), to_len = strlen(to_sig);
+    while (*sigp != '\0') {
+      assert(bufp < buf + buflen - to_len - 1, "oob");
+      if (strncmp(sigp, from_sig, from_len) != 0) {
+        *bufp++ = *sigp++;
+      } else {
+        strcpy(bufp, to_sig);
+        bufp += to_len;
+        sigp += from_len;
+      }
+    }
+    *bufp = '\0';
+    methods[i].signature = buf;  // replace with new signature
+    if (TraceMethodHandles)
+      tty->print_cr("MethodHandleNatives: %s: change signature %s => %s", methods[i].name, sig, buf);
+  }
+}
 
 // This one function is exported, used by NativeLookup.
 
@@ -2600,45 +2625,78 @@ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class))
     return;  // bind nothing
   }
 
+  if (SystemDictionary::MethodHandleNatives_klass() != NULL &&
+      SystemDictionary::MethodHandleNatives_klass() != java_lang_Class::as_klassOop(JNIHandles::resolve(MHN_class))) {
+    warning("multiple versions of MethodHandleNatives in boot classpath; consider using -XX:+PreferTransitionalJSR292");
+    THROW_MSG(vmSymbols::java_lang_InternalError(), "multiple versions of MethodHandleNatives in boot classpath; consider using -XX:+PreferTransitionalJSR292");
+  }
+
   bool enable_MH = true;
 
-  {
+  // Loop control.  FIXME: Replace by dead reckoning after AllowTransitionalJSR292 is removed.
+  bool registered_natives = false;
+  bool try_plain = true, try_JDYN = true, try_IDYN = true;
+  for (;;) {
     ThreadToNativeFromVM ttnfv(thread);
 
+    if      (try_plain) { try_plain = false; }
+    else if (try_JDYN)  { try_JDYN  = false; hack_signatures(methods, sizeof(methods)/sizeof(JNINativeMethod), IDYN, JDYN); }
+    else if (try_IDYN)  { try_IDYN  = false; hack_signatures(methods, sizeof(methods)/sizeof(JNINativeMethod), JDYN, JLINV); }
+    else                { break; }
     int status = env->RegisterNatives(MHN_class, methods, sizeof(methods)/sizeof(JNINativeMethod));
     if (env->ExceptionOccurred()) {
-      MethodHandles::set_enabled(false);
-      warning("JSR 292 method handle code is mismatched to this JVM.  Disabling support.");
-      enable_MH = false;
       env->ExceptionClear();
+      // and try again...
+    } else {
+      registered_natives = true;
+      break;
     }
   }
+  if (!registered_natives) {
+    MethodHandles::set_enabled(false);
+    warning("JSR 292 method handle code is mismatched to this JVM.  Disabling support.");
+    enable_MH = false;
+  }
 
   if (enable_MH) {
+    bool found_raise_exception = false;
+    KlassHandle MHN_klass = SystemDictionaryHandles::MethodHandleNatives_klass();
     KlassHandle MHI_klass = SystemDictionaryHandles::MethodHandleImpl_klass();
-    if (MHI_klass.not_null()) {
+    // Loop control.  FIXME: Replace by dead reckoning after AllowTransitionalJSR292 is removed.
+    bool try_MHN = true, try_MHI = AllowTransitionalJSR292;
+    for (;;) {
+      KlassHandle try_klass;
+      if      (try_MHN) { try_MHN = false; try_klass = MHN_klass; }
+      else if (try_MHI) { try_MHI = false; try_klass = MHI_klass; }
+      else              { break; }
+      if (try_klass.is_null())  continue;
       TempNewSymbol raiseException_name = SymbolTable::new_symbol("raiseException", CHECK);
       TempNewSymbol raiseException_sig = SymbolTable::new_symbol("(ILjava/lang/Object;Ljava/lang/Object;)V", CHECK);
-      methodOop raiseException_method  = instanceKlass::cast(MHI_klass->as_klassOop())
+      methodOop raiseException_method  = instanceKlass::cast(try_klass->as_klassOop())
                     ->find_method(raiseException_name, raiseException_sig);
       if (raiseException_method != NULL && raiseException_method->is_static()) {
         MethodHandles::set_raise_exception_method(raiseException_method);
-      } else {
-        warning("JSR 292 method handle code is mismatched to this JVM.  Disabling support.");
-        enable_MH = false;
+        found_raise_exception = true;
+        break;
       }
-    } else {
+    }
+    if (!found_raise_exception) {
+      warning("JSR 292 method handle code is mismatched to this JVM.  Disabling support.");
       enable_MH = false;
     }
   }
 
   if (enable_MH) {
-    // We need to link the MethodHandleImpl klass before we generate
-    // the method handle adapters as the _raise_exception adapter uses
-    // one of its methods (and its c2i-adapter).
-    KlassHandle    k  = SystemDictionaryHandles::MethodHandleImpl_klass();
-    instanceKlass* ik = instanceKlass::cast(k());
-    ik->link_class(CHECK);
+    if (AllowTransitionalJSR292) {
+      // We need to link the MethodHandleImpl klass before we generate
+      // the method handle adapters as the _raise_exception adapter uses
+      // one of its methods (and its c2i-adapter).
+      klassOop k = SystemDictionary::MethodHandleImpl_klass();
+      if (k != NULL) {
+        instanceKlass* ik = instanceKlass::cast(k);
+        ik->link_class(CHECK);
+      }
+    }
 
     MethodHandles::generate_adapters();
     MethodHandles::set_enabled(true);
@@ -2649,16 +2707,14 @@ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class))
     return;  // bind nothing
   }
 
-  {
+  if (AllowTransitionalJSR292) {
     ThreadToNativeFromVM ttnfv(thread);
 
     int status = env->RegisterNatives(MHN_class, methods2, sizeof(methods2)/sizeof(JNINativeMethod));
     if (env->ExceptionOccurred()) {
-      MethodHandles::set_enabled(false);
-      warning("JSR 292 method handle code is mismatched to this JVM.  Disabling support.");
+      // Don't do this, since it's too late:
+      //   MethodHandles::set_enabled(false)
       env->ExceptionClear();
-    } else {
-      MethodHandles::set_enabled(true);
     }
   }
 }
diff --git a/hotspot/src/share/vm/prims/methodHandles.hpp b/hotspot/src/share/vm/prims/methodHandles.hpp
index 01f6272fc41..08e0b537700 100644
--- a/hotspot/src/share/vm/prims/methodHandles.hpp
+++ b/hotspot/src/share/vm/prims/methodHandles.hpp
@@ -37,8 +37,8 @@ class MethodHandleEntry;
 
 class MethodHandles: AllStatic {
   // JVM support for MethodHandle, MethodType, and related types
-  // in java.dyn and java.dyn.hotspot.
-  // See also  javaClasses for layouts java_dyn_Method{Handle,Type,Type::Form}.
+  // in java.lang.invoke and sun.invoke.
+  // See also  javaClasses for layouts java_lang_invoke_Method{Handle,Type,Type::Form}.
  public:
   enum EntryKind {
     _raise_exception,           // stub for error generation from other stubs
@@ -54,21 +54,21 @@ class MethodHandles: AllStatic {
     _bound_long_direct_mh,
 
     _adapter_mh_first,     // adapter sequence goes here...
-    _adapter_retype_only   = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY,
-    _adapter_retype_raw    = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW,
-    _adapter_check_cast    = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_CHECK_CAST,
-    _adapter_prim_to_prim  = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM,
-    _adapter_ref_to_prim   = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM,
-    _adapter_prim_to_ref   = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_PRIM_TO_REF,
-    _adapter_swap_args     = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS,
-    _adapter_rot_args      = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_ROT_ARGS,
-    _adapter_dup_args      = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_DUP_ARGS,
-    _adapter_drop_args     = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_DROP_ARGS,
-    _adapter_collect_args  = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_COLLECT_ARGS,
-    _adapter_spread_args   = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS,
-    _adapter_flyby         = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_FLYBY,
-    _adapter_ricochet      = _adapter_mh_first + sun_dyn_AdapterMethodHandle::OP_RICOCHET,
-    _adapter_mh_last       = _adapter_mh_first + sun_dyn_AdapterMethodHandle::CONV_OP_LIMIT - 1,
+    _adapter_retype_only   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RETYPE_ONLY,
+    _adapter_retype_raw    = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RETYPE_RAW,
+    _adapter_check_cast    = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_CHECK_CAST,
+    _adapter_prim_to_prim  = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_PRIM,
+    _adapter_ref_to_prim   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_REF_TO_PRIM,
+    _adapter_prim_to_ref   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_PRIM_TO_REF,
+    _adapter_swap_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_SWAP_ARGS,
+    _adapter_rot_args      = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_ROT_ARGS,
+    _adapter_dup_args      = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_DUP_ARGS,
+    _adapter_drop_args     = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_DROP_ARGS,
+    _adapter_collect_args  = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_COLLECT_ARGS,
+    _adapter_spread_args   = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_SPREAD_ARGS,
+    _adapter_flyby         = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_FLYBY,
+    _adapter_ricochet      = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::OP_RICOCHET,
+    _adapter_mh_last       = _adapter_mh_first + java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT - 1,
 
     // Optimized adapter types
 
@@ -107,16 +107,16 @@ class MethodHandles: AllStatic {
   static void set_enabled(bool z);
 
  private:
-  enum {  // import sun_dyn_AdapterMethodHandle::CONV_OP_*
-    CONV_OP_LIMIT         = sun_dyn_AdapterMethodHandle::CONV_OP_LIMIT,
-    CONV_OP_MASK          = sun_dyn_AdapterMethodHandle::CONV_OP_MASK,
-    CONV_VMINFO_MASK      = sun_dyn_AdapterMethodHandle::CONV_VMINFO_MASK,
-    CONV_VMINFO_SHIFT     = sun_dyn_AdapterMethodHandle::CONV_VMINFO_SHIFT,
-    CONV_OP_SHIFT         = sun_dyn_AdapterMethodHandle::CONV_OP_SHIFT,
-    CONV_DEST_TYPE_SHIFT  = sun_dyn_AdapterMethodHandle::CONV_DEST_TYPE_SHIFT,
-    CONV_SRC_TYPE_SHIFT   = sun_dyn_AdapterMethodHandle::CONV_SRC_TYPE_SHIFT,
-    CONV_STACK_MOVE_SHIFT = sun_dyn_AdapterMethodHandle::CONV_STACK_MOVE_SHIFT,
-    CONV_STACK_MOVE_MASK  = sun_dyn_AdapterMethodHandle::CONV_STACK_MOVE_MASK
+  enum {  // import java_lang_invoke_AdapterMethodHandle::CONV_OP_*
+    CONV_OP_LIMIT         = java_lang_invoke_AdapterMethodHandle::CONV_OP_LIMIT,
+    CONV_OP_MASK          = java_lang_invoke_AdapterMethodHandle::CONV_OP_MASK,
+    CONV_VMINFO_MASK      = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_MASK,
+    CONV_VMINFO_SHIFT     = java_lang_invoke_AdapterMethodHandle::CONV_VMINFO_SHIFT,
+    CONV_OP_SHIFT         = java_lang_invoke_AdapterMethodHandle::CONV_OP_SHIFT,
+    CONV_DEST_TYPE_SHIFT  = java_lang_invoke_AdapterMethodHandle::CONV_DEST_TYPE_SHIFT,
+    CONV_SRC_TYPE_SHIFT   = java_lang_invoke_AdapterMethodHandle::CONV_SRC_TYPE_SHIFT,
+    CONV_STACK_MOVE_SHIFT = java_lang_invoke_AdapterMethodHandle::CONV_STACK_MOVE_SHIFT,
+    CONV_STACK_MOVE_MASK  = java_lang_invoke_AdapterMethodHandle::CONV_STACK_MOVE_MASK
   };
 
   static bool _enabled;
@@ -471,7 +471,7 @@ class MethodHandles: AllStatic {
 };
 
 
-// Access methods for the "entry" field of a java.dyn.MethodHandle.
+// Access methods for the "entry" field of a java.lang.invoke.MethodHandle.
 // The field is primarily a jump target for compiled calls.
 // However, we squirrel away some nice pointers for other uses,
 // just before the jump target.
diff --git a/hotspot/src/share/vm/prims/nativeLookup.cpp b/hotspot/src/share/vm/prims/nativeLookup.cpp
index 2a427f77d00..f05061bd0c0 100644
--- a/hotspot/src/share/vm/prims/nativeLookup.cpp
+++ b/hotspot/src/share/vm/prims/nativeLookup.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -107,29 +107,30 @@ extern "C" {
   void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
 }
 
-static address lookup_special_native(char* jni_name) {
-  // NB: To ignore the jni prefix and jni postfix strstr is used matching.
-  if (!JDK_Version::is_gte_jdk14x_version()) {
-    // These functions only exist for compatibility with 1.3.1 and earlier
-    // Intercept ObjectOutputStream getPrimitiveFieldValues for faster serialization
-    if (strstr(jni_name, "Java_java_io_ObjectOutputStream_getPrimitiveFieldValues") != NULL) {
-      return CAST_FROM_FN_PTR(address, JVM_GetPrimitiveFieldValues);
-    }
-    // Intercept ObjectInputStream setPrimitiveFieldValues for faster serialization
-    if (strstr(jni_name, "Java_java_io_ObjectInputStream_setPrimitiveFieldValues") != NULL) {
-      return CAST_FROM_FN_PTR(address, JVM_SetPrimitiveFieldValues);
-    }
-  }
-  if (strstr(jni_name, "Java_sun_misc_Unsafe_registerNatives") != NULL) {
-    return CAST_FROM_FN_PTR(address, JVM_RegisterUnsafeMethods);
-  }
-  if (strstr(jni_name, "Java_sun_dyn_MethodHandleNatives_registerNatives") != NULL) {
-    return CAST_FROM_FN_PTR(address, JVM_RegisterMethodHandleMethods);
-  }
-  if (strstr(jni_name, "Java_sun_misc_Perf_registerNatives") != NULL) {
-    return CAST_FROM_FN_PTR(address, JVM_RegisterPerfMethods);
-  }
+#define CC (char*)  /* cast a literal from (const char*) */
+#define FN_PTR(f) CAST_FROM_FN_PTR(void*, &f)
 
+static JNINativeMethod lookup_special_native_methods[] = {
+  // Next two functions only exist for compatibility with 1.3.1 and earlier.
+  { CC"Java_java_io_ObjectOutputStream_getPrimitiveFieldValues",   NULL, FN_PTR(JVM_GetPrimitiveFieldValues)     },  // intercept ObjectOutputStream getPrimitiveFieldValues for faster serialization
+  { CC"Java_java_io_ObjectInputStream_setPrimitiveFieldValues",    NULL, FN_PTR(JVM_SetPrimitiveFieldValues)     },  // intercept ObjectInputStream setPrimitiveFieldValues for faster serialization
+
+  { CC"Java_sun_misc_Unsafe_registerNatives",                      NULL, FN_PTR(JVM_RegisterUnsafeMethods)       },
+  { CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
+  { CC"Java_sun_dyn_MethodHandleNatives_registerNatives",          NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },  // AllowTransitionalJSR292
+  { CC"Java_java_dyn_MethodHandleNatives_registerNatives",         NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },  // AllowTransitionalJSR292
+  { CC"Java_sun_misc_Perf_registerNatives",                        NULL, FN_PTR(JVM_RegisterPerfMethods)         }
+};
+
+static address lookup_special_native(char* jni_name) {
+  int i = !JDK_Version::is_gte_jdk14x_version() ? 0 : 2;  // see comment in lookup_special_native_methods
+  int count = sizeof(lookup_special_native_methods) / sizeof(JNINativeMethod);
+  for (; i < count; i++) {
+    // NB: To ignore the jni prefix and jni postfix strstr is used matching.
+    if (strstr(jni_name, lookup_special_native_methods[i].name) != NULL) {
+      return CAST_FROM_FN_PTR(address, lookup_special_native_methods[i].fnPtr);
+    }
+  }
   return NULL;
 }
 
diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp
index b96f635898a..a4531e948a0 100644
--- a/hotspot/src/share/vm/prims/unsafe.cpp
+++ b/hotspot/src/share/vm/prims/unsafe.cpp
@@ -688,7 +688,7 @@ UNSAFE_ENTRY(jobject, Unsafe_StaticFieldBaseFromField(JNIEnv *env, jobject unsaf
     THROW_0(vmSymbols::java_lang_IllegalArgumentException());
   }
 
-  return JNIHandles::make_local(env, java_lang_Class::as_klassOop(mirror));
+  return JNIHandles::make_local(env, mirror);
 UNSAFE_END
 
 //@deprecated
@@ -706,7 +706,7 @@ UNSAFE_ENTRY(jobject, Unsafe_StaticFieldBaseFromClass(JNIEnv *env, jobject unsaf
   if (clazz == NULL) {
     THROW_0(vmSymbols::java_lang_NullPointerException());
   }
-  return JNIHandles::make_local(env, java_lang_Class::as_klassOop(JNIHandles::resolve_non_null(clazz)));
+  return JNIHandles::make_local(env, JNIHandles::resolve_non_null(clazz));
 UNSAFE_END
 
 UNSAFE_ENTRY(void, Unsafe_EnsureClassInitialized(JNIEnv *env, jobject unsafe, jobject clazz))
diff --git a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp
new file mode 100644
index 00000000000..e195ff4854d
--- /dev/null
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp
@@ -0,0 +1,450 @@
+/*
+* Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
+* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+*/
+
+#include "precompiled.hpp"
+#include "runtime/advancedThresholdPolicy.hpp"
+#include "runtime/simpleThresholdPolicy.inline.hpp"
+
+#ifdef TIERED
+// Print an event.
+void AdvancedThresholdPolicy::print_specific(EventType type, methodHandle mh, methodHandle imh,
+                                             int bci, CompLevel level) {
+  tty->print(" rate: ");
+  if (mh->prev_time() == 0) tty->print("n/a");
+  else tty->print("%f", mh->rate());
+
+  tty->print(" k: %.2lf,%.2lf", threshold_scale(CompLevel_full_profile, Tier3LoadFeedback),
+                                threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback));
+
+}
+
+void AdvancedThresholdPolicy::initialize() {
+  // Turn on ergonomic compiler count selection
+  if (FLAG_IS_DEFAULT(CICompilerCountPerCPU) && FLAG_IS_DEFAULT(CICompilerCount)) {
+    FLAG_SET_DEFAULT(CICompilerCountPerCPU, true);
+  }
+  int count = CICompilerCount;
+  if (CICompilerCountPerCPU) {
+    // Simple log n seems to grow too slowly for tiered, try something faster: log n * log log n
+    int log_cpu = log2_intptr(os::active_processor_count());
+    int loglog_cpu = log2_intptr(MAX2(log_cpu, 1));
+    count = MAX2(log_cpu * loglog_cpu, 1) * 3 / 2;
+  }
+
+  set_c1_count(MAX2(count / 3, 1));
+  set_c2_count(MAX2(count - count / 3, 1));
+
+  // Some inlining tuning
+#ifdef X86
+  if (FLAG_IS_DEFAULT(InlineSmallCode)) {
+    FLAG_SET_DEFAULT(InlineSmallCode, 2000);
+  }
+#endif
+
+#ifdef SPARC
+  if (FLAG_IS_DEFAULT(InlineSmallCode)) {
+    FLAG_SET_DEFAULT(InlineSmallCode, 2500);
+  }
+#endif
+
+
+  set_start_time(os::javaTimeMillis());
+}
+
+// update_rate() is called from select_task() while holding a compile queue lock.
+void AdvancedThresholdPolicy::update_rate(jlong t, methodOop m) {
+  if (is_old(m)) {
+    // We don't remove old methods from the queue,
+    // so we can just zero the rate.
+    m->set_rate(0);
+    return;
+  }
+
+  // We don't update the rate if we've just came out of a safepoint.
+  // delta_s is the time since last safepoint in milliseconds.
+  jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint();
+  jlong delta_t = t - (m->prev_time() != 0 ? m->prev_time() : start_time()); // milliseconds since the last measurement
+  // How many events were there since the last time?
+  int event_count = m->invocation_count() + m->backedge_count();
+  int delta_e = event_count - m->prev_event_count();
+
+  // We should be running for at least 1ms.
+  if (delta_s >= TieredRateUpdateMinTime) {
+    // And we must've taken the previous point at least 1ms before.
+    if (delta_t >= TieredRateUpdateMinTime && delta_e > 0) {
+      m->set_prev_time(t);
+      m->set_prev_event_count(event_count);
+      m->set_rate((float)delta_e / (float)delta_t); // Rate is events per millisecond
+    } else
+      if (delta_t > TieredRateUpdateMaxTime && delta_e == 0) {
+        // If nothing happened for 25ms, zero the rate. Don't modify prev values.
+        m->set_rate(0);
+      }
+  }
+}
+
+// Check if this method has been stale from a given number of milliseconds.
+// See select_task().
+bool AdvancedThresholdPolicy::is_stale(jlong t, jlong timeout, methodOop m) {
+  jlong delta_s = t - SafepointSynchronize::end_of_last_safepoint();
+  jlong delta_t = t - m->prev_time();
+  if (delta_t > timeout && delta_s > timeout) {
+    int event_count = m->invocation_count() + m->backedge_count();
+    int delta_e = event_count - m->prev_event_count();
+    // Return true if there were no events.
+    return delta_e == 0;
+  }
+  return false;
+}
+
+// We don't remove old methods from the compile queue even if they have
+// very low activity. See select_task().
+bool AdvancedThresholdPolicy::is_old(methodOop method) {
+  return method->invocation_count() > 50000 || method->backedge_count() > 500000;
+}
+
+double AdvancedThresholdPolicy::weight(methodOop method) {
+  return (method->rate() + 1) * ((method->invocation_count() + 1) *  (method->backedge_count() + 1));
+}
+
+// Apply heuristics and return true if x should be compiled before y
+bool AdvancedThresholdPolicy::compare_methods(methodOop x, methodOop y) {
+  if (x->highest_comp_level() > y->highest_comp_level()) {
+    // recompilation after deopt
+    return true;
+  } else
+    if (x->highest_comp_level() == y->highest_comp_level()) {
+      if (weight(x) > weight(y)) {
+        return true;
+      }
+    }
+  return false;
+}
+
+// Is method profiled enough?
+bool AdvancedThresholdPolicy::is_method_profiled(methodOop method) {
+  methodDataOop mdo = method->method_data();
+  if (mdo != NULL) {
+    int i = mdo->invocation_count_delta();
+    int b = mdo->backedge_count_delta();
+    return call_predicate_helper<CompLevel_full_profile>(i, b, 1);
+  }
+  return false;
+}
+
+// Called with the queue locked and with at least one element
+CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) {
+  CompileTask *max_task = NULL;
+  methodOop max_method;
+  jlong t = os::javaTimeMillis();
+  // Iterate through the queue and find a method with a maximum rate.
+  for (CompileTask* task = compile_queue->first(); task != NULL;) {
+    CompileTask* next_task = task->next();
+    methodOop method = (methodOop)JNIHandles::resolve(task->method_handle());
+    methodDataOop mdo = method->method_data();
+    update_rate(t, method);
+    if (max_task == NULL) {
+      max_task = task;
+      max_method = method;
+    } else {
+      // If a method has been stale for some time, remove it from the queue.
+      if (is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) {
+        if (PrintTieredEvents) {
+          print_event(KILL, method, method, task->osr_bci(), (CompLevel)task->comp_level());
+        }
+        CompileTaskWrapper ctw(task); // Frees the task
+        compile_queue->remove(task);
+        method->clear_queued_for_compilation();
+        task = next_task;
+        continue;
+      }
+
+      // Select a method with a higher rate
+      if (compare_methods(method, max_method)) {
+        max_task = task;
+        max_method = method;
+      }
+    }
+    task = next_task;
+  }
+
+  if (max_task->comp_level() == CompLevel_full_profile && is_method_profiled(max_method)) {
+    max_task->set_comp_level(CompLevel_limited_profile);
+    if (PrintTieredEvents) {
+      print_event(UPDATE, max_method, max_method, max_task->osr_bci(), (CompLevel)max_task->comp_level());
+    }
+  }
+
+  return max_task;
+}
+
+double AdvancedThresholdPolicy::threshold_scale(CompLevel level, int feedback_k) {
+  double queue_size = CompileBroker::queue_size(level);
+  int comp_count = compiler_count(level);
+  double k = queue_size / (feedback_k * comp_count) + 1;
+  return k;
+}
+
+// Call and loop predicates determine whether a transition to a higher
+// compilation level should be performed (pointers to predicate functions
+// are passed to common()).
+// Tier?LoadFeedback is basically a coefficient that determines of
+// how many methods per compiler thread can be in the queue before
+// the threshold values double.
+bool AdvancedThresholdPolicy::loop_predicate(int i, int b, CompLevel cur_level) {
+  switch(cur_level) {
+  case CompLevel_none:
+  case CompLevel_limited_profile: {
+    double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback);
+    return loop_predicate_helper<CompLevel_none>(i, b, k);
+  }
+  case CompLevel_full_profile: {
+    double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback);
+    return loop_predicate_helper<CompLevel_full_profile>(i, b, k);
+  }
+  default:
+    return true;
+  }
+}
+
+bool AdvancedThresholdPolicy::call_predicate(int i, int b, CompLevel cur_level) {
+  switch(cur_level) {
+  case CompLevel_none:
+  case CompLevel_limited_profile: {
+    double k = threshold_scale(CompLevel_full_profile, Tier3LoadFeedback);
+    return call_predicate_helper<CompLevel_none>(i, b, k);
+  }
+  case CompLevel_full_profile: {
+    double k = threshold_scale(CompLevel_full_optimization, Tier4LoadFeedback);
+    return call_predicate_helper<CompLevel_full_profile>(i, b, k);
+  }
+  default:
+    return true;
+  }
+}
+
+// If a method is old enough and is still in the interpreter we would want to
+// start profiling without waiting for the compiled method to arrive.
+// We also take the load on compilers into the account.
+bool AdvancedThresholdPolicy::should_create_mdo(methodOop method, CompLevel cur_level) {
+  if (cur_level == CompLevel_none &&
+      CompileBroker::queue_size(CompLevel_full_optimization) <=
+      Tier3DelayOn * compiler_count(CompLevel_full_optimization)) {
+    int i = method->invocation_count();
+    int b = method->backedge_count();
+    double k = Tier0ProfilingStartPercentage / 100.0;
+    return call_predicate_helper<CompLevel_none>(i, b, k) || loop_predicate_helper<CompLevel_none>(i, b, k);
+  }
+  return false;
+}
+
+// Create MDO if necessary.
+void AdvancedThresholdPolicy::create_mdo(methodHandle mh, TRAPS) {
+  if (mh->is_native() || mh->is_abstract() || mh->is_accessor()) return;
+  if (mh->method_data() == NULL) {
+    methodOopDesc::build_interpreter_method_data(mh, THREAD);
+    if (HAS_PENDING_EXCEPTION) {
+      CLEAR_PENDING_EXCEPTION;
+    }
+  }
+}
+
+
+/*
+ * Method states:
+ *   0 - interpreter (CompLevel_none)
+ *   1 - pure C1 (CompLevel_simple)
+ *   2 - C1 with invocation and backedge counting (CompLevel_limited_profile)
+ *   3 - C1 with full profiling (CompLevel_full_profile)
+ *   4 - C2 (CompLevel_full_optimization)
+ *
+ * Common state transition patterns:
+ * a. 0 -> 3 -> 4.
+ *    The most common path. But note that even in this straightforward case
+ *    profiling can start at level 0 and finish at level 3.
+ *
+ * b. 0 -> 2 -> 3 -> 4.
+ *    This case occures when the load on C2 is deemed too high. So, instead of transitioning
+ *    into state 3 directly and over-profiling while a method is in the C2 queue we transition to
+ *    level 2 and wait until the load on C2 decreases. This path is disabled for OSRs.
+ *
+ * c. 0 -> (3->2) -> 4.
+ *    In this case we enqueue a method for compilation at level 3, but the C1 queue is long enough
+ *    to enable the profiling to fully occur at level 0. In this case we change the compilation level
+ *    of the method to 2, because it'll allow it to run much faster without full profiling while c2
+ *    is compiling.
+ *
+ * d. 0 -> 3 -> 1 or 0 -> 2 -> 1.
+ *    After a method was once compiled with C1 it can be identified as trivial and be compiled to
+ *    level 1. These transition can also occur if a method can't be compiled with C2 but can with C1.
+ *
+ * e. 0 -> 4.
+ *    This can happen if a method fails C1 compilation (it will still be profiled in the interpreter)
+ *    or because of a deopt that didn't require reprofiling (compilation won't happen in this case because
+ *    the compiled version already exists).
+ *
+ * Note that since state 0 can be reached from any other state via deoptimization different loops
+ * are possible.
+ *
+ */
+
+// Common transition function. Given a predicate determines if a method should transition to another level.
+CompLevel AdvancedThresholdPolicy::common(Predicate p, methodOop method, CompLevel cur_level) {
+  if (is_trivial(method)) return CompLevel_simple;
+
+  CompLevel next_level = cur_level;
+  int i = method->invocation_count();
+  int b = method->backedge_count();
+
+  switch(cur_level) {
+  case CompLevel_none:
+    // If we were at full profile level, would we switch to full opt?
+    if (common(p, method, CompLevel_full_profile) == CompLevel_full_optimization) {
+      next_level = CompLevel_full_optimization;
+    } else if ((this->*p)(i, b, cur_level)) {
+      // C1-generated fully profiled code is about 30% slower than the limited profile
+      // code that has only invocation and backedge counters. The observation is that
+      // if C2 queue is large enough we can spend too much time in the fully profiled code
+      // while waiting for C2 to pick the method from the queue. To alleviate this problem
+      // we introduce a feedback on the C2 queue size. If the C2 queue is sufficiently long
+      // we choose to compile a limited profiled version and then recompile with full profiling
+      // when the load on C2 goes down.
+      if (CompileBroker::queue_size(CompLevel_full_optimization) >
+          Tier3DelayOn * compiler_count(CompLevel_full_optimization)) {
+        next_level = CompLevel_limited_profile;
+      } else {
+        next_level = CompLevel_full_profile;
+      }
+    }
+    break;
+  case CompLevel_limited_profile:
+    if (is_method_profiled(method)) {
+      // Special case: we got here because this method was fully profiled in the interpreter.
+      next_level = CompLevel_full_optimization;
+    } else {
+      methodDataOop mdo = method->method_data();
+      if (mdo != NULL) {
+        if (mdo->would_profile()) {
+          if (CompileBroker::queue_size(CompLevel_full_optimization) <=
+              Tier3DelayOff * compiler_count(CompLevel_full_optimization) &&
+              (this->*p)(i, b, cur_level)) {
+            next_level = CompLevel_full_profile;
+          }
+        } else {
+          next_level = CompLevel_full_optimization;
+        }
+      }
+    }
+    break;
+  case CompLevel_full_profile:
+    {
+      methodDataOop mdo = method->method_data();
+      if (mdo != NULL) {
+        if (mdo->would_profile()) {
+          int mdo_i = mdo->invocation_count_delta();
+          int mdo_b = mdo->backedge_count_delta();
+          if ((this->*p)(mdo_i, mdo_b, cur_level)) {
+            next_level = CompLevel_full_optimization;
+          }
+        } else {
+          next_level = CompLevel_full_optimization;
+        }
+      }
+    }
+    break;
+  }
+  return next_level;
+}
+
+// Determine if a method should be compiled with a normal entry point at a different level.
+CompLevel AdvancedThresholdPolicy::call_event(methodOop method,  CompLevel cur_level) {
+  CompLevel osr_level = (CompLevel) method->highest_osr_comp_level();
+  CompLevel next_level = common(&AdvancedThresholdPolicy::call_predicate, method, cur_level);
+
+  // If OSR method level is greater than the regular method level, the levels should be
+  // equalized by raising the regular method level in order to avoid OSRs during each
+  // invocation of the method.
+  if (osr_level == CompLevel_full_optimization && cur_level == CompLevel_full_profile) {
+    methodDataOop mdo = method->method_data();
+    guarantee(mdo != NULL, "MDO should not be NULL");
+    if (mdo->invocation_count() >= 1) {
+      next_level = CompLevel_full_optimization;
+    }
+  } else {
+    next_level = MAX2(osr_level, next_level);
+  }
+
+  return next_level;
+}
+
+// Determine if we should do an OSR compilation of a given method.
+CompLevel AdvancedThresholdPolicy::loop_event(methodOop method, CompLevel cur_level) {
+  if (cur_level == CompLevel_none) {
+    // If there is a live OSR method that means that we deopted to the interpreter
+    // for the transition.
+    CompLevel osr_level = (CompLevel)method->highest_osr_comp_level();
+    if (osr_level > CompLevel_none) {
+      return osr_level;
+    }
+  }
+  return common(&AdvancedThresholdPolicy::loop_predicate, method, cur_level);
+}
+
+// Update the rate and submit compile
+void AdvancedThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS) {
+  int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
+  update_rate(os::javaTimeMillis(), mh());
+  CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", THREAD);
+}
+
+
+// Handle the invocation event.
+void AdvancedThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh,
+                                                      CompLevel level, TRAPS) {
+  if (should_create_mdo(mh(), level)) {
+    create_mdo(mh, THREAD);
+  }
+  if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) {
+    CompLevel next_level = call_event(mh(), level);
+    if (next_level != level) {
+      compile(mh, InvocationEntryBci, next_level, THREAD);
+    }
+  }
+}
+
+// Handle the back branch event. Notice that we can compile the method
+// with a regular entry from here.
+void AdvancedThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh,
+                                                       int bci, CompLevel level, TRAPS) {
+  if (should_create_mdo(mh(), level)) {
+    create_mdo(mh, THREAD);
+  }
+
+  // If the method is already compiling, quickly bail out.
+  if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, bci)) {
+    // Use loop event as an opportinity to also check there's been
+    // enough calls.
+    CompLevel cur_level = comp_level(mh());
+    CompLevel next_level = call_event(mh(), cur_level);
+    CompLevel next_osr_level = loop_event(mh(), level);
+    if (next_osr_level  == CompLevel_limited_profile) {
+      next_osr_level = CompLevel_full_profile; // OSRs are supposed to be for very hot methods.
+    }
+    next_level = MAX2(next_level,
+                      next_osr_level < CompLevel_full_optimization ? next_osr_level : cur_level);
+    bool is_compiling = false;
+    if (next_level != cur_level) {
+      compile(mh, InvocationEntryBci, next_level, THREAD);
+      is_compiling = true;
+    }
+
+    // Do the OSR version
+    if (!is_compiling && next_osr_level != level) {
+      compile(mh, bci, next_osr_level, THREAD);
+    }
+  }
+}
+
+#endif // TIERED
diff --git a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp
new file mode 100644
index 00000000000..1cab763e034
--- /dev/null
+++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp
@@ -0,0 +1,207 @@
+/*
+* Copyright (c) 2010, 2011 Oracle and/or its affiliates. All rights reserved.
+* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+*/
+
+#ifndef SHARE_VM_RUNTIME_ADVANCEDTHRESHOLDPOLICY_HPP
+#define SHARE_VM_RUNTIME_ADVANCEDTHRESHOLDPOLICY_HPP
+
+#include "runtime/simpleThresholdPolicy.hpp"
+
+#ifdef TIERED
+class CompileTask;
+class CompileQueue;
+
+/*
+ *  The system supports 5 execution levels:
+ *  * level 0 - interpreter
+ *  * level 1 - C1 with full optimization (no profiling)
+ *  * level 2 - C1 with invocation and backedge counters
+ *  * level 3 - C1 with full profiling (level 2 + MDO)
+ *  * level 4 - C2
+ *
+ * Levels 0, 2 and 3 periodically notify the runtime about the current value of the counters
+ * (invocation counters and backedge counters). The frequency of these notifications is
+ * different at each level. These notifications are used by the policy to decide what transition
+ * to make.
+ *
+ * Execution starts at level 0 (interpreter), then the policy can decide either to compile the
+ * method at level 3 or level 2. The decision is based on the following factors:
+ *    1. The length of the C2 queue determines the next level. The observation is that level 2
+ * is generally faster than level 3 by about 30%, therefore we would want to minimize the time
+ * a method spends at level 3. We should only spend the time at level 3 that is necessary to get
+ * adequate profiling. So, if the C2 queue is long enough it is more beneficial to go first to
+ * level 2, because if we transitioned to level 3 we would be stuck there until our C2 compile
+ * request makes its way through the long queue. When the load on C2 recedes we are going to
+ * recompile at level 3 and start gathering profiling information.
+ *    2. The length of C1 queue is used to dynamically adjust the thresholds, so as to introduce
+ * additional filtering if the compiler is overloaded. The rationale is that by the time a
+ * method gets compiled it can become unused, so it doesn't make sense to put too much onto the
+ * queue.
+ *
+ * After profiling is completed at level 3 the transition is made to level 4. Again, the length
+ * of the C2 queue is used as a feedback to adjust the thresholds.
+ *
+ * After the first C1 compile some basic information is determined about the code like the number
+ * of the blocks and the number of the loops. Based on that it can be decided that a method
+ * is trivial and compiling it with C1 will yield the same code. In this case the method is
+ * compiled at level 1 instead of 4.
+ *
+ * We also support profiling at level 0. If C1 is slow enough to produce the level 3 version of
+ * the code and the C2 queue is sufficiently small we can decide to start profiling in the
+ * interpreter (and continue profiling in the compiled code once the level 3 version arrives).
+ * If the profiling at level 0 is fully completed before level 3 version is produced, a level 2
+ * version is compiled instead in order to run faster waiting for a level 4 version.
+ *
+ * Compile queues are implemented as priority queues - for each method in the queue we compute
+ * the event rate (the number of invocation and backedge counter increments per unit of time).
+ * When getting an element off the queue we pick the one with the largest rate. Maintaining the
+ * rate also allows us to remove stale methods (the ones that got on the queue but stopped
+ * being used shortly after that).
+*/
+
+/* Command line options:
+ * - Tier?InvokeNotifyFreqLog and Tier?BackedgeNotifyFreqLog control the frequency of method
+ *   invocation and backedge notifications. Basically every n-th invocation or backedge a mutator thread
+ *   makes a call into the runtime.
+ *
+ * - Tier?CompileThreshold, Tier?BackEdgeThreshold, Tier?MinInvocationThreshold control
+ *   compilation thresholds.
+ *   Level 2 thresholds are not used and are provided for option-compatibility and potential future use.
+ *   Other thresholds work as follows:
+ *
+ *   Transition from interpreter (level 0) to C1 with full profiling (level 3) happens when
+ *   the following predicate is true (X is the level):
+ *
+ *   i > TierXInvocationThreshold * s || (i > TierXMinInvocationThreshold * s  && i + b > TierXCompileThreshold * s),
+ *
+ *   where $i$ is the number of method invocations, $b$ number of backedges and $s$ is the scaling
+ *   coefficient that will be discussed further.
+ *   The intuition is to equalize the time that is spend profiling each method.
+ *   The same predicate is used to control the transition from level 3 to level 4 (C2). It should be
+ *   noted though that the thresholds are relative. Moreover i and b for the 0->3 transition come
+ *   from methodOop and for 3->4 transition they come from MDO (since profiled invocations are
+ *   counted separately).
+ *
+ *   OSR transitions are controlled simply with b > TierXBackEdgeThreshold * s predicates.
+ *
+ * - Tier?LoadFeedback options are used to automatically scale the predicates described above depending
+ *   on the compiler load. The scaling coefficients are computed as follows:
+ *
+ *   s = queue_size_X / (TierXLoadFeedback * compiler_count_X) + 1,
+ *
+ *   where queue_size_X is the current size of the compiler queue of level X, and compiler_count_X
+ *   is the number of level X compiler threads.
+ *
+ *   Basically these parameters describe how many methods should be in the compile queue
+ *   per compiler thread before the scaling coefficient increases by one.
+ *
+ *   This feedback provides the mechanism to automatically control the flow of compilation requests
+ *   depending on the machine speed, mutator load and other external factors.
+ *
+ * - Tier3DelayOn and Tier3DelayOff parameters control another important feedback loop.
+ *   Consider the following observation: a method compiled with full profiling (level 3)
+ *   is about 30% slower than a method at level 2 (just invocation and backedge counters, no MDO).
+ *   Normally, the following transitions will occur: 0->3->4. The problem arises when the C2 queue
+ *   gets congested and the 3->4 transition is delayed. While the method is the C2 queue it continues
+ *   executing at level 3 for much longer time than is required by the predicate and at suboptimal speed.
+ *   The idea is to dynamically change the behavior of the system in such a way that if a substantial
+ *   load on C2 is detected we would first do the 0->2 transition allowing a method to run faster.
+ *   And then when the load decreases to allow 2->3 transitions.
+ *
+ *   Tier3Delay* parameters control this switching mechanism.
+ *   Tier3DelayOn is the number of methods in the C2 queue per compiler thread after which the policy
+ *   no longer does 0->3 transitions but does 0->2 transitions instead.
+ *   Tier3DelayOff switches the original behavior back when the number of methods in the C2 queue
+ *   per compiler thread falls below the specified amount.
+ *   The hysteresis is necessary to avoid jitter.
+ *
+ * - TieredCompileTaskTimeout is the amount of time an idle method can spend in the compile queue.
+ *   Basically, since we use the event rate d(i + b)/dt as a value of priority when selecting a method to
+ *   compile from the compile queue, we also can detect stale methods for which the rate has been
+ *   0 for some time in the same iteration. Stale methods can appear in the queue when an application
+ *   abruptly changes its behavior.
+ *
+ * - TieredStopAtLevel, is used mostly for testing. It allows to bypass the policy logic and stick
+ *   to a given level. For example it's useful to set TieredStopAtLevel = 1 in order to compile everything
+ *   with pure c1.
+ *
+ * - Tier0ProfilingStartPercentage allows the interpreter to start profiling when the inequalities in the
+ *   0->3 predicate are already exceeded by the given percentage but the level 3 version of the
+ *   method is still not ready. We can even go directly from level 0 to 4 if c1 doesn't produce a compiled
+ *   version in time. This reduces the overall transition to level 4 and decreases the startup time.
+ *   Note that this behavior is also guarded by the Tier3Delay mechanism: when the c2 queue is too long
+ *   these is not reason to start profiling prematurely.
+ *
+ * - TieredRateUpdateMinTime and TieredRateUpdateMaxTime are parameters of the rate computation.
+ *   Basically, the rate is not computed more frequently than TieredRateUpdateMinTime and is considered
+ *   to be zero if no events occurred in TieredRateUpdateMaxTime.
+ */
+
+
+class AdvancedThresholdPolicy : public SimpleThresholdPolicy {
+  jlong _start_time;
+
+  // Call and loop predicates determine whether a transition to a higher compilation
+  // level should be performed (pointers to predicate functions are passed to common().
+  // Predicates also take compiler load into account.
+  typedef bool (AdvancedThresholdPolicy::*Predicate)(int i, int b, CompLevel cur_level);
+  bool call_predicate(int i, int b, CompLevel cur_level);
+  bool loop_predicate(int i, int b, CompLevel cur_level);
+  // Common transition function. Given a predicate determines if a method should transition to another level.
+  CompLevel common(Predicate p, methodOop method, CompLevel cur_level);
+  // Transition functions.
+  // call_event determines if a method should be compiled at a different
+  // level with a regular invocation entry.
+  CompLevel call_event(methodOop method, CompLevel cur_level);
+  // loop_event checks if a method should be OSR compiled at a different
+  // level.
+  CompLevel loop_event(methodOop method, CompLevel cur_level);
+  // Has a method been long around?
+  // We don't remove old methods from the compile queue even if they have
+  // very low activity (see select_task()).
+  inline bool is_old(methodOop method);
+  // Was a given method inactive for a given number of milliseconds.
+  // If it is, we would remove it from the queue (see select_task()).
+  inline bool is_stale(jlong t, jlong timeout, methodOop m);
+  // Compute the weight of the method for the compilation scheduling
+  inline double weight(methodOop method);
+  // Apply heuristics and return true if x should be compiled before y
+  inline bool compare_methods(methodOop x, methodOop y);
+  // Compute event rate for a given method. The rate is the number of event (invocations + backedges)
+  // per millisecond.
+  inline void update_rate(jlong t, methodOop m);
+  // Compute threshold scaling coefficient
+  inline double threshold_scale(CompLevel level, int feedback_k);
+  // If a method is old enough and is still in the interpreter we would want to
+  // start profiling without waiting for the compiled method to arrive. This function
+  // determines whether we should do that.
+  inline bool should_create_mdo(methodOop method, CompLevel cur_level);
+  // Create MDO if necessary.
+  void create_mdo(methodHandle mh, TRAPS);
+  // Is method profiled enough?
+  bool is_method_profiled(methodOop method);
+
+protected:
+  void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level);
+
+  void set_start_time(jlong t) { _start_time = t;    }
+  jlong start_time() const     { return _start_time; }
+
+  // Submit a given method for compilation (and update the rate).
+  virtual void submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS);
+  // event() from SimpleThresholdPolicy would call these.
+  virtual void method_invocation_event(methodHandle method, methodHandle inlinee,
+                                       CompLevel level, TRAPS);
+  virtual void method_back_branch_event(methodHandle method, methodHandle inlinee,
+                                        int bci, CompLevel level, TRAPS);
+public:
+  AdvancedThresholdPolicy() : _start_time(0) { }
+  // Select task is called by CompileBroker. We should return a task or NULL.
+  virtual CompileTask* select_task(CompileQueue* compile_queue);
+  virtual void initialize();
+};
+
+#endif // TIERED
+
+#endif // SHARE_VM_RUNTIME_ADVANCEDTHRESHOLDPOLICY_HPP
diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp
index 79899432915..6532c305f76 100644
--- a/hotspot/src/share/vm/runtime/arguments.cpp
+++ b/hotspot/src/share/vm/runtime/arguments.cpp
@@ -242,6 +242,7 @@ static ObsoleteFlag obsolete_jvm_flags[] = {
                            JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
   { "MaxLiveObjectEvacuationRatio",
                            JDK_Version::jdk_update(6,24), JDK_Version::jdk(8) },
+  { "ForceSharedSpaces",   JDK_Version::jdk_update(6,25), JDK_Version::jdk(8) },
   { NULL, JDK_Version(0), JDK_Version(0) }
 };
 
@@ -1003,31 +1004,10 @@ static void no_shared_spaces() {
   }
 }
 
-void Arguments::check_compressed_oops_compat() {
-#ifdef _LP64
-  assert(UseCompressedOops, "Precondition");
-  // Is it on by default or set on ergonomically
-  bool is_on_by_default = FLAG_IS_DEFAULT(UseCompressedOops) || FLAG_IS_ERGO(UseCompressedOops);
-
-  // If dumping an archive or forcing its use, disable compressed oops if possible
-  if (DumpSharedSpaces || RequireSharedSpaces) {
-    if (is_on_by_default) {
-      FLAG_SET_DEFAULT(UseCompressedOops, false);
-      return;
-    } else {
-      vm_exit_during_initialization(
-        "Class Data Sharing is not supported with compressed oops yet", NULL);
-    }
-  } else if (UseSharedSpaces) {
-    // UseSharedSpaces is on by default. With compressed oops, we turn it off.
-    FLAG_SET_DEFAULT(UseSharedSpaces, false);
-  }
-#endif
-}
-
 void Arguments::set_tiered_flags() {
+  // With tiered, set default policy to AdvancedThresholdPolicy, which is 3.
   if (FLAG_IS_DEFAULT(CompilationPolicyChoice)) {
-    FLAG_SET_DEFAULT(CompilationPolicyChoice, 2);
+    FLAG_SET_DEFAULT(CompilationPolicyChoice, 3);
   }
   if (CompilationPolicyChoice < 2) {
     vm_exit_during_initialization(
@@ -1122,40 +1102,28 @@ void Arguments::set_cms_and_parnew_gc_flags() {
     set_parnew_gc_flags();
   }
 
-  // Now make adjustments for CMS
-  size_t young_gen_per_worker;
-  intx new_ratio;
-  size_t min_new_default;
-  intx tenuring_default;
-  if (CMSUseOldDefaults) {  // old defaults: "old" as of 6.0
-    if FLAG_IS_DEFAULT(CMSYoungGenPerWorker) {
-      FLAG_SET_ERGO(intx, CMSYoungGenPerWorker, 4*M);
-    }
-    young_gen_per_worker = 4*M;
-    new_ratio = (intx)15;
-    min_new_default = 4*M;
-    tenuring_default = (intx)0;
-  } else { // new defaults: "new" as of 6.0
-    young_gen_per_worker = CMSYoungGenPerWorker;
-    new_ratio = (intx)7;
-    min_new_default = 16*M;
-    tenuring_default = (intx)4;
-  }
+  // MaxHeapSize is aligned down in collectorPolicy
+  size_t max_heap = align_size_down(MaxHeapSize,
+                                    CardTableRS::ct_max_alignment_constraint());
 
-  // Preferred young gen size for "short" pauses
+  // Now make adjustments for CMS
+  intx   tenuring_default = (intx)6;
+  size_t young_gen_per_worker = CMSYoungGenPerWorker;
+
+  // Preferred young gen size for "short" pauses:
+  // upper bound depends on # of threads and NewRatio.
   const uintx parallel_gc_threads =
     (ParallelGCThreads == 0 ? 1 : ParallelGCThreads);
   const size_t preferred_max_new_size_unaligned =
-    ScaleForWordSize(young_gen_per_worker * parallel_gc_threads);
-  const size_t preferred_max_new_size =
+    MIN2(max_heap/(NewRatio+1), ScaleForWordSize(young_gen_per_worker * parallel_gc_threads));
+  size_t preferred_max_new_size =
     align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
 
   // Unless explicitly requested otherwise, size young gen
-  // for "short" pauses ~ 4M*ParallelGCThreads
+  // for "short" pauses ~ CMSYoungGenPerWorker*ParallelGCThreads
 
   // If either MaxNewSize or NewRatio is set on the command line,
   // assume the user is trying to set the size of the young gen.
-
   if (FLAG_IS_DEFAULT(MaxNewSize) && FLAG_IS_DEFAULT(NewRatio)) {
 
     // Set MaxNewSize to our calculated preferred_max_new_size unless
@@ -1168,49 +1136,13 @@ void Arguments::set_cms_and_parnew_gc_flags() {
     }
     if (PrintGCDetails && Verbose) {
       // Too early to use gclog_or_tty
-      tty->print_cr("Ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
+      tty->print_cr("CMS ergo set MaxNewSize: " SIZE_FORMAT, MaxNewSize);
     }
 
-    // Unless explicitly requested otherwise, prefer a large
-    // Old to Young gen size so as to shift the collection load
-    // to the old generation concurrent collector
-
-    // If this is only guarded by FLAG_IS_DEFAULT(NewRatio)
-    // then NewSize and OldSize may be calculated.  That would
-    // generally lead to some differences with ParNewGC for which
-    // there was no obvious reason.  Also limit to the case where
-    // MaxNewSize has not been set.
-
-    FLAG_SET_ERGO(intx, NewRatio, MAX2(NewRatio, new_ratio));
-
     // Code along this path potentially sets NewSize and OldSize
 
-    // Calculate the desired minimum size of the young gen but if
-    // NewSize has been set on the command line, use it here since
-    // it should be the final value.
-    size_t min_new;
-    if (FLAG_IS_DEFAULT(NewSize)) {
-      min_new = align_size_up(ScaleForWordSize(min_new_default),
-                              os::vm_page_size());
-    } else {
-      min_new = NewSize;
-    }
-    size_t prev_initial_size = InitialHeapSize;
-    if (prev_initial_size != 0 && prev_initial_size < min_new + OldSize) {
-      FLAG_SET_ERGO(uintx, InitialHeapSize, min_new + OldSize);
-      // Currently minimum size and the initial heap sizes are the same.
-      set_min_heap_size(InitialHeapSize);
-      if (PrintGCDetails && Verbose) {
-        warning("Initial heap size increased to " SIZE_FORMAT " M from "
-                SIZE_FORMAT " M; use -XX:NewSize=... for finer control.",
-                InitialHeapSize/M, prev_initial_size/M);
-      }
-    }
-
-    // MaxHeapSize is aligned down in collectorPolicy
-    size_t max_heap =
-      align_size_down(MaxHeapSize,
-                      CardTableRS::ct_max_alignment_constraint());
+    assert(max_heap >= InitialHeapSize, "Error");
+    assert(max_heap >= NewSize, "Error");
 
     if (PrintGCDetails && Verbose) {
       // Too early to use gclog_or_tty
@@ -1219,7 +1151,11 @@ void Arguments::set_cms_and_parnew_gc_flags() {
            " max_heap: " SIZE_FORMAT,
            min_heap_size(), InitialHeapSize, max_heap);
     }
-    if (max_heap > min_new) {
+    size_t min_new = preferred_max_new_size;
+    if (FLAG_IS_CMDLINE(NewSize)) {
+      min_new = NewSize;
+    }
+    if (max_heap > min_new && min_heap_size() > min_new) {
       // Unless explicitly requested otherwise, make young gen
       // at least min_new, and at most preferred_max_new_size.
       if (FLAG_IS_DEFAULT(NewSize)) {
@@ -1227,18 +1163,17 @@ void Arguments::set_cms_and_parnew_gc_flags() {
         FLAG_SET_ERGO(uintx, NewSize, MIN2(preferred_max_new_size, NewSize));
         if (PrintGCDetails && Verbose) {
           // Too early to use gclog_or_tty
-          tty->print_cr("Ergo set NewSize: " SIZE_FORMAT, NewSize);
+          tty->print_cr("CMS ergo set NewSize: " SIZE_FORMAT, NewSize);
         }
       }
       // Unless explicitly requested otherwise, size old gen
-      // so that it's at least 3X of NewSize to begin with;
-      // later NewRatio will decide how it grows; see above.
+      // so it's NewRatio x of NewSize.
       if (FLAG_IS_DEFAULT(OldSize)) {
         if (max_heap > NewSize) {
-          FLAG_SET_ERGO(uintx, OldSize, MIN2(3*NewSize, max_heap - NewSize));
+          FLAG_SET_ERGO(uintx, OldSize, MIN2(NewRatio*NewSize, max_heap - NewSize));
           if (PrintGCDetails && Verbose) {
             // Too early to use gclog_or_tty
-            tty->print_cr("Ergo set OldSize: " SIZE_FORMAT, OldSize);
+            tty->print_cr("CMS ergo set OldSize: " SIZE_FORMAT, OldSize);
           }
         }
       }
@@ -1382,7 +1317,7 @@ bool Arguments::should_auto_select_low_pause_collector() {
 void Arguments::set_ergonomics_flags() {
   // Parallel GC is not compatible with sharing. If one specifies
   // that they want sharing explicitly, do not set ergonomics flags.
-  if (DumpSharedSpaces || ForceSharedSpaces) {
+  if (DumpSharedSpaces || RequireSharedSpaces) {
     return;
   }
 
@@ -1689,13 +1624,13 @@ bool Arguments::verify_interval(uintx val, uintx min,
 }
 
 bool Arguments::verify_min_value(intx val, intx min, const char* name) {
-  // Returns true if given value is greater than specified min threshold
+  // Returns true if given value is at least specified min threshold
   // false, otherwise.
   if (val >= min ) {
       return true;
   }
   jio_fprintf(defaultStream::error_stream(),
-              "%s of " INTX_FORMAT " is invalid; must be greater than " INTX_FORMAT "\n",
+              "%s of " INTX_FORMAT " is invalid; must be at least " INTX_FORMAT "\n",
               name, val, min);
   return false;
 }
@@ -1845,33 +1780,6 @@ bool Arguments::check_vm_args_consistency() {
 
   status = status && verify_percentage(GCHeapFreeLimit, "GCHeapFreeLimit");
 
-  // Check whether user-specified sharing option conflicts with GC or page size.
-  // Both sharing and large pages are enabled by default on some platforms;
-  // large pages override sharing only if explicitly set on the command line.
-  const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode ||
-          UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC ||
-          UseLargePages && FLAG_IS_CMDLINE(UseLargePages);
-  if (cannot_share) {
-    // Either force sharing on by forcing the other options off, or
-    // force sharing off.
-    if (DumpSharedSpaces || ForceSharedSpaces) {
-      jio_fprintf(defaultStream::error_stream(),
-                  "Using Serial GC and default page size because of %s\n",
-                  ForceSharedSpaces ? "-Xshare:on" : "-Xshare:dump");
-      force_serial_gc();
-      FLAG_SET_DEFAULT(UseLargePages, false);
-    } else {
-      if (UseSharedSpaces && Verbose) {
-        jio_fprintf(defaultStream::error_stream(),
-                    "Turning off use of shared archive because of "
-                    "choice of garbage collector or large pages\n");
-      }
-      no_shared_spaces();
-    }
-  } else if (UseLargePages && (UseSharedSpaces || DumpSharedSpaces)) {
-    FLAG_SET_DEFAULT(UseLargePages, false);
-  }
-
   status = status && check_gc_consistency();
   status = status && check_stack_pages();
 
@@ -1949,6 +1857,8 @@ bool Arguments::check_vm_args_consistency() {
     status = false;
   }
 
+  status = status && verify_min_value(ParGCArrayScanChunk, 1, "ParGCArrayScanChunk");
+
 #ifndef SERIALGC
   if (UseG1GC) {
     status = status && verify_percentage(InitiatingHeapOccupancyPercent,
@@ -2412,9 +2322,6 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
     } else if (match_option(option, "-Xshare:on", &tail)) {
       FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
       FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true);
-#ifdef TIERED
-      FLAG_SET_CMDLINE(bool, ForceSharedSpaces, true);
-#endif // TIERED
     // -Xshare:auto
     } else if (match_option(option, "-Xshare:auto", &tail)) {
       FLAG_SET_CMDLINE(bool, UseSharedSpaces, true);
@@ -2911,6 +2818,52 @@ jint Arguments::parse_options_environment_variable(const char* name, SysClassPat
   return JNI_OK;
 }
 
+void Arguments::set_shared_spaces_flags() {
+  const bool must_share = DumpSharedSpaces || RequireSharedSpaces;
+  const bool might_share = must_share || UseSharedSpaces;
+
+  // The string table is part of the shared archive so the size must match.
+  if (!FLAG_IS_DEFAULT(StringTableSize)) {
+    // Disable sharing.
+    if (must_share) {
+      warning("disabling shared archive %s because of non-default "
+              "StringTableSize", DumpSharedSpaces ? "creation" : "use");
+    }
+    if (might_share) {
+      FLAG_SET_DEFAULT(DumpSharedSpaces, false);
+      FLAG_SET_DEFAULT(RequireSharedSpaces, false);
+      FLAG_SET_DEFAULT(UseSharedSpaces, false);
+    }
+    return;
+  }
+
+  // Check whether class data sharing settings conflict with GC, compressed oops
+  // or page size, and fix them up.  Explicit sharing options override other
+  // settings.
+  const bool cannot_share = UseConcMarkSweepGC || CMSIncrementalMode ||
+    UseG1GC || UseParNewGC || UseParallelGC || UseParallelOldGC ||
+    UseCompressedOops || UseLargePages && FLAG_IS_CMDLINE(UseLargePages);
+  if (cannot_share) {
+    if (must_share) {
+        warning("selecting serial gc and disabling large pages %s"
+                "because of %s", "" LP64_ONLY("and compressed oops "),
+                DumpSharedSpaces ? "-Xshare:dump" : "-Xshare:on");
+        force_serial_gc();
+        FLAG_SET_CMDLINE(bool, UseLargePages, false);
+        LP64_ONLY(FLAG_SET_CMDLINE(bool, UseCompressedOops, false));
+    } else {
+      if (UseSharedSpaces && Verbose) {
+        warning("turning off use of shared archive because of "
+                "choice of garbage collector or large pages");
+      }
+      no_shared_spaces();
+    }
+  } else if (UseLargePages && might_share) {
+    // Disable large pages to allow shared spaces.  This is sub-optimal, since
+    // there may not even be a shared archive to use.
+    FLAG_SET_DEFAULT(UseLargePages, false);
+  }
+}
 
 // Parse entry point called from JNI_CreateJavaVM
 
@@ -3039,6 +2992,12 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
     }
     ScavengeRootsInCode = 1;
   }
+  if (!JavaObjectsInPerm && ScavengeRootsInCode == 0) {
+    if (!FLAG_IS_DEFAULT(ScavengeRootsInCode)) {
+      warning("forcing ScavengeRootsInCode non-zero because JavaObjectsInPerm is false");
+    }
+    ScavengeRootsInCode = 1;
+  }
 
   if (PrintGCDetails) {
     // Turn on -verbose:gc options as well
@@ -3058,9 +3017,7 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
   // Set flags based on ergonomics.
   set_ergonomics_flags();
 
-  if (UseCompressedOops) {
-    check_compressed_oops_compat();
-  }
+  set_shared_spaces_flags();
 
   // Check the GC selections again.
   if (!check_gc_consistency()) {
@@ -3078,22 +3035,17 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
   }
 
 #ifndef KERNEL
-  if (UseConcMarkSweepGC) {
-    // Set flags for CMS and ParNew.  Check UseConcMarkSweep first
-    // to ensure that when both UseConcMarkSweepGC and UseParNewGC
-    // are true, we don't call set_parnew_gc_flags() as well.
+  // Set heap size based on available physical memory
+  set_heap_size();
+  // Set per-collector flags
+  if (UseParallelGC || UseParallelOldGC) {
+    set_parallel_gc_flags();
+  } else if (UseConcMarkSweepGC) { // should be done before ParNew check below
     set_cms_and_parnew_gc_flags();
-  } else {
-    // Set heap size based on available physical memory
-    set_heap_size();
-    // Set per-collector flags
-    if (UseParallelGC || UseParallelOldGC) {
-      set_parallel_gc_flags();
-    } else if (UseParNewGC) {
-      set_parnew_gc_flags();
-    } else if (UseG1GC) {
-      set_g1_gc_flags();
-    }
+  } else if (UseParNewGC) {  // skipped if CMS is set above
+    set_parnew_gc_flags();
+  } else if (UseG1GC) {
+    set_g1_gc_flags();
   }
 #endif // KERNEL
 
@@ -3110,7 +3062,11 @@ jint Arguments::parse(const JavaVMInitArgs* args) {
   // Turn off biased locking for locking debug mode flags,
   // which are subtlely different from each other but neither works with
   // biased locking.
-  if (!UseFastLocking || UseHeavyMonitors) {
+  if (UseHeavyMonitors
+#ifdef COMPILER1
+      || !UseFastLocking
+#endif // COMPILER1
+    ) {
     if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) {
       // flag set to true on command line; warn the user that they
       // can't enable biased locking here
diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp
index fec2bf0f665..076b4861db1 100644
--- a/hotspot/src/share/vm/runtime/arguments.hpp
+++ b/hotspot/src/share/vm/runtime/arguments.hpp
@@ -301,8 +301,6 @@ class Arguments : AllStatic {
 
   // Tiered
   static void set_tiered_flags();
-  // Check compressed oops compatibility with other flags
-  static void check_compressed_oops_compat();
   // CMS/ParNew garbage collectors
   static void set_parnew_gc_flags();
   static void set_cms_and_parnew_gc_flags();
@@ -312,6 +310,7 @@ class Arguments : AllStatic {
   static void set_g1_gc_flags();
   // GC ergonomics
   static void set_ergonomics_flags();
+  static void set_shared_spaces_flags();
   // Setup heap size
   static void set_heap_size();
   // Based on automatic selection criteria, should the
diff --git a/hotspot/src/share/vm/runtime/compilationPolicy.cpp b/hotspot/src/share/vm/runtime/compilationPolicy.cpp
index 9d2ed651004..e5f1bf64b67 100644
--- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp
+++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 #include "oops/methodOop.hpp"
 #include "oops/oop.inline.hpp"
 #include "prims/nativeLookup.hpp"
+#include "runtime/advancedThresholdPolicy.hpp"
 #include "runtime/compilationPolicy.hpp"
 #include "runtime/frame.hpp"
 #include "runtime/handles.inline.hpp"
@@ -70,10 +71,17 @@ void compilationPolicy_init() {
     CompilationPolicy::set_policy(new SimpleThresholdPolicy());
 #else
     Unimplemented();
+#endif
+    break;
+  case 3:
+#ifdef TIERED
+    CompilationPolicy::set_policy(new AdvancedThresholdPolicy());
+#else
+    Unimplemented();
 #endif
     break;
   default:
-    fatal("CompilationPolicyChoice must be in the range: [0-2]");
+    fatal("CompilationPolicyChoice must be in the range: [0-3]");
   }
   CompilationPolicy::policy()->initialize();
 }
diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp
index 36fd0be4bd3..3e03486d3ea 100644
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp
@@ -101,9 +101,9 @@ Deoptimization::UnrollBlock::UnrollBlock(int  size_of_deoptimized_frame,
   _frame_pcs                 = frame_pcs;
   _register_block            = NEW_C_HEAP_ARRAY(intptr_t, RegisterMap::reg_count * 2);
   _return_type               = return_type;
+  _initial_fp                = 0;
   // PD (x86 only)
   _counter_temp              = 0;
-  _initial_fp                = 0;
   _unpack_kind               = 0;
   _sender_sp_temp            = 0;
 
@@ -459,18 +459,9 @@ Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread
                                       frame_sizes,
                                       frame_pcs,
                                       return_type);
-#if defined(IA32) || defined(AMD64)
-  // We need a way to pass fp to the unpacking code so the skeletal frames
-  // come out correct. This is only needed for x86 because of c2 using ebp
-  // as an allocatable register. So this update is useless (and harmless)
-  // on the other platforms. It would be nice to do this in a different
-  // way but even the old style deoptimization had a problem with deriving
-  // this value. NEEDS_CLEANUP
-  // Note: now that c1 is using c2's deopt blob we must do this on all
-  // x86 based platforms
-  intptr_t** fp_addr = (intptr_t**) (((address)info) + info->initial_fp_offset_in_bytes());
-  *fp_addr = array->sender().fp(); // was adapter_caller
-#endif /* IA32 || AMD64 */
+  // On some platforms, we need a way to pass fp to the unpacking code
+  // so the skeletal frames come out correct.
+  info->set_initial_fp((intptr_t) array->sender().fp());
 
   if (array->frames() > 1) {
     if (VerifyStack && TraceDeoptimization) {
diff --git a/hotspot/src/share/vm/runtime/deoptimization.hpp b/hotspot/src/share/vm/runtime/deoptimization.hpp
index e560fde5d81..c62616fcb74 100644
--- a/hotspot/src/share/vm/runtime/deoptimization.hpp
+++ b/hotspot/src/share/vm/runtime/deoptimization.hpp
@@ -136,12 +136,12 @@ class Deoptimization : AllStatic {
     address*  _frame_pcs;                 // Array of frame pc's, in bytes, for unrolling the stack
     intptr_t* _register_block;            // Block for storing callee-saved registers.
     BasicType _return_type;               // Tells if we have to restore double or long return value
+    intptr_t  _initial_fp;                // FP of the sender frame
     // The following fields are used as temps during the unpacking phase
     // (which is tight on registers, especially on x86). They really ought
     // to be PD variables but that involves moving this class into its own
     // file to use the pd include mechanism. Maybe in a later cleanup ...
     intptr_t  _counter_temp;              // SHOULD BE PD VARIABLE (x86 frame count temp)
-    intptr_t  _initial_fp;                // SHOULD BE PD VARIABLE (x86/c2 initial ebp)
     intptr_t  _unpack_kind;               // SHOULD BE PD VARIABLE (x86 unpack kind)
     intptr_t  _sender_sp_temp;            // SHOULD BE PD VARIABLE (x86 sender_sp)
    public:
@@ -165,6 +165,8 @@ class Deoptimization : AllStatic {
     // Returns the total size of frames
     int size_of_frames() const;
 
+    void set_initial_fp(intptr_t fp) { _initial_fp = fp; }
+
     // Accessors used by the code generator for the unpack stub.
     static int size_of_deoptimized_frame_offset_in_bytes() { return offset_of(UnrollBlock, _size_of_deoptimized_frame); }
     static int caller_adjustment_offset_in_bytes()         { return offset_of(UnrollBlock, _caller_adjustment);         }
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index 02dbf79bd5b..cd320ba6fc8 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -851,7 +851,7 @@ class CommandLineFlags {
   diagnostic(bool, TraceNMethodInstalls, false,                             \
              "Trace nmethod intallation")                                   \
                                                                             \
-  diagnostic(intx, ScavengeRootsInCode, 0,                                  \
+  diagnostic(intx, ScavengeRootsInCode, 1,                                  \
              "0: do not allow scavengable oops in the code cache; "         \
              "1: allow scavenging from the code cache; "                    \
              "2: emit as many constants as the compiler can see")           \
@@ -1221,6 +1221,11 @@ class CommandLineFlags {
           "Decay time (in milliseconds) to re-enable bulk rebiasing of a "  \
           "type after previous bulk rebias")                                \
                                                                             \
+  develop(bool, JavaObjectsInPerm, false,                                   \
+          "controls whether Classes and interned Strings are allocated"     \
+          "in perm.  This purely intended to allow debugging issues"        \
+          "in production.")                                                 \
+                                                                            \
   /* tracing */                                                             \
                                                                             \
   notproduct(bool, TraceRuntimeCalls, false,                                \
@@ -1540,12 +1545,8 @@ class CommandLineFlags {
   product(bool, AlwaysPreTouch, false,                                      \
           "It forces all freshly committed pages to be pre-touched.")       \
                                                                             \
-  product(bool, CMSUseOldDefaults, false,                                   \
-          "A flag temporarily introduced to allow reverting to some "       \
-          "older default settings; older as of 6.0")                        \
-                                                                            \
-  product(intx, CMSYoungGenPerWorker, 16*M,                                 \
-          "The amount of young gen chosen by default per GC worker "        \
+  product_pd(intx, CMSYoungGenPerWorker,                                    \
+          "The maximum size of young gen chosen by default per GC worker "  \
           "thread available")                                               \
                                                                             \
   product(bool, GCOverheadReporting, false,                                 \
@@ -3653,9 +3654,6 @@ class CommandLineFlags {
   product(bool, RequireSharedSpaces, false,                                 \
           "Require shared spaces in the permanent generation")              \
                                                                             \
-  product(bool, ForceSharedSpaces, false,                                   \
-          "Require shared spaces in the permanent generation")              \
-                                                                            \
   product(bool, DumpSharedSpaces, false,                                    \
            "Special mode: JVM reads a class list, loads classes, builds "   \
             "shared spaces, and dumps the shared spaces to a file to be "   \
@@ -3719,6 +3717,13 @@ class CommandLineFlags {
   experimental(bool, AllowTransitionalJSR292, true,                         \
           "recognize pre-PFD formats of invokedynamic")                     \
                                                                             \
+  experimental(bool, PreferTransitionalJSR292, false,                       \
+          "prefer pre-PFD APIs on boot class path, if they exist")          \
+                                                                            \
+  experimental(bool, AllowInvokeForInvokeGeneric, false,                    \
+          "accept MethodHandle.invoke and MethodHandle.invokeGeneric "      \
+          "as equivalent methods")                                          \
+                                                                            \
   develop(bool, TraceInvokeDynamic, false,                                  \
           "trace internal invoke dynamic operations")                       \
                                                                             \
@@ -3751,6 +3756,9 @@ class CommandLineFlags {
   diagnostic(bool, PrintDTraceDOF, false,                                   \
              "Print the DTrace DOF passed to the system for JSDT probes")   \
                                                                             \
+  product(uintx, StringTableSize, 1009,                                     \
+          "Number of buckets in the interned String table")                 \
+                                                                            \
   product(bool, UseVMInterruptibleIO, false,                                \
           "(Unstable, Solaris-specific) Thread interrupt before or with "   \
           "EINTR for I/O operations results in OS_INTRPT. The default value"\
diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp
index f13b5e28812..cf949071bc9 100644
--- a/hotspot/src/share/vm/runtime/os.cpp
+++ b/hotspot/src/share/vm/runtime/os.cpp
@@ -633,10 +633,10 @@ void  os::free(void *memblock) {
       *q = (u_char)freeBlockPad;
     }
     if (PrintMalloc && tty != NULL)
-      fprintf(stderr, "os::free " SIZE_FORMAT " bytes --> " PTR_FORMAT "\n", size, memblock);
+      fprintf(stderr, "os::free " SIZE_FORMAT " bytes --> " PTR_FORMAT "\n", size, (uintptr_t)memblock);
   } else if (PrintMalloc && tty != NULL) {
     // tty->print_cr("os::free %p", memblock);
-    fprintf(stderr, "os::free " PTR_FORMAT "\n", memblock);
+    fprintf(stderr, "os::free " PTR_FORMAT "\n", (uintptr_t)memblock);
   }
 #endif
   ::free((char*)memblock - space_before);
@@ -1079,11 +1079,6 @@ bool os::set_boot_path(char fileSep, char pathSep) {
         "%/lib/jsse.jar:"
         "%/lib/jce.jar:"
         "%/lib/charsets.jar:"
-
-        // ## TEMPORARY hack to keep the legacy launcher working when
-        // ## only the boot module is installed (cf. j.l.ClassLoader)
-        "%/lib/modules/jdk.boot.jar:"
-
         "%/classes";
     char* sysclasspath = format_boot_path(classpath_format, home, home_len, fileSep, pathSep);
     if (sysclasspath == NULL) return false;
diff --git a/hotspot/src/share/vm/runtime/osThread.hpp b/hotspot/src/share/vm/runtime/osThread.hpp
index 2cae9cd0211..5df645ad8cf 100644
--- a/hotspot/src/share/vm/runtime/osThread.hpp
+++ b/hotspot/src/share/vm/runtime/osThread.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,7 +65,7 @@ class OSThread: public CHeapObj {
   OSThreadStartFunc _start_proc;  // Thread start routine
   void* _start_parm;              // Thread start routine parameter
   volatile ThreadState _state;    // Thread state *hint*
-  jint _interrupted;              // Thread.isInterrupted state
+  volatile jint _interrupted;     // Thread.isInterrupted state
 
   // Note:  _interrupted must be jint, so that Java intrinsics can access it.
   // The value stored there must be either 0 or 1.  It must be possible
@@ -89,7 +89,7 @@ class OSThread: public CHeapObj {
   void* start_parm() const                          { return _start_parm; }
   void set_start_parm(void* start_parm)             { _start_parm = start_parm; }
 
-  bool interrupted() const                          { return _interrupted != 0; }
+  volatile bool interrupted() const                 { return _interrupted != 0; }
   void set_interrupted(bool z)                      { _interrupted = z ? 1 : 0; }
 
   // Printing
diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp
index 412910e8baa..e25c1afb050 100644
--- a/hotspot/src/share/vm/runtime/reflection.cpp
+++ b/hotspot/src/share/vm/runtime/reflection.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -649,7 +649,7 @@ oop get_mirror_from_signature(methodHandle method, SignatureStream* ss, TRAPS) {
       if (TraceClassResolution) {
         trace_class_resolution(k);
       }
-      return k->klass_part()->java_mirror();
+      return k->java_mirror();
   };
 }
 
diff --git a/hotspot/src/share/vm/runtime/serviceThread.cpp b/hotspot/src/share/vm/runtime/serviceThread.cpp
index 600398d1c12..e5c70f7b70c 100644
--- a/hotspot/src/share/vm/runtime/serviceThread.cpp
+++ b/hotspot/src/share/vm/runtime/serviceThread.cpp
@@ -70,11 +70,10 @@ void ServiceThread::initialize() {
     java_lang_Thread::set_priority(thread_oop(), NearMaxPriority);
     java_lang_Thread::set_daemon(thread_oop());
     thread->set_threadObj(thread_oop());
+    _instance = thread;
 
     Threads::add(thread);
     Thread::start(thread);
-
-    _instance = thread;
   }
 }
 
diff --git a/hotspot/src/share/vm/runtime/sweeper.cpp b/hotspot/src/share/vm/runtime/sweeper.cpp
index 94ee13145bf..c845b1761b6 100644
--- a/hotspot/src/share/vm/runtime/sweeper.cpp
+++ b/hotspot/src/share/vm/runtime/sweeper.cpp
@@ -426,9 +426,7 @@ void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) {
       tty->vprint(format, ap);
       va_end(ap);
     }
-    tty->print_cr(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
-                  " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
-                  CodeCache::nof_blobs(), CodeCache::nof_nmethods(), CodeCache::nof_adapters(), CodeCache::unallocated_capacity());
+    CodeCache::log_state(tty); tty->cr();
   }
 
   if (LogCompilation && (xtty != NULL)) {
@@ -440,9 +438,7 @@ void NMethodSweeper::log_sweep(const char* msg, const char* format, ...) {
       xtty->vprint(format, ap);
       va_end(ap);
     }
-    xtty->print(" total_blobs='" UINT32_FORMAT "' nmethods='" UINT32_FORMAT "'"
-                " adapters='" UINT32_FORMAT "' free_code_cache='" SIZE_FORMAT "'",
-                CodeCache::nof_blobs(), CodeCache::nof_nmethods(), CodeCache::nof_adapters(), CodeCache::unallocated_capacity());
+    CodeCache::log_state(xtty);
     xtty->stamp();
     xtty->end_elem();
   }
diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp
index c198e86b0a8..817a80170b4 100644
--- a/hotspot/src/share/vm/runtime/thread.cpp
+++ b/hotspot/src/share/vm/runtime/thread.cpp
@@ -3166,7 +3166,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
         fieldDescriptor fd;
         // Possible we might not find this field; if so, don't break
         if (ik->find_local_field(vmSymbols::frontCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
-          k()->bool_field_put(fd.offset(), true);
+          k()->java_mirror()->bool_field_put(fd.offset(), true);
         }
       }
 
@@ -3182,7 +3182,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
           fieldDescriptor fd;
           // Possible we might not find this field: if so, silently don't break
           if (ik->find_local_field(vmSymbols::stringCacheEnabled_name(), vmSymbols::bool_signature(), &fd)) {
-            k()->bool_field_put(fd.offset(), true);
+            k()->java_mirror()->bool_field_put(fd.offset(), true);
           }
         }
       }
diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp
index 8319877e6ac..2d5cd6dcf66 100644
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp
@@ -269,7 +269,7 @@ static inline uint64_t cast_uint64_t(size_t x)
   nonstatic_field(instanceKlass,               _inner_classes,                                typeArrayOop)                          \
   nonstatic_field(instanceKlass,               _nonstatic_field_size,                         int)                                   \
   nonstatic_field(instanceKlass,               _static_field_size,                            int)                                   \
-  nonstatic_field(instanceKlass,               _static_oop_field_size,                        int)                                   \
+  nonstatic_field(instanceKlass,               _static_oop_field_count,                       int)                                   \
   nonstatic_field(instanceKlass,               _nonstatic_oop_map_size,                       int)                                   \
   nonstatic_field(instanceKlass,               _is_marked_dependent,                          bool)                                  \
   nonstatic_field(instanceKlass,               _minor_version,                                u2)                                    \
@@ -840,7 +840,7 @@ static inline uint64_t cast_uint64_t(size_t x)
   /* OSThread */                                                                                                                     \
   /************/                                                                                                                     \
                                                                                                                                      \
-  nonstatic_field(OSThread,                    _interrupted,                                  jint)                                  \
+  volatile_nonstatic_field(OSThread,           _interrupted,                                  jint)                                  \
                                                                                                                                      \
   /************************/                                                                                                         \
   /* OopMap and OopMapSet */                                                                                                         \
@@ -945,6 +945,15 @@ static inline uint64_t cast_uint64_t(size_t x)
   static_field(Arguments,                      _num_jvm_args,                                 int)                                   \
   static_field(Arguments,                      _java_command,                                 char*)                                 \
                                                                                                                                      \
+  /*********************************/                                                                                                \
+  /* java_lang_Class fields        */                                                                                                \
+  /*********************************/                                                                                                \
+                                                                                                                                     \
+  static_field(java_lang_Class,                klass_offset,                                  int)                                   \
+  static_field(java_lang_Class,                resolved_constructor_offset,                   int)                                   \
+  static_field(java_lang_Class,                array_klass_offset,                            int)                                   \
+  static_field(java_lang_Class,                oop_size_offset,                               int)                                   \
+  static_field(java_lang_Class,                static_oop_field_count_offset,                 int)                                   \
                                                                                                                                      \
   /************************/                                                                                                         \
   /* Miscellaneous fields */                                                                                                         \
@@ -1414,6 +1423,7 @@ static inline uint64_t cast_uint64_t(size_t x)
   declare_toplevel_type(intptr_t*)                                        \
    declare_unsigned_integer_type(InvocationCounter) /* FIXME: wrong type (not integer) */ \
   declare_toplevel_type(JavaThread*)                                      \
+  declare_toplevel_type(java_lang_Class)                                  \
   declare_toplevel_type(jbyte*)                                           \
   declare_toplevel_type(jbyte**)                                          \
   declare_toplevel_type(jint*)                                            \
@@ -1543,12 +1553,6 @@ static inline uint64_t cast_uint64_t(size_t x)
                                                                           \
   declare_constant(SymbolTable::symbol_table_size)                        \
                                                                           \
-  /***************/                                                       \
-  /* StringTable */                                                       \
-  /***************/                                                       \
-                                                                          \
-  declare_constant(StringTable::string_table_size)                        \
-                                                                          \
   /********************/                                                  \
   /* SystemDictionary */                                                  \
   /********************/                                                  \
@@ -1700,15 +1704,6 @@ static inline uint64_t cast_uint64_t(size_t x)
                                                                           \
   declare_constant(ConstantPoolCacheEntry::tosBits)                       \
                                                                           \
-  /*********************************/                                     \
-  /* java_lang_Class field offsets */                                     \
-  /*********************************/                                     \
-                                                                          \
-  declare_constant(java_lang_Class::hc_klass_offset)                      \
-  declare_constant(java_lang_Class::hc_array_klass_offset)                \
-  declare_constant(java_lang_Class::hc_resolved_constructor_offset)       \
-  declare_constant(java_lang_Class::hc_number_of_fake_oop_fields)         \
-                                                                          \
   /***************************************/                               \
   /* java_lang_Thread::ThreadStatus enum */                               \
   /***************************************/                               \
diff --git a/hotspot/src/share/vm/services/heapDumper.cpp b/hotspot/src/share/vm/services/heapDumper.cpp
index 62c4756a040..0252ddfff7c 100644
--- a/hotspot/src/share/vm/services/heapDumper.cpp
+++ b/hotspot/src/share/vm/services/heapDumper.cpp
@@ -832,7 +832,7 @@ void DumperSupport::dump_static_fields(DumpWriter* writer, klassOop k) {
 
       // value
       int offset = fld.offset();
-      address addr = (address)k + offset;
+      address addr = (address)ikh->java_mirror() + offset;
 
       dump_field_value(writer, sig->byte_at(0), addr);
     }
diff --git a/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp b/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp
index 5896d36394b..e4b3347c5c9 100644
--- a/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp
+++ b/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp
@@ -101,7 +101,7 @@ void SharkNativeWrapper::initialize(const char *name) {
     builder()->CreateStore(
       builder()->CreateInlineOop(
         JNIHandles::make_local(
-          target()->method_holder()->klass_part()->java_mirror())),
+          target()->method_holder()->java_mirror())),
       oop_tmp_slot());
 
     param_types.push_back(box_type);
diff --git a/hotspot/src/share/vm/utilities/debug.hpp b/hotspot/src/share/vm/utilities/debug.hpp
index a4f16060e1d..75a9a27bd6b 100644
--- a/hotspot/src/share/vm/utilities/debug.hpp
+++ b/hotspot/src/share/vm/utilities/debug.hpp
@@ -25,6 +25,7 @@
 #ifndef SHARE_VM_UTILITIES_DEBUG_HPP
 #define SHARE_VM_UTILITIES_DEBUG_HPP
 
+#include "prims/jvm.h"
 #include "utilities/globalDefinitions.hpp"
 
 #include <stdarg.h>
@@ -48,7 +49,7 @@ template <size_t bufsz>
 FormatBuffer<bufsz>::FormatBuffer(const char * format, ...) {
   va_list argp;
   va_start(argp, format);
-  vsnprintf(_buf, bufsz, format, argp);
+  jio_vsnprintf(_buf, bufsz, format, argp);
   va_end(argp);
 }
 
@@ -61,7 +62,7 @@ void FormatBuffer<bufsz>::append(const char* format, ...) {
 
   va_list argp;
   va_start(argp, format);
-  vsnprintf(buf_end, bufsz - len, format, argp);
+  jio_vsnprintf(buf_end, bufsz - len, format, argp);
   va_end(argp);
 }
 
diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp
index 820b6abcb7e..a742d221486 100644
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp
@@ -1185,7 +1185,7 @@ inline int build_int_from_shorts( jushort low, jushort high ) {
 // '%d' formats to indicate a 64-bit quantity; commonly "l" (in LP64) or "ll"
 // (in ILP32).
 
-#define BOOL_TO_STR(__b) (__b) ? "true" : "false"
+#define BOOL_TO_STR(_b_) ((_b_) ? "true" : "false")
 
 // Format 32-bit quantities.
 #define INT32_FORMAT  "%d"
diff --git a/hotspot/src/share/vm/utilities/workgroup.cpp b/hotspot/src/share/vm/utilities/workgroup.cpp
index 45b2f28f64e..e53d78d49b3 100644
--- a/hotspot/src/share/vm/utilities/workgroup.cpp
+++ b/hotspot/src/share/vm/utilities/workgroup.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -156,7 +156,7 @@ void WorkGang::run_task(AbstractGangTask* task) {
     tty->print_cr("/nFinished work gang %s: %d/%d sequence %d",
                   name(), finished_workers(), total_workers(),
                   _sequence_number);
-    }
+  }
 }
 
 void AbstractWorkGang::stop() {
diff --git a/hotspot/src/share/vm/utilities/workgroup.hpp b/hotspot/src/share/vm/utilities/workgroup.hpp
index 9737bf931f5..2bd6e9c0511 100644
--- a/hotspot/src/share/vm/utilities/workgroup.hpp
+++ b/hotspot/src/share/vm/utilities/workgroup.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,20 @@
 # include "thread_windows.inline.hpp"
 #endif
 
+// Task class hierarchy:
+//   AbstractGangTask
+//     AbstractGangTaskWOopQueues
+//
+// Gang/Group class hierarchy:
+//   AbstractWorkGang
+//     WorkGang
+//       FlexibleWorkGang
+//         YieldingFlexibleWorkGang (defined in another file)
+//
+// Worker class hierarchy:
+//   GangWorker (subclass of WorkerThread)
+//     YieldingFlexibleGangWorker   (defined in another file)
+
 // Forward declarations of classes defined here
 
 class WorkGang;
diff --git a/jaxp/.hgtags b/jaxp/.hgtags
index 727cedd7436..d305fff8865 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -108,3 +108,5 @@ ab107c1bc4b918404b191838c455e9b2892389f3 jdk7-b130
 eab6f27131e4e2f0af0016b35b18ae65cdd249d9 jdk7-b131
 abe04c59a556a3821c30bd8839e3c74f5d4281d1 jdk7-b132
 8e1148c7911b02e00a727461525f239da025cab7 jdk7-b133
+d56b326ae0544fc16c3e0d0285876f3c82054db2 jdk7-b134
+4aa9916693dc1078580c1865e6f2584046851e5a jdk7-b135
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index 34f4cc6b772..938b0888cb5 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -108,3 +108,5 @@ ba1fac1c2083196422a12130db174334179a4d44 jdk7-b130
 438abc0356cd97d91b25f67cd1abc9883e22f6ed jdk7-b131
 0e57c3272d377eee04cc32c898e9a558051516b0 jdk7-b132
 359d0c8c00a02d3a094c19f8a485b2217c99a4e0 jdk7-b133
+545de8303fec939db3892f7c324dd7df197e8f09 jdk7-b134
+d5fc61f18043765705ef22b57a68c924ab2f1a5b jdk7-b135
diff --git a/jdk/.hgtags b/jdk/.hgtags
index 77659b823f6..6c271f6efae 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -109,3 +109,5 @@ bdc069d3f9101f89ec3f81c2950ee2d68fa846d3 jdk7-b130
 6bbc7a4734952ae7604578f270e1566639fa8752 jdk7-b132
 5e5f68a01d12a4432172f384d5201f3a05254493 jdk7-b133
 554adcfb615e63e62af530b1c10fcf7813a75b26 jdk7-b134
+d8ced728159fbb2caa8b6adb477fd8efdbbdf179 jdk7-b135
+aa13e7702cd9d8aca9aa38f1227f966990866944 jdk7-b136
diff --git a/jdk/make/common/Defs-windows.gmk b/jdk/make/common/Defs-windows.gmk
index 87bc793596d..f5000e4465f 100644
--- a/jdk/make/common/Defs-windows.gmk
+++ b/jdk/make/common/Defs-windows.gmk
@@ -68,40 +68,10 @@ PLATFORM_INCLUDE      = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
 # The following DLL's are considered MS runtime libraries and should
 #     not to be REBASEd, see deploy/make/common/Release.gmk.
 #     msvcr*.dll: Microsoft runtimes
-ifeq ($(ARCH_DATA_MODEL), 32)
-  ifeq ($(COMPILER_VERSION), VS2003)
-    MSVCRNN_DLL = msvcr71.dll
-    MSVCPNN_DLL = msvcp71.dll
-    MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL)
-  endif
-  ifeq ($(COMPILER_VERSION), VS2005)
-    MSVCRNN_DLL = msvcr80.dll
-    MSVCPNN_DLL = msvcp80.dll
-    MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL)
-  endif
-  ifeq ($(COMPILER_VERSION), VS2008)
-    MSVCRNN_DLL = msvcr90.dll
-    MSVCPNN_DLL = msvcp90.dll
-    MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL)
-  endif
-  ifeq ($(COMPILER_VERSION), VS2010)
-    MSVCRNN_DLL = msvcr100.dll
-    MSVCPNN_DLL = msvcp100.dll
-    MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL)
-  endif
-endif
-
-ifeq ($(ARCH_DATA_MODEL), 64)
-  ifeq ($(COMPILER_VERSION), VS2008)
-    MSVCRNN_DLL = msvcr90.dll
-    MSVCPNN_DLL = msvcp90.dll
-    MS_RUNTIME_LIBRARIES = msvcrt.dll $(MSVCRNN_DLL)
-  endif
-  ifeq ($(COMPILER_VERSION), VS2010)
-    MSVCRNN_DLL = msvcr100.dll
-    MSVCPNN_DLL = msvcp100.dll
-    MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL)
-  endif
+ifeq ($(COMPILER_VERSION), VS2010)
+  MSVCRNN_DLL = msvcr100.dll
+  MSVCPNN_DLL = msvcp100.dll
+  MS_RUNTIME_LIBRARIES = $(MSVCRNN_DLL)
 endif
 
 EXTRA_LFLAGS += /LIBPATH:$(DXSDK_LIB_PATH)
@@ -124,109 +94,31 @@ ifndef FASTDEBUG_OPTIMIZATION_LEVEL
 endif
 
 ifeq ($(CC_VERSION),msvc)
-  # Visual Studio .NET 2003 or VS2003 compiler option definitions:
+  # Visual Studio compiler option definitions:
   #   -O1      Favors reduced size over speed (-Og     -Os -Oy -Ob2 -Gs -GF -Gy)
   #   -O2      Favors speed over reduced size (-Og -Oi -Ot -Oy -Ob2 -Gs -GF -Gy)
-  #   -Ox      Full optimization (use -O2)    (-Og -Oi -Ot -Oy -Ob2)
-  #              (Removed in Visual Studio 2005 or VS2005)
   #   -Ob2     More aggressive inlining
   #   -Og      Global optimizations
   #   -Oi      Replace some functions with intrinsic or special forms
-  #   -Op      Improve floating point calculations (disables some optimizations)
-  #              (Replaced with -fp:precise in VS2005, /Op is default now)
+  #   -fp:precise (should be the default)
+  #            Improve floating point calculations (disables some optimizations)
   #   -Os      Favor small code
   #   -Ot      Favor faster code
   #   -Oy      Frame pointer omission
-  #   -GB      Optimize for pentium (old VC6 option?)
-  #   -G6      VS2003 version of -GB?
+  #   -G6      Used to be -GB?
   #   -GF      Pool strings in read-only memory
   #   -Gf      Pool strings in read-write memory (the default)
   #   -Gs      Controls stack probess
-  #   -GS      Adds buffer overflow checks on stacks
-  #              (Default in VS2005)
-  #   -GX      Enables exception handling 
-  #              (Replaced with /EHsc in VS2005)
+  #   -GS      Adds buffer overflow checks on stacks (the default)
+  #   -EHsc    Enables exception handling 
   #   -Gy      Function level linking only
   #
-  # NOTE: With VC6, -Ox included -Gs.
-  # NOTE: With VC6, -Ox, -O1, and -O2 used -Ob1, not -Ob2.
-  # NOTE: With VC6, -O1 and -O2 used -Gf, not -GF.
-  #
 
   CC_OPT/NONE    = -Od
   CC_OPT/LOWER   = -O2
   CC_OPT/HIGHER  = -O3
   CC_OPT/HIGHEST = -O3
   
-  ifeq ($(COMPILER_VERSION), VC6)
-    # VC6 (6.2) msvc compiler (the way Tiger and early Mustang were built)
-    # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
-    AUTOMATIC_PCH_OPTION =
-    GX_OPTION = -GX
-    GZ_OPTION = -GZ
-    ifeq ($(ARCH_DATA_MODEL), 32)
-      CC_OPT/HIGHEST = -Ox -Gy -Os -GB
-      CC_OPT/HIGHER  = -Ox -Gy -Os -GB
-      CC_OPT/LOWER   = -Ox -Gy -Os -GB
-    else
-      CC_OPT/HIGHEST = -Ox -Gy -Op
-      CC_OPT/HIGHER  = -Ox -Gy -Op
-      CC_OPT/LOWER   = -Ox -Gy -Op
-    endif
-  endif
-  
-  ifeq ($(COMPILER_VERSION), VS2003)
-    # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
-    AUTOMATIC_PCH_OPTION = -YX
-    # Also known as VC7 compiler
-    GX_OPTION = -GX
-    GZ_OPTION = -GZ
-    ifeq ($(ARCH_DATA_MODEL), 32)
-      # Lowered opt level to try and reduce footprint, dll size especially.
-      #     Was: CC_OPT/HIGHEST = -O2 -G6
-      #     Was: CC_OPT/HIGHER  = -O2
-      CC_OPT/HIGHEST = -O2
-      CC_OPT/HIGHER  = -O1
-      CC_OPT/LOWER   = -O1
-    else
-      CC_OPT/HIGHEST = -O2 -Op
-      CC_OPT/HIGHER  = -O2 -Op
-      CC_OPT/LOWER   = -O1 -Op
-    endif
-  endif
-  
-  ifeq ($(COMPILER_VERSION), VS2005)
-    # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
-    AUTOMATIC_PCH_OPTION =
-    # VS2005 compiler, only with Platform SDK right now?
-    GX_OPTION = -EHsc
-    GZ_OPTION = -RTC1
-    ifeq ($(ARCH_DATA_MODEL), 32)
-      CC_OPT/HIGHEST = -O2
-      CC_OPT/HIGHER  = -O1
-      CC_OPT/LOWER   = -O1
-    else
-      CC_OPT/HIGHEST = -O2
-      CC_OPT/HIGHER  = -O1
-      CC_OPT/LOWER   = -O1
-    endif
-  endif
-  ifeq ($(COMPILER_VERSION), VS2008)
-    # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
-    AUTOMATIC_PCH_OPTION =
-    GX_OPTION = -EHsc
-    GZ_OPTION = -RTC1
-    ifeq ($(ARCH_DATA_MODEL), 32)
-      CC_OPT/HIGHEST = -O2
-      CC_OPT/HIGHER  = -O1
-      CC_OPT/LOWER   = -O1
-    else
-      CC_OPT/HIGHEST = -O2
-      CC_OPT/HIGHER  = -O1
-      CC_OPT/LOWER   = -O1
-    endif
-  endif
-
   ifeq ($(COMPILER_VERSION), VS2010)
     # Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
     AUTOMATIC_PCH_OPTION =
@@ -256,7 +148,7 @@ CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
 
 # Select the runtime support library carefully, need to be consistent
 #
-# VS2003 compiler option definitions:
+# Visual Studio Runtime compiler option definitions:
 #   -MD        Use dynamic multi-threaded runtime library
 #   -MDd       Use debug version (don't use, doesn't mix with -MD DLL's)
 #   -MT        Use static multi-threaded runtime library (-ML is going away)
@@ -265,12 +157,9 @@ CC_OPT = $(CC_OPT/$(OPTIMIZATION_LEVEL))
 #
 #      NOTE: We also will use /D _STATIC_CPPLIB  so we don't need msvcpnn.dll
 #
-# If MS_RUNTIME_STATIC is requested, use -MT only with VS2003.
-ifeq ($(MS_RUNTIME_STATIC),true)
-  ifeq ($(COMPILER_VERSION), VS2003)
-    MS_RUNTIME_OPTION=-MT
-  endif
-else
+# If MS_RUNTIME_STATIC is requested we may have a problem, it is no longer
+#     supported by VS2010
+ifneq ($(MS_RUNTIME_STATIC),true)
   MS_RUNTIME_OPTION=-MD
 endif
 # The _DEBUG macro option (changes things like malloc to use debug version)
@@ -302,7 +191,7 @@ endif
 MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION)
 
 ifeq ($(CC_VERSION),msvc)
-  # VS2003 compiler option definitions:
+  # Visual Studio compiler option definitions:
   #   -Zi      Cause *.pdb file to be created, full debug information
   #   -Z7      Full debug inside the .obj, no .pdb
   #   -Zd      Basic debug, no local variables? In the .obj
@@ -317,31 +206,10 @@ ifeq ($(CC_VERSION),msvc)
   CFLAGS_OPT      = $(CC_OPT)
   CFLAGS_DBG      = -Od $(MS_RUNTIME_DEBUG_OPTION)
 
-  # REMIND: I don't see where CFLAGS_VS2005 is used. I suspect its
-  # pulled in as a combined "CFLAGS_$(COMPILER_VERSION)" string
-  # but the lack of this isn't causing any apparent build problems
-  # with VS 2010 but it could be causing compiler warnings.
-  # For now, I  will add it for all cases :
   CFLAGS_VS2010 += -Zc:wchar_t-
-  #
-  # Starting from VS2005 the wchar_t is handled as a built-in C/C++ data type
-  # by default. However, we expect the wchar_t to be a typedef to the
-  # unsigned short data type. The -Zc:wchar_t- option restores the old
-  # behavior (as seen in VS2003) to avoid massive code modifications.
-  # When/if our code will be "C/C++ Standard"-compliant (at least in the area
-  # of handling the wchar_t type), the option won't be necessary.
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    CFLAGS_VS2005 += -Zc:wchar_t-
-  else
-    # The 64bit Platform SDK we use (April 2005) doesn't like this option
-    ifneq ($(CC_VER), 14.00.40310.41)
-      CFLAGS_VS2005 += -Zc:wchar_t-
-    endif
-  endif
 
   # All builds get the same runtime setting
   CFLAGS_COMMON += $(MS_RUNTIME_OPTION) $(CFLAGS_$(COMPILER_VERSION))
-  
 
   LDEBUG = /debug
   
@@ -350,21 +218,9 @@ ifeq ($(CC_VERSION),msvc)
     LDEBUG += /pdb:NONE
   endif
   
-  # The new Platform SDK and VS2005 has /GS as a default and requires 
-  #    bufferoverflowU.lib on the link command line, otherwise 
-  #    we get missing __security_check_cookie externals at link time. 
-  BUFFEROVERFLOWLIB = bufferoverflowU.lib
-  # Always add bufferoverflowU.lib to VS2005 link commands (pack uses LDDFLAGS)
-  LFLAGS_VS2005 = $(BUFFEROVERFLOWLIB)
-
-  # VS2008 has bufferoverflow baked in:
-  LFLAGS_VS2008 = 
-
   # VS2010, always need safe exception handlers, not needed on 64bit
   ifeq ($(ARCH_DATA_MODEL), 32)
-    LFLAGS_VS2010 =  -SAFESEH
-  else
-    LFLAGS_VS2010 =
+    LFLAGS_VS2010 +=  -SAFESEH
   endif
 
   # LFLAGS are the flags given to $(LINK) and used to build the actual DLL file
diff --git a/jdk/make/common/Defs.gmk b/jdk/make/common/Defs.gmk
index 3c1ff2c0270..1e12d411942 100644
--- a/jdk/make/common/Defs.gmk
+++ b/jdk/make/common/Defs.gmk
@@ -524,6 +524,10 @@ else
   COPYRIGHT_YEAR := $(shell $(DATE) '+%Y')
 endif
 
+ifndef OPENJDK
+include $(JDK_TOPDIR)/make/closed/common/Defs.gmk
+endif
+
 # Install of imported file (JDK_IMPORT_PATH, or some other external location)
 define install-importonly-file
 @$(ECHO) "ASSEMBLY_IMPORT: $@"
diff --git a/jdk/make/common/Release.gmk b/jdk/make/common/Release.gmk
index d528fc5c7a9..17297d573b0 100644
--- a/jdk/make/common/Release.gmk
+++ b/jdk/make/common/Release.gmk
@@ -54,9 +54,6 @@ EXCLUDE_PROPWARN_PKGS = com.sun.java.swing.plaf.windows  \
                         com.sun.java.swing.plaf.motif    \
                         com.sun.java.swing.plaf.gtk
 
-# This is a stopgap until 6839872 is fixed.
-EXCLUDE_PROPWARN_PKGS += sun.dyn
-
 #
 # Include the exported private packages in ct.sym.
 # This is an interim solution until the ct.sym is replaced
@@ -86,14 +83,7 @@ ifdef OPENJDK
   IMAGE_DOCLIST_JDK = LICENSE ASSEMBLY_EXCEPTION THIRD_PARTY_README
   IMAGE_DOCLIST_JRE = LICENSE ASSEMBLY_EXCEPTION THIRD_PARTY_README
 else
-  # Where to find these files
-  ifeq ($(J4B), true)
-      SHARE_JDK_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jdkfb
-      SHARE_JRE_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jrefb
-  else
-      SHARE_JDK_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jdk
-      SHARE_JRE_DOC_SRC = $(CLOSED_SHARE_SRC)/doc/jre
-  endif
+  # make/closed/common/Defs.gmk for closed location of SHARE_JDK_DOC_SRC
 
   IMAGE_DOCLIST_JDK = COPYRIGHT README.html  THIRDPARTYLICENSEREADME.txt
   IMAGE_DOCLIST_JRE = COPYRIGHT Welcome.html THIRDPARTYLICENSEREADME.txt
@@ -932,11 +922,6 @@ initial-image-jdk:: initial-image-jdk-setup \
     ifeq ($(COMPILER_VERSION), VS2010)
 	$(CP) $(BINDIR)/msvc*100.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin
     endif
-    ifeq ($(ARCH_DATA_MODEL), 32)
-      ifeq ($(COMPILER_VERSION), VS2003)
-	$(CP) $(BINDIR)/msvc*71.$(LIBRARY_SUFFIX) $(JDK_IMAGE_DIR)/bin
-      endif
-    endif
   else # PLATFORM
 	@#
 	@# bin/
diff --git a/jdk/make/common/shared/Compiler-msvc.gmk b/jdk/make/common/shared/Compiler-msvc.gmk
index 8be9f79f822..ff00095c565 100644
--- a/jdk/make/common/shared/Compiler-msvc.gmk
+++ b/jdk/make/common/shared/Compiler-msvc.gmk
@@ -47,82 +47,8 @@ ifeq ($(PLATFORM), windows)
   # Compiler version and type (Always get word after "Version")
   CC_VER  := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(SED) 's/.*\(Version.*\)/\1/' | $(NAWK) '{print $$2}')
 
-  # The MSDEVTOOLS_PATH is for older compilers, place for rc, mt, etc.
-  _OTHER_TOOLS_PATH = $(MSDEVTOOLS_PATH)
-
-  # SDK-64 and MSVC6 put REBASE.EXE in a different places - go figure...
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
-    CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
-    ifeq ($(CC_MAJORVER), 13)
-      # This should be: CC_VER=13.10.3077 LINK_VER=7.10.3077
-      COMPILER_NAME=Visual Studio .NET 2003 Professional C++
-      COMPILER_VERSION=VS2003
-      RC         = $(_OTHER_TOOLS_PATH)rc
-      REBASE     = $(COMPILER_PATH)../../Common7/Tools/Bin/rebase
-      MTL        = $(COMPILER_PATH)../../Common7/Tools/Bin/midl
-    endif
-    ifeq ($(CC_MAJORVER), 14)
-      COMPILER_NAME=Visual Studio 8
-      COMPILER_VERSION=VS2005
-      RC         = $(_OTHER_TOOLS_PATH)rc
-      REBASE     = $(COMPILER_PATH)../../Common8/Tools/Bin/rebase
-      MTL        = $(COMPILER_PATH)../../Common8/Tools/Bin/midl
-      MT         = $(_OTHER_TOOLS_PATH)/mt
-    endif
-    ifeq ($(CC_MAJORVER), 15)
-      COMPILER_NAME=Visual Studio 9
-      COMPILER_VERSION=VS2008
-      RC         = $(_OTHER_TOOLS_PATH)rc
-      #rebase and midl moved out of Visual Studio into the SDK:
-      REBASE     = $(_OTHER_TOOLS_PATH)/rebase
-      MTL        = $(_OTHER_TOOLS_PATH)/midl.exe
-      MT         = $(_OTHER_TOOLS_PATH)mt
-    endif
-  else
-    # else ARCH_DATA_MODEL is 64
-    LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
-    CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
-    CC_MINORVER :=$(call MinorVersion,$(CC_VER))
-    CC_MICROVER :=$(call MicroVersion,$(CC_VER))
-    ifeq ($(CC_MAJORVER), 13)
-      ifeq ($(ARCH), ia64)
-        # This should be: CC_VER=13.00.9337.7 LINK_VER=7.00.9337.7
-        COMPILER_NAME=Microsoft Platform SDK - November 2001 Edition
-        COMPILER_VERSION=VS2003
-        RC = $(_OTHER_TOOLS_PATH)rc
-      endif
-    endif
-    ifeq ($(CC_MAJORVER), 14)
-      ifeq ($(ARCH), amd64)
-        #rebase and midl moved out of Visual Studio into the SDK:
-        RC         = $(_OTHER_TOOLS_PATH)/rc
-        REBASE     = $(_OTHER_TOOLS_PATH)/rebase
-        MTL        = $(_OTHER_TOOLS_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
-	  #          have all the VS2005 compiler option changes, so treat
-	  #          this like a VS2003 compiler.
-          COMPILER_NAME=Microsoft Platform SDK - February 2003 Edition
-          COMPILER_VERSION=VS2003
-        else
-          # This should be: CC_VER=14.00.40310.41 LINK_VER=8.00.40310.39
-	  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)
-      COMPILER_NAME=Microsoft Windows SDK with Visual Studio 9 (6001.18000.367)
-      COMPILER_VERSION=VS2008
-      RC = $(MSSDK61)/Bin/X64/rc.exe
-      MT = $(MSSDK61)/Bin/X64/mt.exe
-      MTL = $(MSSDK61)/Bin/X64/midl.exe
-    endif
-  endif
+  LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
+  CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
   
   # The VS2010 compiler is the same one used on both 32bit and 64bit
   ifeq ($(CC_MAJORVER), 16)
diff --git a/jdk/make/common/shared/Defs-versions.gmk b/jdk/make/common/shared/Defs-versions.gmk
index 9521e66c996..05d81efec08 100644
--- a/jdk/make/common/shared/Defs-versions.gmk
+++ b/jdk/make/common/shared/Defs-versions.gmk
@@ -190,25 +190,10 @@ ifeq ($(PLATFORM), windows)
   REQUIRED_FREE_SPACE         = 500000
   REQUIRED_DXSDK_VER          = 0x0900
   ifeq ($(CC_VERSION),msvc)
-    ifeq ($(ARCH_DATA_MODEL), 32)
-      REQUIRED_COMPILER_NAME    = Visual Studio 10
-      REQUIRED_COMPILER_VERSION = VS2010
-      REQUIRED_CC_VER           = 16.00.30319.01
-      REQUIRED_LINK_VER         = 10.00.30319.01
-    else
-      ifeq ($(ARCH), ia64)
-        REQUIRED_COMPILER_NAME    = Microsoft Platform SDK - November 2001 Edition
-        REQUIRED_COMPILER_VERSION = VS2003
-        REQUIRED_CC_VER           = 13.00.9337.7
-        REQUIRED_LINK_VER         = 7.00.9337.7
-      endif
-      ifeq ($(ARCH), amd64)
-        REQUIRED_COMPILER_NAME    = Visual Studio 10
-        REQUIRED_COMPILER_VERSION = VS2010
-        REQUIRED_CC_VER           = 16.00.30319.01
-        REQUIRED_LINK_VER         = 10.00.30319.01
-      endif
-    endif
+    REQUIRED_COMPILER_NAME    = Visual Studio 10
+    REQUIRED_COMPILER_VERSION = VS2010
+    REQUIRED_CC_VER           = 16.00.30319.01
+    REQUIRED_LINK_VER         = 10.00.30319.01
   endif
   ifeq ($(CC_VERSION),gcc)
     REQUIRED_CC_VER           = 3.4.3
diff --git a/jdk/make/common/shared/Defs-windows.gmk b/jdk/make/common/shared/Defs-windows.gmk
index d928448b48f..44df76cb3c2 100644
--- a/jdk/make/common/shared/Defs-windows.gmk
+++ b/jdk/make/common/shared/Defs-windows.gmk
@@ -333,136 +333,26 @@ ifndef VS2010_EXISTS
   export WINDOWSSDKDIR
 endif
 
-# Setup for VS2010 is simple, others logic is historic
-ifeq ($(VS2010_EXISTS),true)
-  
-  # VS2010 Compiler root directory
-  _msvc_dir :=$(VS100COMNTOOLS)/../../Vc
-  # SDK root directory
-  _ms_sdk   :=$(WINDOWSSDKDIR)
-  # Compiler bin directory and redist directory
-  ifeq ($(ARCH_DATA_MODEL), 32)
-    _compiler_bin :=$(_msvc_dir)/Bin
-    _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC100.CRT)
-  endif
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    _compiler_bin :=$(_msvc_dir)/bin/amd64
-    _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x64/Microsoft.VC100.CRT)
-  endif
-  ifeq ($(_redist_sdk),)
-    _redist_sdk   :=$(_system_root)/system32
-  endif
+ifneq ($(VS2010_EXISTS),true)
+  x:=$(error ERROR: No VS2010 found on system.)
+endif 
 
-else # Not VS2010
-
-  # Compilers, SDK, and Visual Studio (MSDEV) [32bit is different from 64bit]
-  ifeq ($(ARCH_DATA_MODEL), 32)
-
-    # Try looking in MSVCDIR or MSVCDir area first 
-    # (set by vcvars32.bat for VC .NET, not defined in the VC 2008/2010)
-    ifdef MSVCDIR
-      xMSVCDIR  :="$(subst \,/,$(MSVCDIR))"
-      _msvc_dir :=$(call FullPath,$(xMSVCDIR))
-    else
-      ifdef MSVCDir
-        xMSVCDIR  :="$(subst \,/,$(MSVCDir))"
-        _msvc_dir :=$(call FullPath,$(xMSVCDIR))
-      endif
-    endif
-    # If we still don't have it, look for VSnnCOMNTOOLS (newest first),
-    # set by installer?
-    ifeq ($(_msvc_dir),)
-      ifdef VS90COMNTOOLS  # /Common/Tools directory, use ../../Vc
-        xVS90COMNTOOLS :="$(subst \,/,$(VS90COMNTOOLS))"
-        _vs90tools     :=$(call FullPath,$(xVS90COMNTOOLS))
-      endif
-      ifneq ($(_vs90tools),)
-        _msvc_dir   :=$(_vs90tools)/../../Vc
-      else
-        ifdef VS80COMNTOOLS  # /Common/Tools directory, use ../../Vc
-          xVS80COMNTOOLS :="$(subst \,/,$(VS80COMNTOOLS))"
-          _vs80tools     :=$(call FullPath,$(xVS80COMNTOOLS))
-        endif
-        ifneq ($(_vs80tools),)
-          _msvc_dir   :=$(_vs80tools)/../../Vc
-        else
-          ifdef VS71COMNTOOLS  # /Common/Tools directory, use ../../Vc7
-            xVS71COMNTOOLS :="$(subst \,/,$(VS71COMNTOOLS))"
-            _vs71tools     :=$(call FullPath,$(xVS71COMNTOOLS))
-          endif
-          ifneq ($(_vs71tools),)
-            _msvc_dir   :=$(_vs71tools)/../../Vc7
-          endif
-        endif
-      endif
-    endif
-  
-    ifneq ($(_msvc_dir),)
-      _compiler_bin :=$(_msvc_dir)/Bin
-      # Assume PlatformSDK is in VS71 (will be empty if VS90)
-      _ms_sdk       :=$(call FullPath,$(_msvc_dir)/PlatformSDK)
-      _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC90.CRT)
-      ifeq ($(_redist_sdk),)
-        _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC80.CRT)
-        ifeq ($(_redist_sdk),)
-          _redist_sdk   :=$(call FullPath,$(_msvc_dir)/../SDK/v1.1/Bin)
-        endif
-      endif
-    endif
-  endif
-
-  # The Microsoft Platform SDK installed by itself
-  ifneq ($(_program_files),)
-    _PSDK :="$(_program_files)/Microsoft SDKs/Windows/v6.1/"
-    _psdk :=$(call FullPath,$(xMSSDK61))
-    ifeq ($(_psdk),)
-      xPSDK  :="$(_program_files)/Microsoft Platform SDK"
-      _psdk  :=$(call FullPath,$(xPSDK))
-      ifeq ($(_psdk),)
-        xPSDK  :="$(_program_files)/Microsoft SDK"
-        _psdk :=$(call FullPath,$(xMSSDK))
-      endif
-    endif
-  endif
-
-  # If no SDK found yet, look in other places
-  ifeq ($(_ms_sdk),)
-    ifdef MSSDK
-    xMSSDK  :="$(subst \,/,$(MSSDK))"
-    _ms_sdk :=$(call FullPath,$(xMSSDK))
-  else
-    ifdef MSSdk
-      xMSSDK  :="$(subst \,/,$(MSSdk))"
-      _ms_sdk :=$(call FullPath,$(xMSSDK))
-    else
-        _ms_sdk :=$(_psdk)
-      endif
-    endif
-  endif
-  
-  # Compilers for 64bit may be from the free SDK, or Visual Studio Professional.
-  ifeq ($(ARCH_DATA_MODEL), 64)
-    xVS2008 :="$(_program_files32)/Microsoft Visual Studio 9.0/"
-    VS2008 :=$(call FullPath,$(xVS2008))
-    ifneq ($(VS2008),)
-      _compiler_bin :=$(VS2008)/VC/Bin/$(ARCH)
-      xMSSDK61      :="$(_program_files)/Microsoft SDKs/Windows/v6.1/"
-      MSSDK61       :=$(call FullPath,$(xMSSDK61))
-      _redist_sdk   :=$(VS2008)/VC/redist/x64/Microsoft.VC90.CRT
-    else
-      ifneq ($(_ms_sdk),)
-        ifeq ($(ARCH), ia64)
-          _compiler_bin :=$(_ms_sdk)/Bin/Win64
-        endif
-        ifeq ($(ARCH), amd64)
-          _compiler_bin :=$(_ms_sdk)/Bin/Win64/x86/$(ARCH)
-          _redist_sdk   :=$(_ms_sdk)/redist/win64/AMD64
-        endif
-      endif
-    endif
-  endif
-
-endif # VS2010_EXISTS
+# VS2010 Compiler root directory
+_msvc_dir :=$(VS100COMNTOOLS)/../../Vc
+# SDK root directory
+_ms_sdk   :=$(WINDOWSSDKDIR)
+# Compiler bin directory and redist directory
+ifeq ($(ARCH_DATA_MODEL), 32)
+  _compiler_bin :=$(_msvc_dir)/Bin
+  _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x86/Microsoft.VC100.CRT)
+endif
+ifeq ($(ARCH_DATA_MODEL), 64)
+  _compiler_bin :=$(_msvc_dir)/bin/amd64
+  _redist_sdk   :=$(call FullPath,$(_msvc_dir)/redist/x64/Microsoft.VC100.CRT)
+endif
+ifeq ($(_redist_sdk),)
+  _redist_sdk   :=$(_system_root)/system32
+endif
 
 # Location on system where jdk installs might be
 ifneq ($(_program_files),)
@@ -566,20 +456,8 @@ ifndef ALT_BOOTDIR
   _BOOTDIR3  =$(SLASH_JAVA)/re/jdk/$(PREVIOUS_JDK_VERSION)/archive/fcs/binaries/$(PLATFORM)-$(ARCH)
 endif
 
-# 32bit always needs the MSVCRNN runtime, 64bit does when using VS2008
-ifeq ($(ARCH_DATA_MODEL), 32)
-  _NEEDS_MSVCRNN = true
-else
-  ifeq ($(VS2010_EXISTS),true)
-    _NEEDS_MSVCRNN = true
-  else 
-    ifneq ($(VS2008),)
-      _NEEDS_MSVCRNN = true
-    else
-      _NEEDS_MSVCRNN = false
-    endif
-  endif
-endif
+# Everybody needs the MSVCRNN runtime starting with VS2010
+_NEEDS_MSVCRNN = true
 
 ifeq ($(_NEEDS_MSVCRNN), true)
   # MSVCRNN_DLL_PATH: location of msvcrnn.dll that will be re-distributed
@@ -758,8 +636,6 @@ HOTSPOT_LIB_PATH:=$(call AltCheckValue,HOTSPOT_LIB_PATH)
 
 # Special define for checking the binaries
 
-ifeq ($(VS2010_EXISTS),true)
-
 # All windows dll and exe files should have been built with /NXCOMPAT
 #   and be setup for dynamic base addresses.
 #   In addition, we should not be dependent on certain dll files that
@@ -841,12 +717,3 @@ define binary_file_verification # binary_file
 endef
 endif
 
-else
-
-# Macro to check it's input file for banned dependencies and verify the
-#   binary was built properly. Relies on process exit code.
-define binary_file_verification # binary_file
-endef
-
-endif
-
diff --git a/jdk/make/common/shared/Sanity.gmk b/jdk/make/common/shared/Sanity.gmk
index 127c9009811..99f64fd3842 100644
--- a/jdk/make/common/shared/Sanity.gmk
+++ b/jdk/make/common/shared/Sanity.gmk
@@ -996,25 +996,15 @@ endif
 ######################################################
 sane-msdevtools_path:
 ifeq ($(PLATFORM), windows)
-  ifneq ($(COMPILER_VERSION), VS2010)
-	@if [ "$(MSDEVTOOLS_PATH)" != "" -a ! -r "$(MSDEVTOOLS_PATH)" ]; then \
-	  $(ECHO) "ERROR: You do not have a valid MSDEVTOOLS_PATH setting. \n" \
-	    "      Please check your access to \n" \
-	    "          $(MSDEVTOOLS_PATH) \n" \
-	    "      and/or check your value of ALT_MSDEVTOOLS_PATH. \n" \
-	    "" >> $(ERROR_FILE) ; \
-	fi
-  else
-    ifeq ($(wildcard $(RC)),)
+  ifeq ($(wildcard $(RC)),)
 	@$(ECHO) "ERROR: Cannot find the RC utility from path: $(RC)\n" \
 	    "      This is normally obtained from the WINDOWSSDKDIR." \
 	    "" >> $(ERROR_FILE)
-    endif
-    ifeq ($(wildcard $(DUMPBIN)),)
+  endif
+  ifeq ($(wildcard $(DUMPBIN)),)
 	@$(ECHO) "ERROR: Cannot find the DUMPBIN utility from path: $(DUMPBIN)\n" \
 	    "      This is normally obtained from the COMPILER_PATH." \
 	    "" >> $(ERROR_FILE)
-    endif
   endif
 endif
 
@@ -1432,7 +1422,6 @@ endif
 ######################################################
 sane-install-mssdk_path:
 ifeq ($(PLATFORM), windows)
-  ifeq ($(COMPILER_VERSION), VS2010)
 	@if [ -z "$(WINDOWSSDKDIR)" ]; then \
 	  $(ECHO) "WARNING: Your WINDOWSSDKDIR setting is empty.\n" \
 	    "        It is recommended to set ALT_WINDOWSSDKDIR.\n" \
@@ -1445,7 +1434,6 @@ ifeq ($(PLATFORM), windows)
 	    "      and/or check your value of ALT_WINDOWSSDKDIR. \n" \
 	    "" >> $(ERROR_FILE) ; \
 	fi
-  endif
 	@if [ -z "$(INSTALL_MSSDK)" ]; then \
 	  $(ECHO) "WARNING: Your INSTALL_MSSDK setting is empty.\n" \
 	    "        It is recommended to set ALT_INSTALL_MSSDK.\n" \
diff --git a/jdk/make/docs/CORE_PKGS.gmk b/jdk/make/docs/CORE_PKGS.gmk
index 66a03df3978..84c8986370c 100644
--- a/jdk/make/docs/CORE_PKGS.gmk
+++ b/jdk/make/docs/CORE_PKGS.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@ EXCLUDE_PKGS =             \
 # This is a list of regular expressions. So foo.* matches "foo" and "foo.bar".
 #
 ACTIVE_JSR_PKGS= \
-  java.dyn \
+  java.lang.invoke \
   java.sql  \
   javax.activation  \
   javax.annotation.*  \
@@ -97,11 +97,11 @@ CORE_PKGS =                                      \
   java.awt.print                                 \
   java.beans                                     \
   java.beans.beancontext                         \
-  java.dyn                                       \
   java.io                                        \
   java.lang                                      \
   java.lang.annotation                           \
   java.lang.instrument                           \
+  java.lang.invoke                               \
   java.lang.management                           \
   java.lang.ref                                  \
   java.lang.reflect                              \
diff --git a/jdk/make/java/Makefile b/jdk/make/java/Makefile
index f988fe95d07..3956cadd2f7 100644
--- a/jdk/make/java/Makefile
+++ b/jdk/make/java/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@ SUBDIRS += security math util text net nio jar
 SUBDIRS_desktop    = awt applet beans
 SUBDIRS_management = management
 SUBDIRS_misc       = npt java_crw_demo java_hprof_demo \
-                     logging instrument dyn sql rmi
+                     logging instrument invoke sql rmi
 
 
 ifeq ($(PLATFORM), solaris)
diff --git a/jdk/make/java/dyn/Makefile b/jdk/make/java/invoke/Makefile
similarity index 86%
rename from jdk/make/java/dyn/Makefile
rename to jdk/make/java/invoke/Makefile
index 61ca68800b6..93b1f46f5d3 100644
--- a/jdk/make/java/dyn/Makefile
+++ b/jdk/make/java/invoke/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -25,18 +25,18 @@
 
 BUILDDIR = ../..
 
-PACKAGE = java.dyn
+PACKAGE = java.lang.invoke
 PRODUCT = java
 include $(BUILDDIR)/common/Defs.gmk
 
-AUTO_FILES_JAVA_DIRS = java/dyn sun/dyn
+AUTO_FILES_JAVA_DIRS = java/lang/invoke sun/invoke
+FILES_java = \
+    java/lang/ClassValue.java \
+    java/lang/BootstrapMethodError.java
 
 # The sources built here use new language syntax to generate
 # method handle calls.  Let's be sure we are using that format.
 LANGUAGE_VERSION = -source 7
 CLASS_VERSION = -target 7
 
-# Tell the compiler not to accept transitional forms.
-OTHER_JAVACFLAGS = -XDallowTransitionalJSR292=no
-
 include $(BUILDDIR)/common/Classes.gmk
diff --git a/jdk/make/java/text/base/FILES_java.gmk b/jdk/make/java/text/base/FILES_java.gmk
index 8d721300c27..34c3491d209 100644
--- a/jdk/make/java/text/base/FILES_java.gmk
+++ b/jdk/make/java/text/base/FILES_java.gmk
@@ -136,6 +136,7 @@ FILES_java = \
         sun/text/resources/CollationData_sl.java \
         sun/text/resources/CollationData_sq.java \
         sun/text/resources/CollationData_sr.java \
+        sun/text/resources/CollationData_sr_Latn.java \
         sun/text/resources/CollationData_sv.java \
         sun/text/resources/CollationData_tr.java \
         sun/text/resources/CollationData_uk.java \
@@ -251,6 +252,10 @@ FILES_java = \
         sun/text/resources/FormatData_sr_CS.java \
         sun/text/resources/FormatData_sr_ME.java \
         sun/text/resources/FormatData_sr_RS.java \
+        sun/text/resources/FormatData_sr_Latn.java \
+        sun/text/resources/FormatData_sr_Latn_BA.java \
+        sun/text/resources/FormatData_sr_Latn_ME.java \
+        sun/text/resources/FormatData_sr_Latn_RS.java \
         sun/text/resources/FormatData_sv.java \
         sun/text/resources/FormatData_sv_SE.java \
         sun/text/resources/FormatData_tr.java \
diff --git a/jdk/make/java/util/FILES_properties.gmk b/jdk/make/java/util/FILES_properties.gmk
index 49bfc65ef8c..5f3bec5e516 100644
--- a/jdk/make/java/util/FILES_properties.gmk
+++ b/jdk/make/java/util/FILES_properties.gmk
@@ -65,6 +65,7 @@ FILES_compiled_properties = \
         sun/util/resources/LocaleNames_sl.properties \
         sun/util/resources/LocaleNames_sq.properties \
         sun/util/resources/LocaleNames_sr.properties \
+        sun/util/resources/LocaleNames_sr_Latn.properties \
         sun/util/resources/LocaleNames_sv.properties \
         sun/util/resources/LocaleNames_tr.properties \
         sun/util/resources/LocaleNames_uk.properties \
@@ -111,6 +112,9 @@ FILES_compiled_properties = \
         sun/util/resources/CalendarData_sl.properties \
         sun/util/resources/CalendarData_sq.properties \
         sun/util/resources/CalendarData_sr.properties \
+        sun/util/resources/CalendarData_sr_Latn_BA.properties \
+        sun/util/resources/CalendarData_sr_Latn_ME.properties \
+        sun/util/resources/CalendarData_sr_Latn_RS.properties \
         sun/util/resources/CalendarData_sv.properties \
         sun/util/resources/CalendarData_tr.properties \
         sun/util/resources/CalendarData_uk.properties \
@@ -186,6 +190,7 @@ FILES_compiled_properties = \
         sun/util/resources/CurrencyNames_nl_NL.properties \
         sun/util/resources/CurrencyNames_no_NO.properties \
         sun/util/resources/CurrencyNames_pl_PL.properties \
+        sun/util/resources/CurrencyNames_pt.properties \
         sun/util/resources/CurrencyNames_pt_BR.properties \
         sun/util/resources/CurrencyNames_pt_PT.properties \
         sun/util/resources/CurrencyNames_ro_RO.properties \
@@ -196,6 +201,10 @@ FILES_compiled_properties = \
         sun/util/resources/CurrencyNames_sr_BA.properties \
         sun/util/resources/CurrencyNames_sr_CS.properties \
         sun/util/resources/CurrencyNames_sr_ME.properties \
+        sun/util/resources/CurrencyNames_sr_RS.properties \
+        sun/util/resources/CurrencyNames_sr_Latn_BA.properties \
+        sun/util/resources/CurrencyNames_sr_Latn_ME.properties \
+        sun/util/resources/CurrencyNames_sr_Latn_RS.properties \
         sun/util/resources/CurrencyNames_sv.properties \
         sun/util/resources/CurrencyNames_sv_SE.properties \
         sun/util/resources/CurrencyNames_tr_TR.properties \
diff --git a/jdk/make/mkdemo/jfc/Laffy/Makefile b/jdk/make/mkdemo/jfc/Laffy/Makefile
new file mode 100644
index 00000000000..7685f1e1381
--- /dev/null
+++ b/jdk/make/mkdemo/jfc/Laffy/Makefile
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# Makefile to build the Laffy demo.
+#
+
+BUILDDIR = ../../..
+PRODUCT = demo/jfc
+DEMONAME = Laffy
+include $(BUILDDIR)/common/Defs.gmk
+
+DEMO_ROOT       = $(CLOSED_SRC)/share/demo/jfc/$(DEMONAME)
+DEMO_DESTDIR    = $(DEMODIR)/jfc/$(DEMONAME)
+DEMO_TOPFILES	= ./readme.html ./laffy.png
+DEMO_SKIP_SRCZIP = true
+
+#
+# Demo jar building rules.
+#
+include $(BUILDDIR)/common/Demo.gmk
diff --git a/jdk/make/mkdemo/jfc/Makefile b/jdk/make/mkdemo/jfc/Makefile
index decfac45061..768e5b8f4a8 100644
--- a/jdk/make/mkdemo/jfc/Makefile
+++ b/jdk/make/mkdemo/jfc/Makefile
@@ -43,7 +43,7 @@ SUBDIRS =           \
 
 # Some demos aren't currently included in OpenJDK
 ifndef OPENJDK
-  SUBDIRS += Java2D SwingSet2 SwingSet3 Stylepad
+  SUBDIRS += Java2D Laffy SwingSet2 SwingSet3 Stylepad
 endif
 
 include $(BUILDDIR)/common/Subdirs.gmk
diff --git a/jdk/make/sun/cmm/kcms/Makefile b/jdk/make/sun/cmm/kcms/Makefile
index b0dd8434ee7..abcdd9bb39a 100644
--- a/jdk/make/sun/cmm/kcms/Makefile
+++ b/jdk/make/sun/cmm/kcms/Makefile
@@ -71,7 +71,8 @@ $(SERVICEDIR)/%: $(CLOSED_SRC)/share/classes/sun/java2d/cmm/kcms/META-INF/servic
 # Extra rules
 #
 ifeq  ($(PLATFORM), linux)
-LDLIBS += -lpthread
+    LDLIBS += -lpthread
+    OTHER_CFLAGS += -Wno-missing-field-initializers
 endif
 
 clean clobber:: 
@@ -103,6 +104,5 @@ CPPFLAGS += -I$(CLASSHDRDIR) \
 
 endif # PLATFORM
 
-#CFLAGS += -DJAVACMM -DFUT_CALC_EX -DNO_FUT_GCONST
-CFLAGS += -DFUT_CALC_EX -DNO_FUT_GCONST
+CFLAGS += -DJAVACMM -DFUT_CALC_EX -DNO_FUT_GCONST
 
diff --git a/jdk/make/sun/cmm/lcms/Makefile b/jdk/make/sun/cmm/lcms/Makefile
index 52b550dda10..f2794fc5253 100644
--- a/jdk/make/sun/cmm/lcms/Makefile
+++ b/jdk/make/sun/cmm/lcms/Makefile
@@ -81,10 +81,6 @@ vpath %.c   $(SHARE_SRC)/native/sun/java2d
 ifeq ($(PLATFORM), windows)
 OTHER_CFLAGS += -DCMS_IS_WINDOWS_
 
-ifeq ($(COMPILER_VERSION), VS2003)
-OTHER_CFLAGS += -Dsqrtf=sqrt
-endif
-
 OTHER_LDLIBS = $(OBJDIR)/../../../sun.awt/awt/$(OBJDIRNAME)/awt.lib
 OTHER_INCLUDES += -I$(SHARE_SRC)/native/sun/java2d \
                   -I$(SHARE_SRC)/native/sun/awt/debug
diff --git a/jdk/make/sun/javazic/tzdata/VERSION b/jdk/make/sun/javazic/tzdata/VERSION
index b82ee890a30..0b57ca90d10 100644
--- a/jdk/make/sun/javazic/tzdata/VERSION
+++ b/jdk/make/sun/javazic/tzdata/VERSION
@@ -21,4 +21,4 @@
 # or visit www.oracle.com if you need additional information or have any
 # questions.
 #
-tzdata2011b
+tzdata2011d
diff --git a/jdk/make/sun/javazic/tzdata/australasia b/jdk/make/sun/javazic/tzdata/australasia
index 430a6f146f5..61d338f9683 100644
--- a/jdk/make/sun/javazic/tzdata/australasia
+++ b/jdk/make/sun/javazic/tzdata/australasia
@@ -531,11 +531,31 @@ Zone Pacific/Pago_Pago	 12:37:12 -	LMT	1879 Jul  5
 # to 01:00am and First Sunday April 2011 (03/04/11) - adjust clocks
 # backwards from 1:00am to 12:00am"
 
+# From Raymond Hughes (2011-03-07)
+# I believe this will be posted shortly on the website
+# <a href="http://www.mcil.gov.ws">
+# www.mcil.gov.ws
+# </a>
+#
+# PUBLIC NOTICE ON DAYLIGHT SAVING TIME
+#
+# Pursuant to the Daylight Saving Act 2009 and Cabinets decision,
+# businesses and the general public are hereby advised that daylight
+# saving time is on the first Saturday of April 2011 (02/04/11).
+#
+# The public is therefore advised that when the standard time strikes
+# the hour of four oclock (4.00am or 0400 Hours) on the 2nd April 2011,
+# then all instruments used to measure standard time are to be
+# adjusted/changed to three oclock (3:00am or 0300Hrs).
+#
+# Margaret Fruean ACTING CHIEF EXECUTIVE OFFICER MINISTRY OF COMMERCE,
+# INDUSTRY AND LABOUR 28th February 2011
+
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time
 			-11:00	-	WST	2010 Sep 26
-			-11:00	1:00	WSDT	2011 Apr 3 1:00
+			-11:00	1:00	WSDT	2011 Apr 2 4:00
 			-11:00	-	WST
 
 # Solomon Is
diff --git a/jdk/make/sun/javazic/tzdata/etcetera b/jdk/make/sun/javazic/tzdata/etcetera
index e8b3a60fc90..609b305493c 100644
--- a/jdk/make/sun/javazic/tzdata/etcetera
+++ b/jdk/make/sun/javazic/tzdata/etcetera
@@ -58,8 +58,7 @@ Link	Etc/GMT				Etc/GMT0
 # (i.e. west of Greenwich) even though many people would expect it to
 # mean 4 hours ahead of UTC (i.e. east of Greenwich).
 #
-# In the draft 5 of POSIX 1003.1-200x, the angle bracket notation
-# (which is not yet supported by the tz code) allows for
+# In the draft 5 of POSIX 1003.1-200x, the angle bracket notation allows for
 # TZ='<GMT-4>+4'; if you want time zone abbreviations conforming to
 # ISO 8601 you can use TZ='<-0400>+4'.  Thus the commonly-expected
 # offset is kept within the angle bracket (and is used for display)
diff --git a/jdk/make/sun/javazic/tzdata/europe b/jdk/make/sun/javazic/tzdata/europe
index 6fc7d22f3c2..5b11dfb5122 100644
--- a/jdk/make/sun/javazic/tzdata/europe
+++ b/jdk/make/sun/javazic/tzdata/europe
@@ -2505,25 +2505,18 @@ Zone	Europe/Zurich	0:34:08 -	LMT	1848 Sep 12
 # (on a non-government server though) describing dates between 2002 and 2006:
 # http://www.alomaliye.com/bkk_2002_3769.htm
 
-# From Sue Williams (2008-08-11):
-# I spotted this news article about a potential change in Turkey.
-#
-# <a href="http://www.hurriyet.com.tr/english/domestic/9626174.asp?scr=1">
-# http://www.hurriyet.com.tr/english/domestic/9626174.asp?scr=1
+# From G&ouml;kdeniz Karada&#x011f; (2011-03-10):
+# 
+# According to the articles linked below, Turkey will change into summer
+# time zone (GMT+3) on March 28, 2011 at 3:00 a.m. instead of March 27.
+# This change is due to a nationwide exam on 27th.
+# 
+# <a href="http://www.worldbulletin.net/?aType=haber&ArticleID=70872">
+# http://www.worldbulletin.net/?aType=haber&ArticleID=70872
 # </a>
-
-# From Sue Williams (2008-08-20):
-# This article says that around the end of March 2011, Turkey wants to
-# adjust the clocks forward by 1/2 hour and stay that way permanently.
-# The article indicates that this is a change in timezone offset in addition
-# to stopping observance of DST.
-# This proposal has not yet been approved.
-#
-# Read more here...
-#
-# Turkey to abandon daylight saving time in 2011
-# <a href="http://www.turkishdailynews.com.tr/article.php?enewsid=112989">
-# http://www.turkishdailynews.com.tr/article.php?enewsid=112989
+# Turkish:
+# <a href="http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373">
+# http://www.hurriyet.com.tr/ekonomi/17230464.asp?gid=373
 # </a>
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
@@ -2591,6 +2584,8 @@ Zone	Europe/Istanbul	1:55:52 -	LMT	1880
 			2:00	Turkey	EE%sT	1978 Oct 15
 			3:00	Turkey	TR%sT	1985 Apr 20 # Turkey Time
 			2:00	Turkey	EE%sT	2007
+			2:00	EU	EE%sT	2011 Mar 27 1:00u
+			2:00	-	EET	2011 Mar 28 1:00u
 			2:00	EU	EE%sT
 Link	Europe/Istanbul	Asia/Istanbul	# Istanbul is in both continents.
 
diff --git a/jdk/make/sun/javazic/tzdata/leapseconds b/jdk/make/sun/javazic/tzdata/leapseconds
index 50426088b76..368366a1a92 100644
--- a/jdk/make/sun/javazic/tzdata/leapseconds
+++ b/jdk/make/sun/javazic/tzdata/leapseconds
@@ -78,13 +78,13 @@ Leap	2008	Dec	31	23:59:60	+	S
 # SERVICE DE LA ROTATION TERRESTRE
 # OBSERVATOIRE DE PARIS
 # 61, Av. de l'Observatoire 75014 PARIS (France)
-# Tel.      : 33 (0) 1 40 51 22 26
+# Tel.      : 33 (0) 1 40 51 22 29
 # FAX       : 33 (0) 1 40 51 22 91
 # Internet  : services.iers@obspm.fr
 #
-# Paris, 14 July 2010
+# Paris, 2 February 2011
 #
-# Bulletin C 40
+# Bulletin C 41
 #
 # To authorities responsible
 # for the measurement and
@@ -92,9 +92,9 @@ Leap	2008	Dec	31	23:59:60	+	S
 #
 # INFORMATION ON UTC - TAI
 #
-# NO positive leap second will be introduced at the end of December 2010.
+# NO positive leap second will be introduced at the end of June 2011.
 # The difference between Coordinated Universal Time UTC and the
-# International Atomic Time TAI is :
+# International Atomic Time TAI is :		
 #
 # from 2009 January 1, 0h UTC, until further notice : UTC-TAI = -34 s
 #
@@ -104,6 +104,6 @@ Leap	2008	Dec	31	23:59:60	+	S
 # will be no time step at the next possible date.
 #
 # Daniel GAMBIS
-# Director
-# Earth Orientation Center of IERS
+# Head			
+# Earth Orientation Center of the IERS
 # Observatoire de Paris, France
diff --git a/jdk/make/sun/javazic/tzdata/northamerica b/jdk/make/sun/javazic/tzdata/northamerica
index 281ab4f6748..7111cb7048d 100644
--- a/jdk/make/sun/javazic/tzdata/northamerica
+++ b/jdk/make/sun/javazic/tzdata/northamerica
@@ -448,15 +448,74 @@ Zone America/Los_Angeles -7:52:58 -	LMT	1883 Nov 18 12:07:02
 # were nearby inhabitants in some cases and for our purposes perhaps
 # it's best to simply use the official transition.
 #
+
+# From Steve Ferguson (2011-01-31):
+# The author lives in Alaska and many of the references listed are only
+# available to Alaskan residents.
+#
+# <a href="http://www.alaskahistoricalsociety.org/index.cfm?section=discover%20alaska&page=Glimpses%20of%20the%20Past&viewpost=2&ContentId=98">
+# http://www.alaskahistoricalsociety.org/index.cfm?section=discover%20alaska&page=Glimpses%20of%20the%20Past&viewpost=2&ContentId=98
+# </a>
+
+# From Arthur David Olson (2011-02-01):
+# Here's database-relevant material from the 2001 "Alaska History" article:
+#
+# On September 20 [1979]...DOT...officials decreed that on April 27,
+# 1980, Juneau and other nearby communities would move to Yukon Time.
+# Sitka, Petersburg, Wrangell, and Ketchikan, however, would remain on
+# Pacific Time.
+#
+# ...on September 22, 1980, DOT Secretary Neil E. Goldschmidt rescinded the
+# Department's September 1979 decision. Juneau and other communities in
+# northern Southeast reverted to Pacific Time on October 26.
+#
+# On October 28 [1983]...the Metlakatla Indian Community Council voted
+# unanimously to keep the reservation on Pacific Time.
+#
+# According to DOT official Joanne Petrie, Indian reservations are not
+# bound to follow time zones imposed by neighboring jurisdictions.
+#
+# (The last is consistent with how the database now handles the Navajo
+# Nation.)
+
+# From Arthur David Olson (2011-02-09):
+# I just spoke by phone with a staff member at the Metlakatla Indian
+# Community office (using contact information available at
+# <a href="http://www.commerce.state.ak.us/dca/commdb/CIS.cfm?Comm_Boro_name=Metlakatla">
+# http://www.commerce.state.ak.us/dca/commdb/CIS.cfm?Comm_Boro_name=Metlakatla
+# </a>).
+# It's shortly after 1:00 here on the east coast of the United States;
+# the staffer said it was shortly after 10:00 there. When I asked whether
+# that meant they were on Pacific time, they said no--they were on their
+# own time. I asked about daylight saving; they said it wasn't used. I
+# did not inquire about practices in the past.
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Juneau	 15:02:19 -	LMT	1867 Oct 18
 			 -8:57:41 -	LMT	1900 Aug 20 12:00
 			 -8:00	-	PST	1942
 			 -8:00	US	P%sT	1946
 			 -8:00	-	PST	1969
+			 -8:00	US	P%sT	1980 Apr 27 2:00
+			 -9:00	US	Y%sT	1980 Oct 26 2:00	
 			 -8:00	US	P%sT	1983 Oct 30 2:00
 			 -9:00	US	Y%sT	1983 Nov 30
 			 -9:00	US	AK%sT
+Zone America/Sitka	 -14:58:47 -	LMT	1867 Oct 18
+			 -9:01:13 -	LMT	1900 Aug 20 12:00
+			 -8:00	-	PST	1942
+			 -8:00	US	P%sT	1946
+			 -8:00	-	PST	1969
+			 -8:00	US	P%sT	1983 Oct 30 2:00
+			 -9:00	US	Y%sT	1983 Nov 30
+			 -9:00	US	AK%sT
+Zone America/Metlakatla	 15:13:42 -	LMT	1867 Oct 18
+			 -8:46:18 -	LMT	1900 Aug 20 12:00
+			 -8:00	-	PST	1942
+			 -8:00	US	P%sT	1946
+			 -8:00	-	PST	1969
+			 -8:00	US	P%sT	1983 Oct 30 2:00
+			 -8:00	US	MeST
 Zone America/Yakutat	 14:41:05 -	LMT	1867 Oct 18
 			 -9:18:55 -	LMT	1900 Aug 20 12:00
 			 -9:00	-	YST	1942
@@ -2569,6 +2628,21 @@ Zone America/Costa_Rica	-5:36:20 -	LMT	1890		# San Jose
 # the time was announced as "diez cinco"--the same time as here, indicating
 # that has indeed switched to DST. Assume second Sunday from 2009 forward.
 
+# From Steffen Thorsen (2011-03-08):
+# Granma announced that Cuba is going to start DST on 2011-03-20 00:00:00
+# this year. Nothing about the end date known so far (if that has
+# changed at all).
+#
+# Source:
+# <a href="http://granma.co.cu/2011/03/08/nacional/artic01.html">
+# http://granma.co.cu/2011/03/08/nacional/artic01.html
+# </a>
+#
+# Our info:
+# <a href="http://www.timeanddate.com/news/time/cuba-starts-dst-2011.html">
+# http://www.timeanddate.com/news/time/cuba-starts-dst-2011.html
+# </a>
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Cuba	1928	only	-	Jun	10	0:00	1:00	D
 Rule	Cuba	1928	only	-	Oct	10	0:00	0	S
@@ -2602,7 +2676,9 @@ Rule	Cuba	2000	2004	-	Apr	Sun>=1	0:00s	1:00	D
 Rule	Cuba	2006	max	-	Oct	lastSun	0:00s	0	S
 Rule	Cuba	2007	only	-	Mar	Sun>=8	0:00s	1:00	D
 Rule	Cuba	2008	only	-	Mar	Sun>=15	0:00s	1:00	D
-Rule	Cuba	2009	max	-	Mar	Sun>=8	0:00s	1:00	D
+Rule	Cuba	2009	2010	-	Mar	Sun>=8	0:00s	1:00	D
+Rule	Cuba	2011	only	-	Mar	Sun>=15	0:00s	1:00	D
+Rule	Cuba	2012	max	-	Mar	Sun>=8	0:00s	1:00	D
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Havana	-5:29:28 -	LMT	1890
diff --git a/jdk/make/sun/javazic/tzdata/southamerica b/jdk/make/sun/javazic/tzdata/southamerica
index ea82c22b12c..a11df76f6e9 100644
--- a/jdk/make/sun/javazic/tzdata/southamerica
+++ b/jdk/make/sun/javazic/tzdata/southamerica
@@ -1176,6 +1176,23 @@ Zone America/Rio_Branco	-4:31:12 -	LMT	1914
 # From Arthur Daivd Olson (2010-03-06):
 # Angel Chiang's message confirmed by Julio Pacheco; Julio provided a patch.
 
+# From Glenn Eychaner (2011-03-02): [geychaner@mac.com]
+# It appears that the Chilean government has decided to postpone the
+# change from summer time to winter time again, by three weeks to April
+# 2nd:
+# <a href="http://www.emol.com/noticias/nacional/detalle/detallenoticias.asp?idnoticia=467651">
+# http://www.emol.com/noticias/nacional/detalle/detallenoticias.asp?idnoticia=467651
+# </a>
+#
+# This is not yet reflected in the offical "cambio de hora" site, but
+# probably will be soon:
+# <a href="http://www.horaoficial.cl/cambio.htm">
+# http://www.horaoficial.cl/cambio.htm
+# </a>
+
+# From Arthur David Olson (2011-03-02):
+# The emol.com article mentions a water shortage as the cause of the
+# postponement, which may mean that it's not a permanent change.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Chile	1927	1932	-	Sep	 1	0:00	1:00	S
 Rule	Chile	1928	1932	-	Apr	 1	0:00	0	-
@@ -1211,8 +1228,8 @@ Rule	Chile	2000	2007	-	Mar	Sun>=9	3:00u	0	-
 # which is used below in specifying the transition.
 Rule	Chile	2008	only	-	Mar	30	3:00u	0	-
 Rule	Chile	2009	only	-	Mar	Sun>=9	3:00u	0	-
-Rule	Chile	2010	only	-	Apr	 4	3:00u	0	-
-Rule	Chile	2011	max	-	Mar	Sun>=9	3:00u	0	-
+Rule	Chile	2010	2011	-	Apr	Sun>=1	3:00u	0	-
+Rule	Chile	2012	max	-	Mar	Sun>=9	3:00u	0	-
 # IATA SSIM anomalies: (1992-02) says 1992-03-14;
 # (1996-09) says 1998-03-08.  Ignore these.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
diff --git a/jdk/make/sun/javazic/tzdata/zone.tab b/jdk/make/sun/javazic/tzdata/zone.tab
index cddfedae509..0b158ec2234 100644
--- a/jdk/make/sun/javazic/tzdata/zone.tab
+++ b/jdk/make/sun/javazic/tzdata/zone.tab
@@ -434,9 +434,11 @@ US	+332654-1120424	America/Phoenix	Mountain Standard Time - Arizona
 US	+340308-1181434	America/Los_Angeles	Pacific Time
 US	+611305-1495401	America/Anchorage	Alaska Time
 US	+581807-1342511	America/Juneau	Alaska Time - Alaska panhandle
+US	+571035-1351807	America/Sitka	Alaska Time - southeast Alaska panhandle
 US	+593249-1394338	America/Yakutat	Alaska Time - Alaska panhandle neck
 US	+643004-1652423	America/Nome	Alaska Time - west Alaska
 US	+515248-1763929	America/Adak	Aleutian Islands
+US	+550737-1313435	America/Metlakatla	Metlakatla Time - Annette Island
 US	+211825-1575130	Pacific/Honolulu	Hawaii
 UY	-3453-05611	America/Montevideo
 UZ	+3940+06648	Asia/Samarkand	west Uzbekistan
diff --git a/jdk/make/sun/net/FILES_java.gmk b/jdk/make/sun/net/FILES_java.gmk
index 576159c4799..6c140abc68b 100644
--- a/jdk/make/sun/net/FILES_java.gmk
+++ b/jdk/make/sun/net/FILES_java.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@ FILES_java = \
 	sun/net/ProgressListener.java \
 	sun/net/ProgressMeteringPolicy.java \
 	sun/net/SocksProxy.java \
+	sun/net/ResourceManager.java \
 	sun/net/TelnetInputStream.java \
 	sun/net/TelnetOutputStream.java \
 	sun/net/TelnetProtocolException.java \
@@ -100,6 +101,7 @@ FILES_java = \
 	sun/net/www/protocol/http/NegotiateAuthentication.java \
 	sun/net/www/protocol/http/Negotiator.java \
 	sun/net/www/protocol/http/ntlm/NTLMAuthentication.java \
+	sun/net/www/protocol/http/ntlm/NTLMAuthenticationCallback.java \
 	sun/net/www/protocol/http/spnego/NegotiatorImpl.java \
 	sun/net/www/protocol/http/spnego/NegotiateCallbackHandler.java \
 	sun/net/www/protocol/http/logging/HttpLogFormatter.java \
diff --git a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
index 27fcaac0ac7..74713133a7d 100644
--- a/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
+++ b/jdk/src/share/classes/com/sun/org/apache/xml/internal/security/transforms/Transform.java
@@ -210,6 +210,8 @@ public final class Transform extends SignatureElementProxy {
     public static void init() {
         if (!alreadyInitialized) {
             transformClassHash = new HashMap(10);
+            // make sure builtin algorithms are all registered first
+            com.sun.org.apache.xml.internal.security.Init.init();
             alreadyInitialized = true;
         }
     }
@@ -236,12 +238,7 @@ public final class Transform extends SignatureElementProxy {
                "algorithm.alreadyRegistered", exArgs);
         }
 
-        ClassLoader cl = (ClassLoader) AccessController.doPrivileged(
-            new PrivilegedAction() {
-                public Object run() {
-                    return Thread.currentThread().getContextClassLoader();
-                }
-            });
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
 
         try {
             transformClassHash.put
diff --git a/jdk/src/share/classes/java/awt/AWTEvent.java b/jdk/src/share/classes/java/awt/AWTEvent.java
index 60ab93e1dc6..5afd14afa23 100644
--- a/jdk/src/share/classes/java/awt/AWTEvent.java
+++ b/jdk/src/share/classes/java/awt/AWTEvent.java
@@ -33,6 +33,11 @@ import java.lang.reflect.Field;
 import sun.awt.AWTAccessor;
 import sun.util.logging.PlatformLogger;
 
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.io.ObjectInputStream;
+import java.io.IOException;
+
 /**
  * The root event class for all AWT events.
  * This class and its subclasses supercede the original
@@ -97,6 +102,22 @@ public abstract class AWTEvent extends EventObject {
      */
     protected boolean consumed = false;
 
+   /*
+    * The event's AccessControlContext.
+    */
+    private transient volatile AccessControlContext acc =
+        AccessController.getContext();
+
+   /*
+    * Returns the acc this event was constructed with.
+    */
+    final AccessControlContext getAccessControlContext() {
+        if (acc == null) {
+            throw new SecurityException("AWTEvent is missing AccessControlContext");
+        }
+        return acc;
+    }
+
     transient boolean focusManagerIsDispatching = false;
     transient boolean isPosted;
 
@@ -247,6 +268,10 @@ public abstract class AWTEvent extends EventObject {
                 public boolean isSystemGenerated(AWTEvent ev) {
                     return ev.isSystemGenerated;
                 }
+
+                public AccessControlContext getAccessControlContext(AWTEvent ev) {
+                    return ev.getAccessControlContext();
+                }
             });
     }
 
diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java
index d0eda994f1b..c6ab0494574 100644
--- a/jdk/src/share/classes/java/awt/Component.java
+++ b/jdk/src/share/classes/java/awt/Component.java
@@ -59,6 +59,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.security.AccessControlContext;
 import javax.accessibility.*;
 import java.applet.Applet;
 
@@ -471,6 +472,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
     static final Object LOCK = new AWTTreeLock();
     static class AWTTreeLock {}
 
+    /*
+     * The component's AccessControlContext.
+     */
+    private transient volatile AccessControlContext acc =
+        AccessController.getContext();
+
     /**
      * Minimum size.
      * (This field perhaps should have been transient).
@@ -671,6 +678,16 @@ public abstract class Component implements ImageObserver, MenuContainer,
         return objectLock;
     }
 
+    /*
+     * Returns the acc this component was constructed with.
+     */
+    final AccessControlContext getAccessControlContext() {
+        if (acc == null) {
+            throw new SecurityException("Component is missing AccessControlContext");
+        }
+        return acc;
+    }
+
     boolean isPacked = false;
 
     /**
@@ -950,6 +967,10 @@ public abstract class Component implements ImageObserver, MenuContainer,
             public void processEvent(Component comp, AWTEvent e) {
                 comp.processEvent(e);
             }
+
+            public AccessControlContext getAccessControlContext(Component comp) {
+                return comp.getAccessControlContext();
+            }
         });
     }
 
@@ -3873,6 +3894,11 @@ public abstract class Component implements ImageObserver, MenuContainer,
          * supported or met
          * @exception ClassCastException if the component is not a canvas or
          * window.
+         * @exception IllegalStateException if the component has no peer
+         * @exception IllegalArgumentException if {@code numBuffers} is less than two,
+         * or if {@code BufferCapabilities.isPageFlipping} is not
+         * {@code true}.
+         * @see #createBuffers(int, BufferCapabilities)
          */
         protected FlipBufferStrategy(int numBuffers, BufferCapabilities caps)
             throws AWTException
@@ -8608,6 +8634,8 @@ public abstract class Component implements ImageObserver, MenuContainer,
     {
         objectLock = new Object();
 
+        acc = AccessController.getContext();
+
         s.defaultReadObject();
 
         appContext = AppContext.getAppContext();
diff --git a/jdk/src/share/classes/java/awt/EventQueue.java b/jdk/src/share/classes/java/awt/EventQueue.java
index d4c763b4f3f..8aab49f075a 100644
--- a/jdk/src/share/classes/java/awt/EventQueue.java
+++ b/jdk/src/share/classes/java/awt/EventQueue.java
@@ -48,6 +48,12 @@ import sun.awt.AWTAccessor;
 import java.util.concurrent.locks.Condition;
 import java.util.concurrent.locks.Lock;
 
+import java.security.AccessControlContext;
+import java.security.ProtectionDomain;
+
+import sun.misc.SharedSecrets;
+import sun.misc.JavaSecurityAccess;
+
 /**
  * <code>EventQueue</code> is a platform-independent class
  * that queues events, both from the underlying peer classes
@@ -612,6 +618,9 @@ public class EventQueue {
         return null;
     }
 
+    private static final JavaSecurityAccess javaSecurityAccess =
+        SharedSecrets.getJavaSecurityAccess();
+
     /**
      * Dispatches an event. The manner in which the event is
      * dispatched depends upon the type of the event and the
@@ -650,13 +659,49 @@ public class EventQueue {
      * @throws NullPointerException if <code>event</code> is <code>null</code>
      * @since           1.2
      */
-    protected void dispatchEvent(AWTEvent event) {
+    protected void dispatchEvent(final AWTEvent event) {
+        final Object src = event.getSource();
+        final PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
+            public Void run() {
+                dispatchEventImpl(event, src);
+                return null;
+            }
+        };
+
+        final AccessControlContext stack = AccessController.getContext();
+        final AccessControlContext srcAcc = getAccessControlContextFrom(src);
+        final AccessControlContext eventAcc = event.getAccessControlContext();
+        if (srcAcc == null) {
+            javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc);
+        } else {
+            javaSecurityAccess.doIntersectionPrivilege(
+                new PrivilegedAction<Void>() {
+                    public Void run() {
+                        javaSecurityAccess.doIntersectionPrivilege(action, eventAcc);
+                        return null;
+                    }
+                }, stack, srcAcc);
+        }
+    }
+
+    private static AccessControlContext getAccessControlContextFrom(Object src) {
+        return src instanceof Component ?
+            ((Component)src).getAccessControlContext() :
+            src instanceof MenuComponent ?
+                ((MenuComponent)src).getAccessControlContext() :
+                src instanceof TrayIcon ?
+                    ((TrayIcon)src).getAccessControlContext() :
+                    null;
+    }
+
+    /**
+     * Called from dispatchEvent() under a correct AccessControlContext
+     */
+    private void dispatchEventImpl(final AWTEvent event, final Object src) {
         event.isPosted = true;
-        Object src = event.getSource();
         if (event instanceof ActiveEvent) {
             // This could become the sole method of dispatching in time.
             setCurrentEventAndMostRecentTimeImpl(event);
-
             ((ActiveEvent)event).dispatch();
         } else if (src instanceof Component) {
             ((Component)src).dispatchEvent(event);
diff --git a/jdk/src/share/classes/java/awt/LinearGradientPaint.java b/jdk/src/share/classes/java/awt/LinearGradientPaint.java
index 8d5d727540b..7a60c7d4b6c 100644
--- a/jdk/src/share/classes/java/awt/LinearGradientPaint.java
+++ b/jdk/src/share/classes/java/awt/LinearGradientPaint.java
@@ -57,8 +57,14 @@ import java.beans.ConstructorProperties;
  * </pre>
  *
  * <p>
- * The user may also select what action the {@code LinearGradientPaint}
- * should take when filling color outside the start and end points.
+ * The user may also select what action the {@code LinearGradientPaint} object
+ * takes when it is filling the space outside the start and end points by
+ * setting {@code CycleMethod} to either {@code REFLECTION} or {@code REPEAT}.
+ * The distances between any two colors in any of the reflected or repeated
+ * copies of the gradient are the same as the distance between those same two
+ * colors between the start and end points.
+ * Note that some minor variations in distances may occur due to sampling at
+ * the granularity of a pixel.
  * If no cycle method is specified, {@code NO_CYCLE} will be chosen by
  * default, which means the endpoint colors will be used to fill the
  * remaining area.
diff --git a/jdk/src/share/classes/java/awt/MenuComponent.java b/jdk/src/share/classes/java/awt/MenuComponent.java
index 19d57394a23..d1a5a2577b4 100644
--- a/jdk/src/share/classes/java/awt/MenuComponent.java
+++ b/jdk/src/share/classes/java/awt/MenuComponent.java
@@ -33,6 +33,9 @@ import sun.awt.SunToolkit;
 import sun.awt.AWTAccessor;
 import javax.accessibility.*;
 
+import java.security.AccessControlContext;
+import java.security.AccessController;
+
 /**
  * The abstract class <code>MenuComponent</code> is the superclass
  * of all menu-related components. In this respect, the class
@@ -99,6 +102,23 @@ public abstract class MenuComponent implements java.io.Serializable {
      */
     boolean newEventsOnly = false;
 
+    /*
+     * The menu's AccessControlContext.
+     */
+    private transient volatile AccessControlContext acc =
+            AccessController.getContext();
+
+    /*
+     * Returns the acc this menu component was constructed with.
+     */
+    final AccessControlContext getAccessControlContext() {
+        if (acc == null) {
+            throw new SecurityException(
+                    "MenuComponent is missing AccessControlContext");
+        }
+        return acc;
+    }
+
     /*
      * Internal constants for serialization.
      */
@@ -402,6 +422,9 @@ public abstract class MenuComponent implements java.io.Serializable {
         throws ClassNotFoundException, IOException, HeadlessException
     {
         GraphicsEnvironment.checkHeadless();
+
+        acc = AccessController.getContext();
+
         s.defaultReadObject();
 
         appContext = AppContext.getAppContext();
diff --git a/jdk/src/share/classes/java/awt/MultipleGradientPaint.java b/jdk/src/share/classes/java/awt/MultipleGradientPaint.java
index 598f68f6f03..0dfaf5071ae 100644
--- a/jdk/src/share/classes/java/awt/MultipleGradientPaint.java
+++ b/jdk/src/share/classes/java/awt/MultipleGradientPaint.java
@@ -286,6 +286,10 @@ public abstract class MultipleGradientPaint implements Paint {
     /**
      * Returns a copy of the transform applied to the gradient.
      *
+     * <p>
+     * Note that if no transform is applied to the gradient
+     * when it is created, the identity transform is used.
+     *
      * @return a copy of the transform applied to the gradient
      */
     public final AffineTransform getTransform() {
@@ -293,10 +297,12 @@ public abstract class MultipleGradientPaint implements Paint {
     }
 
     /**
-     * Returns the transparency mode for this Paint object.
+     * Returns the transparency mode for this {@code Paint} object.
      *
-     * @return an integer value representing the transparency mode for
-     * this Paint object
+     * @return {@code OPAQUE} if all colors used by this
+     *         {@code Paint} object are opaque,
+     *         {@code TRANSLUCENT} if at least one of the
+     *         colors used by this {@code Paint} object is not opaque.
      * @see java.awt.Transparency
      */
     public final int getTransparency() {
diff --git a/jdk/src/share/classes/java/awt/RadialGradientPaint.java b/jdk/src/share/classes/java/awt/RadialGradientPaint.java
index d87a3253d46..ee99c32d9de 100644
--- a/jdk/src/share/classes/java/awt/RadialGradientPaint.java
+++ b/jdk/src/share/classes/java/awt/RadialGradientPaint.java
@@ -71,8 +71,24 @@ import java.beans.ConstructorProperties;
  * </pre>
  *
  * <p>
- * The user may also select what action the {@code RadialGradientPaint}
- * should take when filling color outside the bounds of the circle's radius.
+ * The user may also select what action the {@code RadialGradientPaint} object
+ * takes when it is filling the space outside the circle's radius by
+ * setting {@code CycleMethod} to either {@code REFLECTION} or {@code REPEAT}.
+ * The gradient color proportions are equal for any particular line drawn
+ * from the focus point. The following figure shows that the distance AB
+ * is equal to the distance BC, and the distance AD is equal to the distance DE.
+ * <center>
+ * <img src = "doc-files/RadialGradientPaint-3.png">
+ * </center>
+ * If the gradient and graphics rendering transforms are uniformly scaled and
+ * the user sets the focus so that it coincides with the center of the circle,
+ * the gradient color proportions are equal for any line drawn from the center.
+ * The following figure shows the distances AB, BC, AD, and DE. They are all equal.
+ * <center>
+ * <img src = "doc-files/RadialGradientPaint-4.png">
+ * </center>
+ * Note that some minor variations in distances may occur due to sampling at
+ * the granularity of a pixel.
  * If no cycle method is specified, {@code NO_CYCLE} will be chosen by
  * default, which means the the last keyframe color will be used to fill the
  * remaining area.
@@ -604,7 +620,7 @@ public final class RadialGradientPaint extends MultipleGradientPaint {
     }
 
     /**
-     * Returns a copy of the end point of the gradient axis.
+     * Returns a copy of the focus point of the radial gradient.
      *
      * @return a {@code Point2D} object that is a copy of the focus point
      */
diff --git a/jdk/src/share/classes/java/awt/TrayIcon.java b/jdk/src/share/classes/java/awt/TrayIcon.java
index 35a98706e7f..13185bf92fd 100644
--- a/jdk/src/share/classes/java/awt/TrayIcon.java
+++ b/jdk/src/share/classes/java/awt/TrayIcon.java
@@ -40,6 +40,8 @@ import sun.awt.AppContext;
 import sun.awt.SunToolkit;
 import sun.awt.HeadlessToolkit;
 import java.util.EventObject;
+import java.security.AccessControlContext;
+import java.security.AccessController;
 
 /**
  * A <code>TrayIcon</code> object represents a tray icon that can be
@@ -90,6 +92,7 @@ import java.util.EventObject;
  * @author Anton Tarasov
  */
 public class TrayIcon {
+
     private Image image;
     private String tooltip;
     private PopupMenu popup;
@@ -103,6 +106,24 @@ public class TrayIcon {
     transient MouseMotionListener mouseMotionListener;
     transient ActionListener actionListener;
 
+    /*
+     * The tray icon's AccessControlContext.
+     *
+     * Unlike the acc in Component, this field is made final
+     * because TrayIcon is not serializable.
+     */
+    private final AccessControlContext acc = AccessController.getContext();
+
+    /*
+     * Returns the acc this tray icon was constructed with.
+     */
+    final AccessControlContext getAccessControlContext() {
+        if (acc == null) {
+            throw new SecurityException("TrayIcon is missing AccessControlContext");
+        }
+        return acc;
+    }
+
     static {
         Toolkit.loadLibraries();
         if (!GraphicsEnvironment.isHeadless()) {
diff --git a/jdk/src/share/classes/java/awt/doc-files/RadialGradientPaint-3.png b/jdk/src/share/classes/java/awt/doc-files/RadialGradientPaint-3.png
new file mode 100644
index 00000000000..46484fdb766
Binary files /dev/null and b/jdk/src/share/classes/java/awt/doc-files/RadialGradientPaint-3.png differ
diff --git a/jdk/src/share/classes/java/awt/doc-files/RadialGradientPaint-4.png b/jdk/src/share/classes/java/awt/doc-files/RadialGradientPaint-4.png
new file mode 100644
index 00000000000..6ab38c833ce
Binary files /dev/null and b/jdk/src/share/classes/java/awt/doc-files/RadialGradientPaint-4.png differ
diff --git a/jdk/src/share/classes/java/awt/image/PackedColorModel.java b/jdk/src/share/classes/java/awt/image/PackedColorModel.java
index 532f8d2678b..b2ab7ad9c91 100644
--- a/jdk/src/share/classes/java/awt/image/PackedColorModel.java
+++ b/jdk/src/share/classes/java/awt/image/PackedColorModel.java
@@ -343,8 +343,13 @@ public abstract class PackedColorModel extends ColorModel {
         if (bitMasks.length != maskArray.length) {
             return false;
         }
+
+        /* compare 'effective' masks only, i.e. only part of the mask
+         * which fits the capacity of the transfer type.
+         */
+        int maxMask = (int)((1L << DataBuffer.getDataTypeSize(transferType)) - 1);
         for (int i=0; i < bitMasks.length; i++) {
-            if (bitMasks[i] != maskArray[i]) {
+            if ((maxMask & bitMasks[i]) != (maxMask & maskArray[i])) {
                 return false;
             }
         }
diff --git a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java
index d5c24edcb64..64570928afb 100644
--- a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java
+++ b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java
@@ -35,7 +35,7 @@ import sun.reflect.misc.*;
  * is the delegate used by default for classes about
  * which no information is available. The <code>DefaultPersistenceDelegate</code>
  * provides, version resilient, public API-based persistence for
- * classes that follow the JavaBeans conventions without any class specific
+ * classes that follow the JavaBeans&trade; conventions without any class specific
  * configuration.
  * <p>
  * The key assumptions are that the class has a nullary constructor
diff --git a/jdk/src/share/classes/java/beans/DesignMode.java b/jdk/src/share/classes/java/beans/DesignMode.java
index 3080706c5a0..af86266dc3f 100644
--- a/jdk/src/share/classes/java/beans/DesignMode.java
+++ b/jdk/src/share/classes/java/beans/DesignMode.java
@@ -31,7 +31,7 @@ package java.beans;
  * of java.beans.beancontext.BeanContext, in order to propagate to its nested hierarchy
  * of java.beans.beancontext.BeanContextChild instances, the current "designTime" property.
  * <p>
- * The JavaBeans specification defines the notion of design time as is a
+ * The JavaBeans&trade; specification defines the notion of design time as is a
  * mode in which JavaBeans instances should function during their composition
  * and customization in a interactive design, composition or construction tool,
  * as opposed to runtime when the JavaBean is part of an applet, application,
diff --git a/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java b/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java
index a255ccabd8b..7ec03d8fb75 100644
--- a/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyChangeEvent.java
@@ -26,7 +26,7 @@ package java.beans;
 
 /**
  * An "IndexedPropertyChange" event gets delivered whenever a component that
- * conforms to the JavaBeans<TM> specification (a "bean") changes a bound
+ * conforms to the JavaBeans&trade; specification (a "bean") changes a bound
  * indexed property. This class is an extension of <code>PropertyChangeEvent</code>
  * but contains the index of the property that has changed.
  * <P>
diff --git a/jdk/src/share/classes/java/beans/Introspector.java b/jdk/src/share/classes/java/beans/Introspector.java
index 9046da81719..5892df6cb29 100644
--- a/jdk/src/share/classes/java/beans/Introspector.java
+++ b/jdk/src/share/classes/java/beans/Introspector.java
@@ -87,7 +87,7 @@ import sun.reflect.misc.ReflectUtil;
  * <p>
  * For more information about introspection and design patterns, please
  * consult the
- *  <a href="http://java.sun.com/products/javabeans/docs/index.html">JavaBeans specification</a>.
+ *  <a href="http://java.sun.com/products/javabeans/docs/index.html">JavaBeans&trade; specification</a>.
  */
 
 public class Introspector {
@@ -1245,7 +1245,7 @@ public class Introspector {
         try {
             type = ClassFinder.findClass(name, type.getClassLoader());
             // Each customizer should inherit java.awt.Component and implement java.beans.Customizer
-            // according to the section 9.3 of JavaBeans specification
+            // according to the section 9.3 of JavaBeans&trade; specification
             if (Component.class.isAssignableFrom(type) && Customizer.class.isAssignableFrom(type)) {
                 return type;
             }
diff --git a/jdk/src/share/classes/java/beans/VetoableChangeSupport.java b/jdk/src/share/classes/java/beans/VetoableChangeSupport.java
index a8573da5fc9..d26f58a219d 100644
--- a/jdk/src/share/classes/java/beans/VetoableChangeSupport.java
+++ b/jdk/src/share/classes/java/beans/VetoableChangeSupport.java
@@ -474,7 +474,7 @@ public class VetoableChangeSupport implements Serializable {
     /**
      * @serialField children                                   Hashtable
      * @serialField source                                     Object
-     * @serialField propertyChangeSupportSerializedDataVersion int
+     * @serialField vetoableChangeSupportSerializedDataVersion int
      */
     private static final ObjectStreamField[] serialPersistentFields = {
             new ObjectStreamField("children", Hashtable.class),
diff --git a/jdk/src/share/classes/java/beans/package.html b/jdk/src/share/classes/java/beans/package.html
index 576e1f763dc..b1f0a8cf336 100644
--- a/jdk/src/share/classes/java/beans/package.html
+++ b/jdk/src/share/classes/java/beans/package.html
@@ -29,7 +29,7 @@
 
 Contains classes related to developing
 <em>beans</em> -- components
-based on the JavaBeans<sup><font size=-2>TM</font></sup> architecture.
+based on the JavaBeans&trade; architecture.
 A few of the
 classes are used by beans while they run in an application. 
 For example, the event classes are
diff --git a/jdk/src/share/classes/java/dyn/Linkage.java b/jdk/src/share/classes/java/dyn/Linkage.java
deleted file mode 100644
index 4ddda0a1990..00000000000
--- a/jdk/src/share/classes/java/dyn/Linkage.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.dyn;
-
-import java.dyn.MethodHandles.Lookup;
-import java.util.WeakHashMap;
-import sun.dyn.Access;
-import sun.dyn.MethodHandleImpl;
-import sun.dyn.util.VerifyAccess;
-import sun.reflect.Reflection;
-import static sun.dyn.MemberName.newIllegalArgumentException;
-
-/**
- * <em>CLASS WILL BE REMOVED FOR PFD:</em>
- * Static routines for controlling invokedynamic behavior.
- * Replaced by non-static APIs.
- * @author John Rose, JSR 292 EG
- * @deprecated This class will be removed in the Public Final Draft.
- */
-public class Linkage {
-    private static final Access IMPL_TOKEN = Access.getToken();
-
-    private Linkage() {}  // do not instantiate
-
-    /**
-     * <em>METHOD WILL BE REMOVED FOR PFD:</em>
-     * Register a <em>bootstrap method</em> to use when linking dynamic call sites within
-     * a given caller class.
-     * @deprecated Use @{@link BootstrapMethod} annotations instead.
-     */
-    public static
-    void registerBootstrapMethod(Class callerClass, MethodHandle bootstrapMethod) {
-        Class callc = Reflection.getCallerClass(2);
-        if (callc != null && !VerifyAccess.isSamePackage(callerClass, callc))
-            throw new IllegalArgumentException("cannot set bootstrap method on "+callerClass);
-        MethodHandleImpl.registerBootstrap(IMPL_TOKEN, callerClass, bootstrapMethod);
-    }
-
-    /**
-     * <em>METHOD WILL BE REMOVED FOR PFD:</em>
-     * Simplified version of {@code registerBootstrapMethod} for self-registration,
-     * to be called from a static initializer.
-     * @deprecated Use @{@link BootstrapMethod} annotations instead.
-     */
-    public static
-    void registerBootstrapMethod(Class<?> runtime, String name) {
-        Class callerClass = Reflection.getCallerClass(2);
-        registerBootstrapMethodLookup(callerClass, runtime, name);
-    }
-
-    /**
-     * <em>METHOD WILL BE REMOVED FOR PFD:</em>
-     * Simplified version of {@code registerBootstrapMethod} for self-registration,
-     * @deprecated Use @{@link BootstrapMethod} annotations instead.
-     */
-    public static
-    void registerBootstrapMethod(String name) {
-        Class callerClass = Reflection.getCallerClass(2);
-        registerBootstrapMethodLookup(callerClass, callerClass, name);
-    }
-
-    private static
-    void registerBootstrapMethodLookup(Class<?> callerClass, Class<?> runtime, String name) {
-        Lookup lookup = new Lookup(IMPL_TOKEN, callerClass);
-        MethodHandle bootstrapMethod;
-        try {
-            bootstrapMethod = lookup.findStatic(runtime, name, BOOTSTRAP_METHOD_TYPE);
-        } catch (ReflectiveOperationException ex) {
-            throw new IllegalArgumentException("no such bootstrap method in "+runtime+": "+name, ex);
-        }
-        MethodHandleImpl.registerBootstrap(IMPL_TOKEN, callerClass, bootstrapMethod);
-    }
-
-    private static final MethodType BOOTSTRAP_METHOD_TYPE
-            = MethodType.methodType(CallSite.class,
-                                    Class.class, String.class, MethodType.class);
-
-    /**
-     * <em>METHOD WILL BE REMOVED FOR PFD:</em>
-     * Invalidate all <code>invokedynamic</code> call sites everywhere.
-     * @deprecated Use {@linkplain MutableCallSite#setTarget call site target setting},
-     * {@link MutableCallSite#syncAll call site update pushing},
-     * and {@link SwitchPoint#guardWithTest target switching} instead.
-     */
-    public static
-    Object invalidateAll() {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * <em>METHOD WILL BE REMOVED FOR PFD:</em>
-     * Invalidate all {@code invokedynamic} call sites in the bytecodes
-     * of any methods of the given class.
-     * @deprecated Use {@linkplain MutableCallSite#setTarget call site target setting},
-     * {@link MutableCallSite#syncAll call site update pushing},
-     * and {@link SwitchPoint#guardWithTest target switching} instead.
-     */
-    public static
-    Object invalidateCallerClass(Class<?> callerClass) {
-        throw new UnsupportedOperationException();
-    }
-}
diff --git a/jdk/src/share/classes/java/dyn/InvokeDynamicBootstrapError.java b/jdk/src/share/classes/java/lang/BootstrapMethodError.java
similarity index 66%
rename from jdk/src/share/classes/java/dyn/InvokeDynamicBootstrapError.java
rename to jdk/src/share/classes/java/lang/BootstrapMethodError.java
index 76e795e2f0e..0fee75ad33d 100644
--- a/jdk/src/share/classes/java/dyn/InvokeDynamicBootstrapError.java
+++ b/jdk/src/share/classes/java/lang/BootstrapMethodError.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,58 +23,56 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang;
 
 /**
  * Thrown to indicate that an {@code invokedynamic} instruction has
- * failed to find its
- * {@linkplain BootstrapMethod bootstrap method},
- * or the bootstrap method has
- * failed to provide a
- * {@linkplain CallSite call site} with a {@linkplain CallSite#getTarget target}
- * of the correct {@linkplain MethodHandle#type method type}.
+ * failed to find its bootstrap method,
+ * or the bootstrap method has failed to provide a
+ * {@linkplain java.lang.invoke.CallSite call site} with a {@linkplain java.lang.invoke.CallSite#getTarget target}
+ * of the correct {@linkplain java.lang.invoke.MethodHandle#type method type}.
  *
  * @author John Rose, JSR 292 EG
  * @since 1.7
  */
-public class InvokeDynamicBootstrapError extends LinkageError {
+public class BootstrapMethodError extends LinkageError {
     private static final long serialVersionUID = 292L;
 
     /**
-     * Constructs an {@code InvokeDynamicBootstrapError} with no detail message.
+     * Constructs an {@code BootstrapMethodError} with no detail message.
      */
-    public InvokeDynamicBootstrapError() {
+    public BootstrapMethodError() {
         super();
     }
 
     /**
-     * Constructs an {@code InvokeDynamicBootstrapError} with the specified
+     * Constructs an {@code BootstrapMethodError} with the specified
      * detail message.
      *
      * @param s the detail message.
      */
-    public InvokeDynamicBootstrapError(String s) {
+    public BootstrapMethodError(String s) {
         super(s);
     }
 
     /**
-     * Constructs a {@code InvokeDynamicBootstrapError} with the specified
+     * Constructs a {@code BootstrapMethodError} with the specified
      * detail message and cause.
      *
      * @param s the detail message.
      * @param cause the cause, may be {@code null}.
      */
-    public InvokeDynamicBootstrapError(String s, Throwable cause) {
+    public BootstrapMethodError(String s, Throwable cause) {
         super(s, cause);
     }
 
     /**
-     * Constructs a {@code InvokeDynamicBootstrapError} with the specified
+     * Constructs a {@code BootstrapMethodError} with the specified
      * cause.
      *
      * @param cause the cause, may be {@code null}.
      */
-    public InvokeDynamicBootstrapError(Throwable cause) {
+    public BootstrapMethodError(Throwable cause) {
         // cf. Throwable(Throwable cause) constructor.
         super(cause == null ? null : cause.toString());
         initCause(cause);
diff --git a/jdk/src/share/classes/java/dyn/ClassValue.java b/jdk/src/share/classes/java/lang/ClassValue.java
similarity index 94%
rename from jdk/src/share/classes/java/dyn/ClassValue.java
rename to jdk/src/share/classes/java/lang/ClassValue.java
index 597dd951eb6..92c49a92ef2 100644
--- a/jdk/src/share/classes/java/dyn/ClassValue.java
+++ b/jdk/src/share/classes/java/lang/ClassValue.java
@@ -23,12 +23,10 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang;
 
 import java.util.WeakHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import java.lang.reflect.UndeclaredThrowableException;
 
 /**
  * Lazily associate a computed value with (potentially) every type.
@@ -37,10 +35,11 @@ import java.lang.reflect.UndeclaredThrowableException;
  * it can use a {@code ClassValue} to cache information needed to
  * perform the message send quickly, for each class encountered.
  * @author John Rose, JSR 292 EG
+ * @since 1.7
  */
 public abstract class ClassValue<T> {
     /**
-     * Compute the given class's derived value for this {@code ClassValue}.
+     * Computes the given class's derived value for this {@code ClassValue}.
      * <p>
      * This method will be invoked within the first thread that accesses
      * the value with the {@link #get get} method.
@@ -159,13 +158,7 @@ public abstract class ClassValue<T> {
     }
 
     /// Implementation...
-
-    // The hash code for this type is based on the identity of the object,
-    // and is well-dispersed for power-of-two tables.
-    /** @deprecated This override, which is implementation-specific, will be removed for PFD. */
-    public final int hashCode() { return hashCode; }
-    private final int hashCode = HASH_CODES.getAndAdd(0x61c88647);
-    private static final AtomicInteger HASH_CODES = new AtomicInteger();
+    // FIXME: Use a data structure here similar that of ThreadLocal (7030453).
 
     private static final AtomicInteger STORE_BARRIER = new AtomicInteger();
 
diff --git a/jdk/src/share/classes/sun/dyn/AdapterMethodHandle.java b/jdk/src/share/classes/java/lang/invoke/AdapterMethodHandle.java
similarity index 89%
rename from jdk/src/share/classes/sun/dyn/AdapterMethodHandle.java
rename to jdk/src/share/classes/java/lang/invoke/AdapterMethodHandle.java
index 676907c9185..a47b38f8bb3 100644
--- a/jdk/src/share/classes/sun/dyn/AdapterMethodHandle.java
+++ b/jdk/src/share/classes/java/lang/invoke/AdapterMethodHandle.java
@@ -23,20 +23,19 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import sun.dyn.util.VerifyType;
-import sun.dyn.util.Wrapper;
-import java.dyn.*;
+import sun.invoke.util.VerifyType;
+import sun.invoke.util.Wrapper;
 import java.util.Arrays;
-import static sun.dyn.MethodHandleNatives.Constants.*;
-import static sun.dyn.MemberName.newIllegalArgumentException;
+import static java.lang.invoke.MethodHandleNatives.Constants.*;
+import static java.lang.invoke.MethodHandleStatics.*;
 
 /**
  * This method handle performs simple conversion or checking of a single argument.
  * @author jrose
  */
-public class AdapterMethodHandle extends BoundMethodHandle {
+class AdapterMethodHandle extends BoundMethodHandle {
 
     //MethodHandle vmtarget;   // next AMH or BMH in chain or final DMH
     //Object       argument;   // parameter to the conversion if needed
@@ -48,25 +47,21 @@ public class AdapterMethodHandle extends BoundMethodHandle {
                 long conv, Object convArg) {
         super(newType, convArg, newType.parameterSlotDepth(1+convArgPos(conv)));
         this.conversion = convCode(conv);
-        if (MethodHandleNatives.JVM_SUPPORT) {
-            // JVM might update VM-specific bits of conversion (ignore)
-            MethodHandleNatives.init(this, target, convArgPos(conv));
-        }
+        // JVM might update VM-specific bits of conversion (ignore)
+        MethodHandleNatives.init(this, target, convArgPos(conv));
     }
     private AdapterMethodHandle(MethodHandle target, MethodType newType,
                 long conv) {
         this(target, newType, conv, null);
     }
 
-    private static final Access IMPL_TOKEN = Access.getToken();
-
     // TO DO:  When adapting another MH with a null conversion, clone
     // the target and change its type, instead of adding another layer.
 
     /** Can a JVM-level adapter directly implement the proposed
      *  argument conversions, as if by MethodHandles.convertArguments?
      */
-    public static boolean canPairwiseConvert(MethodType newType, MethodType oldType) {
+    static boolean canPairwiseConvert(MethodType newType, MethodType oldType) {
         // same number of args, of course
         int len = newType.parameterCount();
         if (len != oldType.parameterCount())
@@ -92,7 +87,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     /** Can a JVM-level adapter directly implement the proposed
      *  argument conversion, as if by MethodHandles.convertArguments?
      */
-    public static boolean canConvertArgument(Class<?> src, Class<?> dst) {
+    static boolean canConvertArgument(Class<?> src, Class<?> dst) {
         // ? Retool this logic to use RETYPE_ONLY, CHECK_CAST, etc., as opcodes,
         // so we don't need to repeat so much decision making.
         if (VerifyType.isNullConversion(src, dst)) {
@@ -118,16 +113,13 @@ public class AdapterMethodHandle extends BoundMethodHandle {
      * the JVM supports ricochet adapters).
      * The argument conversions allowed are casting, unboxing,
      * integral widening or narrowing, and floating point widening or narrowing.
-     * @param token access check
      * @param newType required call type
      * @param target original method handle
      * @return an adapter to the original handle with the desired new type,
      *          or the original target if the types are already identical
      *          or null if the adaptation cannot be made
      */
-    public static MethodHandle makePairwiseConvert(Access token,
-                MethodType newType, MethodHandle target) {
-        Access.check(token);
+    static MethodHandle makePairwiseConvert(MethodType newType, MethodHandle target) {
         MethodType oldType = target.type();
         if (newType == oldType)  return target;
 
@@ -170,9 +162,9 @@ public class AdapterMethodHandle extends BoundMethodHandle {
             // It parallels canConvertArgument() above.
             if (src.isPrimitive()) {
                 if (dst.isPrimitive()) {
-                    adapter = makePrimCast(token, midType, adapter, i, dst);
+                    adapter = makePrimCast(midType, adapter, i, dst);
                 } else {
-                    adapter = makeBoxArgument(token, midType, adapter, i, dst);
+                    adapter = makeBoxArgument(midType, adapter, i, dst);
                 }
             } else {
                 if (dst.isPrimitive()) {
@@ -182,13 +174,13 @@ public class AdapterMethodHandle extends BoundMethodHandle {
                     // conversions supported by reflect.Method.invoke.
                     // Those conversions require a big nest of if/then/else logic,
                     // which we prefer to make a user responsibility.
-                    adapter = makeUnboxArgument(token, midType, adapter, i, dst);
+                    adapter = makeUnboxArgument(midType, adapter, i, dst);
                 } else {
                     // Simple reference conversion.
                     // Note:  Do not check for a class hierarchy relation
                     // between src and dst.  In all cases a 'null' argument
                     // will pass the cast conversion.
-                    adapter = makeCheckCast(token, midType, adapter, i, dst);
+                    adapter = makeCheckCast(midType, adapter, i, dst);
                 }
             }
             assert(adapter != null);
@@ -196,7 +188,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
         }
         if (adapter.type() != newType) {
             // Only trivial conversions remain.
-            adapter = makeRetypeOnly(IMPL_TOKEN, newType, adapter);
+            adapter = makeRetypeOnly(newType, adapter);
             assert(adapter != null);
             // Actually, that's because there were no non-trivial ones:
             assert(lastConv == -1);
@@ -208,7 +200,6 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     /**
      * Create a JVM-level adapter method handle to permute the arguments
      * of the given method.
-     * @param token access check
      * @param newType required call type
      * @param target original method handle
      * @param argumentMap for each target argument, position of its source in newType
@@ -218,8 +209,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
      * @throws IllegalArgumentException if the adaptation cannot be made
      *          directly by a JVM-level adapter, without help from Java code
      */
-    public static MethodHandle makePermutation(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makePermutation(MethodType newType, MethodHandle target,
                 int[] argumentMap) {
         MethodType oldType = target.type();
         boolean nullPermutation = true;
@@ -234,7 +224,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
         if (argumentMap.length != oldType.parameterCount())
             throw newIllegalArgumentException("bad permutation: "+Arrays.toString(argumentMap));
         if (nullPermutation) {
-            MethodHandle res = makePairwiseConvert(token, newType, target);
+            MethodHandle res = makePairwiseConvert(newType, target);
             // well, that was easy
             if (res == null)
                 throw newIllegalArgumentException("cannot convert pairwise: "+newType);
@@ -435,7 +425,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     }
 
     /** Can a retyping adapter (alone) validly convert the target to newType? */
-    public static boolean canRetypeOnly(MethodType newType, MethodType targetType) {
+    static boolean canRetypeOnly(MethodType newType, MethodType targetType) {
         return canRetype(newType, targetType, false);
     }
     /** Can a retyping adapter (alone) convert the target to newType?
@@ -444,7 +434,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
      *  reference conversions on return.  This last feature requires that the
      *  caller be trusted, and perform explicit cast conversions on return values.
      */
-    public static boolean canRetypeRaw(MethodType newType, MethodType targetType) {
+    static boolean canRetypeRaw(MethodType newType, MethodType targetType) {
         return canRetype(newType, targetType, true);
     }
     static boolean canRetype(MethodType newType, MethodType targetType, boolean raw) {
@@ -459,17 +449,13 @@ public class AdapterMethodHandle extends BoundMethodHandle {
      *  Allows unchecked argument conversions pairwise, if they are safe.
      *  Returns null if not possible.
      */
-    public static MethodHandle makeRetypeOnly(Access token,
-                MethodType newType, MethodHandle target) {
-        return makeRetype(token, newType, target, false);
+    static MethodHandle makeRetypeOnly(MethodType newType, MethodHandle target) {
+        return makeRetype(newType, target, false);
     }
-    public static MethodHandle makeRetypeRaw(Access token,
-                MethodType newType, MethodHandle target) {
-        return makeRetype(token, newType, target, true);
+    static MethodHandle makeRetypeRaw(MethodType newType, MethodHandle target) {
+        return makeRetype(newType, target, true);
     }
-    static MethodHandle makeRetype(Access token,
-                MethodType newType, MethodHandle target, boolean raw) {
-        Access.check(token);
+    static MethodHandle makeRetype(MethodType newType, MethodHandle target, boolean raw) {
         MethodType oldType = target.type();
         if (oldType == newType)  return target;
         if (!canRetype(newType, oldType, raw))
@@ -478,9 +464,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
         return new AdapterMethodHandle(target, newType, makeConv(raw ? OP_RETYPE_RAW : OP_RETYPE_ONLY));
     }
 
-    static MethodHandle makeVarargsCollector(Access token,
-                MethodHandle target, Class<?> arrayType) {
-        Access.check(token);
+    static MethodHandle makeVarargsCollector(MethodHandle target, Class<?> arrayType) {
         return new AsVarargsCollector(target, arrayType);
     }
 
@@ -526,6 +510,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
             return collector.asType(newType);
         }
 
+        @Override
         public MethodHandle asVarargsCollector(Class<?> arrayType) {
             MethodType type = this.type();
             if (type.parameterType(type.parameterCount()-1) == arrayType)
@@ -537,7 +522,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     /** Can a checkcast adapter validly convert the target to newType?
      *  The JVM supports all kind of reference casts, even silly ones.
      */
-    public static boolean canCheckCast(MethodType newType, MethodType targetType,
+    static boolean canCheckCast(MethodType newType, MethodType targetType,
                 int arg, Class<?> castType) {
         if (!convOpSupported(OP_CHECK_CAST))  return false;
         Class<?> src = newType.parameterType(arg);
@@ -549,7 +534,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
         return (diff == arg+1);  // arg is sole non-trivial diff
     }
     /** Can an primitive conversion adapter validly convert src to dst? */
-    public static boolean canCheckCast(Class<?> src, Class<?> dst) {
+    static boolean canCheckCast(Class<?> src, Class<?> dst) {
         return (!src.isPrimitive() && !dst.isPrimitive());
     }
 
@@ -558,10 +543,8 @@ public class AdapterMethodHandle extends BoundMethodHandle {
      *  with a null conversion to the corresponding target parameter.
      *  Return null if this cannot be done.
      */
-    public static MethodHandle makeCheckCast(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makeCheckCast(MethodType newType, MethodHandle target,
                 int arg, Class<?> castType) {
-        Access.check(token);
         if (!canCheckCast(newType, target.type(), arg, castType))
             return null;
         long conv = makeConv(OP_CHECK_CAST, arg, T_OBJECT, T_OBJECT);
@@ -572,7 +555,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
      *  The JVM currently supports all conversions except those between
      *  floating and integral types.
      */
-    public static boolean canPrimCast(MethodType newType, MethodType targetType,
+    static boolean canPrimCast(MethodType newType, MethodType targetType,
                 int arg, Class<?> convType) {
         if (!convOpSupported(OP_PRIM_TO_PRIM))  return false;
         Class<?> src = newType.parameterType(arg);
@@ -584,7 +567,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
         return (diff == arg+1);  // arg is sole non-trivial diff
     }
     /** Can an primitive conversion adapter validly convert src to dst? */
-    public static boolean canPrimCast(Class<?> src, Class<?> dst) {
+    static boolean canPrimCast(Class<?> src, Class<?> dst) {
         if (src == dst || !src.isPrimitive() || !dst.isPrimitive()) {
             return false;
         } else if (Wrapper.forPrimitiveType(dst).isFloating()) {
@@ -604,10 +587,8 @@ public class AdapterMethodHandle extends BoundMethodHandle {
      *  with a null conversion to the corresponding target parameter.
      *  Return null if this cannot be done.
      */
-    public static MethodHandle makePrimCast(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makePrimCast(MethodType newType, MethodHandle target,
                 int arg, Class<?> convType) {
-        Access.check(token);
         MethodType oldType = target.type();
         if (!canPrimCast(newType, oldType, arg, convType))
             return null;
@@ -620,7 +601,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
      *  The JVM currently supports all kinds of casting and unboxing.
      *  The convType is the unboxed type; it can be either a primitive or wrapper.
      */
-    public static boolean canUnboxArgument(MethodType newType, MethodType targetType,
+    static boolean canUnboxArgument(MethodType newType, MethodType targetType,
                 int arg, Class<?> convType) {
         if (!convOpSupported(OP_REF_TO_PRIM))  return false;
         Class<?> src = newType.parameterType(arg);
@@ -635,15 +616,14 @@ public class AdapterMethodHandle extends BoundMethodHandle {
         return (diff == arg+1);  // arg is sole non-trivial diff
     }
     /** Can an primitive unboxing adapter validly convert src to dst? */
-    public static boolean canUnboxArgument(Class<?> src, Class<?> dst) {
+    static boolean canUnboxArgument(Class<?> src, Class<?> dst) {
         return (!src.isPrimitive() && Wrapper.asPrimitiveType(dst).isPrimitive());
     }
 
     /** Factory method:  Unbox the given argument.
      *  Return null if this cannot be done.
      */
-    public static MethodHandle makeUnboxArgument(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makeUnboxArgument(MethodType newType, MethodHandle target,
                 int arg, Class<?> convType) {
         MethodType oldType = target.type();
         Class<?> src = newType.parameterType(arg);
@@ -659,11 +639,11 @@ public class AdapterMethodHandle extends BoundMethodHandle {
         MethodHandle adapter = new AdapterMethodHandle(target, castDone, conv, boxType);
         if (castDone == newType)
             return adapter;
-        return makeCheckCast(token, newType, adapter, arg, boxType);
+        return makeCheckCast(newType, adapter, arg, boxType);
     }
 
     /** Can an primitive boxing adapter validly convert src to dst? */
-    public static boolean canBoxArgument(Class<?> src, Class<?> dst) {
+    static boolean canBoxArgument(Class<?> src, Class<?> dst) {
         if (!convOpSupported(OP_PRIM_TO_REF))  return false;
         throw new UnsupportedOperationException("NYI");
     }
@@ -671,15 +651,14 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     /** Factory method:  Unbox the given argument.
      *  Return null if this cannot be done.
      */
-    public static MethodHandle makeBoxArgument(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makeBoxArgument(MethodType newType, MethodHandle target,
                 int arg, Class<?> convType) {
         // this is difficult to do in the JVM because it must GC
         return null;
     }
 
     /** Can an adapter simply drop arguments to convert the target to newType? */
-    public static boolean canDropArguments(MethodType newType, MethodType targetType,
+    static boolean canDropArguments(MethodType newType, MethodType targetType,
                 int dropArgPos, int dropArgCount) {
         if (dropArgCount == 0)
             return canRetypeOnly(newType, targetType);
@@ -706,12 +685,10 @@ public class AdapterMethodHandle extends BoundMethodHandle {
      *  Allow unchecked retyping of remaining arguments, pairwise.
      *  Return null if this is not possible.
      */
-    public static MethodHandle makeDropArguments(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makeDropArguments(MethodType newType, MethodHandle target,
                 int dropArgPos, int dropArgCount) {
-        Access.check(token);
         if (dropArgCount == 0)
-            return makeRetypeOnly(IMPL_TOKEN, newType, target);
+            return makeRetypeOnly(newType, target);
         if (!canDropArguments(newType, target.type(), dropArgPos, dropArgCount))
             return null;
         // in  arglist: [0: ...keep1 | dpos: drop... | dpos+dcount: keep2... ]
@@ -727,7 +704,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     }
 
     /** Can an adapter duplicate an argument to convert the target to newType? */
-    public static boolean canDupArguments(MethodType newType, MethodType targetType,
+    static boolean canDupArguments(MethodType newType, MethodType targetType,
                 int dupArgPos, int dupArgCount) {
         if (!convOpSupported(OP_DUP_ARGS))  return false;
         if (diffReturnTypes(newType, targetType, false) != 0)
@@ -749,10 +726,8 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     /** Factory method:  Duplicate the selected argument.
      *  Return null if this is not possible.
      */
-    public static MethodHandle makeDupArguments(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makeDupArguments(MethodType newType, MethodHandle target,
                 int dupArgPos, int dupArgCount) {
-        Access.check(token);
         if (!canDupArguments(newType, target.type(), dupArgPos, dupArgCount))
             return null;
         if (dupArgCount == 0)
@@ -769,7 +744,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     }
 
     /** Can an adapter swap two arguments to convert the target to newType? */
-    public static boolean canSwapArguments(MethodType newType, MethodType targetType,
+    static boolean canSwapArguments(MethodType newType, MethodType targetType,
                 int swapArg1, int swapArg2) {
         if (!convOpSupported(OP_SWAP_ARGS))  return false;
         if (diffReturnTypes(newType, targetType, false) != 0)
@@ -796,10 +771,8 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     /** Factory method:  Swap the selected arguments.
      *  Return null if this is not possible.
      */
-    public static MethodHandle makeSwapArguments(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makeSwapArguments(MethodType newType, MethodHandle target,
                 int swapArg1, int swapArg2) {
-        Access.check(token);
         if (swapArg1 == swapArg2)
             return target;
         if (swapArg1 > swapArg2) { int t = swapArg1; swapArg1 = swapArg2; swapArg2 = t; }
@@ -829,7 +802,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     final static int MAX_ARG_ROTATION = 1;
 
     /** Can an adapter rotate arguments to convert the target to newType? */
-    public static boolean canRotateArguments(MethodType newType, MethodType targetType,
+    static boolean canRotateArguments(MethodType newType, MethodType targetType,
                 int firstArg, int argCount, int rotateBy) {
         if (!convOpSupported(OP_ROT_ARGS))  return false;
         if (argCount <= 2)  return false;  // must be a swap, not a rotate
@@ -861,10 +834,8 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     /** Factory method:  Rotate the selected argument range.
      *  Return null if this is not possible.
      */
-    public static MethodHandle makeRotateArguments(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makeRotateArguments(MethodType newType, MethodHandle target,
                 int firstArg, int argCount, int rotateBy) {
-        Access.check(token);
         rotateBy = positiveRotation(argCount, rotateBy);
         if (!canRotateArguments(newType, target.type(), firstArg, argCount, rotateBy))
             return null;
@@ -904,7 +875,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
     }
 
     /** Can an adapter spread an argument to convert the target to newType? */
-    public static boolean canSpreadArguments(MethodType newType, MethodType targetType,
+    static boolean canSpreadArguments(MethodType newType, MethodType targetType,
                 Class<?> spreadArgType, int spreadArgPos, int spreadArgCount) {
         if (!convOpSupported(OP_SPREAD_ARGS))  return false;
         if (diffReturnTypes(newType, targetType, false) != 0)
@@ -937,10 +908,8 @@ public class AdapterMethodHandle extends BoundMethodHandle {
 
 
     /** Factory method:  Spread selected argument. */
-    public static MethodHandle makeSpreadArguments(Access token,
-                MethodType newType, MethodHandle target,
+    static MethodHandle makeSpreadArguments(MethodType newType, MethodHandle target,
                 Class<?> spreadArgType, int spreadArgPos, int spreadArgCount) {
-        Access.check(token);
         MethodType targetType = target.type();
         if (!canSpreadArguments(newType, targetType, spreadArgType, spreadArgPos, spreadArgCount))
             return null;
@@ -962,7 +931,7 @@ public class AdapterMethodHandle extends BoundMethodHandle {
 
     @Override
     public String toString() {
-        return MethodHandleImpl.getNameString(IMPL_TOKEN, nonAdapter((MethodHandle)vmtarget), this);
+        return getNameString(nonAdapter((MethodHandle)vmtarget), this);
     }
 
     private static MethodHandle nonAdapter(MethodHandle mh) {
diff --git a/jdk/src/share/classes/sun/dyn/BoundMethodHandle.java b/jdk/src/share/classes/java/lang/invoke/BoundMethodHandle.java
similarity index 80%
rename from jdk/src/share/classes/sun/dyn/BoundMethodHandle.java
rename to jdk/src/share/classes/java/lang/invoke/BoundMethodHandle.java
index 0fab63f7c77..d0d78895e77 100644
--- a/jdk/src/share/classes/sun/dyn/BoundMethodHandle.java
+++ b/jdk/src/share/classes/java/lang/invoke/BoundMethodHandle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,15 +23,11 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import sun.dyn.util.VerifyType;
-import sun.dyn.util.Wrapper;
-import java.dyn.*;
-import java.util.List;
-import sun.dyn.MethodHandleNatives.Constants;
-import static sun.dyn.MethodHandleImpl.IMPL_LOOKUP;
-import static sun.dyn.MemberName.newIllegalArgumentException;
+import sun.invoke.util.VerifyType;
+import sun.invoke.util.Wrapper;
+import static java.lang.invoke.MethodHandleStatics.*;
 
 /**
  * The flavor of method handle which emulates an invoke instruction
@@ -39,37 +35,29 @@ import static sun.dyn.MemberName.newIllegalArgumentException;
  * when the handle is created, not when it is invoked.
  * @author jrose
  */
-public class BoundMethodHandle extends MethodHandle {
+class BoundMethodHandle extends MethodHandle {
     //MethodHandle vmtarget;           // next BMH or final DMH or methodOop
     private final Object argument;     // argument to insert
     private final int    vmargslot;    // position at which it is inserted
 
-    private static final Access IMPL_TOKEN = Access.getToken();
-    private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory(IMPL_TOKEN);
-
     // Constructors in this class *must* be package scoped or private.
 
     /** Bind a direct MH to its receiver (or first ref. argument).
      *  The JVM will pre-dispatch the MH if it is not already static.
      */
-    BoundMethodHandle(DirectMethodHandle mh, Object argument) {
-        super(Access.TOKEN, mh.type().dropParameterTypes(0, 1));
+    /*non-public*/ BoundMethodHandle(DirectMethodHandle mh, Object argument) {
+        super(mh.type().dropParameterTypes(0, 1));
         // check the type now, once for all:
         this.argument = checkReferenceArgument(argument, mh, 0);
         this.vmargslot = this.type().parameterSlotCount();
-        if (MethodHandleNatives.JVM_SUPPORT) {
-            this.vmtarget = null;  // maybe updated by JVM
-            MethodHandleNatives.init(this, mh, 0);
-        } else {
-            this.vmtarget = mh;
-        }
+        initTarget(mh, 0);
     }
 
     /** Insert an argument into an arbitrary method handle.
      *  If argnum is zero, inserts the first argument, etc.
      *  The argument type must be a reference.
      */
-    BoundMethodHandle(MethodHandle mh, Object argument, int argnum) {
+    /*non-public*/ BoundMethodHandle(MethodHandle mh, Object argument, int argnum) {
         this(mh.type().dropParameterTypes(argnum, argnum+1),
              mh, argument, argnum);
     }
@@ -77,8 +65,8 @@ public class BoundMethodHandle extends MethodHandle {
     /** Insert an argument into an arbitrary method handle.
      *  If argnum is zero, inserts the first argument, etc.
      */
-    BoundMethodHandle(MethodType type, MethodHandle mh, Object argument, int argnum) {
-        super(Access.TOKEN, type);
+    /*non-public*/ BoundMethodHandle(MethodType type, MethodHandle mh, Object argument, int argnum) {
+        super(type);
         if (mh.type().parameterType(argnum).isPrimitive())
             this.argument = bindPrimitiveArgument(argument, mh, argnum);
         else {
@@ -89,18 +77,14 @@ public class BoundMethodHandle extends MethodHandle {
     }
 
     private void initTarget(MethodHandle mh, int argnum) {
-        if (MethodHandleNatives.JVM_SUPPORT) {
-            this.vmtarget = null; // maybe updated by JVM
-            MethodHandleNatives.init(this, mh, argnum);
-        } else {
-            this.vmtarget = mh;
-        }
+        //this.vmtarget = mh;  // maybe updated by JVM
+        MethodHandleNatives.init(this, mh, argnum);
     }
 
     /** For the AdapterMethodHandle subclass.
      */
-    BoundMethodHandle(MethodType type, Object argument, int vmargslot) {
-        super(Access.TOKEN, type);
+    /*non-public*/ BoundMethodHandle(MethodType type, Object argument, int vmargslot) {
+        super(type);
         this.argument = argument;
         this.vmargslot = vmargslot;
         assert(this instanceof AdapterMethodHandle);
@@ -112,8 +96,8 @@ public class BoundMethodHandle extends MethodHandle {
      *  same as {@code entryPoint},  except that the first argument
      *  type will be dropped.
      */
-    protected BoundMethodHandle(Access token, MethodHandle entryPoint) {
-        super(token, entryPoint.type().dropParameterTypes(0, 1));
+    /*non-public*/ BoundMethodHandle(MethodHandle entryPoint) {
+        super(entryPoint.type().dropParameterTypes(0, 1));
         this.argument = this; // kludge; get rid of
         this.vmargslot = this.type().parameterSlotDepth(0);
         initTarget(entryPoint, 0);
@@ -172,7 +156,7 @@ public class BoundMethodHandle extends MethodHandle {
 
     @Override
     public String toString() {
-        return MethodHandleImpl.addTypeString(baseName(), this);
+        return addTypeString(baseName(), this);
     }
 
     /** Component of toString() before the type string. */
diff --git a/jdk/src/share/classes/java/dyn/CallSite.java b/jdk/src/share/classes/java/lang/invoke/CallSite.java
similarity index 75%
rename from jdk/src/share/classes/java/dyn/CallSite.java
rename to jdk/src/share/classes/java/lang/invoke/CallSite.java
index 42af08a729b..b2da146d261 100644
--- a/jdk/src/share/classes/java/dyn/CallSite.java
+++ b/jdk/src/share/classes/java/lang/invoke/CallSite.java
@@ -23,12 +23,12 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang.invoke;
 
-import sun.dyn.*;
-import sun.dyn.empty.Empty;
+import sun.invoke.empty.Empty;
 import sun.misc.Unsafe;
-import java.util.Collection;
+import static java.lang.invoke.MethodHandleStatics.*;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
  * A {@code CallSite} is a holder for a variable {@link MethodHandle},
@@ -85,7 +85,6 @@ private static CallSite bootstrapDynamic(MethodHandles.Lookup caller, String nam
  */
 abstract
 public class CallSite {
-    private static final Access IMPL_TOKEN = Access.getToken();
     static { MethodHandleImpl.initStatics(); }
 
     // Fields used only by the JVM.  Do not use or change.
@@ -96,9 +95,6 @@ public class CallSite {
     /*package-private*/
     MethodHandle target;
 
-    // Remove this field for PFD and delete deprecated methods:
-    private MemberName calleeNameRemoveForPFD;
-
     /**
      * Make a blank call site object with the given method type.
      * An initial target method is supplied which will throw
@@ -111,7 +107,7 @@ public class CallSite {
      */
     /*package-private*/
     CallSite(MethodType type) {
-        target = MethodHandles.invokers(type).uninitializedCallSite();
+        target = type.invokers().uninitializedCallSite();
     }
 
     /**
@@ -145,7 +141,7 @@ public class CallSite {
                            int        callerBCI) {
         if (this.vmmethod != null) {
             // FIXME
-            throw new InvokeDynamicBootstrapError("call site has already been linked to an invokedynamic instruction");
+            throw new BootstrapMethodError("call site has already been linked to an invokedynamic instruction");
         }
         if (!this.type().equals(type)) {
             throw wrongTargetType(target, type);
@@ -202,7 +198,7 @@ public class CallSite {
     }
 
     /**
-     * Produce a method handle equivalent to an invokedynamic instruction
+     * Produces a method handle equivalent to an invokedynamic instruction
      * which has been linked to this call site.
      * <p>
      * This method is equivalent to the following code:
@@ -218,7 +214,7 @@ public class CallSite {
     public abstract MethodHandle dynamicInvoker();
 
     /*non-public*/ MethodHandle makeDynamicInvoker() {
-        MethodHandle getTarget = MethodHandleImpl.bindReceiver(IMPL_TOKEN, GET_TARGET, this);
+        MethodHandle getTarget = MethodHandleImpl.bindReceiver(GET_TARGET, this);
         MethodHandle invoker = MethodHandles.exactInvoker(this.type());
         return MethodHandles.foldArguments(invoker, getTarget);
     }
@@ -226,7 +222,7 @@ public class CallSite {
     private static final MethodHandle GET_TARGET;
     static {
         try {
-            GET_TARGET = MethodHandles.Lookup.IMPL_LOOKUP.
+            GET_TARGET = IMPL_LOOKUP.
                 findVirtual(CallSite.class, "getTarget", MethodType.methodType(MethodHandle.class));
         } catch (ReflectiveOperationException ignore) {
             throw new InternalError();
@@ -252,7 +248,6 @@ public class CallSite {
     /*package-private*/
     void setTargetNormal(MethodHandle newTarget) {
         target = newTarget;
-        //CallSiteImpl.setCallSiteTarget(IMPL_TOKEN, this, newTarget);
     }
     /*package-private*/
     MethodHandle getTargetVolatile() {
@@ -261,6 +256,68 @@ public class CallSite {
     /*package-private*/
     void setTargetVolatile(MethodHandle newTarget) {
         unsafe.putObjectVolatile(this, TARGET_OFFSET, newTarget);
-        //CallSiteImpl.setCallSiteTarget(IMPL_TOKEN, this, newTarget);
+    }
+
+    // this implements the upcall from the JVM, MethodHandleNatives.makeDynamicCallSite:
+    static CallSite makeSite(MethodHandle bootstrapMethod,
+                             // Callee information:
+                             String name, MethodType type,
+                             // Extra arguments for BSM, if any:
+                             Object info,
+                             // Caller information:
+                             MemberName callerMethod, int callerBCI) {
+        Class<?> callerClass = callerMethod.getDeclaringClass();
+        Object caller = IMPL_LOOKUP.in(callerClass);
+        CallSite site;
+        try {
+            Object binding;
+            info = maybeReBox(info);
+            if (info == null) {
+                binding = bootstrapMethod.invokeGeneric(caller, name, type);
+            } else if (!info.getClass().isArray()) {
+                binding = bootstrapMethod.invokeGeneric(caller, name, type, info);
+            } else {
+                Object[] argv = (Object[]) info;
+                maybeReBoxElements(argv);
+                if (3 + argv.length > 255)
+                    throw new BootstrapMethodError("too many bootstrap method arguments");
+                MethodType bsmType = bootstrapMethod.type();
+                if (bsmType.parameterCount() == 4 && bsmType.parameterType(3) == Object[].class)
+                    binding = bootstrapMethod.invokeGeneric(caller, name, type, argv);
+                else
+                    binding = MethodHandles.spreadInvoker(bsmType, 3)
+                        .invokeGeneric(bootstrapMethod, caller, name, type, argv);
+            }
+            //System.out.println("BSM for "+name+type+" => "+binding);
+            if (binding instanceof CallSite) {
+                site = (CallSite) binding;
+            }  else {
+                throw new ClassCastException("bootstrap method failed to produce a CallSite");
+            }
+            assert(site.getTarget() != null);
+            assert(site.getTarget().type().equals(type));
+        } catch (Throwable ex) {
+            BootstrapMethodError bex;
+            if (ex instanceof BootstrapMethodError)
+                bex = (BootstrapMethodError) ex;
+            else
+                bex = new BootstrapMethodError("call site initialization exception", ex);
+            throw bex;
+        }
+        return site;
+    }
+
+    private static Object maybeReBox(Object x) {
+        if (x instanceof Integer) {
+            int xi = (int) x;
+            if (xi == (byte) xi)
+                x = xi;  // must rebox; see JLS 5.1.7
+        }
+        return x;
+    }
+    private static void maybeReBoxElements(Object[] xa) {
+        for (int i = 0; i < xa.length; i++) {
+            xa[i] = maybeReBox(xa[i]);
+        }
     }
 }
diff --git a/jdk/src/share/classes/java/dyn/ConstantCallSite.java b/jdk/src/share/classes/java/lang/invoke/ConstantCallSite.java
similarity index 99%
rename from jdk/src/share/classes/java/dyn/ConstantCallSite.java
rename to jdk/src/share/classes/java/lang/invoke/ConstantCallSite.java
index 50240a0f50f..e182c54aaa9 100644
--- a/jdk/src/share/classes/java/dyn/ConstantCallSite.java
+++ b/jdk/src/share/classes/java/lang/invoke/ConstantCallSite.java
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang.invoke;
 
 /**
  * A {@code ConstantCallSite} is a {@link CallSite} whose target is permanent, and can never be changed.
diff --git a/jdk/src/share/classes/sun/dyn/DirectMethodHandle.java b/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java
similarity index 91%
rename from jdk/src/share/classes/sun/dyn/DirectMethodHandle.java
rename to jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java
index b43f353bbd6..13bedb17859 100644
--- a/jdk/src/share/classes/sun/dyn/DirectMethodHandle.java
+++ b/jdk/src/share/classes/java/lang/invoke/DirectMethodHandle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,9 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
-import static sun.dyn.MethodHandleNatives.Constants.*;
+import static java.lang.invoke.MethodHandleNatives.Constants.*;
 
 /**
  * The flavor of method handle which emulates invokespecial or invokestatic.
@@ -39,7 +38,7 @@ class DirectMethodHandle extends MethodHandle {
 
     // Constructors in this class *must* be package scoped or private.
     DirectMethodHandle(MethodType mtype, MemberName m, boolean doDispatch, Class<?> lookupClass) {
-        super(Access.TOKEN, mtype);
+        super(mtype);
 
         assert(m.isMethod() || !doDispatch && m.isConstructor());
         if (!m.isResolved())
diff --git a/jdk/src/share/classes/sun/dyn/FilterGeneric.java b/jdk/src/share/classes/java/lang/invoke/FilterGeneric.java
similarity index 99%
rename from jdk/src/share/classes/sun/dyn/FilterGeneric.java
rename to jdk/src/share/classes/java/lang/invoke/FilterGeneric.java
index e77d742a11e..6c3395002f5 100644
--- a/jdk/src/share/classes/sun/dyn/FilterGeneric.java
+++ b/jdk/src/share/classes/java/lang/invoke/FilterGeneric.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,11 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
 import java.lang.reflect.*;
-import static sun.dyn.MemberName.newIllegalArgumentException;
+import static java.lang.invoke.MethodHandleStatics.*;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
  * These adapters apply arbitrary conversions to arguments
@@ -123,7 +123,7 @@ class FilterGeneric {
         MethodType entryType = entryType(kind, pos, filterType, targetType);
         if (entryType.generic() != entryType)
             throw newIllegalArgumentException("must be generic: "+entryType);
-        MethodTypeImpl form = MethodTypeImpl.of(entryType);
+        MethodTypeForm form = entryType.form();
         FilterGeneric filterGen = form.filterGeneric;
         if (filterGen == null)
             form.filterGeneric = filterGen = new FilterGeneric(entryType);
@@ -186,7 +186,7 @@ class FilterGeneric {
             // see if it has the required invoke method
             MethodHandle entryPoint = null;
             try {
-                entryPoint = MethodHandleImpl.IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
+                entryPoint = IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
             } catch (ReflectiveOperationException ex) {
             }
             if (entryPoint == null)  continue;
@@ -231,7 +231,7 @@ class FilterGeneric {
 
         @Override
         public String toString() {
-            return MethodHandleImpl.addTypeString(target, this);
+            return addTypeString(target, this);
         }
 
         protected boolean isPrototype() { return target == null; }
@@ -246,7 +246,7 @@ class FilterGeneric {
 
         protected Adapter(MethodHandle entryPoint,
                           MethodHandle filter, MethodHandle target) {
-            super(Access.TOKEN, entryPoint);
+            super(entryPoint);
             this.filter = filter;
             this.target = target;
         }
@@ -256,7 +256,7 @@ class FilterGeneric {
                 MethodHandle filter, MethodHandle target);
         // { return new ThisType(entryPoint, filter, target); }
 
-        static private final String CLASS_PREFIX; // "sun.dyn.FilterGeneric$"
+        static private final String CLASS_PREFIX; // "java.lang.invoke.FilterGeneric$"
         static {
             String aname = Adapter.class.getName();
             String sname = Adapter.class.getSimpleName();
diff --git a/jdk/src/share/classes/sun/dyn/FilterOneArgument.java b/jdk/src/share/classes/java/lang/invoke/FilterOneArgument.java
similarity index 86%
rename from jdk/src/share/classes/sun/dyn/FilterOneArgument.java
rename to jdk/src/share/classes/java/lang/invoke/FilterOneArgument.java
index 86c722f3c0a..64a9f072797 100644
--- a/jdk/src/share/classes/sun/dyn/FilterOneArgument.java
+++ b/jdk/src/share/classes/java/lang/invoke/FilterOneArgument.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,10 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
-import static sun.dyn.MemberName.uncaughtException;
+import static java.lang.invoke.MethodHandleStatics.*;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
  * Unary function composition, useful for many small plumbing jobs.
@@ -36,7 +36,7 @@ import static sun.dyn.MemberName.uncaughtException;
  * final method type is the responsibility of a JVM-level adapter.
  * @author jrose
  */
-public class FilterOneArgument extends BoundMethodHandle {
+class FilterOneArgument extends BoundMethodHandle {
     protected final MethodHandle filter;  // Object -> Object
     protected final MethodHandle target;  // Object -> Object
 
@@ -54,15 +54,15 @@ public class FilterOneArgument extends BoundMethodHandle {
     static {
         try {
             INVOKE =
-                MethodHandleImpl.IMPL_LOOKUP.findVirtual(FilterOneArgument.class, "invoke",
-                                                         MethodType.genericMethodType(1));
+                IMPL_LOOKUP.findVirtual(FilterOneArgument.class, "invoke",
+                                        MethodType.genericMethodType(1));
         } catch (ReflectiveOperationException ex) {
             throw uncaughtException(ex);
         }
     }
 
     protected FilterOneArgument(MethodHandle filter, MethodHandle target) {
-        super(Access.TOKEN, INVOKE);
+        super(INVOKE);
         this.filter = filter;
         this.target = target;
     }
diff --git a/jdk/src/share/classes/sun/dyn/FromGeneric.java b/jdk/src/share/classes/java/lang/invoke/FromGeneric.java
similarity index 97%
rename from jdk/src/share/classes/sun/dyn/FromGeneric.java
rename to jdk/src/share/classes/java/lang/invoke/FromGeneric.java
index b996a6b3ead..1c0523a4a36 100644
--- a/jdk/src/share/classes/sun/dyn/FromGeneric.java
+++ b/jdk/src/share/classes/java/lang/invoke/FromGeneric.java
@@ -23,12 +23,13 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
+import sun.invoke.util.ValueConversions;
+import sun.invoke.util.Wrapper;
 import java.lang.reflect.*;
-import sun.dyn.util.*;
-import static sun.dyn.MethodTypeImpl.invokers;
+import static java.lang.invoke.MethodHandleStatics.*;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
  * Adapters which mediate between incoming calls which are generic
@@ -82,8 +83,8 @@ class FromGeneric {
         }
 
         // outgoing primitive arguments will be wrapped; unwrap them
-        MethodType primsAsObj = MethodTypeImpl.of(targetType).primArgsAsBoxes();
-        MethodType objArgsRawRet = MethodTypeImpl.of(primsAsObj).primsAsInts();
+        MethodType primsAsObj = targetType.form().primArgsAsBoxes();
+        MethodType objArgsRawRet = primsAsObj.form().primsAsInts();
         if (objArgsRawRet != targetType)
             ad = findAdapter(internalType0 = objArgsRawRet);
         if (ad == null) {
@@ -129,16 +130,16 @@ class FromGeneric {
             MethodType targetType, MethodType internalType) {
         // All the adapters we have here have reference-untyped internal calls.
         assert(internalType == internalType.erase());
-        MethodHandle invoker = invokers(targetType).exactInvoker();
+        MethodHandle invoker = targetType.invokers().exactInvoker();
         // cast all narrow reference types, unbox all primitive arguments:
         MethodType fixArgsType = internalType.changeReturnType(targetType.returnType());
-        MethodHandle fixArgs = AdapterMethodHandle.convertArguments(Access.TOKEN,
+        MethodHandle fixArgs = MethodHandleImpl.convertArguments(
                                  invoker, Invokers.invokerType(fixArgsType),
                                  invoker.type(), null);
         if (fixArgs == null)
             throw new InternalError("bad fixArgs");
         // reinterpret the calling sequence as raw:
-        MethodHandle retyper = AdapterMethodHandle.makeRetypeRaw(Access.TOKEN,
+        MethodHandle retyper = AdapterMethodHandle.makeRetypeRaw(
                                         Invokers.invokerType(internalType), fixArgs);
         if (retyper == null)
             throw new InternalError("bad retyper");
@@ -171,7 +172,7 @@ class FromGeneric {
 
     /** Return the adapter information for this type's erasure. */
     static FromGeneric of(MethodType type) {
-        MethodTypeImpl form = MethodTypeImpl.of(type);
+        MethodTypeForm form = type.form();
         FromGeneric fromGen = form.fromGeneric;
         if (fromGen == null)
             form.fromGeneric = fromGen = new FromGeneric(form.erasedType());
@@ -185,7 +186,7 @@ class FromGeneric {
     /* Create an adapter that handles spreading calls for the given type. */
     static Adapter findAdapter(MethodType internalType) {
         MethodType entryType = internalType.generic();
-        MethodTypeImpl form = MethodTypeImpl.of(internalType);
+        MethodTypeForm form = internalType.form();
         Class<?> rtype = internalType.returnType();
         int argc = form.parameterCount();
         int lac = form.longPrimitiveParameterCount();
@@ -203,7 +204,7 @@ class FromGeneric {
             // see if it has the required invoke method
             MethodHandle entryPoint = null;
             try {
-                entryPoint = MethodHandleImpl.IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
+                entryPoint = IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
             } catch (ReflectiveOperationException ex) {
             }
             if (entryPoint == null)  continue;
@@ -257,7 +258,7 @@ class FromGeneric {
 
         @Override
         public String toString() {
-            return MethodHandleImpl.addTypeString(target, this);
+            return addTypeString(target, this);
         }
 
         protected boolean isPrototype() { return target == null; }
@@ -272,7 +273,7 @@ class FromGeneric {
 
         protected Adapter(MethodHandle entryPoint,
                           MethodHandle invoker, MethodHandle convert, MethodHandle target) {
-            super(Access.TOKEN, entryPoint);
+            super(entryPoint);
             this.invoker = invoker;
             this.convert = convert;
             this.target  = target;
@@ -290,7 +291,7 @@ class FromGeneric {
         protected Object convert_F(float  result) throws Throwable { return convert.invokeExact(result); }
         protected Object convert_D(double result) throws Throwable { return convert.invokeExact(result); }
 
-        static private final String CLASS_PREFIX; // "sun.dyn.FromGeneric$"
+        static private final String CLASS_PREFIX; // "java.lang.invoke.FromGeneric$"
         static {
             String aname = Adapter.class.getName();
             String sname = Adapter.class.getSimpleName();
diff --git a/jdk/src/share/classes/java/dyn/InvokeDynamic.java b/jdk/src/share/classes/java/lang/invoke/InvokeDynamic.java
similarity index 93%
rename from jdk/src/share/classes/java/dyn/InvokeDynamic.java
rename to jdk/src/share/classes/java/lang/invoke/InvokeDynamic.java
index 9c3ede1ee36..4668d741bbb 100644
--- a/jdk/src/share/classes/java/dyn/InvokeDynamic.java
+++ b/jdk/src/share/classes/java/lang/invoke/InvokeDynamic.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang.invoke;
 
 /**
  * This is a place-holder class.  Some HotSpot implementations need to see it.
diff --git a/jdk/src/share/classes/sun/dyn/InvokeGeneric.java b/jdk/src/share/classes/java/lang/invoke/InvokeGeneric.java
similarity index 86%
rename from jdk/src/share/classes/sun/dyn/InvokeGeneric.java
rename to jdk/src/share/classes/java/lang/invoke/InvokeGeneric.java
index 0d1a5defce3..a235e7318da 100644
--- a/jdk/src/share/classes/sun/dyn/InvokeGeneric.java
+++ b/jdk/src/share/classes/java/lang/invoke/InvokeGeneric.java
@@ -23,15 +23,13 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
-import java.lang.reflect.*;
-import sun.dyn.util.*;
-import static sun.dyn.MethodTypeImpl.invokers;
+import sun.invoke.util.*;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
- * Adapters which manage MethodHanndle.invokeGeneric calls.
+ * Adapters which manage MethodHandle.invokeGeneric calls.
  * The JVM calls one of these when the exact type match fails.
  * @author jrose
  */
@@ -44,7 +42,8 @@ class InvokeGeneric {
     /** Compute and cache information for this adapter, so that it can
      *  call out to targets of the erasure-family of the given erased type.
      */
-    private InvokeGeneric(MethodType erasedCallerType) throws ReflectiveOperationException {
+    /*non-public*/ InvokeGeneric(MethodType erasedCallerType) throws ReflectiveOperationException {
+        assert(erasedCallerType.equals(erasedCallerType.erase()));
         this.erasedCallerType = erasedCallerType;
         this.initialInvoker = makeInitialInvoker();
         assert initialInvoker.type().equals(erasedCallerType
@@ -53,22 +52,13 @@ class InvokeGeneric {
     }
 
     private static MethodHandles.Lookup lookup() {
-        return MethodHandleImpl.IMPL_LOOKUP;
+        return IMPL_LOOKUP;
     }
 
     /** Return the adapter information for this type's erasure. */
-    static MethodHandle genericInvokerOf(MethodType type) {
-        MethodTypeImpl form = MethodTypeImpl.of(type);
-        MethodHandle genericInvoker = form.genericInvoker;
-        if (genericInvoker == null) {
-            try {
-                InvokeGeneric gen = new InvokeGeneric(form.erasedType());
-                form.genericInvoker = genericInvoker = gen.initialInvoker;
-            } catch (ReflectiveOperationException ex) {
-                throw new RuntimeException(ex);
-            }
-        }
-        return genericInvoker;
+    /*non-public*/ static MethodHandle genericInvokerOf(MethodType erasedCallerType) throws ReflectiveOperationException {
+        InvokeGeneric gen = new InvokeGeneric(erasedCallerType);
+        return gen.initialInvoker;
     }
 
     private MethodHandle makeInitialInvoker() throws ReflectiveOperationException {
@@ -88,7 +78,7 @@ class InvokeGeneric {
     private MethodHandle makePostDispatchInvoker() {
         // Take (MH'; MT, MH; A...) and run MH'(MT, MH; A...).
         MethodType invokerType = erasedCallerType.insertParameterTypes(0, EXTRA_ARGS);
-        return invokers(invokerType).exactInvoker();
+        return invokerType.invokers().exactInvoker();
     }
     private MethodHandle dropDispatchArguments(MethodHandle targetInvoker) {
         assert(targetInvoker.type().parameterType(0) == MethodHandle.class);
@@ -112,7 +102,7 @@ class InvokeGeneric {
         if (USE_AS_TYPE_PATH || target.isVarargsCollector()) {
             MethodHandle newTarget = target.asType(callerType);
             targetType = callerType;
-            Invokers invokers = MethodTypeImpl.invokers(Access.TOKEN, targetType);
+            Invokers invokers = targetType.invokers();
             MethodHandle invoker = invokers.erasedInvokerWithDrops;
             if (invoker == null) {
                 invokers.erasedInvokerWithDrops = invoker =
diff --git a/jdk/src/share/classes/sun/dyn/Invokers.java b/jdk/src/share/classes/java/lang/invoke/Invokers.java
similarity index 87%
rename from jdk/src/share/classes/sun/dyn/Invokers.java
rename to jdk/src/share/classes/java/lang/invoke/Invokers.java
index 55eef1911ba..4eeb36f76b7 100644
--- a/jdk/src/share/classes/sun/dyn/Invokers.java
+++ b/jdk/src/share/classes/java/lang/invoke/Invokers.java
@@ -23,16 +23,16 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
-import sun.dyn.empty.Empty;
+import sun.invoke.empty.Empty;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
  * Construction and caching of often-used invokers.
  * @author jrose
  */
-public class Invokers {
+class Invokers {
     // exact type (sans leading taget MH) for the outgoing call
     private final MethodType targetType;
 
@@ -60,15 +60,15 @@ public class Invokers {
         this.spreadInvokers = new MethodHandle[targetType.parameterCount()+1];
     }
 
-    public static MethodType invokerType(MethodType targetType) {
+    /*non-public*/ static MethodType invokerType(MethodType targetType) {
         return targetType.insertParameterTypes(0, MethodHandle.class);
     }
 
-    public MethodHandle exactInvoker() {
+    /*non-public*/ MethodHandle exactInvoker() {
         MethodHandle invoker = exactInvoker;
         if (invoker != null)  return invoker;
         try {
-            invoker = MethodHandleImpl.IMPL_LOOKUP.findVirtual(MethodHandle.class, "invokeExact", targetType);
+            invoker = IMPL_LOOKUP.findVirtual(MethodHandle.class, "invokeExact", targetType);
         } catch (ReflectiveOperationException ex) {
             throw new InternalError("JVM cannot find invoker for "+targetType);
         }
@@ -77,7 +77,7 @@ public class Invokers {
         return invoker;
     }
 
-    public MethodHandle genericInvoker() {
+    /*non-public*/ MethodHandle genericInvoker() {
         MethodHandle invoker1 = exactInvoker();
         MethodHandle invoker = genericInvoker;
         if (invoker != null)  return invoker;
@@ -87,7 +87,7 @@ public class Invokers {
         return invoker;
     }
 
-    public MethodHandle erasedInvoker() {
+    /*non-public*/ MethodHandle erasedInvoker() {
         MethodHandle invoker1 = exactInvoker();
         MethodHandle invoker = erasedInvoker;
         if (invoker != null)  return invoker;
@@ -100,7 +100,7 @@ public class Invokers {
         return invoker;
     }
 
-    public MethodHandle spreadInvoker(int objectArgCount) {
+    /*non-public*/ MethodHandle spreadInvoker(int objectArgCount) {
         MethodHandle vaInvoker = spreadInvokers[objectArgCount];
         if (vaInvoker != null)  return vaInvoker;
         MethodHandle gInvoker = genericInvoker();
@@ -111,12 +111,12 @@ public class Invokers {
 
     private static MethodHandle THROW_UCS = null;
 
-    public MethodHandle uninitializedCallSite() {
+    /*non-public*/ MethodHandle uninitializedCallSite() {
         MethodHandle invoker = uninitializedCallSite;
         if (invoker != null)  return invoker;
         if (targetType.parameterCount() > 0) {
             MethodType type0 = targetType.dropParameterTypes(0, targetType.parameterCount());
-            Invokers invokers0 = MethodTypeImpl.invokers(type0);
+            Invokers invokers0 = type0.invokers();
             invoker = MethodHandles.dropArguments(invokers0.uninitializedCallSite(),
                                                   0, targetType.parameterList());
             assert(invoker.type().equals(targetType));
@@ -125,14 +125,14 @@ public class Invokers {
         }
         if (THROW_UCS == null) {
             try {
-                THROW_UCS = MethodHandleImpl.IMPL_LOOKUP
+                THROW_UCS = IMPL_LOOKUP
                     .findStatic(CallSite.class, "uninitializedCallSite",
                                 MethodType.methodType(Empty.class));
             } catch (ReflectiveOperationException ex) {
                 throw new RuntimeException(ex);
             }
         }
-        invoker = AdapterMethodHandle.makeRetypeRaw(Access.TOKEN, targetType, THROW_UCS);
+        invoker = AdapterMethodHandle.makeRetypeRaw(targetType, THROW_UCS);
         assert(invoker.type().equals(targetType));
         uninitializedCallSite = invoker;
         return invoker;
diff --git a/jdk/src/share/classes/sun/dyn/MemberName.java b/jdk/src/share/classes/java/lang/invoke/MemberName.java
similarity index 93%
rename from jdk/src/share/classes/sun/dyn/MemberName.java
rename to jdk/src/share/classes/java/lang/invoke/MemberName.java
index 5e98b85ca60..0300fe758cc 100644
--- a/jdk/src/share/classes/sun/dyn/MemberName.java
+++ b/jdk/src/share/classes/java/lang/invoke/MemberName.java
@@ -23,10 +23,9 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import sun.dyn.util.BytecodeDescriptor;
-import java.dyn.*;
+import sun.invoke.util.BytecodeDescriptor;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
@@ -37,7 +36,8 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import static sun.dyn.MethodHandleNatives.Constants.*;
+import static java.lang.invoke.MethodHandleNatives.Constants.*;
+import static java.lang.invoke.MethodHandleStatics.*;
 
 /**
  * A {@code MemberName} is a compact symbolic datum which fully characterizes
@@ -66,7 +66,7 @@ import static sun.dyn.MethodHandleNatives.Constants.*;
  * and those seven fields omit much of the information in Method.
  * @author jrose
  */
-public final class MemberName implements Member, Cloneable {
+/*non-public*/ final class MemberName implements Member, Cloneable {
     private Class<?>   clazz;       // class in which the method is defined
     private String     name;        // may be null if not yet materialized
     private Object     type;        // may be null if not yet materialized
@@ -435,7 +435,7 @@ public final class MemberName implements Member, Cloneable {
     /** Query whether this member name is resolved to a non-static, non-final method.
      */
     public boolean hasReceiverTypeDispatch() {
-        return (isMethod() && getVMIndex(Access.TOKEN) >= 0);
+        return (isMethod() && getVMIndex() >= 0);
     }
 
     /** Produce a string form of this member name.
@@ -490,59 +490,38 @@ public final class MemberName implements Member, Cloneable {
 
     // Queries to the JVM:
     /** Document? */
-    public int getVMIndex(Access token) {
-        Access.check(token);
+    /*non-public*/ int getVMIndex() {
         if (!isResolved())
-            throw newIllegalStateException("not resolved");
+            throw newIllegalStateException("not resolved", this);
         return vmindex;
     }
-//    public Object getVMTarget(Access token) {
-//        Access.check(token);
+//    /*non-public*/ Object getVMTarget() {
 //        if (!isResolved())
-//            throw newIllegalStateException("not resolved");
+//            throw newIllegalStateException("not resolved", this);
 //        return vmtarget;
 //    }
-    private RuntimeException newIllegalStateException(String message) {
-        return new IllegalStateException(message+": "+this);
-    }
 
-    // handy shared exception makers (they simplify the common case code)
-    public static RuntimeException newIllegalArgumentException(String message) {
-        return new IllegalArgumentException(message);
-    }
-    public static IllegalAccessException newNoAccessException(MemberName name, Object from) {
-        return newNoAccessException("cannot access", name, from);
-    }
-    public static IllegalAccessException newNoAccessException(String message,
-            MemberName name, Object from) {
-        message += ": " + name;
+    public IllegalAccessException makeAccessException(String message, Object from) {
+        message = message + ": "+ toString();
         if (from != null)  message += ", from " + from;
         return new IllegalAccessException(message);
     }
-    public static ReflectiveOperationException newNoAccessException(MemberName name) {
-        if (name.isResolved())
-            return new IllegalAccessException(name.toString());
-        else if (name.isConstructor())
-            return new NoSuchMethodException(name.toString());
-        else if (name.isMethod())
-            return new NoSuchMethodException(name.toString());
+    public ReflectiveOperationException makeAccessException(String message) {
+        message = message + ": "+ toString();
+        if (isResolved())
+            return new IllegalAccessException(message);
+        else if (isConstructor())
+            return new NoSuchMethodException(message);
+        else if (isMethod())
+            return new NoSuchMethodException(message);
         else
-            return new NoSuchFieldException(name.toString());
-    }
-    public static Error uncaughtException(Exception ex) {
-        Error err = new InternalError("uncaught exception");
-        err.initCause(ex);
-        return err;
+            return new NoSuchFieldException(message);
     }
 
     /** Actually making a query requires an access check. */
-    public static Factory getFactory(Access token) {
-        Access.check(token);
+    /*non-public*/ static Factory getFactory() {
         return Factory.INSTANCE;
     }
-    public static Factory getFactory() {
-        return getFactory(Access.getToken());
-    }
     /** A factory type for resolving member names with the help of the VM.
      *  TBD: Define access-safe public constructors for this factory.
      */
@@ -662,7 +641,7 @@ public final class MemberName implements Member, Cloneable {
             MemberName result = resolveOrNull(m, searchSupers, lookupClass);
             if (result != null)
                 return result;
-            ReflectiveOperationException ex = newNoAccessException(m);
+            ReflectiveOperationException ex = m.makeAccessException("no access");
             if (ex instanceof IllegalAccessException)  throw (IllegalAccessException) ex;
             throw nsmClass.cast(ex);
         }
diff --git a/jdk/src/share/classes/java/dyn/MethodHandle.java b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java
similarity index 88%
rename from jdk/src/share/classes/java/dyn/MethodHandle.java
rename to jdk/src/share/classes/java/lang/invoke/MethodHandle.java
index b78b4024805..8165915c7bb 100644
--- a/jdk/src/share/classes/java/dyn/MethodHandle.java
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandle.java
@@ -23,15 +23,10 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang.invoke;
 
-//import sun.dyn.*;
 
-import sun.dyn.Access;
-import sun.dyn.MethodHandleImpl;
-
-import static java.dyn.MethodHandles.invokers;  // package-private API
-import static sun.dyn.MemberName.newIllegalArgumentException;  // utility
+import static java.lang.invoke.MethodHandleStatics.*;
 
 /**
  * A method handle is a typed, directly executable reference to an underlying method,
@@ -40,14 +35,8 @@ import static sun.dyn.MemberName.newIllegalArgumentException;  // utility
  * These transformations are quite general, and include such patterns as
  * {@linkplain #asType conversion},
  * {@linkplain #bindTo insertion},
- * {@linkplain java.dyn.MethodHandles#dropArguments deletion},
- * and {@linkplain java.dyn.MethodHandles#filterArguments substitution}.
- * <p>
- * <em>Note: The super-class of MethodHandle is Object.
- *     Any other super-class visible in the Reference Implementation
- *     will be removed before the Proposed Final Draft.
- *     Also, the final version will not include any public or
- *     protected constructors.</em>
+ * {@linkplain java.lang.invoke.MethodHandles#dropArguments deletion},
+ * and {@linkplain java.lang.invoke.MethodHandles#filterArguments substitution}.
  *
  * <h3>Method handle contents</h3>
  * Method handles are dynamically and strongly typed according to type descriptor.
@@ -56,7 +45,7 @@ import static sun.dyn.MemberName.newIllegalArgumentException;  // utility
  * the method handle's own {@linkplain #type method type}.
  * <p>
  * Every method handle reports its type via the {@link #type type} accessor.
- * This type descriptor is a {@link java.dyn.MethodType MethodType} object,
+ * This type descriptor is a {@link java.lang.invoke.MethodType MethodType} object,
  * whose structure is a series of classes, one of which is
  * the return type of the method (or {@code void.class} if none).
  * <p>
@@ -156,7 +145,7 @@ import static sun.dyn.MemberName.newIllegalArgumentException;  // utility
  * This allows a more powerful negotiation of method type
  * between caller and callee.
  * <p>
- * (Note: The adjusted method handle {@code M2} is not directly observable,
+ * (<em>Note:</em> The adjusted method handle {@code M2} is not directly observable,
  * and implementations are therefore not required to materialize it.)
  *
  * <h3>Invocation checking</h3>
@@ -204,11 +193,11 @@ import static sun.dyn.MemberName.newIllegalArgumentException;  // utility
  * Java code can create a method handle that directly accesses
  * any method, constructor, or field that is accessible to that code.
  * This is done via a reflective, capability-based API called
- * {@link java.dyn.MethodHandles.Lookup MethodHandles.Lookup}
+ * {@link java.lang.invoke.MethodHandles.Lookup MethodHandles.Lookup}
  * For example, a static method handle can be obtained
- * from {@link java.dyn.MethodHandles.Lookup#findStatic Lookup.findStatic}.
+ * from {@link java.lang.invoke.MethodHandles.Lookup#findStatic Lookup.findStatic}.
  * There are also conversion methods from Core Reflection API objects,
- * such as {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect}.
+ * such as {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect}.
  * <p>
  * Like classes and strings, method handles that correspond to accessible
  * fields, methods, and constructors can also be represented directly
@@ -269,7 +258,7 @@ mh = mh.asType(mt);
 x = mh.invokeExact((Object)1, (Object)2, (Object)3);
 // invokeExact(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
 assert(x.equals(java.util.Arrays.asList(1,2,3)));
-// mt is { =&gt; int}
+// mt is int()
 mt = MethodType.methodType(int.class);
 mh = lookup.findVirtual(java.util.List.class, "size", mt);
 i = (int) mh.invokeExact(java.util.Arrays.asList(1,2,3));
@@ -325,15 +314,15 @@ mh.invokeExact(System.out, "Hello, world.");
  * <p>
  * For the sake of tools (but not as a programming API), the signature polymorphic
  * methods are marked with a private yet standard annotation,
- * {@code @java.dyn.MethodHandle.PolymorphicSignature}.
+ * {@code @java.lang.invoke.MethodHandle.PolymorphicSignature}.
  * The annotation's retention is {@code RUNTIME}, so that all tools can see it.
  *
  * <h3>Formal rules for processing signature polymorphic methods</h3>
  * <p>
  * The following methods (and no others) are signature polymorphic:
  * <ul>
- * <li>{@link java.dyn.MethodHandle#invokeExact   MethodHandle.invokeExact}
- * <li>{@link java.dyn.MethodHandle#invokeGeneric MethodHandle.invokeGeneric}
+ * <li>{@link java.lang.invoke.MethodHandle#invokeExact   MethodHandle.invokeExact}
+ * <li>{@link java.lang.invoke.MethodHandle#invokeGeneric MethodHandle.invokeGeneric}
  * </ul>
  * <p>
  * A signature polymorphic method will be declared with the following properties:
@@ -341,7 +330,7 @@ mh.invokeExact(System.out, "Hello, world.");
  * <li>It must be native.
  * <li>It must take a single varargs parameter of the form {@code Object...}.
  * <li>It must produce a return value of type {@code Object}.
- * <li>It must be contained within the {@code java.dyn} package.
+ * <li>It must be contained within the {@code java.lang.invoke} package.
  * </ul>
  * Because of these requirements, a signature polymorphic method is able to accept
  * any number and type of actual arguments, and can, with a cast, produce a value of any type.
@@ -354,7 +343,7 @@ mh.invokeExact(System.out, "Hello, world.");
  * <p>
  * In an argument position of a method invocation on a signature polymorphic method,
  * a null literal has type {@code java.lang.Void}, unless cast to a reference type.
- * (Note: This typing rule allows the null type to have its own encoding in linkage information
+ * (<em>Note:</em> This typing rule allows the null type to have its own encoding in linkage information
  * distinct from other types.
  * <p>
  * The linkage information for the return type is derived from a context-dependent target typing convention.
@@ -374,12 +363,12 @@ mh.invokeExact(System.out, "Hello, world.");
  * and without implicit boxing or unboxing.
  *
  * <h3>Interoperation between method handles and the Core Reflection API</h3>
- * Using factory methods in the {@link java.dyn.MethodHandles.Lookup Lookup} API,
+ * Using factory methods in the {@link java.lang.invoke.MethodHandles.Lookup Lookup} API,
  * any class member represented by a Core Reflection API object
  * can be converted to a behaviorally equivalent method handle.
  * For example, a reflective {@link java.lang.reflect.Method Method} can
  * be converted to a method handle using
- * {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect}.
+ * {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect}.
  * The resulting method handles generally provide more direct and efficient
  * access to the underlying class members.
  * <p>
@@ -398,9 +387,9 @@ mh.invokeExact(System.out, "Hello, world.");
  * they will throw {@code UnsupportedOperationException}.
  * <p>
  * In order to obtain an invoker method for a particular type descriptor,
- * use {@link java.dyn.MethodHandles#exactInvoker MethodHandles.exactInvoker},
- * or {@link java.dyn.MethodHandles#genericInvoker MethodHandles.genericInvoker}.
- * The {@link java.dyn.MethodHandles.Lookup#findVirtual Lookup.findVirtual}
+ * use {@link java.lang.invoke.MethodHandles#exactInvoker MethodHandles.exactInvoker},
+ * or {@link java.lang.invoke.MethodHandles#genericInvoker MethodHandles.genericInvoker}.
+ * The {@link java.lang.invoke.MethodHandles.Lookup#findVirtual Lookup.findVirtual}
  * API is also able to return a method handle
  * to call {@code invokeExact} or {@code invokeGeneric},
  * for any specified type descriptor .
@@ -436,12 +425,35 @@ mh.invokeExact(System.out, "Hello, world.");
  * @see MethodHandles
  * @author John Rose, JSR 292 EG
  */
-public abstract class MethodHandle
-        // Note: This is an implementation inheritance hack, and will be removed
-        // with a JVM change which moves the required hidden state onto this class.
-        extends MethodHandleImpl
-{
-    private static Access IMPL_TOKEN = Access.getToken();
+public abstract class MethodHandle {
+    // { JVM internals:
+
+    private byte       vmentry;    // adapter stub or method entry point
+    //private int      vmslots;    // optionally, hoist type.form.vmslots
+    /*non-public*/ Object vmtarget;   // VM-specific, class-specific target value
+
+    // TO DO:  vmtarget should be invisible to Java, since the JVM puts internal
+    // managed pointers into it.  Making it visible exposes it to debuggers,
+    // which can cause errors when they treat the pointer as an Object.
+
+    // These two dummy fields are present to force 'I' and 'J' signatures
+    // into this class's constant pool, so they can be transferred
+    // to vmentry when this class is loaded.
+    static final int  INT_FIELD = 0;
+    static final long LONG_FIELD = 0;
+
+    // vmentry (a void* field) is used *only* by the JVM.
+    // The JVM adjusts its type to int or long depending on system wordsize.
+    // Since it is statically typed as neither int nor long, it is impossible
+    // to use this field from Java bytecode.  (Please don't try to, either.)
+
+    // The vmentry is an assembly-language stub which is jumped to
+    // immediately after the method type is verified.
+    // For a direct MH, this stub loads the vmtarget's entry point
+    // and jumps to it.
+
+    // } End of JVM internals.
+
     static { MethodHandleImpl.initStatics(); }
 
     // interface MethodHandle<R throws X extends Exception,A...>
@@ -458,7 +470,7 @@ public abstract class MethodHandle
     private MethodType type;
 
     /**
-     * Report the type of this method handle.
+     * Reports the type of this method handle.
      * Every invocation of this method handle via {@code invokeExact} must exactly match this type.
      * @return the method handle type
      */
@@ -467,39 +479,18 @@ public abstract class MethodHandle
     }
 
     /**
-     * <em>CONSTRUCTOR WILL BE REMOVED FOR PFD:</em>
-     * Temporary constructor in early versions of the Reference Implementation.
-     * Method handle inheritance (if any) will be contained completely within
-     * the {@code java.dyn} package.
+     * Package-private constructor for the method handle implementation hierarchy.
+     * Method handle inheritance will be contained completely within
+     * the {@code java.lang.invoke} package.
      */
-    // The constructor for MethodHandle may only be called by privileged code.
-    // Subclasses may be in other packages, but must possess
-    // a token which they obtained from MH with a security check.
-    // @param token non-null object which proves access permission
     // @param type type (permanently assigned) of the new method handle
-    protected MethodHandle(Access token, MethodType type) {
-        super(token);
-        Access.check(token);
-        this.type = type;
-    }
-
-    private void initType(MethodType type) {
+    /*non-public*/ MethodHandle(MethodType type) {
         type.getClass();  // elicit NPE
-        if (this.type != null)  throw new InternalError();
         this.type = type;
     }
 
-    static {
-        // This hack allows the implementation package special access to
-        // the internals of MethodHandle.  In particular, the MTImpl has all sorts
-        // of cached information useful to the implementation code.
-        MethodHandleImpl.setMethodHandleFriend(IMPL_TOKEN, new MethodHandleImpl.MethodHandleFriend() {
-            public void initType(MethodHandle mh, MethodType type) { mh.initType(type); }
-        });
-    }
-
     /**
-     * Invoke the method handle, allowing any caller type descriptor, but requiring an exact type match.
+     * Invokes the method handle, allowing any caller type descriptor, but requiring an exact type match.
      * The type descriptor at the call site of {@code invokeExact} must
      * exactly match this method handle's {@link #type type}.
      * No conversions are allowed on arguments or return values.
@@ -508,7 +499,7 @@ public abstract class MethodHandle
      * it will appear as a single native method, taking an object array and returning an object.
      * If this native method is invoked directly via
      * {@link java.lang.reflect.Method#invoke Method.invoke}, via JNI,
-     * or indirectly via {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect},
+     * or indirectly via {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect},
      * it will throw an {@code UnsupportedOperationException}.
      * @throws WrongMethodTypeException if the target's type is not identical with the caller's type descriptor
      * @throws Throwable anything thrown by the underlying method propagates unchanged through the method handle call
@@ -516,7 +507,7 @@ public abstract class MethodHandle
     public final native @PolymorphicSignature Object invokeExact(Object... args) throws Throwable;
 
     /**
-     * Invoke the method handle, allowing any caller type descriptor,
+     * Invokes the method handle, allowing any caller type descriptor,
      * and optionally performing conversions on arguments and return values.
      * <p>
      * If the call site type descriptor exactly matches this method handle's {@link #type type},
@@ -542,7 +533,7 @@ public abstract class MethodHandle
      * it will appear as a single native method, taking an object array and returning an object.
      * If this native method is invoked directly via
      * {@link java.lang.reflect.Method#invoke Method.invoke}, via JNI,
-     * or indirectly via {@link java.dyn.MethodHandles.Lookup#unreflect Lookup.unreflect},
+     * or indirectly via {@link java.lang.invoke.MethodHandles.Lookup#unreflect Lookup.unreflect},
      * it will throw an {@code UnsupportedOperationException}.
      * @throws WrongMethodTypeException if the target's type cannot be adjusted to the caller's type descriptor
      * @throws ClassCastException if the target's type can be adjusted to the caller, but a reference cast fails
@@ -551,7 +542,7 @@ public abstract class MethodHandle
     public final native @PolymorphicSignature Object invokeGeneric(Object... args) throws Throwable;
 
     /**
-     * Perform a varargs invocation, passing the arguments in the given array
+     * Performs a varargs invocation, passing the arguments in the given array
      * to the method handle, as if via {@link #invokeGeneric invokeGeneric} from a call site
      * which mentions only the type {@code Object}, and whose arity is the length
      * of the argument array.
@@ -608,7 +599,7 @@ public abstract class MethodHandle
             return asType(MethodType.genericMethodType(argc)).invokeWithArguments(arguments);
         }
         if (argc <= 10) {
-            MethodHandle invoker = invokers(type).genericInvoker();
+            MethodHandle invoker = type.invokers().genericInvoker();
             switch (argc) {
                 case 0:  return invoker.invokeExact(this);
                 case 1:  return invoker.invokeExact(this,
@@ -647,17 +638,34 @@ public abstract class MethodHandle
         }
 
         // more than ten arguments get boxed in a varargs list:
-        MethodHandle invoker = invokers(type).spreadInvoker(0);
+        MethodHandle invoker = type.invokers().spreadInvoker(0);
         return invoker.invokeExact(this, arguments);
     }
-    /** Equivalent to {@code invokeWithArguments(arguments.toArray())}. */
+
+    /**
+     * Performs a varargs invocation, passing the arguments in the given array
+     * to the method handle, as if via {@link #invokeGeneric invokeGeneric} from a call site
+     * which mentions only the type {@code Object}, and whose arity is the length
+     * of the argument array.
+     * <p>
+     * This method is also equivalent to the following code:
+     * <p><blockquote><pre>
+     * {@link #invokeWithArguments(Object...) invokeWithArguments}(arguments.toArray())
+     * </pre></blockquote>
+     *
+     * @param arguments the arguments to pass to the target
+     * @return the result returned by the target
+     * @throws ClassCastException if an argument cannot be converted by reference casting
+     * @throws WrongMethodTypeException if the target's type cannot be adjusted to take the given number of {@code Object} arguments
+     * @throws Throwable anything thrown by the target method invocation
+     */
     public Object invokeWithArguments(java.util.List<?> arguments) throws Throwable {
         return invokeWithArguments(arguments.toArray());
     }
 
     /**
-     * Produce an adapter method handle which adapts the type of the
-     * current method handle to a new type
+     * Produces an adapter method handle which adapts the type of the
+     * current method handle to a new type.
      * The resulting method handle is guaranteed to report a type
      * which is equal to the desired new type.
      * <p>
@@ -685,7 +693,7 @@ public abstract class MethodHandle
     }
 
     /**
-     * Make an adapter which accepts a trailing array argument
+     * Makes an adapter which accepts a trailing array argument
      * and spreads its elements as positional arguments.
      * The new method handle adapts, as its <i>target</i>,
      * the current method handle.  The type of the adapter will be
@@ -733,7 +741,7 @@ public abstract class MethodHandle
     }
 
     /**
-     * Make an adapter which accepts a given number of trailing
+     * Makes an adapter which accepts a given number of trailing
      * positional arguments and collects them into an array argument.
      * The new method handle adapts, as its <i>target</i>,
      * the current method handle.  The type of the adapter will be
@@ -784,7 +792,7 @@ public abstract class MethodHandle
     }
 
     /**
-     * Make a <em>variable arity</em> adapter which is able to accept
+     * Makes a <em>variable arity</em> adapter which is able to accept
      * any number of trailing positional arguments and collect them
      * into an array argument.
      * <p>
@@ -942,12 +950,12 @@ assert(failed);
     }
 
     /**
-     * Determine if this method handle
+     * Determines if this method handle
      * supports {@linkplain #asVarargsCollector variable arity} calls.
      * Such method handles arise from the following sources:
      * <ul>
      * <li>a call to {@linkplain #asVarargsCollector asVarargsCollector}
-     * <li>a call to a {@linkplain java.dyn.MethodHandles.Lookup lookup method}
+     * <li>a call to a {@linkplain java.lang.invoke.MethodHandles.Lookup lookup method}
      *     which resolves to a variable arity Java method or constructor
      * <li>an {@code ldc} instruction of a {@code CONSTANT_MethodHandle}
      *     which resolves to a variable arity Java method or constructor
@@ -960,9 +968,9 @@ assert(failed);
     }
 
     /**
-     * Bind a value {@code x} to the first argument of a method handle, without invoking it.
+     * Binds a value {@code x} to the first argument of a method handle, without invoking it.
      * The new method handle adapts, as its <i>target</i>,
-     * to the current method handle.
+     * the current method handle by binding it to the given argument.
      * The type of the bound handle will be
      * the same as the type of the target, except that a single leading
      * reference parameter will be omitted.
@@ -974,9 +982,12 @@ assert(failed);
      * <p>
      * The reference {@code x} must be convertible to the first parameter
      * type of the target.
+     * <p>
+     * (<em>Note:</em>  Because method handles are immutable, the target method handle
+     * retains its original type and behavior.)
      * @param x  the value to bind to the first argument of the target
-     * @return a new method handle which collects some trailing argument
-     *         into an array, before calling the original method handle
+     * @return a new method handle which prepends the given value to the incoming
+     *         argument list, before calling the original method handle
      * @throws IllegalArgumentException if the target does not have a
      *         leading parameter type that is a reference type
      * @throws ClassCastException if {@code x} cannot be converted
@@ -984,7 +995,15 @@ assert(failed);
      * @see MethodHandles#insertArguments
      */
     public MethodHandle bindTo(Object x) {
-        return MethodHandles.insertArguments(this, 0, x);
+        Class<?> ptype;
+        if (type().parameterCount() == 0 ||
+            (ptype = type().parameterType(0)).isPrimitive())
+            throw newIllegalArgumentException("no leading reference parameter", x);
+        x = MethodHandles.checkValue(ptype, x);
+        // Cf. MethodHandles.insertArguments for the following logic:
+        MethodHandle bmh = MethodHandleImpl.bindReceiver(this, x);
+        if (bmh != null)  return bmh;
+        return MethodHandleImpl.bindArgument(this, 0, x);
     }
 
     /**
@@ -996,14 +1015,14 @@ assert(failed);
      * "MethodHandle" + type().toString()
      * </pre></blockquote>
      * <p>
-     * Note:  Future releases of this API may add further information
+     * (<em>Note:</em>  Future releases of this API may add further information
      * to the string representation.
-     * Therefore, the present syntax should not be parsed by applications.
+     * Therefore, the present syntax should not be parsed by applications.)
      *
      * @return a string representation of the method handle
      */
     @Override
     public String toString() {
-        return MethodHandleImpl.getNameString(IMPL_TOKEN, this);
+        return getNameString(this);
     }
 }
diff --git a/jdk/src/share/classes/sun/dyn/MethodHandleImpl.java b/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java
similarity index 78%
rename from jdk/src/share/classes/sun/dyn/MethodHandleImpl.java
rename to jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java
index eab4923540e..e82442092fe 100644
--- a/jdk/src/share/classes/sun/dyn/MethodHandleImpl.java
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleImpl.java
@@ -23,136 +23,36 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
-import java.dyn.MethodHandles.Lookup;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import sun.dyn.util.VerifyType;
+import sun.invoke.util.VerifyType;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
-import sun.dyn.empty.Empty;
-import sun.dyn.util.ValueConversions;
-import sun.dyn.util.Wrapper;
+import sun.invoke.empty.Empty;
+import sun.invoke.util.ValueConversions;
+import sun.invoke.util.Wrapper;
 import sun.misc.Unsafe;
-import static sun.dyn.MemberName.newIllegalArgumentException;
-import static sun.dyn.MemberName.newNoAccessException;
-import static sun.dyn.MemberName.uncaughtException;
+import static java.lang.invoke.MethodHandleStatics.*;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
- * Base class for method handles, containing JVM-specific fields and logic.
- * TO DO:  It should not be a base class.
+ * Trusted implementation code for MethodHandle.
  * @author jrose
  */
-public abstract class MethodHandleImpl {
-
-    // Fields which really belong in MethodHandle:
-    private byte       vmentry;    // adapter stub or method entry point
-    //private int      vmslots;    // optionally, hoist type.form.vmslots
-    protected Object   vmtarget;   // VM-specific, class-specific target value
-    //MethodType       type;       // defined in MethodHandle
-
-    // TO DO:  vmtarget should be invisible to Java, since the JVM puts internal
-    // managed pointers into it.  Making it visible exposes it to debuggers,
-    // which can cause errors when they treat the pointer as an Object.
-
-    // These two dummy fields are present to force 'I' and 'J' signatures
-    // into this class's constant pool, so they can be transferred
-    // to vmentry when this class is loaded.
-    static final int  INT_FIELD = 0;
-    static final long LONG_FIELD = 0;
-
-    /** Access methods for the internals of MethodHandle, supplied to
-     *  MethodHandleImpl as a trusted agent.
-     */
-    static public interface MethodHandleFriend {
-        void initType(MethodHandle mh, MethodType type);
-    }
-    public static void setMethodHandleFriend(Access token, MethodHandleFriend am) {
-        Access.check(token);
-        if (METHOD_HANDLE_FRIEND != null)
-            throw new InternalError();  // just once
-        METHOD_HANDLE_FRIEND = am;
-    }
-    static private MethodHandleFriend METHOD_HANDLE_FRIEND;
-
-    // NOT public
-    static void initType(MethodHandle mh, MethodType type) {
-        METHOD_HANDLE_FRIEND.initType(mh, type);
-    }
-
-    // type is defined in java.dyn.MethodHandle, which is platform-independent
-
-    // vmentry (a void* field) is used *only* by by the JVM.
-    // The JVM adjusts its type to int or long depending on system wordsize.
-    // Since it is statically typed as neither int nor long, it is impossible
-    // to use this field from Java bytecode.  (Please don't try to, either.)
-
-    // The vmentry is an assembly-language stub which is jumped to
-    // immediately after the method type is verified.
-    // For a direct MH, this stub loads the vmtarget's entry point
-    // and jumps to it.
-
-    /**
-     * VM-based method handles must have a security token.
-     * This security token can only be obtained by trusted code.
-     * Do not create method handles directly; use factory methods.
-     */
-    public MethodHandleImpl(Access token) {
-        Access.check(token);
-    }
-
-    /** Initialize the method type form to participate in JVM calls.
-     *  This is done once for each erased type.
-     */
-    public static void init(Access token, MethodType self) {
-        Access.check(token);
-        if (MethodHandleNatives.JVM_SUPPORT)
-            MethodHandleNatives.init(self);
-    }
-
+/*non-public*/ abstract class MethodHandleImpl {
     /// Factory methods to create method handles:
 
     private static final MemberName.Factory LOOKUP = MemberName.Factory.INSTANCE;
 
-    static private Lookup IMPL_LOOKUP_INIT;
-
-    public static void initLookup(Access token, Lookup lookup) {
-        Access.check(token);
-        if (IMPL_LOOKUP_INIT != null)
-            throw new InternalError();
-        IMPL_LOOKUP_INIT = lookup;
-    }
-
-    public static Lookup getLookup(Access token) {
-        Access.check(token);
-        return IMPL_LOOKUP;
-    }
-
-    static {
-        if (!MethodHandleNatives.JVM_SUPPORT)  // force init of native API
-            throw new InternalError("No JVM support for JSR 292");
-        // Force initialization of Lookup, so it calls us back as initLookup:
-        MethodHandles.publicLookup();
-        if (IMPL_LOOKUP_INIT == null)
-            throw new InternalError();
-    }
-
-    public static void initStatics() {
+    static void initStatics() {
         // Trigger preceding sequence.
     }
 
-    /** Shared secret with MethodHandles.Lookup, a copy of Lookup.IMPL_LOOKUP. */
-    static final Lookup IMPL_LOOKUP = IMPL_LOOKUP_INIT;
-
-
     /** Look up a given method.
-     * Callable only from java.dyn and related packages.
+     * Callable only from sun.invoke and related packages.
      * <p>
      * The resulting method handle type will be of the given type,
      * with a receiver type {@code rcvc} prepended if the member is not static.
@@ -170,10 +70,9 @@ public abstract class MethodHandleImpl {
      * @return a direct handle to the matching method
      * @throws IllegalAccessException if the given method cannot be accessed by the lookup class
      */
-    public static
-    MethodHandle findMethod(Access token, MemberName method,
+    static
+    MethodHandle findMethod(MemberName method,
                             boolean doDispatch, Class<?> lookupClass) throws IllegalAccessException {
-        Access.check(token);  // only trusted calls
         MethodType mtype = method.getMethodType();
         if (!method.isStatic()) {
             // adjust the advertised receiver type to be exactly the one requested
@@ -183,7 +82,7 @@ public abstract class MethodHandleImpl {
         }
         DirectMethodHandle mh = new DirectMethodHandle(mtype, method, doDispatch, lookupClass);
         if (!mh.isValid())
-            throw newNoAccessException(method, lookupClass);
+            throw method.makeAccessException("no access", lookupClass);
         assert(mh.type() == mtype);
         if (!method.isVarargs())
             return mh;
@@ -191,13 +90,12 @@ public abstract class MethodHandleImpl {
             return mh.asVarargsCollector(mtype.parameterType(mtype.parameterCount()-1));
     }
 
-    public static
-    MethodHandle makeAllocator(Access token, MethodHandle rawConstructor) {
-        Access.check(token);
+    static
+    MethodHandle makeAllocator(MethodHandle rawConstructor) {
         MethodType rawConType = rawConstructor.type();
         // Wrap the raw (unsafe) constructor with the allocation of a suitable object.
         MethodHandle allocator
-            = AllocateObject.make(token, rawConType.parameterType(0), rawConstructor);
+            = AllocateObject.make(rawConType.parameterType(0), rawConstructor);
         assert(allocator.type()
                .equals(rawConType.dropParameterTypes(0, 1).changeReturnType(rawConType.parameterType(0))));
         return allocator;
@@ -211,13 +109,11 @@ public abstract class MethodHandleImpl {
 
         private AllocateObject(MethodHandle invoker,
                                Class<C> allocateClass, MethodHandle rawConstructor) {
-            super(Access.TOKEN, invoker);
+            super(invoker);
             this.allocateClass = allocateClass;
             this.rawConstructor = rawConstructor;
         }
-        static MethodHandle make(Access token,
-                                 Class<?> allocateClass, MethodHandle rawConstructor) {
-            Access.check(token);
+        static MethodHandle make(Class<?> allocateClass, MethodHandle rawConstructor) {
             MethodType rawConType = rawConstructor.type();
             assert(rawConType.parameterType(0) == allocateClass);
             MethodType newType = rawConType.dropParameterTypes(0, 1).changeReturnType(allocateClass);
@@ -225,18 +121,18 @@ public abstract class MethodHandleImpl {
             if (nargs < INVOKES.length) {
                 MethodHandle invoke = INVOKES[nargs];
                 MethodType conType = CON_TYPES[nargs];
-                MethodHandle gcon = convertArguments(token, rawConstructor, conType, rawConType, null);
+                MethodHandle gcon = convertArguments(rawConstructor, conType, rawConType, null);
                 if (gcon == null)  return null;
                 MethodHandle galloc = new AllocateObject(invoke, allocateClass, gcon);
                 assert(galloc.type() == newType.generic());
-                return convertArguments(token, galloc, newType, galloc.type(), null);
+                return convertArguments(galloc, newType, galloc.type(), null);
             } else {
                 MethodHandle invoke = VARARGS_INVOKE;
                 MethodType conType = CON_TYPES[nargs];
-                MethodHandle gcon = spreadArguments(token, rawConstructor, conType, 1);
+                MethodHandle gcon = spreadArguments(rawConstructor, conType, 1);
                 if (gcon == null)  return null;
                 MethodHandle galloc = new AllocateObject(invoke, allocateClass, gcon);
-                return collectArguments(token, galloc, newType, 1, null);
+                return collectArguments(galloc, newType, 1, null);
             }
         }
         @Override
@@ -338,20 +234,16 @@ public abstract class MethodHandleImpl {
         }
     }
 
-    public static
-    MethodHandle accessField(Access token,
-                             MemberName member, boolean isSetter,
+    static
+    MethodHandle accessField(MemberName member, boolean isSetter,
                              Class<?> lookupClass) {
-        Access.check(token);
         // Use sun. misc.Unsafe to dig up the dirt on the field.
-        MethodHandle mh = new FieldAccessor(token, member, isSetter);
+        MethodHandle mh = new FieldAccessor(member, isSetter);
         return mh;
     }
 
-    public static
-    MethodHandle accessArrayElement(Access token,
-                                    Class<?> arrayClass, boolean isSetter) {
-        Access.check(token);
+    static
+    MethodHandle accessArrayElement(Class<?> arrayClass, boolean isSetter) {
         if (!arrayClass.isArray())
             throw newIllegalArgumentException("not an array: "+arrayClass);
         Class<?> elemClass = arrayClass.getComponentType();
@@ -379,12 +271,13 @@ public abstract class MethodHandleImpl {
         final long offset;
         final String name;
 
-        public FieldAccessor(Access token, MemberName field, boolean isSetter) {
-            super(Access.TOKEN, fhandle(field.getDeclaringClass(), field.getFieldType(), isSetter, field.isStatic()));
-            this.offset = (long) field.getVMIndex(token);
+        FieldAccessor(MemberName field, boolean isSetter) {
+            super(fhandle(field.getDeclaringClass(), field.getFieldType(), isSetter, field.isStatic()));
+            this.offset = (long) field.getVMIndex();
             this.name = field.getName();
             this.base = staticBase(field);
         }
+        @Override
         public String toString() { return addTypeString(name, this); }
 
         int getFieldI(C obj) { return unsafe.getInt(obj, offset); }
@@ -560,10 +453,8 @@ public abstract class MethodHandleImpl {
      * @param receiver Receiver (or first static method argument) to pre-bind.
      * @return a BoundMethodHandle for the given DirectMethodHandle, or null if it does not exist
      */
-    public static
-    MethodHandle bindReceiver(Access token,
-                              MethodHandle target, Object receiver) {
-        Access.check(token);
+    static
+    MethodHandle bindReceiver(MethodHandle target, Object receiver) {
         if (target instanceof AdapterMethodHandle &&
             ((AdapterMethodHandle)target).conversionOp() == MethodHandleNatives.Constants.OP_RETYPE_ONLY
             ) {
@@ -574,7 +465,7 @@ public abstract class MethodHandleImpl {
                     dmh.type().parameterType(0).isAssignableFrom(receiver.getClass())) {
                     MethodHandle bmh = new BoundMethodHandle(dmh, receiver, 0);
                     MethodType newType = target.type().dropParameterTypes(0, 1);
-                    return convertArguments(token, bmh, newType, bmh.type(), null);
+                    return convertArguments(bmh, newType, bmh.type(), null);
                 }
             }
         }
@@ -590,19 +481,15 @@ public abstract class MethodHandleImpl {
      * @param receiver Argument (which can be a boxed primitive) to pre-bind.
      * @return a suitable BoundMethodHandle
      */
-    public static
-    MethodHandle bindArgument(Access token,
-                              MethodHandle target, int argnum, Object receiver) {
-        Access.check(token);
+    static
+    MethodHandle bindArgument(MethodHandle target, int argnum, Object receiver) {
         return new BoundMethodHandle(target, receiver, argnum);
     }
 
-    public static MethodHandle convertArguments(Access token,
-                                                MethodHandle target,
+    static MethodHandle convertArguments(MethodHandle target,
                                                 MethodType newType,
                                                 MethodType oldType,
                                                 int[] permutationOrNull) {
-        Access.check(token);
         assert(oldType.parameterCount() == target.type().parameterCount());
         if (permutationOrNull != null) {
             int outargs = oldType.parameterCount(), inargs = newType.parameterCount();
@@ -613,7 +500,7 @@ public abstract class MethodHandleImpl {
             for (int i = 0; i < outargs; i++)
                 callTypeArgs[i] = newType.parameterType(permutationOrNull[i]);
             MethodType callType = MethodType.methodType(oldType.returnType(), callTypeArgs);
-            target = convertArguments(token, target, callType, oldType, null);
+            target = convertArguments(target, callType, oldType, null);
             assert(target != null);
             oldType = target.type();
             List<Integer> goal = new ArrayList<Integer>();  // i*TOKEN
@@ -710,7 +597,7 @@ public abstract class MethodHandleImpl {
                         Collections.rotate(ptypes.subList(rotBeg, rotEnd+1), -rotBy);
                         MethodType rotType = MethodType.methodType(oldType.returnType(), ptypes);
                         MethodHandle nextTarget
-                                = AdapterMethodHandle.makeRotateArguments(token, rotType, target,
+                                = AdapterMethodHandle.makeRotateArguments(rotType, target,
                                         rotBeg, rotSpan.size(), rotBy);
                         if (nextTarget != null) {
                             //System.out.println("Rot: "+rotSpan+" by "+rotBy);
@@ -733,7 +620,7 @@ public abstract class MethodHandleImpl {
                         int j = state.indexOf(arg);
                         Collections.swap(ptypes, i, j);
                         MethodType swapType = MethodType.methodType(oldType.returnType(), ptypes);
-                        target = AdapterMethodHandle.makeSwapArguments(token, swapType, target, i, j);
+                        target = AdapterMethodHandle.makeSwapArguments(swapType, target, i, j);
                         if (target == null)  throw newIllegalArgumentException("cannot swap");
                         assert(target.type() == swapType);
                         oldType = swapType;
@@ -760,7 +647,7 @@ public abstract class MethodHandleImpl {
                 List<Class<?>> ptypes = oldType.parameterList();
                 ptypes = ptypes.subList(0, ptypes.size() - dupArgCount);
                 MethodType dupType = MethodType.methodType(oldType.returnType(), ptypes);
-                target = AdapterMethodHandle.makeDupArguments(token, dupType, target, dupArgPos, dupArgCount);
+                target = AdapterMethodHandle.makeDupArguments(dupType, target, dupArgPos, dupArgCount);
                 if (target == null)
                     throw newIllegalArgumentException("cannot dup");
                 oldType = target.type();
@@ -778,7 +665,7 @@ public abstract class MethodHandleImpl {
                 List<Class<?>> dropTypes = newType.parameterList()
                         .subList(dropArgPos, dropArgPos + dropArgCount);
                 MethodType dropType = oldType.insertParameterTypes(dropArgPos, dropTypes);
-                target = AdapterMethodHandle.makeDropArguments(token, dropType, target, dropArgPos, dropArgCount);
+                target = AdapterMethodHandle.makeDropArguments(dropType, target, dropArgPos, dropArgCount);
                 if (target == null)  throw newIllegalArgumentException("cannot drop");
                 oldType = target.type();
             }
@@ -787,7 +674,7 @@ public abstract class MethodHandleImpl {
             return target;
         if (oldType.parameterCount() != newType.parameterCount())
             throw newIllegalArgumentException("mismatched parameter count");
-        MethodHandle res = AdapterMethodHandle.makePairwiseConvert(token, newType, target);
+        MethodHandle res = AdapterMethodHandle.makePairwiseConvert(newType, target);
         if (res != null)
             return res;
         int argc = oldType.parameterCount();
@@ -797,26 +684,24 @@ public abstract class MethodHandleImpl {
         // then back to the desired types.  We might have to use Java-based
         // method handles to do this.
         MethodType objType = MethodType.genericMethodType(argc);
-        MethodHandle objTarget = AdapterMethodHandle.makePairwiseConvert(token, objType, target);
+        MethodHandle objTarget = AdapterMethodHandle.makePairwiseConvert(objType, target);
         if (objTarget == null)
             objTarget = FromGeneric.make(target);
-        res = AdapterMethodHandle.makePairwiseConvert(token, newType, objTarget);
+        res = AdapterMethodHandle.makePairwiseConvert(newType, objTarget);
         if (res != null)
             return res;
         return ToGeneric.make(newType, objTarget);
     }
 
-    public static MethodHandle spreadArguments(Access token,
-                                               MethodHandle target,
+    static MethodHandle spreadArguments(MethodHandle target,
                                                MethodType newType,
                                                int spreadArg) {
-        Access.check(token);
         // TO DO: maybe allow the restarg to be Object and implicitly cast to Object[]
         MethodType oldType = target.type();
         // spread the last argument of newType to oldType
         int spreadCount = oldType.parameterCount() - spreadArg;
         Class<Object[]> spreadArgType = Object[].class;
-        MethodHandle res = AdapterMethodHandle.makeSpreadArguments(token, newType, target, spreadArgType, spreadArg, spreadCount);
+        MethodHandle res = AdapterMethodHandle.makeSpreadArguments(newType, target, spreadArgType, spreadArg, spreadCount);
         if (res != null)
             return res;
         // try an intermediate adapter
@@ -829,20 +714,19 @@ public abstract class MethodHandleImpl {
             ptypes[spreadArg + i] = VerifyType.spreadArgElementType(spreadType, i);
         MethodType midType = MethodType.methodType(newType.returnType(), ptypes);
         // after spreading, some arguments may need further conversion
-        MethodHandle target2 = convertArguments(token, target, midType, oldType, null);
+        MethodHandle target2 = convertArguments(target, midType, oldType, null);
         if (target2 == null)
             throw new UnsupportedOperationException("NYI: convert "+midType+" =calls=> "+oldType);
-        res = AdapterMethodHandle.makeSpreadArguments(token, newType, target2, spreadArgType, spreadArg, spreadCount);
+        res = AdapterMethodHandle.makeSpreadArguments(newType, target2, spreadArgType, spreadArg, spreadCount);
         if (res != null)
             return res;
         res = SpreadGeneric.make(target2, spreadCount);
         if (res != null)
-            res = convertArguments(token, res, newType, res.type(), null);
+            res = convertArguments(res, newType, res.type(), null);
         return res;
     }
 
-    public static MethodHandle collectArguments(Access token,
-                                                MethodHandle target,
+    static MethodHandle collectArguments(MethodHandle target,
                                                 MethodType newType,
                                                 int collectArg,
                                                 MethodHandle collector) {
@@ -856,29 +740,27 @@ public abstract class MethodHandleImpl {
         //         oldType                      // (a..., b...)=>r
         assert(newType.parameterCount() == collectArg + colType.parameterCount());
         assert(oldType.parameterCount() == collectArg + 1);
-        MethodHandle gtarget = convertArguments(token, target, oldType.generic(), oldType, null);
-        MethodHandle gcollector = convertArguments(token, collector, colType.generic(), colType, null);
+        MethodHandle gtarget = convertArguments(target, oldType.generic(), oldType, null);
+        MethodHandle gcollector = convertArguments(collector, colType.generic(), colType, null);
         if (gtarget == null || gcollector == null)  return null;
         MethodHandle gresult = FilterGeneric.makeArgumentCollector(gcollector, gtarget);
-        MethodHandle result = convertArguments(token, gresult, newType, gresult.type(), null);
+        MethodHandle result = convertArguments(gresult, newType, gresult.type(), null);
         return result;
     }
 
-    public static MethodHandle filterArgument(Access token,
-                                              MethodHandle target,
+    static MethodHandle filterArgument(MethodHandle target,
                                               int pos,
                                               MethodHandle filter) {
-        Access.check(token);
         MethodType ttype = target.type(), gttype = ttype.generic();
         if (ttype != gttype) {
-            target = convertArguments(token, target, gttype, ttype, null);
+            target = convertArguments(target, gttype, ttype, null);
             ttype = gttype;
         }
         MethodType ftype = filter.type(), gftype = ftype.generic();
         if (ftype.parameterCount() != 1)
             throw new InternalError();
         if (ftype != gftype) {
-            filter = convertArguments(token, filter, gftype, ftype, null);
+            filter = convertArguments(filter, gftype, ftype, null);
             ftype = gftype;
         }
         if (ftype == ttype) {
@@ -888,27 +770,24 @@ public abstract class MethodHandleImpl {
         return FilterGeneric.makeArgumentFilter(pos, filter, target);
     }
 
-    public static MethodHandle foldArguments(Access token,
-                                             MethodHandle target,
+    static MethodHandle foldArguments(MethodHandle target,
                                              MethodType newType,
                                              MethodHandle combiner) {
-        Access.check(token);
         MethodType oldType = target.type();
         MethodType ctype = combiner.type();
-        MethodHandle gtarget = convertArguments(token, target, oldType.generic(), oldType, null);
-        MethodHandle gcombiner = convertArguments(token, combiner, ctype.generic(), ctype, null);
+        MethodHandle gtarget = convertArguments(target, oldType.generic(), oldType, null);
+        MethodHandle gcombiner = convertArguments(combiner, ctype.generic(), ctype, null);
         if (gtarget == null || gcombiner == null)  return null;
         MethodHandle gresult = FilterGeneric.makeArgumentFolder(gcombiner, gtarget);
-        MethodHandle result = convertArguments(token, gresult, newType, gresult.type(), null);
+        MethodHandle result = convertArguments(gresult, newType, gresult.type(), null);
         return result;
     }
 
-    public static
-    MethodHandle dropArguments(Access token, MethodHandle target,
+    static
+    MethodHandle dropArguments(MethodHandle target,
                                MethodType newType, int argnum) {
-        Access.check(token);
         int drops = newType.parameterCount() - target.type().parameterCount();
-        MethodHandle res = AdapterMethodHandle.makeDropArguments(token, newType, target, argnum, drops);
+        MethodHandle res = AdapterMethodHandle.makeDropArguments(newType, target, argnum, drops);
         if (res != null)
             return res;
         throw new UnsupportedOperationException("NYI");
@@ -918,36 +797,34 @@ public abstract class MethodHandleImpl {
         private final MethodHandle test, target, fallback;
         private GuardWithTest(MethodHandle invoker,
                               MethodHandle test, MethodHandle target, MethodHandle fallback) {
-            super(Access.TOKEN, invoker);
+            super(invoker);
             this.test = test;
             this.target = target;
             this.fallback = fallback;
         }
-        static MethodHandle make(Access token,
-                                 MethodHandle test, MethodHandle target, MethodHandle fallback) {
-            Access.check(token);
+        static MethodHandle make(MethodHandle test, MethodHandle target, MethodHandle fallback) {
             MethodType type = target.type();
             int nargs = type.parameterCount();
             if (nargs < INVOKES.length) {
                 MethodHandle invoke = INVOKES[nargs];
                 MethodType gtype = type.generic();
                 assert(invoke.type().dropParameterTypes(0,1) == gtype);
-                MethodHandle gtest = convertArguments(token, test, gtype.changeReturnType(boolean.class), test.type(), null);
-                MethodHandle gtarget = convertArguments(token, target, gtype, type, null);
-                MethodHandle gfallback = convertArguments(token, fallback, gtype, type, null);
+                MethodHandle gtest = convertArguments(test, gtype.changeReturnType(boolean.class), test.type(), null);
+                MethodHandle gtarget = convertArguments(target, gtype, type, null);
+                MethodHandle gfallback = convertArguments(fallback, gtype, type, null);
                 if (gtest == null || gtarget == null || gfallback == null)  return null;
                 MethodHandle gguard = new GuardWithTest(invoke, gtest, gtarget, gfallback);
-                return convertArguments(token, gguard, type, gtype, null);
+                return convertArguments(gguard, type, gtype, null);
             } else {
                 MethodHandle invoke = VARARGS_INVOKE;
                 MethodType gtype = MethodType.genericMethodType(1);
                 assert(invoke.type().dropParameterTypes(0,1) == gtype);
-                MethodHandle gtest = spreadArguments(token, test, gtype.changeReturnType(boolean.class), 0);
-                MethodHandle gtarget = spreadArguments(token, target, gtype, 0);
-                MethodHandle gfallback = spreadArguments(token, fallback, gtype, 0);
+                MethodHandle gtest = spreadArguments(test, gtype.changeReturnType(boolean.class), 0);
+                MethodHandle gtarget = spreadArguments(target, gtype, 0);
+                MethodHandle gfallback = spreadArguments(fallback, gtype, 0);
                 MethodHandle gguard = new GuardWithTest(invoke, gtest, gtarget, gfallback);
                 if (gtest == null || gtarget == null || gfallback == null)  return null;
-                return collectArguments(token, gguard, type, 0, null);
+                return collectArguments(gguard, type, 0, null);
             }
         }
         @Override
@@ -1034,24 +911,23 @@ public abstract class MethodHandleImpl {
         }
     }
 
-    public static
-    MethodHandle makeGuardWithTest(Access token,
-                                   MethodHandle test,
+    static
+    MethodHandle makeGuardWithTest(MethodHandle test,
                                    MethodHandle target,
                                    MethodHandle fallback) {
-        return GuardWithTest.make(token, test, target, fallback);
+        return GuardWithTest.make(test, target, fallback);
     }
 
     private static class GuardWithCatch extends BoundMethodHandle {
         private final MethodHandle target;
         private final Class<? extends Throwable> exType;
         private final MethodHandle catcher;
-        public GuardWithCatch(MethodHandle target, Class<? extends Throwable> exType, MethodHandle catcher) {
+        GuardWithCatch(MethodHandle target, Class<? extends Throwable> exType, MethodHandle catcher) {
             this(INVOKES[target.type().parameterCount()], target, exType, catcher);
         }
-        public GuardWithCatch(MethodHandle invoker,
-                              MethodHandle target, Class<? extends Throwable> exType, MethodHandle catcher) {
-            super(Access.TOKEN, invoker);
+       GuardWithCatch(MethodHandle invoker,
+                      MethodHandle target, Class<? extends Throwable> exType, MethodHandle catcher) {
+            super(invoker);
             this.target = target;
             this.exType = exType;
             this.catcher = catcher;
@@ -1171,42 +1047,40 @@ public abstract class MethodHandleImpl {
     }
 
 
-    public static
-    MethodHandle makeGuardWithCatch(Access token,
-                                    MethodHandle target,
+    static
+    MethodHandle makeGuardWithCatch(MethodHandle target,
                                     Class<? extends Throwable> exType,
                                     MethodHandle catcher) {
-        Access.check(token);
         MethodType type = target.type();
         MethodType ctype = catcher.type();
         int nargs = type.parameterCount();
         if (nargs < GuardWithCatch.INVOKES.length) {
             MethodType gtype = type.generic();
             MethodType gcatchType = gtype.insertParameterTypes(0, Throwable.class);
-            MethodHandle gtarget = convertArguments(token, target, gtype, type, null);
-            MethodHandle gcatcher = convertArguments(token, catcher, gcatchType, ctype, null);
+            MethodHandle gtarget = convertArguments(target, gtype, type, null);
+            MethodHandle gcatcher = convertArguments(catcher, gcatchType, ctype, null);
             MethodHandle gguard = new GuardWithCatch(gtarget, exType, gcatcher);
             if (gtarget == null || gcatcher == null || gguard == null)  return null;
-            return convertArguments(token, gguard, type, gtype, null);
+            return convertArguments(gguard, type, gtype, null);
         } else {
             MethodType gtype = MethodType.genericMethodType(0, true);
             MethodType gcatchType = gtype.insertParameterTypes(0, Throwable.class);
-            MethodHandle gtarget = spreadArguments(token, target, gtype, 0);
-            MethodHandle gcatcher = spreadArguments(token, catcher, gcatchType, 1);
+            MethodHandle gtarget = spreadArguments(target, gtype, 0);
+            MethodHandle gcatcher = spreadArguments(catcher, gcatchType, 1);
             MethodHandle gguard = new GuardWithCatch(GuardWithCatch.VARARGS_INVOKE, gtarget, exType, gcatcher);
             if (gtarget == null || gcatcher == null || gguard == null)  return null;
-            return collectArguments(token, gguard, type, 0, null);
+            return collectArguments(gguard, type, 0, null);
         }
     }
 
-    public static
-    MethodHandle throwException(Access token, MethodType type) {
-        Access.check(token);
-        return AdapterMethodHandle.makeRetypeRaw(token, type, THROW_EXCEPTION);
+    static
+    MethodHandle throwException(MethodType type) {
+        return AdapterMethodHandle.makeRetypeRaw(type, throwException());
     }
 
-    static final MethodHandle THROW_EXCEPTION;
-    static {
+    static MethodHandle THROW_EXCEPTION;
+    static MethodHandle throwException() {
+        if (THROW_EXCEPTION != null)  return THROW_EXCEPTION;
         try {
             THROW_EXCEPTION
             = IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "throwException",
@@ -1214,71 +1088,19 @@ public abstract class MethodHandleImpl {
         } catch (ReflectiveOperationException ex) {
             throw new RuntimeException(ex);
         }
+        return THROW_EXCEPTION;
     }
     static <T extends Throwable> Empty throwException(T t) throws T { throw t; }
 
-    public static String getNameString(Access token, MethodHandle target, Object type) {
-        Access.check(token);
-        if (!(type instanceof MethodType)) {
-            if (type == null)
-                type = target.type();
-            else if (type instanceof MethodHandle)
-                type = ((MethodHandle)type).type();
-        }
-        MemberName name = null;
-        if (target != null)
-            name = MethodHandleNatives.getMethodName(target);
-        if (name == null)
-            return "invoke" + type;
-        return name.getName() + type;
-    }
-
-    public static String getNameString(Access token, MethodHandle target) {
-        return getNameString(token, target, null);
-    }
-
-    static String addTypeString(Object obj, MethodHandle target) {
-        String str = String.valueOf(obj);
-        if (target == null)  return str;
-        int paren = str.indexOf('(');
-        if (paren >= 0) str = str.substring(0, paren);
-        return str + target.type();
-    }
-
-    static void checkSpreadArgument(Object av, int n) {
-        if (av == null ? n != 0 : ((Object[])av).length != n)
-            throw newIllegalArgumentException("Array is not of length "+n);
-    }
-
-    static void raiseException(int code, Object actual, Object required) {
-        String message;
-        // disregard the identity of the actual object, if it is not a class:
-        if (!(actual instanceof Class) && !(actual instanceof MethodType))
-            actual = actual.getClass();
-        if (actual != null)
-            message = "required "+required+" but encountered "+actual;
-        else
-            message = "required "+required;
-        switch (code) {
-        case 192: // checkcast
-            throw new ClassCastException(message);
-        default:
-            throw new InternalError("unexpected code "+code+": "+message);
-        }
-    }
-
     // Linkage support:
-    public static void registerBootstrap(Access token, Class<?> callerClass, MethodHandle bootstrapMethod) {
-        Access.check(token);
+    static void registerBootstrap(Class<?> callerClass, MethodHandle bootstrapMethod) {
         MethodHandleNatives.registerBootstrap(callerClass, bootstrapMethod);
     }
-    public static MethodHandle getBootstrap(Access token, Class<?> callerClass) {
-        Access.check(token);
+    static MethodHandle getBootstrap(Class<?> callerClass) {
         return MethodHandleNatives.getBootstrap(callerClass);
     }
 
-    public static MethodHandle asVarargsCollector(Access token, MethodHandle target, Class<?> arrayType) {
-        Access.check(token);
-        return AdapterMethodHandle.makeVarargsCollector(token, target, arrayType);
+    static MethodHandle asVarargsCollector(MethodHandle target, Class<?> arrayType) {
+        return AdapterMethodHandle.makeVarargsCollector(target, arrayType);
     }
 }
diff --git a/jdk/src/share/classes/sun/dyn/MethodHandleNatives.java b/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java
similarity index 89%
rename from jdk/src/share/classes/sun/dyn/MethodHandleNatives.java
rename to jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java
index 5f1076bff6a..82d5d898638 100644
--- a/jdk/src/share/classes/sun/dyn/MethodHandleNatives.java
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleNatives.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,13 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
-import java.dyn.MethodHandles.Lookup;
+import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Field;
-import static sun.dyn.MethodHandleNatives.Constants.*;
-import static sun.dyn.MethodHandleImpl.IMPL_LOOKUP;
+import static java.lang.invoke.MethodHandleNatives.Constants.*;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
  * The JVM interface for the method handles package is all here.
@@ -81,14 +80,12 @@ class MethodHandleNatives {
      *  This routine is for debugging and reflection.
      */
     static MemberName getMethodName(MethodHandle self) {
-        if (!JVM_SUPPORT)  return null;
         return (MemberName) getTarget(self, ETF_METHOD_NAME);
     }
 
     /** Fetch the reflective version of the handled method, if available.
      */
     static AccessibleObject getTargetMethod(MethodHandle self) {
-        if (!JVM_SUPPORT)  return null;
         return (AccessibleObject) getTarget(self, ETF_REFLECT_METHOD);
     }
 
@@ -97,7 +94,6 @@ class MethodHandleNatives {
      *  If it is chained to another method handle, return that handle.
      */
     static Object getTargetInfo(MethodHandle self) {
-        if (!JVM_SUPPORT)  return null;
         return getTarget(self, ETF_HANDLE_OR_METHOD_NAME);
     }
 
@@ -111,11 +107,6 @@ class MethodHandleNatives {
      */
     static native int getConstant(int which);
 
-    /** True iff this HotSpot JVM has built-in support for method handles.
-     * If false, some test cases might run, but functionality will be missing.
-     */
-    public static final boolean JVM_SUPPORT;
-
     /** Java copy of MethodHandlePushLimit in range 2..255. */
     static final int JVM_PUSH_LIMIT;
     /** JVM stack motion (in words) after one slot is pushed, usually -1.
@@ -127,31 +118,24 @@ class MethodHandleNatives {
 
     private static native void registerNatives();
     static {
-        boolean JVM_SUPPORT_;
         int     JVM_PUSH_LIMIT_;
         int     JVM_STACK_MOVE_UNIT_;
         int     CONV_OP_IMPLEMENTED_MASK_;
         try {
             registerNatives();
-            JVM_SUPPORT_ = true;
             JVM_PUSH_LIMIT_ = getConstant(Constants.GC_JVM_PUSH_LIMIT);
             JVM_STACK_MOVE_UNIT_ = getConstant(Constants.GC_JVM_STACK_MOVE_UNIT);
             CONV_OP_IMPLEMENTED_MASK_ = getConstant(Constants.GC_CONV_OP_IMPLEMENTED_MASK);
             //sun.reflect.Reflection.registerMethodsToFilter(MethodHandleImpl.class, "init");
         } catch (UnsatisfiedLinkError ee) {
             // ignore; if we use init() methods later we'll see linkage errors
-            JVM_SUPPORT_ = false;
             JVM_PUSH_LIMIT_ = 3;  // arbitrary
             JVM_STACK_MOVE_UNIT_ = -1;  // arbitrary
             CONV_OP_IMPLEMENTED_MASK_ = 0;
-            //System.out.println("Warning: Running with JVM_SUPPORT=false");
-            //System.out.println(ee);
-            JVM_SUPPORT = JVM_SUPPORT_;
             JVM_PUSH_LIMIT = JVM_PUSH_LIMIT_;
             JVM_STACK_MOVE_UNIT = JVM_STACK_MOVE_UNIT_;
             throw ee;  // just die; hopeless to try to run with an older JVM
         }
-        JVM_SUPPORT = JVM_SUPPORT_;
         JVM_PUSH_LIMIT = JVM_PUSH_LIMIT_;
         JVM_STACK_MOVE_UNIT = JVM_STACK_MOVE_UNIT_;
         if (CONV_OP_IMPLEMENTED_MASK_ == 0)
@@ -189,9 +173,15 @@ class MethodHandleNatives {
                 MN_SEARCH_INTERFACES   = 0x00200000, // for MHN.getMembers
                 VM_INDEX_UNINITIALIZED = -99;
 
+        // BoundMethodHandle
+        /** Constants for decoding the vmargslot field, which contains 2 values. */
+        static final int
+            ARG_SLOT_PUSH_SHIFT = 16,
+            ARG_SLOT_MASK = (1<<ARG_SLOT_PUSH_SHIFT)-1;
+
         // AdapterMethodHandle
         /** Conversions recognized by the JVM.
-         *  They must align with the constants in sun.dyn_AdapterMethodHandle,
+         *  They must align with the constants in java.lang.invoke.AdapterMethodHandle,
          *  in the JVM file hotspot/src/share/vm/classfile/javaClasses.hpp.
          */
         static final int
@@ -292,7 +282,7 @@ class MethodHandleNatives {
         return true;
     }
     static {
-        if (JVM_SUPPORT)  verifyConstants();
+        verifyConstants();
     }
 
     // Up-calls from the JVM.
@@ -305,28 +295,47 @@ class MethodHandleNatives {
                                         String name, MethodType type,
                                         Object info,
                                         MemberName callerMethod, int callerBCI) {
-        return CallSiteImpl.makeSite(bootstrapMethod, name, type, info, callerMethod, callerBCI);
+        return CallSite.makeSite(bootstrapMethod, name, type, info, callerMethod, callerBCI);
+    }
+
+    /**
+     * Called by the JVM to check the length of a spread array.
+     */
+    static void checkSpreadArgument(Object av, int n) {
+        MethodHandleStatics.checkSpreadArgument(av, n);
     }
 
     /**
      * The JVM wants a pointer to a MethodType.  Oblige it by finding or creating one.
      */
     static MethodType findMethodHandleType(Class<?> rtype, Class<?>[] ptypes) {
-        MethodType.genericMethodType(0);  // trigger initialization
-        return MethodTypeImpl.makeImpl(Access.TOKEN, rtype, ptypes, true);
+        return MethodType.makeImpl(rtype, ptypes, true);
     }
 
     /**
      * The JVM wants to use a MethodType with invokeGeneric.  Give the runtime fair warning.
      */
     static void notifyGenericMethodType(MethodType type) {
-        try {
-            // Trigger adapter creation.
-            InvokeGeneric.genericInvokerOf(type);
-        } catch (Exception ex) {
-            Error err = new InternalError("Exception while resolving invokeGeneric");
-            err.initCause(ex);
-            throw err;
+        type.form().notifyGenericMethodType();
+    }
+
+    /**
+     * The JVM wants to raise an exception.  Here's the path.
+     */
+    static void raiseException(int code, Object actual, Object required) {
+        String message;
+        // disregard the identity of the actual object, if it is not a class:
+        if (!(actual instanceof Class) && !(actual instanceof MethodType))
+            actual = actual.getClass();
+        if (actual != null)
+            message = "required "+required+" but encountered "+actual;
+        else
+            message = "required "+required;
+        switch (code) {
+        case 192: // checkcast
+            throw new ClassCastException(message);
+        default:
+            throw new InternalError("unexpected code "+code+": "+message);
         }
     }
 
diff --git a/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java b/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java
new file mode 100644
index 00000000000..6ea8f978b63
--- /dev/null
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandleStatics.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang.invoke;
+
+/**
+ * This class consists exclusively of static names internal to the
+ * method handle implementation.
+ * Usage:  {@code import static java.lang.invoke.MethodHandleStatics.*}
+ * @author John Rose, JSR 292 EG
+ */
+/*non-public*/ class MethodHandleStatics {
+
+    private MethodHandleStatics() { }  // do not instantiate
+
+    /*non-public*/ static String getNameString(MethodHandle target, MethodType type) {
+        if (type == null)
+            type = target.type();
+        MemberName name = null;
+        if (target != null)
+            name = MethodHandleNatives.getMethodName(target);
+        if (name == null)
+            return "invoke" + type;
+        return name.getName() + type;
+    }
+
+    /*non-public*/ static String getNameString(MethodHandle target, MethodHandle typeHolder) {
+        return getNameString(target, typeHolder == null ? (MethodType) null : typeHolder.type());
+    }
+
+    /*non-public*/ static String getNameString(MethodHandle target) {
+        return getNameString(target, (MethodType) null);
+    }
+
+    /*non-public*/ static String addTypeString(Object obj, MethodHandle target) {
+        String str = String.valueOf(obj);
+        if (target == null)  return str;
+        int paren = str.indexOf('(');
+        if (paren >= 0) str = str.substring(0, paren);
+        return str + target.type();
+    }
+
+    static void checkSpreadArgument(Object av, int n) {
+        if (av == null ? n != 0 : ((Object[])av).length != n)
+            throw newIllegalArgumentException("Array is not of length "+n);
+    }
+
+    // handy shared exception makers (they simplify the common case code)
+    /*non-public*/ static RuntimeException newIllegalStateException(String message) {
+        return new IllegalStateException(message);
+    }
+    /*non-public*/ static RuntimeException newIllegalStateException(String message, Object obj) {
+        return new IllegalStateException(message(message, obj));
+    }
+    /*non-public*/ static RuntimeException newIllegalArgumentException(String message) {
+        return new IllegalArgumentException(message);
+    }
+    /*non-public*/ static RuntimeException newIllegalArgumentException(String message, Object obj) {
+        return new IllegalArgumentException(message(message, obj));
+    }
+    /*non-public*/ static Error uncaughtException(Exception ex) {
+        Error err = new InternalError("uncaught exception");
+        err.initCause(ex);
+        return err;
+    }
+    private static String message(String message, Object obj) {
+        if (obj != null)  message = message + ": " + obj;
+        return message;
+    }
+}
diff --git a/jdk/src/share/classes/java/dyn/MethodHandles.java b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java
similarity index 90%
rename from jdk/src/share/classes/java/dyn/MethodHandles.java
rename to jdk/src/share/classes/java/lang/invoke/MethodHandles.java
index 3bc9bd4a327..12e36da623a 100644
--- a/jdk/src/share/classes/java/dyn/MethodHandles.java
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java
@@ -23,24 +23,18 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang.invoke;
 
 import java.lang.reflect.*;
-import sun.dyn.Access;
-import sun.dyn.MemberName;
-import sun.dyn.MethodHandleImpl;
-import sun.dyn.WrapperInstance;
-import sun.dyn.util.ValueConversions;
-import sun.dyn.util.VerifyAccess;
-import sun.dyn.util.Wrapper;
+import sun.invoke.WrapperInstance;
+import sun.invoke.util.ValueConversions;
+import sun.invoke.util.VerifyAccess;
+import sun.invoke.util.Wrapper;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
-import sun.dyn.Invokers;
-import sun.dyn.MethodTypeImpl;
 import sun.reflect.Reflection;
-import static sun.dyn.MemberName.newIllegalArgumentException;
-import static sun.dyn.MemberName.newNoAccessException;
+import static java.lang.invoke.MethodHandleStatics.*;
 
 /**
  * This class consists exclusively of static methods that operate on or return
@@ -49,7 +43,7 @@ import static sun.dyn.MemberName.newNoAccessException;
  * <li>Lookup methods which help create method handles for methods and fields.
  * <li>Combinator methods, which combine or transform pre-existing method handles into new ones.
  * <li>Other factory methods to create method handles that emulate other common JVM operations or control flow patterns.
- * <li>Wrapper methods which can convert between method handles and other function-like "SAM types".
+ * <li>Wrapper methods which can convert between method handles and interface types.
  * </ul>
  * <p>
  * @author John Rose, JSR 292 EG
@@ -58,15 +52,14 @@ public class MethodHandles {
 
     private MethodHandles() { }  // do not instantiate
 
-    private static final Access IMPL_TOKEN = Access.getToken();
-    private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory(IMPL_TOKEN);
+    private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory();
     static { MethodHandleImpl.initStatics(); }
     // See IMPL_LOOKUP below.
 
     //// Method handle creation from ordinary methods.
 
     /**
-     * Return a {@link Lookup lookup object} on the caller,
+     * Returns a {@link Lookup lookup object} on the caller,
      * which has the capability to access any method handle that the caller has access to,
      * including direct method handles to private fields and methods.
      * This lookup object is a <em>capability</em> which may be delegated to trusted agents.
@@ -77,7 +70,7 @@ public class MethodHandles {
     }
 
     /**
-     * Return a {@link Lookup lookup object} which is trusted minimally.
+     * Returns a {@link Lookup lookup object} which is trusted minimally.
      * It can only be used to create method handles to
      * publicly accessible fields and methods.
      * <p>
@@ -120,55 +113,55 @@ public class MethodHandles {
      * <table border=1 cellpadding=5 summary="lookup method behaviors">
      * <tr><th>lookup expression</th><th>member</th><th>behavior</th></tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findGetter lookup.findGetter(C.class,"f",FT.class)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findGetter lookup.findGetter(C.class,"f",FT.class)}</td>
      *     <td>FT f;</td><td>(T) this.f;</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findStaticGetter lookup.findStaticGetter(C.class,"f",FT.class)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findStaticGetter lookup.findStaticGetter(C.class,"f",FT.class)}</td>
      *     <td>static<br>FT f;</td><td>(T) C.f;</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findSetter lookup.findSetter(C.class,"f",FT.class)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findSetter lookup.findSetter(C.class,"f",FT.class)}</td>
      *     <td>FT f;</td><td>this.f = x;</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findStaticSetter lookup.findStaticSetter(C.class,"f",FT.class)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findStaticSetter lookup.findStaticSetter(C.class,"f",FT.class)}</td>
      *     <td>static<br>FT f;</td><td>C.f = arg;</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findVirtual lookup.findVirtual(C.class,"m",MT)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findVirtual lookup.findVirtual(C.class,"m",MT)}</td>
      *     <td>T m(A*);</td><td>(T) this.m(arg*);</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findStatic lookup.findStatic(C.class,"m",MT)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findStatic lookup.findStatic(C.class,"m",MT)}</td>
      *     <td>static<br>T m(A*);</td><td>(T) C.m(arg*);</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findSpecial lookup.findSpecial(C.class,"m",MT,this.class)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findSpecial lookup.findSpecial(C.class,"m",MT,this.class)}</td>
      *     <td>T m(A*);</td><td>(T) super.m(arg*);</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#findConstructor lookup.findConstructor(C.class,MT)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findConstructor lookup.findConstructor(C.class,MT)}</td>
      *     <td>C(A*);</td><td>(T) new C(arg*);</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflectGetter lookup.unreflectGetter(aField)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflectGetter lookup.unreflectGetter(aField)}</td>
      *     <td>(static)?<br>FT f;</td><td>(FT) aField.get(thisOrNull);</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflectSetter lookup.unreflectSetter(aField)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflectSetter lookup.unreflectSetter(aField)}</td>
      *     <td>(static)?<br>FT f;</td><td>aField.set(thisOrNull, arg);</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}</td>
      *     <td>(static)?<br>T m(A*);</td><td>(T) aMethod.invoke(thisOrNull, arg*);</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflectConstructor lookup.unreflectConstructor(aConstructor)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflectConstructor lookup.unreflectConstructor(aConstructor)}</td>
      *     <td>C(A*);</td><td>(C) aConstructor.newInstance(arg*);</td>
      * </tr>
      * <tr>
-     *     <td>{@linkplain java.dyn.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}</td>
+     *     <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#unreflect lookup.unreflect(aMethod)}</td>
      *     <td>(static)?<br>T m(A*);</td><td>(T) aMethod.invoke(thisOrNull, arg*);</td>
      * </tr>
      * </table>
@@ -383,10 +376,10 @@ public class MethodHandles {
          *  and {@linkplain #PACKAGE PACKAGE (0x08)}.
          *  <p>
          *  A freshly-created lookup object
-         *  on the {@linkplain java.dyn.MethodHandles#lookup() caller's class}
+         *  on the {@linkplain java.lang.invoke.MethodHandles#lookup() caller's class}
          *  has all possible bits set, since the caller class can access all its own members.
          *  A lookup object on a new lookup class
-         *  {@linkplain java.dyn.MethodHandles.Lookup#in created from a previous lookup object}
+         *  {@linkplain java.lang.invoke.MethodHandles.Lookup#in created from a previous lookup object}
          *  may have some mode bits set to zero.
          *  The purpose of this is to restrict access via the new lookup object,
          *  so that it can access only names which can be reached by the original
@@ -410,9 +403,8 @@ public class MethodHandles {
             checkUnprivilegedlookupClass(lookupClass);
         }
 
-        Lookup(Access token, Class<?> lookupClass) {
+        Lookup(Class<?> lookupClass) {
             this(lookupClass, ALL_MODES);
-            Access.check(token);
         }
 
         private Lookup(Class<?> lookupClass, int allowedModes) {
@@ -471,7 +463,7 @@ public class MethodHandles {
         }
 
         // Make sure outer class is initialized first.
-        static { IMPL_TOKEN.getClass(); }
+        static { IMPL_NAMES.getClass(); }
 
         /** Version of lookup which is trusted minimally.
          *  It can only be used to create method handles to
@@ -481,11 +473,10 @@ public class MethodHandles {
 
         /** Package-private version of lookup which is trusted. */
         static final Lookup IMPL_LOOKUP = new Lookup(Object.class, TRUSTED);
-        static { MethodHandleImpl.initLookup(IMPL_TOKEN, IMPL_LOOKUP); }
 
         private static void checkUnprivilegedlookupClass(Class<?> lookupClass) {
             String name = lookupClass.getName();
-            if (name.startsWith("java.dyn.") || name.startsWith("sun.dyn."))
+            if (name.startsWith("java.lang.invoke."))
                 throw newIllegalArgumentException("illegal lookupClass: "+lookupClass);
         }
 
@@ -506,8 +497,8 @@ public class MethodHandles {
          * access (public, package, private, and protected) is allowed.
          * In this case, no suffix is added.
          * This is true only of an object obtained originally from
-         * {@link java.dyn.MethodHandles#lookup MethodHandles.lookup}.
-         * Objects created by {@link java.dyn.MethodHandles.Lookup#in Lookup.in}
+         * {@link java.lang.invoke.MethodHandles#lookup MethodHandles.lookup}.
+         * Objects created by {@link java.lang.invoke.MethodHandles.Lookup#in Lookup.in}
          * always have restricted access, and will display a suffix.
          * <p>
          * (It may seem strange that protected access should be
@@ -577,7 +568,7 @@ public class MethodHandles {
         MethodHandle findStatic(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
             MemberName method = resolveOrFail(refc, name, type, true);
             checkMethod(refc, method, true);
-            return MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, lookupClassOrNull());
+            return MethodHandleImpl.findMethod(method, false, lookupClassOrNull());
         }
 
         /**
@@ -601,8 +592,8 @@ public class MethodHandles {
          * if the class is {@code MethodHandle} and the name string is
          * {@code invokeExact} or {@code invokeGeneric}, the resulting
          * method handle is equivalent to one produced by
-         * {@link java.dyn.MethodHandles#exactInvoker MethodHandles.exactInvoker} or
-         * {@link java.dyn.MethodHandles#genericInvoker MethodHandles.genericInvoker}
+         * {@link java.lang.invoke.MethodHandles#exactInvoker MethodHandles.exactInvoker} or
+         * {@link java.lang.invoke.MethodHandles#genericInvoker MethodHandles.genericInvoker}
          * with the same {@code type} argument.
          *
          * @param refc the class or interface from which the method is accessed
@@ -618,7 +609,7 @@ public class MethodHandles {
         public MethodHandle findVirtual(Class<?> refc, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException {
             MemberName method = resolveOrFail(refc, name, type, false);
             checkMethod(refc, method, false);
-            MethodHandle mh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClassOrNull());
+            MethodHandle mh = MethodHandleImpl.findMethod(method, true, lookupClassOrNull());
             return restrictProtectedReceiver(method, mh);
         }
 
@@ -651,8 +642,8 @@ public class MethodHandles {
             MemberName ctor = resolveOrFail(refc, name, type, false, false, lookupClassOrNull());
             assert(ctor.isConstructor());
             checkAccess(refc, ctor);
-            MethodHandle rawMH = MethodHandleImpl.findMethod(IMPL_TOKEN, ctor, false, lookupClassOrNull());
-            MethodHandle allocMH = MethodHandleImpl.makeAllocator(IMPL_TOKEN, rawMH);
+            MethodHandle rawMH = MethodHandleImpl.findMethod(ctor, false, lookupClassOrNull());
+            MethodHandle allocMH = MethodHandleImpl.makeAllocator(rawMH);
             return fixVarargs(allocMH, rawMH);
         }
 
@@ -708,7 +699,7 @@ public class MethodHandles {
             checkSpecialCaller(specialCaller);
             MemberName method = resolveOrFail(refc, name, type, false, false, specialCaller);
             checkMethod(refc, method, false);
-            MethodHandle mh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, specialCaller);
+            MethodHandle mh = MethodHandleImpl.findMethod(method, false, specialCaller);
             return restrictReceiver(method, mh, specialCaller);
         }
 
@@ -839,17 +830,17 @@ return mh1;
             Class<? extends Object> refc = receiver.getClass(); // may get NPE
             MemberName method = resolveOrFail(refc, name, type, false);
             checkMethod(refc, method, false);
-            MethodHandle dmh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClassOrNull());
-            MethodHandle bmh = MethodHandleImpl.bindReceiver(IMPL_TOKEN, dmh, receiver);
+            MethodHandle dmh = MethodHandleImpl.findMethod(method, true, lookupClassOrNull());
+            MethodHandle bmh = MethodHandleImpl.bindReceiver(dmh, receiver);
             if (bmh == null)
-                throw newNoAccessException(method, this);
+                throw method.makeAccessException("no access", this);
             if (dmh.type().parameterCount() == 0)
                 return dmh;  // bound the trailing parameter; no varargs possible
             return fixVarargs(bmh, dmh);
         }
 
         /**
-         * Make a direct method handle to <i>m</i>, if the lookup class has permission.
+         * Makes a direct method handle to <i>m</i>, if the lookup class has permission.
          * If <i>m</i> is non-static, the receiver argument is treated as an initial argument.
          * If <i>m</i> is virtual, overriding is respected on every call.
          * Unlike the Core Reflection API, exceptions are <em>not</em> wrapped.
@@ -871,7 +862,7 @@ return mh1;
             MemberName method = new MemberName(m);
             assert(method.isMethod());
             if (!m.isAccessible())  checkMethod(method.getDeclaringClass(), method, method.isStatic());
-            MethodHandle mh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, true, lookupClassOrNull());
+            MethodHandle mh = MethodHandleImpl.findMethod(method, true, lookupClassOrNull());
             if (!m.isAccessible())  mh = restrictProtectedReceiver(method, mh);
             return mh;
         }
@@ -901,7 +892,7 @@ return mh1;
             assert(method.isMethod());
             // ignore m.isAccessible:  this is a new kind of access
             checkMethod(m.getDeclaringClass(), method, false);
-            MethodHandle mh = MethodHandleImpl.findMethod(IMPL_TOKEN, method, false, lookupClassOrNull());
+            MethodHandle mh = MethodHandleImpl.findMethod(method, false, lookupClassOrNull());
             return restrictReceiver(method, mh, specialCaller);
         }
 
@@ -928,8 +919,8 @@ return mh1;
             MemberName ctor = new MemberName(c);
             assert(ctor.isConstructor());
             if (!c.isAccessible())  checkAccess(c.getDeclaringClass(), ctor);
-            MethodHandle rawCtor = MethodHandleImpl.findMethod(IMPL_TOKEN, ctor, false, lookupClassOrNull());
-            MethodHandle allocator = MethodHandleImpl.makeAllocator(IMPL_TOKEN, rawCtor);
+            MethodHandle rawCtor = MethodHandleImpl.findMethod(ctor, false, lookupClassOrNull());
+            MethodHandle allocator = MethodHandleImpl.makeAllocator(rawCtor);
             return fixVarargs(allocator, rawCtor);
         }
 
@@ -940,7 +931,7 @@ return mh1;
          * If the field is static, the method handle will take no arguments.
          * Otherwise, its single argument will be the instance containing
          * the field.
-         * If the method's {@code accessible} flag is not set,
+         * If the field's {@code accessible} flag is not set,
          * access checking is performed immediately on behalf of the lookup class.
          * @param f the reflected field
          * @return a method handle which can load values from the reflected field
@@ -958,7 +949,7 @@ return mh1;
          * argument, of the field's value type, the value to be stored.
          * Otherwise, the two arguments will be the instance containing
          * the field, and the value to be stored.
-         * If the method's {@code accessible} flag is not set,
+         * If the field's {@code accessible} flag is not set,
          * access checking is performed immediately on behalf of the lookup class.
          * @param f the reflected field
          * @return a method handle which can store values into the reflected field
@@ -999,7 +990,7 @@ return mh1;
         void checkSymbolicClass(Class<?> refc) throws IllegalAccessException {
             Class<?> caller = lookupClassOrNull();
             if (caller != null && !VerifyAccess.isClassAccessible(refc, caller))
-                throw newNoAccessException("symbolic reference class is not public", new MemberName(refc), this);
+                throw new MemberName(refc).makeAccessException("symbolic reference class is not public", this);
         }
 
         void checkMethod(Class<?> refc, MemberName m, boolean wantStatic) throws IllegalAccessException {
@@ -1012,7 +1003,7 @@ return mh1;
                 message = wantStatic ? "expected a static method" : "expected a non-static method";
             else
                 { checkAccess(refc, m); return; }
-            throw newNoAccessException(message, m, this);
+            throw m.makeAccessException(message, this);
         }
 
         void checkAccess(Class<?> refc, MemberName m) throws IllegalAccessException {
@@ -1030,7 +1021,7 @@ return mh1;
                 && VerifyAccess.isSamePackage(m.getDeclaringClass(), lookupClass()))
                 // Protected members can also be checked as if they were package-private.
                 return;
-            throw newNoAccessException(accessFailedMessage(refc, m), m, this);
+            throw m.makeAccessException(accessFailedMessage(refc, m), this);
         }
 
         String accessFailedMessage(Class<?> refc, MemberName m) {
@@ -1064,8 +1055,8 @@ return mh1;
                 || (specialCaller != lookupClass()
                     && !(ALLOW_NESTMATE_ACCESS &&
                          VerifyAccess.isSamePackageMember(specialCaller, lookupClass()))))
-                throw newNoAccessException("no private access for invokespecial",
-                                           new MemberName(specialCaller), this);
+                throw new MemberName(specialCaller).
+                    makeAccessException("no private access for invokespecial", this);
         }
 
         MethodHandle restrictProtectedReceiver(MemberName method, MethodHandle mh) throws IllegalAccessException {
@@ -1084,12 +1075,12 @@ return mh1;
             assert(!method.isStatic());
             Class<?> defc = method.getDeclaringClass();  // receiver type of mh is too wide
             if (defc.isInterface() || !defc.isAssignableFrom(caller)) {
-                throw newNoAccessException("caller class must be a subclass below the method", method, caller);
+                throw method.makeAccessException("caller class must be a subclass below the method", caller);
             }
             MethodType rawType = mh.type();
             if (rawType.parameterType(0) == caller)  return mh;
             MethodType narrowType = rawType.changeParameterType(0, caller);
-            MethodHandle narrowMH = MethodHandleImpl.convertArguments(IMPL_TOKEN, mh, narrowType, rawType, null);
+            MethodHandle narrowMH = MethodHandleImpl.convertArguments(mh, narrowType, rawType, null);
             return fixVarargs(narrowMH, mh);
         }
 
@@ -1097,10 +1088,9 @@ return mh1;
                                   boolean isStatic, boolean isSetter) throws NoSuchFieldException, IllegalAccessException {
             MemberName field = resolveOrFail(refc, name, type, isStatic);
             if (isStatic != field.isStatic())
-                throw newNoAccessException(isStatic
-                                           ? "expected a static field"
-                                           : "expected a non-static field",
-                                           field, this);
+                throw field.makeAccessException(isStatic
+                                                ? "expected a static field"
+                                                : "expected a non-static field", this);
             return makeAccessor(refc, field, false, isSetter);
         }
 
@@ -1108,9 +1098,9 @@ return mh1;
                                   boolean trusted, boolean isSetter) throws IllegalAccessException {
             assert(field.isField());
             if (trusted)
-                return MethodHandleImpl.accessField(IMPL_TOKEN, field, isSetter, lookupClassOrNull());
+                return MethodHandleImpl.accessField(field, isSetter, lookupClassOrNull());
             checkAccess(refc, field);
-            MethodHandle mh = MethodHandleImpl.accessField(IMPL_TOKEN, field, isSetter, lookupClassOrNull());
+            MethodHandle mh = MethodHandleImpl.accessField(field, isSetter, lookupClassOrNull());
             return restrictProtectedReceiver(field, mh);
         }
     }
@@ -1127,7 +1117,7 @@ return mh1;
      */
     public static
     MethodHandle arrayElementGetter(Class<?> arrayClass) throws IllegalArgumentException {
-        return MethodHandleImpl.accessArrayElement(IMPL_TOKEN, arrayClass, false);
+        return MethodHandleImpl.accessArrayElement(arrayClass, false);
     }
 
     /**
@@ -1141,7 +1131,7 @@ return mh1;
      */
     public static
     MethodHandle arrayElementSetter(Class<?> arrayClass) throws IllegalArgumentException {
-        return MethodHandleImpl.accessArrayElement(IMPL_TOKEN, arrayClass, true);
+        return MethodHandleImpl.accessArrayElement(arrayClass, true);
     }
 
     /// method handle invocation (reflective style)
@@ -1191,7 +1181,7 @@ return invoker;
     MethodHandle spreadInvoker(MethodType type, int objectArgCount) {
         if (objectArgCount < 0 || objectArgCount > type.parameterCount())
             throw new IllegalArgumentException("bad argument count "+objectArgCount);
-        return invokers(type).spreadInvoker(objectArgCount);
+        return type.invokers().spreadInvoker(objectArgCount);
     }
 
     /**
@@ -1231,7 +1221,7 @@ publicLookup().findVirtual(MethodHandle.class, "invokeExact", type)
      */
     static public
     MethodHandle exactInvoker(MethodType type) {
-        return invokers(type).exactInvoker();
+        return type.invokers().exactInvoker();
     }
 
     /**
@@ -1258,11 +1248,7 @@ publicLookup().findVirtual(MethodHandle.class, "invokeGeneric", type)
      */
     static public
     MethodHandle genericInvoker(MethodType type) {
-        return invokers(type).genericInvoker();
-    }
-
-    static Invokers invokers(MethodType type) {
-        return MethodTypeImpl.invokers(IMPL_TOKEN, type);
+        return type.invokers().genericInvoker();
     }
 
     /**
@@ -1387,7 +1373,7 @@ publicLookup().findVirtual(MethodHandle.class, "invokeGeneric", type)
             return target;
         MethodHandle res = null;
         try {
-            res = MethodHandleImpl.convertArguments(IMPL_TOKEN, target,
+            res = MethodHandleImpl.convertArguments(target,
                                                     newType, oldType, null);
         } catch (IllegalArgumentException ex) {
         }
@@ -1531,7 +1517,7 @@ assert((int)twice.invokeExact(21) == 42);
     MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) {
         MethodType oldType = target.type();
         checkReorder(reorder, newType, oldType);
-        return MethodHandleImpl.convertArguments(IMPL_TOKEN, target,
+        return MethodHandleImpl.convertArguments(target,
                                                  newType, oldType,
                                                  reorder);
     }
@@ -1574,7 +1560,7 @@ assert((int)twice.invokeExact(21) == 42);
         int numSpread = (outargs - spreadPos);
         MethodHandle res = null;
         if (spreadPos >= 0 && numSpread >= 0) {
-            res = MethodHandleImpl.spreadArguments(IMPL_TOKEN, target, newType, spreadPos);
+            res = MethodHandleImpl.spreadArguments(target, newType, spreadPos);
         }
         if (res == null) {
             throw newIllegalArgumentException("cannot spread "+newType+" to " +oldType);
@@ -1607,7 +1593,7 @@ assert((int)twice.invokeExact(21) == 42);
         int numCollect = (inargs - collectPos);
         if (collectPos < 0 || numCollect < 0)
             throw newIllegalArgumentException("wrong number of arguments");
-        MethodHandle res = MethodHandleImpl.collectArguments(IMPL_TOKEN, target, newType, collectPos, null);
+        MethodHandle res = MethodHandleImpl.collectArguments(target, newType, collectPos, null);
         if (res == null) {
             throw newIllegalArgumentException("cannot collect from "+newType+" to " +oldType);
         }
@@ -1654,7 +1640,13 @@ assert((int)twice.invokeExact(21) == 42);
     MethodHandle identity(Class<?> type) {
         if (type == void.class)
             throw newIllegalArgumentException("void type");
-        return ValueConversions.identity(type);
+        else if (type == Object.class)
+            return ValueConversions.identity();
+        else if (type.isPrimitive())
+            return ValueConversions.identity(Wrapper.forPrimitiveType(type));
+        else
+            return AdapterMethodHandle.makeRetypeRaw(
+                    MethodType.methodType(type, type), ValueConversions.identity());
     }
 
     /**
@@ -1686,8 +1678,6 @@ assert((int)twice.invokeExact(21) == 42);
     MethodHandle insertArguments(MethodHandle target, int pos, Object... values) {
         int insCount = values.length;
         MethodType oldType = target.type();
-        ArrayList<Class<?>> ptypes =
-                new ArrayList<Class<?>>(oldType.parameterList());
         int outargs = oldType.parameterCount();
         int inargs  = outargs - insCount;
         if (inargs < 0)
@@ -1701,14 +1691,14 @@ assert((int)twice.invokeExact(21) == 42);
             value = checkValue(valueType, value);
             if (pos == 0 && !valueType.isPrimitive()) {
                 // At least for now, make bound method handles a special case.
-                MethodHandle bmh = MethodHandleImpl.bindReceiver(IMPL_TOKEN, result, value);
+                MethodHandle bmh = MethodHandleImpl.bindReceiver(result, value);
                 if (bmh != null) {
                     result = bmh;
                     continue;
                 }
                 // else fall through to general adapter machinery
             }
-            result = MethodHandleImpl.bindArgument(IMPL_TOKEN, result, pos, value);
+            result = MethodHandleImpl.bindArgument(result, pos, value);
         }
         return result;
     }
@@ -1726,20 +1716,21 @@ assert((int)twice.invokeExact(21) == 42);
      * <p>
      * <b>Example:</b>
      * <p><blockquote><pre>
-import static java.dyn.MethodHandles.*;
-import static java.dyn.MethodType.*;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
 ...
 MethodHandle cat = lookup().findVirtual(String.class,
   "concat", methodType(String.class, String.class));
 assertEquals("xy", (String) cat.invokeExact("x", "y"));
-MethodHandle d0 = dropArguments(cat, 0, String.class);
-assertEquals("yz", (String) d0.invokeExact("x", "y", "z"));
-MethodHandle d1 = dropArguments(cat, 1, String.class);
-assertEquals("xz", (String) d1.invokeExact("x", "y", "z"));
-MethodHandle d2 = dropArguments(cat, 2, String.class);
-assertEquals("xy", (String) d2.invokeExact("x", "y", "z"));
-MethodHandle d12 = dropArguments(cat, 1, int.class, boolean.class);
-assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
+MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
+MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
+assertEquals(bigType, d0.type());
+assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
+     * </pre></blockquote>
+     * <p>
+     * This method is also equivalent to the following code:
+     * <p><blockquote><pre>
+     * {@link #dropArguments(MethodHandle,int,Class...) dropArguments}(target, pos, valueTypes.toArray(new Class[0]))
      * </pre></blockquote>
      * @param target the method handle to invoke after the arguments are dropped
      * @param valueTypes the type(s) of the argument(s) to drop
@@ -1762,7 +1753,7 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
                 new ArrayList<Class<?>>(oldType.parameterList());
         ptypes.addAll(pos, valueTypes);
         MethodType newType = MethodType.methodType(oldType.returnType(), ptypes);
-        return MethodHandleImpl.dropArguments(IMPL_TOKEN, target, newType, pos);
+        return MethodHandleImpl.dropArguments(target, newType, pos);
     }
 
     /**
@@ -1770,10 +1761,34 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
      * after dropping the given argument(s) at the given position.
      * The type of the new method handle will insert the given argument
      * type(s), at that position, into the original handle's type.
-     * This method is equivalent to the following code:
-     * <code>
+     * <p>
+     * The <i>pos</i> may range between zero and <i>N</i>,
+     * where <i>N</i> is the number of argument types in <i>target</i>,
+     * meaning to drop the first or last argument (respectively),
+     * or an argument somewhere in between.
+     * <p>
+     * <b>Example:</b>
+     * <p><blockquote><pre>
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
+...
+MethodHandle cat = lookup().findVirtual(String.class,
+  "concat", methodType(String.class, String.class));
+assertEquals("xy", (String) cat.invokeExact("x", "y"));
+MethodHandle d0 = dropArguments(cat, 0, String.class);
+assertEquals("yz", (String) d0.invokeExact("x", "y", "z"));
+MethodHandle d1 = dropArguments(cat, 1, String.class);
+assertEquals("xz", (String) d1.invokeExact("x", "y", "z"));
+MethodHandle d2 = dropArguments(cat, 2, String.class);
+assertEquals("xy", (String) d2.invokeExact("x", "y", "z"));
+MethodHandle d12 = dropArguments(cat, 1, int.class, boolean.class);
+assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
+     * </pre></blockquote>
+     * <p>
+     * This method is also equivalent to the following code:
+     * <p><blockquote><pre>
      * {@link #dropArguments(MethodHandle,int,List) dropArguments}(target, pos, Arrays.asList(valueTypes))
-     * </code>
+     * </pre></blockquote>
      * @param target the method handle to invoke after the arguments are dropped
      * @param valueTypes the type(s) of the argument(s) to drop
      * @param pos position of first argument to drop (zero for the leftmost)
@@ -1789,7 +1804,7 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
     }
 
     /**
-     * Adapt a target method handle {@code target} by pre-processing
+     * Adapts a target method handle {@code target} by pre-processing
      * one or more of its arguments, each with its own unary filter function,
      * and then calling the target with each pre-processed argument
      * replaced by the result of its corresponding filter function.
@@ -1812,8 +1827,8 @@ assertEquals("xz", (String) d12.invokeExact("x", 12, true, "z"));
      * which do not correspond to argument positions in the target.
      * <b>Example:</b>
      * <p><blockquote><pre>
-import static java.dyn.MethodHandles.*;
-import static java.dyn.MethodType.*;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
 ...
 MethodHandle cat = lookup().findVirtual(String.class,
   "concat", methodType(String.class, String.class));
@@ -1855,16 +1870,16 @@ assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY
                 || filterType.returnType() != targetType.parameterType(curPos))
                 throw newIllegalArgumentException("target and filter types do not match");
             adapterType = adapterType.changeParameterType(curPos, filterType.parameterType(0));
-            adapter = MethodHandleImpl.filterArgument(IMPL_TOKEN, adapter, curPos, filter);
+            adapter = MethodHandleImpl.filterArgument(adapter, curPos, filter);
         }
         MethodType midType = adapter.type();
         if (midType != adapterType)
-            adapter = MethodHandleImpl.convertArguments(IMPL_TOKEN, adapter, adapterType, midType, null);
+            adapter = MethodHandleImpl.convertArguments(adapter, adapterType, midType, null);
         return adapter;
     }
 
     /**
-     * Adapt a target method handle {@code target} by post-processing
+     * Adapts a target method handle {@code target} by post-processing
      * its return value with a unary filter function.
      * <p>
      * If a filter {@code F} applies to the return value of
@@ -1876,8 +1891,8 @@ assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY
      * return type of the target.
      * <b>Example:</b>
      * <p><blockquote><pre>
-import static java.dyn.MethodHandles.*;
-import static java.dyn.MethodType.*;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
 ...
 MethodHandle cat = lookup().findVirtual(String.class,
   "concat", methodType(String.class, String.class));
@@ -1909,7 +1924,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
     }
 
     /**
-     * Adapt a target method handle {@code target} by pre-processing
+     * Adapts a target method handle {@code target} by pre-processing
      * some of its arguments, and then calling the target with
      * the result of the pre-processing, plus all original arguments.
      * <p>
@@ -1966,11 +1981,11 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
         if (!ok)
             throw misMatchedTypes("target and combiner types", targetType, combinerType);
         MethodType newType = targetType.dropParameterTypes(0, 1);
-        return MethodHandleImpl.foldArguments(IMPL_TOKEN, target, newType, combiner);
+        return MethodHandleImpl.foldArguments(target, newType, combiner);
     }
 
     /**
-     * Make a method handle which adapts a target method handle,
+     * Makes a method handle which adapts a target method handle,
      * by guarding it with a test, a boolean-valued method handle.
      * If the guard fails, a fallback handle is called instead.
      * All three method handles must have the same corresponding
@@ -2021,7 +2036,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
             test = dropArguments(test, gpc, targs.subList(gpc, tpc));
             gtype = test.type();
         }
-        return MethodHandleImpl.makeGuardWithTest(IMPL_TOKEN, test, target, fallback);
+        return MethodHandleImpl.makeGuardWithTest(test, target, fallback);
     }
 
     static RuntimeException misMatchedTypes(String what, MethodType t1, MethodType t2) {
@@ -2029,7 +2044,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
     }
 
     /**
-     * Make a method handle which adapts a target method handle,
+     * Makes a method handle which adapts a target method handle,
      * by running it inside an exception handler.
      * If the target returns normally, the adapter returns that value.
      * If an exception matching the specified type is thrown, the fallback
@@ -2092,7 +2107,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
             handler = dropArguments(handler, hpc, hargs.subList(hpc, tpc));
             htype = handler.type();
         }
-        return MethodHandleImpl.makeGuardWithCatch(IMPL_TOKEN, target, exType, handler);
+        return MethodHandleImpl.makeGuardWithCatch(target, exType, handler);
     }
 
     /**
@@ -2107,51 +2122,45 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
      */
     public static
     MethodHandle throwException(Class<?> returnType, Class<? extends Throwable> exType) {
-        return MethodHandleImpl.throwException(IMPL_TOKEN, MethodType.methodType(returnType, exType));
+        return MethodHandleImpl.throwException(MethodType.methodType(returnType, exType));
     }
 
     /**
-     * Produces an instance of the given "SAM" interface which redirects
+     * Produces an instance of the given single-method interface which redirects
      * its calls to the given method handle.
      * <p>
-     * A SAM interface is an interface which declares a single abstract method.
-     * When determining the unique abstract method of a SAM interface,
+     * A single-method interface is an interface which declares a unique method.
+     * When determining the unique method of a single-method interface,
      * the public {@code Object} methods ({@code toString}, {@code equals}, {@code hashCode})
-     * are disregarded.  For example, {@link java.util.Comparator} is a SAM interface,
+     * are disregarded.  For example, {@link java.util.Comparator} is a single-method interface,
      * even though it re-declares the {@code Object.equals} method.
-     * Also, if the SAM interface has a supertype,
-     * the SAM interface may override an inherited method.
-     * Any such overrides are respected, and the method handle will be accessible
-     * by either the inherited method or the SAM method.
-     * In particular, a {@linkplain java.lang.reflect.Method#isBridge bridge method}
-     * may be created if the methods have different return types.
      * <p>
      * The type must be public.  No additional access checks are performed.
      * <p>
-     * The resulting instance of the required SAM type will respond to
-     * invocation of the SAM type's single abstract method by calling
+     * The resulting instance of the required type will respond to
+     * invocation of the type's single abstract method by calling
      * the given {@code target} on the incoming arguments,
      * and returning or throwing whatever the {@code target}
      * returns or throws.  The invocation will be as if by
      * {@code target.invokeGeneric}.
-     * The target's type will be checked before the SAM
+     * The target's type will be checked before the
      * instance is created, as if by a call to {@code asType},
      * which may result in a {@code WrongMethodTypeException}.
      * <p>
-     * The wrapper instance will implement the requested SAM interface
-     * and its super-types, but no other SAM types.
-     * This means that the SAM instance will not unexpectedly
+     * The wrapper instance will implement the requested interface
+     * and its super-types, but no other single-method interfaces.
+     * This means that the instance will not unexpectedly
      * pass an {@code instanceof} test for any unrequested type.
      * <p style="font-size:smaller;">
      * <em>Implementation Note:</em>
-     * Therefore, each SAM instance must implement a unique SAM type.
+     * Therefore, each instance must implement a unique single-method interface.
      * Implementations may not bundle together
-     * multiple SAM types onto single implementation classes
+     * multiple single-method interfaces onto single implementation classes
      * in the style of {@link java.awt.AWTEventMulticaster}.
      * <p>
      * The method handle may throw an <em>undeclared exception</em>,
      * which means any checked exception (or other checked throwable)
-     * not declared by the SAM type's single abstract method.
+     * not declared by the requested type's single abstract method.
      * If this happens, the throwable will be wrapped in an instance of
      * {@link java.lang.reflect.UndeclaredThrowableException UndeclaredThrowableException}
      * and thrown in that wrapped form.
@@ -2161,28 +2170,37 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
      * by their behavior.
      * It is not guaranteed to return a new instance for every call.
      * <p>
+     * Because of the possibility of {@linkplain java.lang.reflect.Method#isBridge bridge methods}
+     * and other corner cases, the interface may also have several abstract methods
+     * with the same name but having distinct descriptors (types of returns and parameters).
+     * In this case, all the methods are bound in common to the one given {@code target}.
+     * The type check and effective {@code asType} conversion is applied to each
+     * method type descriptor, and all abstract methods are bound to the {@code target} in common.
+     * Beyond this type check, no further checks are made to determine that the
+     * abstract methods are related in any way.
+     * <p>
      * Future versions of this API may accept additional types,
      * such as abstract classes with single abstract methods.
      * Future versions of this API may also equip wrapper instances
      * with one or more additional public "marker" interfaces.
      *
      * @param target the method handle to invoke from the wrapper
-     * @param samType the desired type of the wrapper, a SAM type
+     * @param smType the desired type of the wrapper, a single-method interface
      * @return a correctly-typed wrapper for the given {@code target}
      * @throws NullPointerException if either argument is null
-     * @throws IllegalArgumentException if the {@code samType} is not a
+     * @throws IllegalArgumentException if the {@code smType} is not a
      *         valid argument to this method
      * @throws WrongMethodTypeException if the {@code target} cannot
-     *         be converted to the type required by the SAM type
+     *         be converted to the type required by the requested interface
      */
     // Other notes to implementors:
     // <p>
-    // No stable mapping is promised between the SAM type and
+    // No stable mapping is promised between the single-method interface and
     // the implementation class C.  Over time, several implementation
-    // classes might be used for the same SAM type.
+    // classes might be used for the same type.
     // <p>
     // If the implementation is able
-    // to prove that a wrapper of the required SAM type
+    // to prove that a wrapper of the required type
     // has already been created for a given
     // method handle, or for another method handle with the
     // same behavior, the implementation may return that wrapper in place of
@@ -2191,34 +2209,34 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
     // This method is designed to apply to common use cases
     // where a single method handle must interoperate with
     // an interface that implements a function-like
-    // API.  Additional variations, such as SAM classes with
+    // API.  Additional variations, such as single-abstract-method classes with
     // private constructors, or interfaces with multiple but related
     // entry points, must be covered by hand-written or automatically
     // generated adapter classes.
     //
     public static
-    <T> T asInstance(final MethodHandle target, final Class<T> samType) {
+    <T> T asInstance(final MethodHandle target, final Class<T> smType) {
         // POC implementation only; violates the above contract several ways
-        final Method sam = getSamMethod(samType);
-        if (sam == null)
-            throw new IllegalArgumentException("not a SAM type: "+samType.getName());
-        MethodType samMT = MethodType.methodType(sam.getReturnType(), sam.getParameterTypes());
-        MethodHandle checkTarget = target.asType(samMT);  // make throw WMT
+        final Method sm = getSingleMethod(smType);
+        if (sm == null)
+            throw new IllegalArgumentException("not a single-method interface: "+smType.getName());
+        MethodType smMT = MethodType.methodType(sm.getReturnType(), sm.getParameterTypes());
+        MethodHandle checkTarget = target.asType(smMT);  // make throw WMT
         checkTarget = checkTarget.asType(checkTarget.type().changeReturnType(Object.class));
-        final MethodHandle vaTarget = checkTarget.asSpreader(Object[].class, samMT.parameterCount());
-        return samType.cast(Proxy.newProxyInstance(
-                samType.getClassLoader(),
-                new Class[]{ samType, WrapperInstance.class },
+        final MethodHandle vaTarget = checkTarget.asSpreader(Object[].class, smMT.parameterCount());
+        return smType.cast(Proxy.newProxyInstance(
+                smType.getClassLoader(),
+                new Class[]{ smType, WrapperInstance.class },
                 new InvocationHandler() {
                     private Object getArg(String name) {
                         if ((Object)name == "getWrapperInstanceTarget")  return target;
-                        if ((Object)name == "getWrapperInstanceType")    return samType;
+                        if ((Object)name == "getWrapperInstanceType")    return smType;
                         throw new AssertionError();
                     }
                     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                         if (method.getDeclaringClass() == WrapperInstance.class)
                             return getArg(method.getName());
-                        if (method.equals(sam))
+                        if (method.equals(sm))
                             return vaTarget.invokeExact(args);
                         if (isObjectMethod(method))
                             return callObjectMethod(this, method, args);
@@ -2228,7 +2246,7 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
     }
 
     /**
-     * Determine if the given object was produced by a call to {@link #asInstance asInstance}.
+     * Determines if the given object was produced by a call to {@link #asInstance asInstance}.
      * @param x any reference
      * @return true if the reference is not null and points to an object produced by {@code asInstance}
      */
@@ -2248,11 +2266,11 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
 
     /**
      * Produces or recovers a target method handle which is behaviorally
-     * equivalent to the SAM method of this wrapper instance.
+     * equivalent to the unique method of this wrapper instance.
      * The object {@code x} must have been produced by a call to {@link #asInstance asInstance}.
      * This requirement may be tested via {@link #isWrapperInstance isWrapperInstance}.
      * @param x any reference
-     * @return a method handle implementing the SAM method
+     * @return a method handle implementing the unique method
      * @throws IllegalArgumentException if the reference x is not to a wrapper instance
      */
     public static
@@ -2261,11 +2279,11 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
     }
 
     /**
-     * Recover the SAM type for which this wrapper instance was created.
+     * Recovers the unique single-method interface type for which this wrapper instance was created.
      * The object {@code x} must have been produced by a call to {@link #asInstance asInstance}.
      * This requirement may be tested via {@link #isWrapperInstance isWrapperInstance}.
      * @param x any reference
-     * @return the SAM type for which the wrapper was created
+     * @return the single-method interface type for which the wrapper was created
      * @throws IllegalArgumentException if the reference x is not to a wrapper instance
      */
     public static
@@ -2305,24 +2323,24 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
     }
 
     private static
-    Method getSamMethod(Class<?> samType) {
-        Method sam = null;
-        for (Method m : samType.getMethods()) {
+    Method getSingleMethod(Class<?> smType) {
+        Method sm = null;
+        for (Method m : smType.getMethods()) {
             int mod = m.getModifiers();
             if (Modifier.isAbstract(mod)) {
-                if (sam != null && !isObjectMethod(sam))
+                if (sm != null && !isObjectMethod(sm))
                     return null;  // too many abstract methods
-                sam = m;
+                sm = m;
             }
         }
-        if (!samType.isInterface() && getSamConstructor(samType) == null)
+        if (!smType.isInterface() && getSingleConstructor(smType) == null)
             return null;  // wrong kind of constructor
-        return sam;
+        return sm;
     }
 
     private static
-    Constructor getSamConstructor(Class<?> samType) {
-        for (Constructor c : samType.getDeclaredConstructors()) {
+    Constructor getSingleConstructor(Class<?> smType) {
+        for (Constructor c : smType.getDeclaredConstructors()) {
             if (c.getParameterTypes().length == 0) {
                 int mod = c.getModifiers();
                 if (Modifier.isPublic(mod) || Modifier.isProtected(mod))
@@ -2334,6 +2352,6 @@ System.out.println((int) f0.invokeExact("x", "y")); // 2
 
     /*non-public*/
     static MethodHandle asVarargsCollector(MethodHandle target, Class<?> arrayType) {
-        return MethodHandleImpl.asVarargsCollector(IMPL_TOKEN, target, arrayType);
+        return MethodHandleImpl.asVarargsCollector(target, arrayType);
     }
 }
diff --git a/jdk/src/share/classes/java/dyn/MethodType.java b/jdk/src/share/classes/java/lang/invoke/MethodType.java
similarity index 93%
rename from jdk/src/share/classes/java/dyn/MethodType.java
rename to jdk/src/share/classes/java/lang/invoke/MethodType.java
index a7baf7c634e..a7fa147fa32 100644
--- a/jdk/src/share/classes/java/dyn/MethodType.java
+++ b/jdk/src/share/classes/java/lang/invoke/MethodType.java
@@ -23,18 +23,14 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang.invoke;
 
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
-import sun.dyn.Access;
-import sun.dyn.Invokers;
-import sun.dyn.MethodHandleImpl;
-import sun.dyn.MethodTypeImpl;
-import sun.dyn.util.BytecodeDescriptor;
-import static sun.dyn.MemberName.newIllegalArgumentException;
+import sun.invoke.util.BytecodeDescriptor;
+import static java.lang.invoke.MethodHandleStatics.*;
 
 /**
  * A method type represents the arguments and return type accepted and
@@ -96,34 +92,6 @@ class MethodType implements java.io.Serializable {
     private MethodType wrapAlt;  // alternative wrapped/unwrapped version
     private Invokers invokers;   // cache of handy higher-order adapters
 
-    private static final Access IMPL_TOKEN = Access.getToken();
-
-    // share a cache with a friend in this package
-    Invokers getInvokers() { return invokers; }
-    void setInvokers(Invokers inv) { invokers = inv; }
-
-    static {
-        // This hack allows the implementation package special access to
-        // the internals of MethodType.  In particular, the MTImpl has all sorts
-        // of cached information useful to the implementation code.
-        MethodTypeImpl.setMethodTypeFriend(IMPL_TOKEN, new MethodTypeImpl.MethodTypeFriend() {
-            public Class<?>[] ptypes(MethodType mt)        { return mt.ptypes; }
-            public MethodTypeImpl form(MethodType mt)      { return mt.form; }
-            public void setForm(MethodType mt, MethodTypeImpl form) {
-                assert(mt.form == null);
-                mt.form = (MethodTypeForm) form;
-            }
-            public MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes, boolean trusted) {
-                return MethodType.makeImpl(rtype, ptypes, trusted);
-            }
-            public MethodTypeImpl newMethodTypeForm(MethodType mt) {
-                return new MethodTypeForm(mt);
-            }
-            public Invokers getInvokers(MethodType mt)    { return mt.invokers; }
-            public void setInvokers(MethodType mt, Invokers inv) { mt.invokers = inv; }
-        });
-    }
-
     /**
      * Check the given parameters for validity and store them into the final fields.
      */
@@ -134,6 +102,10 @@ class MethodType implements java.io.Serializable {
         this.ptypes = ptypes;
     }
 
+    /*trusted*/ MethodTypeForm form() { return form; }
+    /*trusted*/ Class<?> rtype() { return rtype; }
+    /*trusted*/ Class<?>[] ptypes() { return ptypes; }
+
     private static void checkRtype(Class<?> rtype) {
         rtype.equals(rtype);  // null check
     }
@@ -168,7 +140,7 @@ class MethodType implements java.io.Serializable {
     static final Class<?>[] NO_PTYPES = {};
 
     /**
-     * Find or create an instance of the given method type.
+     * Finds or creates an instance of the given method type.
      * @param rtype  the return type
      * @param ptypes the parameter types
      * @return a method type with the given components
@@ -253,7 +225,7 @@ class MethodType implements java.io.Serializable {
      * @param trusted whether the ptypes can be used without cloning
      * @return the unique method type of the desired structure
      */
-    private static
+    /*trusted*/ static
     MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes, boolean trusted) {
         if (ptypes == null || ptypes.length == 0) {
             ptypes = NO_PTYPES; trusted = true;
@@ -269,7 +241,12 @@ class MethodType implements java.io.Serializable {
             // defensively copy the array passed in by the user
             mt1 = new MethodType(rtype, ptypes.clone());
         // promote the object to the Real Thing, and reprobe
-        MethodTypeImpl.initForm(IMPL_TOKEN, mt1);
+        MethodTypeForm form = MethodTypeForm.findForm(mt1);
+        mt1.form = form;
+        if (form.erasedType == mt1) {
+            // This is a principal (erased) type; show it to the JVM.
+            MethodHandleNatives.init(mt1);
+        }
         synchronized (internTable) {
             mt0 = internTable.get(mt1);
             if (mt0 != null)
@@ -279,12 +256,6 @@ class MethodType implements java.io.Serializable {
         return mt1;
     }
 
-    // Entry point from JVM.  TODO: Change the name & signature.
-    private static MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes,
-            boolean ignore1, boolean ignore2) {
-        return makeImpl(rtype, ptypes, true);
-    }
-
     private static final MethodType[] objectOnlyTypes = new MethodType[20];
 
     /**
@@ -519,7 +490,7 @@ class MethodType implements java.io.Serializable {
     }
 
     /**
-     * Convert all wrapper types to their corresponding primitive types.
+     * Converts all wrapper types to their corresponding primitive types.
      * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * All primitive types (including {@code void}) will remain unchanged.
      * A return type of {@code java.lang.Void} is changed to {@code void}.
@@ -535,7 +506,7 @@ class MethodType implements java.io.Serializable {
         MethodType wt = pt.wrapAlt;
         if (wt == null) {
             // fill in lazily
-            wt = MethodTypeImpl.canonicalize(pt, MethodTypeImpl.WRAP, MethodTypeImpl.WRAP);
+            wt = MethodTypeForm.canonicalize(pt, MethodTypeForm.WRAP, MethodTypeForm.WRAP);
             assert(wt != null);
             pt.wrapAlt = wt;
         }
@@ -547,7 +518,7 @@ class MethodType implements java.io.Serializable {
         MethodType uwt = wt.wrapAlt;
         if (uwt == null) {
             // fill in lazily
-            uwt = MethodTypeImpl.canonicalize(wt, MethodTypeImpl.UNWRAP, MethodTypeImpl.UNWRAP);
+            uwt = MethodTypeForm.canonicalize(wt, MethodTypeForm.UNWRAP, MethodTypeForm.UNWRAP);
             if (uwt == null)
                 uwt = wt;    // type has no wrappers or prims at all
             wt.wrapAlt = uwt;
@@ -658,7 +629,7 @@ class MethodType implements java.io.Serializable {
     /// Queries which have to do with the bytecode architecture
 
     /** Reports the number of JVM stack slots required to invoke a method
-     * of this type.  Note that (for historic reasons) the JVM requires
+     * of this type.  Note that (for historical reasons) the JVM requires
      * a second stack slot to pass long and double arguments.
      * So this method returns {@link #parameterCount() parameterCount} plus the
      * number of long and double parameters (if any).
@@ -666,12 +637,18 @@ class MethodType implements java.io.Serializable {
      * This method is included for the benfit of applications that must
      * generate bytecodes that process method handles and invokedynamic.
      * @return the number of JVM stack slots for this type's parameters
-     * @deprecated Will be removed for PFD.
      */
-    public int parameterSlotCount() {
+    /*non-public*/ int parameterSlotCount() {
         return form.parameterSlotCount();
     }
 
+    /*non-public*/ Invokers invokers() {
+        Invokers inv = invokers;
+        if (inv != null)  return inv;
+        invokers = inv = new Invokers(this);
+        return inv;
+    }
+
     /** Reports the number of JVM stack slots which carry all parameters including and after
      * the given position, which must be in the range of 0 to
      * {@code parameterCount} inclusive.  Successive parameters are
@@ -694,9 +671,8 @@ class MethodType implements java.io.Serializable {
      * @return the index of the (shallowest) JVM stack slot transmitting the
      *         given parameter
      * @throws IllegalArgumentException if {@code num} is negative or greater than {@code parameterCount()}
-     * @deprecated Will be removed for PFD.
      */
-    public int parameterSlotDepth(int num) {
+    /*non-public*/ int parameterSlotDepth(int num) {
         if (num < 0 || num > ptypes.length)
             parameterType(num);  // force a range check
         return form.parameterToArgSlot(num-1);
@@ -710,14 +686,14 @@ class MethodType implements java.io.Serializable {
      * This method is included for the benfit of applications that must
      * generate bytecodes that process method handles and invokedynamic.
      * @return the number of JVM stack slots (0, 1, or 2) for this type's return value
-     * @deprecated Will be removed for PFD.
+     * Will be removed for PFD.
      */
-    public int returnSlotCount() {
+    /*non-public*/ int returnSlotCount() {
         return form.returnSlotCount();
     }
 
     /**
-     * Find or create an instance of a method type, given the spelling of its bytecode descriptor.
+     * Finds or creates an instance of a method type, given the spelling of its bytecode descriptor.
      * Convenience method for {@link #methodType(java.lang.Class, java.lang.Class[]) methodType}.
      * Any class or interface name embedded in the descriptor string
      * will be resolved by calling {@link ClassLoader#loadClass(java.lang.String)}
diff --git a/jdk/src/share/classes/sun/dyn/MethodTypeImpl.java b/jdk/src/share/classes/java/lang/invoke/MethodTypeForm.java
similarity index 85%
rename from jdk/src/share/classes/sun/dyn/MethodTypeImpl.java
rename to jdk/src/share/classes/java/lang/invoke/MethodTypeForm.java
index 700ed307f74..db73b24d067 100644
--- a/jdk/src/share/classes/sun/dyn/MethodTypeImpl.java
+++ b/jdk/src/share/classes/java/lang/invoke/MethodTypeForm.java
@@ -23,11 +23,10 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
-import sun.dyn.util.Wrapper;
-import static sun.dyn.MemberName.newIllegalArgumentException;
+import sun.invoke.util.Wrapper;
+import static java.lang.invoke.MethodHandleStatics.*;
 
 /**
  * Shared information for a group of method types, which differ
@@ -42,7 +41,7 @@ import static sun.dyn.MemberName.newIllegalArgumentException;
  * No more than half of these are likely to be loaded at once.
  * @author John Rose
  */
-public class MethodTypeImpl {
+class MethodTypeForm {
     final int[] argToSlotTable, slotToArgTable;
     final long argCounts;               // packed slot & value counts
     final long primCounts;              // packed prim & double counts
@@ -66,39 +65,10 @@ public class MethodTypeImpl {
         return erasedType;
     }
 
-    public static MethodTypeImpl of(MethodType type) {
-        return METHOD_TYPE_FRIEND.form(type);
-    }
-
-    /** Access methods for the internals of MethodType, supplied to
-     *  MethodTypeImpl as a trusted agent.
-     */
-    static public interface MethodTypeFriend {
-        Class<?>[]     ptypes(MethodType mt);
-        MethodTypeImpl form(MethodType mt);
-        void           setForm(MethodType mt, MethodTypeImpl form);
-        MethodType     makeImpl(Class<?> rtype, Class<?>[] ptypes, boolean trusted);
-        MethodTypeImpl newMethodTypeForm(MethodType mt);
-        Invokers       getInvokers(MethodType mt);
-        void           setInvokers(MethodType mt, Invokers inv);
-    }
-    public static void setMethodTypeFriend(Access token, MethodTypeFriend am) {
-        Access.check(token);
-        if (METHOD_TYPE_FRIEND != null)
-            throw new InternalError();  // just once
-        METHOD_TYPE_FRIEND = am;
-    }
-    static private MethodTypeFriend METHOD_TYPE_FRIEND;
-
-    static MethodType makeImpl(Access token, Class<?> rtype, Class<?>[] ptypes, boolean trusted) {
-        Access.check(token);
-        return METHOD_TYPE_FRIEND.makeImpl(rtype, ptypes, trusted);
-    }
-
-    protected MethodTypeImpl(MethodType erasedType) {
+    protected MethodTypeForm(MethodType erasedType) {
         this.erasedType = erasedType;
 
-        Class<?>[] ptypes = METHOD_TYPE_FRIEND.ptypes(erasedType);
+        Class<?>[] ptypes = erasedType.ptypes();
         int ptypeCount = ptypes.length;
         int pslotCount = ptypeCount;            // temp. estimate
         int rtypeCount = 1;                     // temp. estimate
@@ -260,7 +230,7 @@ public class MethodTypeImpl {
      *  the type {@code (Object,int)Object} produces {@code null}.
      */
     public static int[] primsAtEndOrder(MethodType mt) {
-        MethodTypeImpl form = METHOD_TYPE_FRIEND.form(mt);
+        MethodTypeForm form = mt.form();
         if (form.primsAtEnd == form.erasedType)
             // quick check shows no reordering is necessary
             return null;
@@ -273,7 +243,7 @@ public class MethodTypeImpl {
         int lac = form.longPrimitiveParameterCount();
         int rfill = 0, ifill = argc - pac, lfill = argc - lac;
 
-        Class<?>[] ptypes = METHOD_TYPE_FRIEND.ptypes(mt);
+        Class<?>[] ptypes = mt.ptypes();
         boolean changed = false;
         for (int i = 0; i < ptypes.length; i++) {
             Class<?> pt = ptypes[i];
@@ -300,7 +270,7 @@ public class MethodTypeImpl {
      */
     public static MethodType reorderParameters(MethodType mt, int[] newParamOrder, Class<?>[] moreParams) {
         if (newParamOrder == null)  return mt;  // no-op reordering
-        Class<?>[] ptypes = METHOD_TYPE_FRIEND.ptypes(mt);
+        Class<?>[] ptypes = mt.ptypes();
         Class<?>[] ntypes = new Class<?>[newParamOrder.length];
         int maxParam = ptypes.length + (moreParams == null ? 0 : moreParams.length);
         boolean changed = (ntypes.length != ptypes.length);
@@ -314,7 +284,7 @@ public class MethodTypeImpl {
             ntypes[i] = nt;
         }
         if (!changed)  return mt;
-        return METHOD_TYPE_FRIEND.makeImpl(mt.returnType(), ntypes, true);
+        return MethodType.makeImpl(mt.returnType(), ntypes, true);
     }
 
     private static boolean hasTwoArgSlots(Class<?> type) {
@@ -376,28 +346,18 @@ public class MethodTypeImpl {
         return slotToArgTable[argSlot] - 1;
     }
 
-    public static void initForm(Access token, MethodType mt) {
-        Access.check(token);
-        MethodTypeImpl form = findForm(mt);
-        METHOD_TYPE_FRIEND.setForm(mt, form);
-        if (form.erasedType == mt) {
-            // This is a principal (erased) type; show it to the JVM.
-            MethodHandleImpl.init(token, mt);
-        }
-    }
-
-    static MethodTypeImpl findForm(MethodType mt) {
+    static MethodTypeForm findForm(MethodType mt) {
         MethodType erased = canonicalize(mt, ERASE, ERASE);
         if (erased == null) {
-            // It is already erased.  Make a new MethodTypeImpl.
-            return METHOD_TYPE_FRIEND.newMethodTypeForm(mt);
+            // It is already erased.  Make a new MethodTypeForm.
+            return new MethodTypeForm(mt);
         } else {
-            // Share the MethodTypeImpl with the erased version.
-            return METHOD_TYPE_FRIEND.form(erased);
+            // Share the MethodTypeForm with the erased version.
+            return erased.form();
         }
     }
 
-    /** Codes for {@link #canonicalize(java.lang.Class, int).
+    /** Codes for {@link #canonicalize(java.lang.Class, int)}.
      * ERASE means change every reference to {@code Object}.
      * WRAP means convert primitives (including {@code void} to their
      * corresponding wrapper types.  UNWRAP means the reverse of WRAP.
@@ -414,10 +374,10 @@ public class MethodTypeImpl {
      * Otherwise return null.
      */
     public static MethodType canonicalize(MethodType mt, int howRet, int howArgs) {
-        Class<?>[] ptypes = METHOD_TYPE_FRIEND.ptypes(mt);
-        Class<?>[] ptc = MethodTypeImpl.canonicalizes(ptypes, howArgs);
+        Class<?>[] ptypes = mt.ptypes();
+        Class<?>[] ptc = MethodTypeForm.canonicalizes(ptypes, howArgs);
         Class<?> rtype = mt.returnType();
-        Class<?> rtc = MethodTypeImpl.canonicalize(rtype, howRet);
+        Class<?> rtc = MethodTypeForm.canonicalize(rtype, howRet);
         if (ptc == null && rtc == null) {
             // It is already canonical.
             return null;
@@ -425,7 +385,7 @@ public class MethodTypeImpl {
         // Find the erased version of the method type:
         if (rtc == null)  rtc = rtype;
         if (ptc == null)  ptc = ptypes;
-        return METHOD_TYPE_FRIEND.makeImpl(rtc, ptc, true);
+        return MethodType.makeImpl(rtc, ptc, true);
     }
 
     /** Canonicalize the given return or param type.
@@ -496,16 +456,16 @@ public class MethodTypeImpl {
         return cs;
     }
 
-    public static Invokers invokers(Access token, MethodType type) {
-        Access.check(token);
-        return invokers(type);
-    }
-    /*non-public*/ static Invokers invokers(MethodType type) {
-        Invokers inv = METHOD_TYPE_FRIEND.getInvokers(type);
-        if (inv != null)  return inv;
-        inv = new Invokers(type);
-        METHOD_TYPE_FRIEND.setInvokers(type, inv);
-        return inv;
+    /*non-public*/ void notifyGenericMethodType() {
+        if (genericInvoker != null)  return;
+        try {
+            // Trigger adapter creation.
+            genericInvoker = InvokeGeneric.genericInvokerOf(erasedType);
+        } catch (Exception ex) {
+            Error err = new InternalError("Exception while resolving invokeGeneric");
+            err.initCause(ex);
+            throw err;
+        }
     }
 
     @Override
diff --git a/jdk/src/share/classes/java/dyn/MutableCallSite.java b/jdk/src/share/classes/java/lang/invoke/MutableCallSite.java
similarity index 99%
rename from jdk/src/share/classes/java/dyn/MutableCallSite.java
rename to jdk/src/share/classes/java/lang/invoke/MutableCallSite.java
index 95df7a6a6d1..fe18237bb38 100644
--- a/jdk/src/share/classes/java/dyn/MutableCallSite.java
+++ b/jdk/src/share/classes/java/lang/invoke/MutableCallSite.java
@@ -23,10 +23,8 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang.invoke;
 
-import sun.dyn.*;
-import sun.dyn.empty.Empty;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
diff --git a/jdk/src/share/classes/sun/dyn/SpreadGeneric.java b/jdk/src/share/classes/java/lang/invoke/SpreadGeneric.java
similarity index 98%
rename from jdk/src/share/classes/sun/dyn/SpreadGeneric.java
rename to jdk/src/share/classes/java/lang/invoke/SpreadGeneric.java
index 4c6a0800bcc..a862723e025 100644
--- a/jdk/src/share/classes/sun/dyn/SpreadGeneric.java
+++ b/jdk/src/share/classes/java/lang/invoke/SpreadGeneric.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,14 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
+import sun.invoke.util.ValueConversions;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
-import sun.dyn.util.ValueConversions;
-import static sun.dyn.MemberName.newIllegalArgumentException;
+import static java.lang.invoke.MethodHandleStatics.*;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
  * Generic spread adapter.
@@ -110,7 +110,7 @@ class SpreadGeneric {
     static SpreadGeneric of(MethodType targetType, int spreadCount) {
         if (targetType != targetType.generic())
             throw new UnsupportedOperationException("NYI type="+targetType);
-        MethodTypeImpl form = MethodTypeImpl.of(targetType);
+        MethodTypeForm form = targetType.form();
         int outcount = form.parameterCount();
         assert(spreadCount <= outcount);
         SpreadGeneric[] spreadGens = form.spreadGeneric;
@@ -129,7 +129,7 @@ class SpreadGeneric {
     // This mini-api is called from an Adapter to manage the spread.
     /** A check/coercion that happens once before any selections. */
     protected Object check(Object av, int n) {
-        MethodHandleImpl.checkSpreadArgument(av, n);
+        checkSpreadArgument(av, n);
         return av;
     }
 
@@ -166,7 +166,7 @@ class SpreadGeneric {
             // see if it has the required invoke method
             MethodHandle entryPoint = null;
             try {
-                entryPoint = MethodHandleImpl.IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
+                entryPoint = IMPL_LOOKUP.findSpecial(acls, iname, entryType, acls);
             } catch (ReflectiveOperationException ex) {
             }
             if (entryPoint == null)  continue;
@@ -221,21 +221,21 @@ class SpreadGeneric {
 
         @Override
         public String toString() {
-            return MethodHandleImpl.addTypeString(target, this);
+            return addTypeString(target, this);
         }
 
         static final MethodHandle NO_ENTRY = ValueConversions.identity();
 
         protected boolean isPrototype() { return target == null; }
         protected Adapter(SpreadGeneric outer) {
-            super(Access.TOKEN, NO_ENTRY);
+            super(NO_ENTRY);
             this.outer = outer;
             this.target = null;
             assert(isPrototype());
         }
 
         protected Adapter(SpreadGeneric outer, MethodHandle target) {
-            super(Access.TOKEN, outer.entryPoint);
+            super(outer.entryPoint);
             this.outer = outer;
             this.target = target;
         }
@@ -251,7 +251,7 @@ class SpreadGeneric {
             return outer.select(av, n);
         }
 
-        static private final String CLASS_PREFIX; // "sun.dyn.SpreadGeneric$"
+        static private final String CLASS_PREFIX; // "java.lang.invoke.SpreadGeneric$"
         static {
             String aname = Adapter.class.getName();
             String sname = Adapter.class.getSimpleName();
diff --git a/jdk/src/share/classes/java/dyn/SwitchPoint.java b/jdk/src/share/classes/java/lang/invoke/SwitchPoint.java
similarity index 96%
rename from jdk/src/share/classes/java/dyn/SwitchPoint.java
rename to jdk/src/share/classes/java/lang/invoke/SwitchPoint.java
index 642e194b863..d81db187c88 100644
--- a/jdk/src/share/classes/java/dyn/SwitchPoint.java
+++ b/jdk/src/share/classes/java/lang/invoke/SwitchPoint.java
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang.invoke;
 
 /**
  * <p>
@@ -73,6 +73,10 @@ assertEquals("hodmet", (String) worker.invokeExact("met", "hod"));
  * Switch points are useful without subclassing.  They may also be subclassed.
  * This may be useful in order to associate application-specific invalidation logic
  * with the switch point.
+ * Notice that there is no permanent association between a switch point and
+ * the method handles it produces and consumes.
+ * The garbage collector may collect method handles produced or consumed
+ * by a switch point independently of the lifetime of the switch point itself.
  * <p style="font-size:smaller;">
  * <em>Implementation Note:</em>
  * A switch point behaves as if implemented on top of {@link MutableCallSite},
diff --git a/jdk/src/share/classes/sun/dyn/ToGeneric.java b/jdk/src/share/classes/java/lang/invoke/ToGeneric.java
similarity index 95%
rename from jdk/src/share/classes/sun/dyn/ToGeneric.java
rename to jdk/src/share/classes/java/lang/invoke/ToGeneric.java
index 38db3fea42f..22723975d5b 100644
--- a/jdk/src/share/classes/sun/dyn/ToGeneric.java
+++ b/jdk/src/share/classes/java/lang/invoke/ToGeneric.java
@@ -23,15 +23,14 @@
  * questions.
  */
 
-package sun.dyn;
+package java.lang.invoke;
 
-import java.dyn.*;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
-import sun.dyn.util.ValueConversions;
-import sun.dyn.util.Wrapper;
-import static sun.dyn.MemberName.newIllegalArgumentException;
-import static sun.dyn.MethodTypeImpl.invokers;
+import sun.invoke.util.ValueConversions;
+import sun.invoke.util.Wrapper;
+import static java.lang.invoke.MethodHandleStatics.*;
+import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
 
 /**
  * Adapters which mediate between incoming calls which are not generic
@@ -73,7 +72,7 @@ class ToGeneric {
         assert(entryType.erase() == entryType); // for now
         // incoming call will first "forget" all reference types except Object
         this.entryType = entryType;
-        MethodHandle invoker0 = invokers(entryType.generic()).exactInvoker();
+        MethodHandle invoker0 = entryType.generic().invokers().exactInvoker();
         MethodType rawEntryTypeInit;
         Adapter ad = findAdapter(rawEntryTypeInit = entryType);
         if (ad != null) {
@@ -89,15 +88,15 @@ class ToGeneric {
         }
 
         // next, it will reorder primitives after references
-        MethodType primsAtEnd = MethodTypeImpl.of(entryType).primsAtEnd();
+        MethodType primsAtEnd = entryType.form().primsAtEnd();
         // at the same time, it will "forget" all primitive types except int/long
-        this.primsAtEndOrder = MethodTypeImpl.primsAtEndOrder(entryType);
+        this.primsAtEndOrder = MethodTypeForm.primsAtEndOrder(entryType);
         if (primsAtEndOrder != null) {
             // reordering is required; build on top of a simpler ToGeneric
             ToGeneric va2 = ToGeneric.of(primsAtEnd);
             this.adapter = va2.adapter;
             if (true) throw new UnsupportedOperationException("NYI: primitive parameters must follow references; entryType = "+entryType);
-            this.entryPoint = MethodHandleImpl.convertArguments(Access.TOKEN,
+            this.entryPoint = MethodHandleImpl.convertArguments(
                     va2.entryPoint, primsAtEnd, entryType, primsAtEndOrder);
             // example: for entryType of (int,Object,Object), the reordered
             // type is (Object,Object,int) and the order is {1,2,0},
@@ -107,7 +106,7 @@ class ToGeneric {
 
         // after any needed argument reordering, it will reinterpret
         // primitive arguments according to their "raw" types int/long
-        MethodType intsAtEnd = MethodTypeImpl.of(primsAtEnd).primsAsInts();
+        MethodType intsAtEnd = primsAtEnd.form().primsAsInts();
         ad = findAdapter(rawEntryTypeInit = intsAtEnd);
         MethodHandle rawEntryPoint;
         if (ad != null) {
@@ -116,7 +115,7 @@ class ToGeneric {
             // Perhaps the adapter is available only for longs.
             // If so, we can use it, but there will have to be a little
             // more stack motion on each call.
-            MethodType longsAtEnd = MethodTypeImpl.of(primsAtEnd).primsAsLongs();
+            MethodType longsAtEnd = primsAtEnd.form().primsAsLongs();
             ad = findAdapter(rawEntryTypeInit = longsAtEnd);
             if (ad != null) {
                 MethodType eptWithLongs = longsAtEnd.insertParameterTypes(0, ad.getClass());
@@ -128,7 +127,7 @@ class ToGeneric {
                         assert(midType.parameterType(i) == long.class);
                         assert(eptWithInts.parameterType(i) == int.class);
                         MethodType nextType = midType.changeParameterType(i, int.class);
-                        rawEntryPoint = MethodHandle.convertArguments(Access.TOKEN,
+                        rawEntryPoint = MethodHandleImpl.convertArguments(
                                 rawEntryPoint, nextType, midType, null);
                         midType = nextType;
                     }
@@ -143,7 +142,7 @@ class ToGeneric {
         }
         MethodType tepType = entryType.insertParameterTypes(0, ad.getClass());
         this.entryPoint =
-            AdapterMethodHandle.makeRetypeRaw(Access.TOKEN, tepType, rawEntryPoint);
+            AdapterMethodHandle.makeRetypeRaw(tepType, rawEntryPoint);
         if (this.entryPoint == null)
             throw new UnsupportedOperationException("cannot retype to "+entryType
                     +" from "+rawEntryPoint.type().dropParameterTypes(0, 1));
@@ -168,7 +167,7 @@ class ToGeneric {
             assert(src.isPrimitive() && dst.isPrimitive());
             if (filteredInvoker == null) {
                 filteredInvoker =
-                        AdapterMethodHandle.makeCheckCast(Access.TOKEN,
+                        AdapterMethodHandle.makeCheckCast(
                             invoker.type().generic(), invoker, 0, MethodHandle.class);
                 if (filteredInvoker == null)  throw new UnsupportedOperationException("NYI");
             }
@@ -177,7 +176,7 @@ class ToGeneric {
             if (filteredInvoker == null)  throw new InternalError();
         }
         if (filteredInvoker == null)  return invoker;
-        return AdapterMethodHandle.makeRetypeOnly(Access.TOKEN, invoker.type(), filteredInvoker);
+        return AdapterMethodHandle.makeRetypeOnly(invoker.type(), filteredInvoker);
     }
 
     /**
@@ -227,7 +226,7 @@ class ToGeneric {
         // retype erased reference arguments (the cast makes it safe to do this)
         MethodType tepType = type.insertParameterTypes(0, adapter.getClass());
         MethodHandle typedEntryPoint =
-            AdapterMethodHandle.makeRetypeRaw(Access.TOKEN, tepType, entryPoint);
+            AdapterMethodHandle.makeRetypeRaw(tepType, entryPoint);
         return adapter.makeInstance(typedEntryPoint, invoker, convert, genericTarget);
     }
 
@@ -248,7 +247,7 @@ class ToGeneric {
 
     /** Return the adapter information for this type's erasure. */
     static ToGeneric of(MethodType type) {
-        MethodTypeImpl form = MethodTypeImpl.of(type);
+        MethodTypeForm form = type.form();
         ToGeneric toGen = form.toGeneric;
         if (toGen == null)
             form.toGeneric = toGen = new ToGeneric(form.erasedType());
@@ -262,7 +261,7 @@ class ToGeneric {
 
     /* Create an adapter for the given incoming call type. */
     static Adapter findAdapter(MethodType entryPointType) {
-        MethodTypeImpl form = MethodTypeImpl.of(entryPointType);
+        MethodTypeForm form = entryPointType.form();
         Class<?> rtype = entryPointType.returnType();
         int argc = form.parameterCount();
         int lac = form.longPrimitiveParameterCount();
@@ -283,7 +282,7 @@ class ToGeneric {
             for (String iname : inames) {
                 MethodHandle entryPoint = null;
                 try {
-                    entryPoint = MethodHandleImpl.IMPL_LOOKUP.
+                    entryPoint = IMPL_LOOKUP.
                                     findSpecial(acls, iname, entryPointType, acls);
                 } catch (ReflectiveOperationException ex) {
                 }
@@ -338,13 +337,13 @@ class ToGeneric {
 
         @Override
         public String toString() {
-            return target == null ? "prototype:"+convert : MethodHandleImpl.addTypeString(target, this);
+            return target == null ? "prototype:"+convert : addTypeString(target, this);
         }
 
         protected boolean isPrototype() { return target == null; }
         /* Prototype constructor. */
         protected Adapter(MethodHandle entryPoint) {
-            super(Access.TOKEN, entryPoint);
+            super(entryPoint);
             this.invoker = null;
             this.convert = entryPoint;
             this.target = null;
@@ -356,7 +355,7 @@ class ToGeneric {
         }
 
         protected Adapter(MethodHandle entryPoint, MethodHandle invoker, MethodHandle convert, MethodHandle target) {
-            super(Access.TOKEN, entryPoint);
+            super(entryPoint);
             this.invoker = invoker;
             this.convert = convert;
             this.target = target;
@@ -396,7 +395,7 @@ class ToGeneric {
         protected float  return_F(Object res) throws Throwable { return (float) convert.invokeExact(res); }
         protected double return_D(Object res) throws Throwable { return (double)convert.invokeExact(res); }
 
-        static private final String CLASS_PREFIX; // "sun.dyn.ToGeneric$"
+        static private final String CLASS_PREFIX; // "java.lang.invoke.ToGeneric$"
         static {
             String aname = Adapter.class.getName();
             String sname = Adapter.class.getSimpleName();
@@ -452,14 +451,15 @@ class genclasses {
     static String[] TCHARS = { "L",     "I",      "J",      "F",      "D",     "A" };
     static String[][] TEMPLATES = { {
         "@for@ arity=0..3   rcat<=4 nrefs<=99 nints<=99 nlongs<=99",
-        "@for@ arity=4..5   rcat<=2 nrefs<=99 nints<=99 nlongs<=99",
+        "@for@ arity=4..4   rcat<=4 nrefs<=99 nints<=99 nlongs<=99",
+        "@for@ arity=5..5   rcat<=2 nrefs<=99 nints<=99 nlongs<=99",
         "@for@ arity=6..10  rcat<=2 nrefs<=99 nints=0   nlongs<=99",
         "    //@each-cat@",
         "    static class @cat@ extends Adapter {",
         "        protected @cat@(MethodHandle entryPoint) { super(entryPoint); }  // to build prototype",
         "        protected @cat@(MethodHandle e, MethodHandle i, MethodHandle c, MethodHandle t) { super(e, i, c, t); }",
         "        protected @cat@ makeInstance(MethodHandle e, MethodHandle i, MethodHandle c, MethodHandle t) { return new @cat@(e, i, c, t); }",
-        "        protected Object target(@Ovav@)   throws Throwable { return invoker.invokeExact(target, @av@); }",
+        "        protected Object target(@Ovav@)   throws Throwable { return invoker.invokeExact(target@comma@@av@); }",
         "        //@each-Tv@",
         "        protected Object target@cat@(@Tvav@) throws Throwable { return target(@av@); }",
         "        //@end-Tv@",
@@ -471,7 +471,7 @@ class genclasses {
         "    }",
     } };
     enum VAR {
-        cat, R, Rc, Tv, av, Tvav, Ovav;
+        cat, R, Rc, Tv, av, comma, Tvav, Ovav;
         public final String pattern = "@"+toString().replace('_','.')+"@";
         public String binding;
         static void makeBindings(boolean topLevel, int rcat, int nrefs, int nints, int nlongs) {
@@ -493,12 +493,13 @@ class genclasses {
             }
             VAR.Tv.binding = comma(Tv);
             VAR.av.binding = comma(av);
+            VAR.comma.binding = (av.length == 0 ? "" : ", ");
             VAR.Tvav.binding = comma(Tvav);
             VAR.Ovav.binding = comma(Ovav);
         }
         static String arg(int i) { return "a"+i; }
         static String param(String t, String a) { return t+" "+a; }
-        static String comma(String[] v) { return comma(v, ""); }
+        static String comma(String[] v) { return comma("", v); }
         static String comma(String sep, String[] v) {
             if (v.length == 0)  return "";
             String res = sep+v[0];
@@ -735,7 +736,7 @@ class genclasses {
         protected float  invoke_F(long   a0, long   a1, long   a2) throws Throwable { return return_F(targetA3(a0, a1, a2)); }
         protected double invoke_D(long   a0, long   a1, long   a2) throws Throwable { return return_D(targetA3(a0, a1, a2)); }
     }
-//params=[4, 5, 2, 99, 99, 99]
+//params=[4, 4, 4, 99, 99, 99]
     static class A4 extends Adapter {
         protected A4(MethodHandle entryPoint) { super(entryPoint); }  // to build prototype
         protected A4(MethodHandle e, MethodHandle i, MethodHandle c, MethodHandle t) { super(e, i, c, t); }
@@ -753,31 +754,50 @@ class genclasses {
         protected Object invoke_L(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); }
         protected int    invoke_I(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); }
         protected long   invoke_J(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); }
+        protected float  invoke_F(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); }
+        protected double invoke_D(Object a0, Object a1, Object a2, Object a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); }
         protected Object invoke_L(Object a0, Object a1, Object a2, int    a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); }
         protected int    invoke_I(Object a0, Object a1, Object a2, int    a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); }
         protected long   invoke_J(Object a0, Object a1, Object a2, int    a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); }
+        protected float  invoke_F(Object a0, Object a1, Object a2, int    a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); }
+        protected double invoke_D(Object a0, Object a1, Object a2, int    a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); }
         protected Object invoke_L(Object a0, Object a1, int    a2, int    a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); }
         protected int    invoke_I(Object a0, Object a1, int    a2, int    a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); }
         protected long   invoke_J(Object a0, Object a1, int    a2, int    a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); }
+        protected float  invoke_F(Object a0, Object a1, int    a2, int    a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); }
+        protected double invoke_D(Object a0, Object a1, int    a2, int    a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); }
         protected Object invoke_L(Object a0, int    a1, int    a2, int    a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); }
         protected int    invoke_I(Object a0, int    a1, int    a2, int    a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); }
         protected long   invoke_J(Object a0, int    a1, int    a2, int    a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); }
+        protected float  invoke_F(Object a0, int    a1, int    a2, int    a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); }
+        protected double invoke_D(Object a0, int    a1, int    a2, int    a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); }
         protected Object invoke_L(int    a0, int    a1, int    a2, int    a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); }
         protected int    invoke_I(int    a0, int    a1, int    a2, int    a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); }
         protected long   invoke_J(int    a0, int    a1, int    a2, int    a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); }
+        protected float  invoke_F(int    a0, int    a1, int    a2, int    a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); }
+        protected double invoke_D(int    a0, int    a1, int    a2, int    a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); }
         protected Object invoke_L(Object a0, Object a1, Object a2, long   a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); }
         protected int    invoke_I(Object a0, Object a1, Object a2, long   a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); }
         protected long   invoke_J(Object a0, Object a1, Object a2, long   a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); }
+        protected float  invoke_F(Object a0, Object a1, Object a2, long   a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); }
+        protected double invoke_D(Object a0, Object a1, Object a2, long   a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); }
         protected Object invoke_L(Object a0, Object a1, long   a2, long   a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); }
         protected int    invoke_I(Object a0, Object a1, long   a2, long   a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); }
         protected long   invoke_J(Object a0, Object a1, long   a2, long   a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); }
+        protected float  invoke_F(Object a0, Object a1, long   a2, long   a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); }
+        protected double invoke_D(Object a0, Object a1, long   a2, long   a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); }
         protected Object invoke_L(Object a0, long   a1, long   a2, long   a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); }
         protected int    invoke_I(Object a0, long   a1, long   a2, long   a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); }
         protected long   invoke_J(Object a0, long   a1, long   a2, long   a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); }
+        protected float  invoke_F(Object a0, long   a1, long   a2, long   a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); }
+        protected double invoke_D(Object a0, long   a1, long   a2, long   a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); }
         protected Object invoke_L(long   a0, long   a1, long   a2, long   a3) throws Throwable { return return_L(targetA4(a0, a1, a2, a3)); }
         protected int    invoke_I(long   a0, long   a1, long   a2, long   a3) throws Throwable { return return_I(targetA4(a0, a1, a2, a3)); }
         protected long   invoke_J(long   a0, long   a1, long   a2, long   a3) throws Throwable { return return_J(targetA4(a0, a1, a2, a3)); }
+        protected float  invoke_F(long   a0, long   a1, long   a2, long   a3) throws Throwable { return return_F(targetA4(a0, a1, a2, a3)); }
+        protected double invoke_D(long   a0, long   a1, long   a2, long   a3) throws Throwable { return return_D(targetA4(a0, a1, a2, a3)); }
     }
+//params=[5, 5, 2, 99, 99, 99]
     static class A5 extends Adapter {
         protected A5(MethodHandle entryPoint) { super(entryPoint); }  // to build prototype
         protected A5(MethodHandle e, MethodHandle i, MethodHandle c, MethodHandle t) { super(e, i, c, t); }
diff --git a/jdk/src/share/classes/java/dyn/VolatileCallSite.java b/jdk/src/share/classes/java/lang/invoke/VolatileCallSite.java
similarity index 99%
rename from jdk/src/share/classes/java/dyn/VolatileCallSite.java
rename to jdk/src/share/classes/java/lang/invoke/VolatileCallSite.java
index 616813ce2f5..de88f36bbb3 100644
--- a/jdk/src/share/classes/java/dyn/VolatileCallSite.java
+++ b/jdk/src/share/classes/java/lang/invoke/VolatileCallSite.java
@@ -23,9 +23,7 @@
  * questions.
  */
 
-package java.dyn;
-
-import java.util.List;
+package java.lang.invoke;
 
 /**
  * A {@code VolatileCallSite} is a {@link CallSite} whose target acts like a volatile variable.
diff --git a/jdk/src/share/classes/java/dyn/WrongMethodTypeException.java b/jdk/src/share/classes/java/lang/invoke/WrongMethodTypeException.java
similarity index 96%
rename from jdk/src/share/classes/java/dyn/WrongMethodTypeException.java
rename to jdk/src/share/classes/java/lang/invoke/WrongMethodTypeException.java
index 2455432e858..7d538dc8096 100644
--- a/jdk/src/share/classes/java/dyn/WrongMethodTypeException.java
+++ b/jdk/src/share/classes/java/lang/invoke/WrongMethodTypeException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package java.dyn;
+package java.lang.invoke;
 
 /**
  * Thrown to indicate that code has attempted to call a method handle
diff --git a/jdk/src/share/classes/java/dyn/package-info.java b/jdk/src/share/classes/java/lang/invoke/package-info.java
similarity index 86%
rename from jdk/src/share/classes/java/dyn/package-info.java
rename to jdk/src/share/classes/java/lang/invoke/package-info.java
index d01c644f312..0eac856d218 100644
--- a/jdk/src/share/classes/java/dyn/package-info.java
+++ b/jdk/src/share/classes/java/lang/invoke/package-info.java
@@ -27,21 +27,18 @@
  * The {@code java.lang.invoke} package contains dynamic language support provided directly by
  * the Java core class libraries and virtual machine.
  *
- * <p style="font-size:smaller;">
- * <em>Historic Note:</em> In some early versions of Java SE 7,
- * the name of this package is {@code java.dyn}.
  * <p>
  * Certain types in this package have special relations to dynamic
  * language support in the virtual machine:
  * <ul>
- * <li>The class {@link java.dyn.MethodHandle MethodHandle} contains
+ * <li>The class {@link java.lang.invoke.MethodHandle MethodHandle} contains
  * <a href="MethodHandle.html#sigpoly">signature polymorphic methods</a>
  * which can be linked regardless of their type descriptor.
  * Normally, method linkage requires exact matching of type descriptors.
  * </li>
  *
  * <li>The JVM bytecode format supports immediate constants of
- * the classes {@link java.dyn.MethodHandle MethodHandle} and {@link java.dyn.MethodType MethodType}.
+ * the classes {@link java.lang.invoke.MethodHandle MethodHandle} and {@link java.lang.invoke.MethodType MethodType}.
  * </li>
  * </ul>
  *
@@ -59,7 +56,7 @@
  * with tag {@code CONSTANT_InvokeDynamic} (decimal 18).  See below for its format.
  * The entry specifies the following information:
  * <ul>
- * <li>a bootstrap method (a {@link java.dyn.MethodHandle MethodHandle} constant)</li>
+ * <li>a bootstrap method (a {@link java.lang.invoke.MethodHandle MethodHandle} constant)</li>
  * <li>the dynamic invocation name (a UTF8 string)</li>
  * <li>the argument and return types of the call (encoded as a type descriptor in a UTF8 string)</li>
  * <li>optionally, a sequence of additional <em>static arguments</em> to the bootstrap method ({@code ldc}-type constants)</li>
@@ -75,11 +72,6 @@
  * A dynamic call site is linked by means of a bootstrap method,
  * as <a href="#bsm">described below</a>.
  *
- * <p style="font-size:smaller;">
- * <em>Historic Note:</em> Some older JVMs may allow the index of a {@code CONSTANT_NameAndType}
- * instead of a {@code CONSTANT_InvokeDynamic}.  In earlier, obsolete versions of this API, the
- * bootstrap method was specified dynamically, in a per-class basis, during class initialization.
- *
  * <h3><a name="indycon"></a>constant pool entries for {@code invokedynamic} instructions</h3>
  * If a constant pool entry has the tag {@code CONSTANT_InvokeDynamic} (decimal 18),
  * it must contain exactly four more bytes after the tag.
@@ -95,20 +87,20 @@
  * except that the bootstrap method specifier reference replaces
  * the {@code CONSTANT_Class} reference of a {@code CONSTANT_Methodref} entry.
  *
- * <h3><a name="mtcon"></a>constant pool entries for {@linkplain java.dyn.MethodType method types}</h3>
+ * <h3><a name="mtcon"></a>constant pool entries for {@linkplain java.lang.invoke.MethodType method types}</h3>
  * If a constant pool entry has the tag {@code CONSTANT_MethodType} (decimal 16),
  * it must contain exactly two more bytes, which must be an index to a {@code CONSTANT_Utf8}
  * entry which represents a method type descriptor.
  * <p>
  * The JVM will ensure that on first
- * execution of an {@code ldc} instruction for this entry, a {@link java.dyn.MethodType MethodType}
+ * execution of an {@code ldc} instruction for this entry, a {@link java.lang.invoke.MethodType MethodType}
  * will be created which represents the type descriptor.
  * Any classes mentioned in the {@code MethodType} will be loaded if necessary,
  * but not initialized.
  * Access checking and error reporting is performed exactly as it is for
  * references by {@code ldc} instructions to {@code CONSTANT_Class} constants.
  *
- * <h3><a name="mhcon"></a>constant pool entries for {@linkplain java.dyn.MethodHandle method handles}</h3>
+ * <h3><a name="mhcon"></a>constant pool entries for {@linkplain java.lang.invoke.MethodHandle method handles}</h3>
  * If a constant pool entry has the tag {@code CONSTANT_MethodHandle} (decimal 15),
  * it must contain exactly three more bytes.  The first byte after the tag is a subtag
  * value which must be in the range 1 through 9, and the last two must be an index to a
@@ -119,7 +111,7 @@
  * must agree according to the table below.
  * <p>
  * The JVM will ensure that on first execution of an {@code ldc} instruction
- * for this entry, a {@link java.dyn.MethodHandle MethodHandle} will be created which represents
+ * for this entry, a {@link java.lang.invoke.MethodHandle MethodHandle} will be created which represents
  * the field or method reference, according to the specific mode implied by the subtag.
  * <p>
  * As with {@code CONSTANT_Class} and {@code CONSTANT_MethodType} constants,
@@ -135,23 +127,23 @@
  * <table border=1 cellpadding=5 summary="CONSTANT_MethodHandle subtypes">
  * <tr><th>N</th><th>subtag name</th><th>member</th><th>MH type</th><th>bytecode behavior</th><th>lookup expression</th></tr>
  * <tr><td>1</td><td>REF_getField</td><td>C.f:T</td><td>(C)T</td><td>getfield C.f:T</td>
- *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findGetter findGetter(C.class,"f",T.class)}</td></tr>
+ *               <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findGetter findGetter(C.class,"f",T.class)}</td></tr>
  * <tr><td>2</td><td>REF_getStatic</td><td>C.f:T</td><td>(&nbsp;)T</td><td>getstatic C.f:T</td>
- *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findStaticGetter findStaticGetter(C.class,"f",T.class)}</td></tr>
+ *               <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findStaticGetter findStaticGetter(C.class,"f",T.class)}</td></tr>
  * <tr><td>3</td><td>REF_putField</td><td>C.f:T</td><td>(C,T)void</td><td>putfield C.f:T</td>
- *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findSetter findSetter(C.class,"f",T.class)}</td></tr>
+ *               <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findSetter findSetter(C.class,"f",T.class)}</td></tr>
  * <tr><td>4</td><td>REF_putStatic</td><td>C.f:T</td><td>(T)void</td><td>putstatic C.f:T</td>
- *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findStaticSetter findStaticSetter(C.class,"f",T.class)}</td></tr>
+ *               <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findStaticSetter findStaticSetter(C.class,"f",T.class)}</td></tr>
  * <tr><td>5</td><td>REF_invokeVirtual</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokevirtual C.m(A*)T</td>
- *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}</td></tr>
+ *               <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}</td></tr>
  * <tr><td>6</td><td>REF_invokeStatic</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokestatic C.m(A*)T</td>
- *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findStatic findStatic(C.class,"m",MT)}</td></tr>
+ *               <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findStatic findStatic(C.class,"m",MT)}</td></tr>
  * <tr><td>7</td><td>REF_invokeSpecial</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokespecial C.m(A*)T</td>
- *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findSpecial findSpecial(C.class,"m",MT,this.class)}</td></tr>
+ *               <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findSpecial findSpecial(C.class,"m",MT,this.class)}</td></tr>
  * <tr><td>8</td><td>REF_newInvokeSpecial</td><td>C.&lt;init&gt;(A*)void</td><td>(A*)C</td><td>new C; dup; invokespecial C.&lt;init&gt;(A*)void</td>
- *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findConstructor findConstructor(C.class,MT)}</td></tr>
+ *               <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findConstructor findConstructor(C.class,MT)}</td></tr>
  * <tr><td>9</td><td>REF_invokeInterface</td><td>C.m(A*)T</td><td>(C,A*)T</td><td>invokeinterface C.m(A*)T</td>
- *               <td>{@linkplain java.dyn.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}</td></tr>
+ *               <td>{@linkplain java.lang.invoke.MethodHandles.Lookup#findVirtual findVirtual(C.class,"m",MT)}</td></tr>
  * </table>
  * </code>
  * Here, the type {@code C} is taken from the {@code CONSTANT_Class} reference associated
@@ -169,7 +161,7 @@
  * and returns the same result (if any) as the corresponding <em>bytecode behavior</em>.
  * <p>
  * Each method handle constant also has an equivalent reflective <em>lookup expression</em>,
- * which is a query to a method in {@link java.dyn.MethodHandles.Lookup}.
+ * which is a query to a method in {@link java.lang.invoke.MethodHandles.Lookup}.
  * In the example lookup method expression given in the table above, the name {@code MT}
  * stands for a {@code MethodType} built from {@code T} and the sequence of argument types {@code A*}.
  * (Note that the type {@code C} is not prepended to the query type {@code MT} even if the member is non-static.)
@@ -191,7 +183,7 @@
  * A constant may refer to a method or constructor with the {@code varargs}
  * bit (hexadecimal {@code 0x0080}) set in its modifier bitmask.
  * The method handle constant produced for such a method behaves as if
- * it were created by {@link java.dyn.MethodHandle#asVarargsCollector asVarargsCollector}.
+ * it were created by {@link java.lang.invoke.MethodHandle#asVarargsCollector asVarargsCollector}.
  * In other words, the constant method handle will exhibit variable arity,
  * when invoked via {@code invokeGeneric}.
  * On the other hand, its behavior with respect to {@code invokeExact} will be the same
@@ -225,7 +217,7 @@
  * the call site must first be <em>linked</em>.
  * Linking is accomplished by calling a <em>bootstrap method</em>
  * which is given the static information content of the call site,
- * and which must produce a {@link java.dyn.MethodHandle method handle}
+ * and which must produce a {@link java.lang.invoke.MethodHandle method handle}
  * that gives the behavior of the call site.
  * <p>
  * Each {@code invokedynamic} instruction statically specifies its own
@@ -234,7 +226,7 @@
  * just like {@code invokevirtual} and the other invoke instructions.
  * <p>
  * Linking starts with resolving the constant pool entry for the
- * bootstrap method, and resolving a {@link java.dyn.MethodType MethodType} object for
+ * bootstrap method, and resolving a {@link java.lang.invoke.MethodType MethodType} object for
  * the type descriptor of the dynamic call site.
  * This resolution process may trigger class loading.
  * It may therefore throw an error if a class fails to load.
@@ -251,8 +243,8 @@
  * <li>optionally, one or more <a href="#args">additional static arguments</a> </li>
  * </ul>
  * The method handle is then applied to the other values as if by
- * {@link java.dyn.MethodHandle#invokeGeneric invokeGeneric}.
- * The returned result must be a {@link java.dyn.CallSite CallSite} (or a subclass).
+ * {@link java.lang.invoke.MethodHandle#invokeGeneric invokeGeneric}.
+ * The returned result must be a {@link java.lang.invoke.CallSite CallSite} (or a subclass).
  * The type of the call site's target must be exactly equal to the type
  * derived from the dynamic call site's type descriptor and passed to
  * the bootstrap method.
@@ -263,18 +255,12 @@
  * For example, the first argument could be {@code Object}
  * instead of {@code MethodHandles.Lookup}, and the return type
  * could also be {@code Object} instead of {@code CallSite}.
- * <p>
- * As with any method handle constant, a {@code varargs} modifier bit
- * on the bootstrap method is ignored.
- * <p>
- * Note that the first argument of the bootstrap method cannot be
- * a simple {@code Class} reference.  (This is a change from earlier
- * versions of this specification.  If the caller class is needed,
- * it is easy to {@linkplain java.dyn.MethodHandles.Lookup#lookupClass() extract it}
- * from the {@code Lookup} object.)
+ * (Note that the types and number of the stacked arguments limit
+ * the legal kinds of bootstrap methods to appropriately typed
+ * static methods and constructors of {@code CallSite} subclasses.)
  * <p>
  * After resolution, the linkage process may fail in a variety of ways.
- * All failures are reported by an {@link java.dyn.InvokeDynamicBootstrapError InvokeDynamicBootstrapError},
+ * All failures are reported by a {@link java.lang.BootstrapMethodError BootstrapMethodError},
  * which is thrown as the abnormal termination of the dynamic call
  * site execution.
  * The following circumstances will cause this:
@@ -290,7 +276,7 @@
  * <li>the bootstrap method has a wrong argument or return type </li>
  * <li>the bootstrap method invocation completes abnormally </li>
  * <li>the result from the bootstrap invocation is not a reference to
- *     an object of type {@link java.dyn.CallSite CallSite} </li>
+ *     an object of type {@link java.lang.invoke.CallSite CallSite} </li>
  * <li>the target of the {@code CallSite} does not have a target of
  *     the expected {@code MethodType} </li>
  * </ul>
@@ -309,7 +295,7 @@
  * <p>
  * In an application which requires dynamic call sites with individually
  * mutable behaviors, their bootstrap methods should produce distinct
- * {@link java.dyn.CallSite CallSite} objects, one for each linkage request.
+ * {@link java.lang.invoke.CallSite CallSite} objects, one for each linkage request.
  * Alternatively, an application can link a single {@code CallSite} object
  * to several {@code invokedynamic} instructions, in which case
  * a change to the target method will become visible at each of
@@ -322,11 +308,12 @@
  * chosen target object.
  *
  * <p style="font-size:smaller;">
- * <em>Historic Note:</em> Unlike some previous versions of this specification,
- * these rules do not enable the JVM to duplicate dynamic call sites,
+ * <em>Discussion:</em>
+ * These rules do not enable the JVM to duplicate dynamic call sites,
  * or to issue &ldquo;causeless&rdquo; bootstrap method calls.
  * Every dynamic call site transitions at most once from unlinked to linked,
  * just before its first invocation.
+ * There is no way to undo the effect of a completed bootstrap method call.
  *
  * <h3><a name="bsmattr">the {@code BootstrapMethods} attribute </h3>
  * Each {@code CONSTANT_InvokeDynamic} entry contains an index which references
@@ -354,7 +341,7 @@
  * <h3><a name="args">static arguments to the bootstrap method</h3>
  * An {@code invokedynamic} instruction specifies at least three arguments
  * to pass to its bootstrap method:
- * The caller class (expressed as a {@link java.dyn.MethodHandles.Lookup Lookup object},
+ * The caller class (expressed as a {@link java.lang.invoke.MethodHandles.Lookup Lookup object},
  * the name (extracted from the {@code CONSTANT_NameAndType} entry),
  * and the type (also extracted from the {@code CONSTANT_NameAndType} entry).
  * The {@code invokedynamic} instruction may specify additional metadata values
@@ -382,8 +369,8 @@
  * <tr><td>CONSTANT_Long</td><td><code>java.lang.Long</code></td><td>the indexed long value</td></tr>
  * <tr><td>CONSTANT_Float</td><td><code>java.lang.Float</code></td><td>the indexed float value</td></tr>
  * <tr><td>CONSTANT_Double</td><td><code>java.lang.Double</code></td><td>the indexed double value</td></tr>
- * <tr><td>CONSTANT_MethodHandle</td><td><code>java.dyn.MethodHandle</code></td><td>the indexed method handle constant</td></tr>
- * <tr><td>CONSTANT_MethodType</td><td><code>java.dyn.MethodType</code></td><td>the indexed method type constant</td></tr>
+ * <tr><td>CONSTANT_MethodHandle</td><td><code>java.lang.invoke.MethodHandle</code></td><td>the indexed method handle constant</td></tr>
+ * <tr><td>CONSTANT_MethodType</td><td><code>java.lang.invoke.MethodType</code></td><td>the indexed method type constant</td></tr>
  * </table>
  * </code>
  * <p>
@@ -403,7 +390,7 @@
  * then some or all of the arguments specified here may be collected into a trailing array parameter.
  * (This is not a special rule, but rather a useful consequence of the interaction
  * between {@code CONSTANT_MethodHandle} constants, the modifier bit for variable arity methods,
- * and the {@code java.dyn.MethodHandle#asVarargsCollector asVarargsCollector} transformation.)
+ * and the {@code java.lang.invoke.MethodHandle#asVarargsCollector asVarargsCollector} transformation.)
  * <p>
  * Given these rules, here are examples of legal bootstrap method declarations,
  * given various numbers {@code N} of extra arguments.
@@ -436,7 +423,7 @@
  * constant as an {@code Object}, but the type matching machinery of {@code invokeGeneric}
  * will cast the reference back to {@code MethodHandle} before invoking the bootstrap method.
  * (If a string constant were passed instead, by badly generated code, that cast would then fail,
- * resulting in an {@code InvokeDynamicBootstrapError}.)
+ * resulting in a {@code BootstrapMethodError}.)
  * <p>
  * Extra bootstrap method arguments are intended to allow language implementors
  * to safely and compactly encode metadata.
@@ -473,6 +460,7 @@ struct BootstrapMethods_attr {
  * </pre></blockquote>
  *
  * @author John Rose, JSR 292 EG
+ * @since 1.7
  */
 
-package java.dyn;
+package java.lang.invoke;
diff --git a/jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java b/jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
index 522fa3956b9..004cd408110 100644
--- a/jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
+++ b/jdk/src/share/classes/java/net/AbstractPlainDatagramSocketImpl.java
@@ -28,6 +28,7 @@ import java.io.FileDescriptor;
 import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.util.Enumeration;
+import sun.net.ResourceManager;
 
 /**
  * Abstract datagram and multicast socket implementation base class.
@@ -66,7 +67,14 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
      */
     protected synchronized void create() throws SocketException {
         fd = new FileDescriptor();
-        datagramSocketCreate();
+        ResourceManager.beforeUdpCreate();
+        try {
+            datagramSocketCreate();
+        } catch (SocketException ioe) {
+            ResourceManager.afterUdpClose();
+            fd = null;
+            throw ioe;
+        }
     }
 
     /**
@@ -211,6 +219,7 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
     protected void close() {
         if (fd != null) {
             datagramSocketClose();
+            ResourceManager.afterUdpClose();
             fd = null;
         }
     }
diff --git a/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java b/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java
index 6d73cbc242c..f61fb34bdf1 100644
--- a/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java
+++ b/jdk/src/share/classes/java/net/AbstractPlainSocketImpl.java
@@ -32,6 +32,7 @@ import java.io.FileDescriptor;
 
 import sun.net.ConnectionResetException;
 import sun.net.NetHooks;
+import sun.net.ResourceManager;
 
 /**
  * Default Socket Implementation. This implementation does
@@ -68,6 +69,10 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
     private int resetState;
     private final Object resetLock = new Object();
 
+   /* whether this Socket is a stream (TCP) socket or not (UDP)
+    */
+    private boolean stream;
+
     /**
      * Load net library into runtime.
      */
@@ -82,7 +87,19 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
      */
     protected synchronized void create(boolean stream) throws IOException {
         fd = new FileDescriptor();
-        socketCreate(stream);
+        this.stream = stream;
+        if (!stream) {
+            ResourceManager.beforeUdpCreate();
+            try {
+                socketCreate(false);
+            } catch (IOException ioe) {
+                ResourceManager.afterUdpClose();
+                fd = null;
+                throw ioe;
+            }
+        } else {
+            socketCreate(true);
+        }
         if (socket != null)
             socket.setCreated();
         if (serverSocket != null)
@@ -479,6 +496,9 @@ abstract class AbstractPlainSocketImpl extends SocketImpl
     protected void close() throws IOException {
         synchronized(fdLock) {
             if (fd != null) {
+                if (!stream) {
+                    ResourceManager.afterUdpClose();
+                }
                 if (fdUseCount == 0) {
                     if (closePending) {
                         return;
diff --git a/jdk/src/share/classes/java/security/AccessControlContext.java b/jdk/src/share/classes/java/security/AccessControlContext.java
index e80953b6696..940aff63770 100644
--- a/jdk/src/share/classes/java/security/AccessControlContext.java
+++ b/jdk/src/share/classes/java/security/AccessControlContext.java
@@ -29,6 +29,9 @@ import java.util.ArrayList;
 import java.util.List;
 import sun.security.util.Debug;
 import sun.security.util.SecurityConstants;
+import sun.misc.JavaSecurityAccess;
+import sun.misc.SharedSecrets;
+
 
 /**
  * An AccessControlContext is used to make system resource access decisions
@@ -196,6 +199,24 @@ public final class AccessControlContext {
         this.isPrivileged = isPrivileged;
     }
 
+    /**
+     * Constructor for JavaSecurityAccess.doIntersectionPrivilege()
+     */
+    AccessControlContext(ProtectionDomain[] context,
+                         AccessControlContext privilegedContext)
+    {
+        this.context = context;
+        this.privilegedContext = privilegedContext;
+        this.isPrivileged = true;
+    }
+
+    /**
+     * Returns this context's context.
+     */
+    ProtectionDomain[] getContext() {
+        return context;
+    }
+
     /**
      * Returns true if this context is privileged.
      */
diff --git a/jdk/src/share/classes/java/security/ProtectionDomain.java b/jdk/src/share/classes/java/security/ProtectionDomain.java
index 43a39028e3d..9025e81b5dc 100644
--- a/jdk/src/share/classes/java/security/ProtectionDomain.java
+++ b/jdk/src/share/classes/java/security/ProtectionDomain.java
@@ -36,6 +36,8 @@ import static sun.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache;
 import sun.misc.SharedSecrets;
 import sun.security.util.Debug;
 import sun.security.util.SecurityConstants;
+import sun.misc.JavaSecurityAccess;
+import sun.misc.SharedSecrets;
 
 /**
  *
@@ -59,6 +61,36 @@ import sun.security.util.SecurityConstants;
 
 public class ProtectionDomain {
 
+    static {
+        // Set up JavaSecurityAccess in SharedSecrets
+        SharedSecrets.setJavaSecurityAccess(
+            new JavaSecurityAccess() {
+                public <T> T doIntersectionPrivilege(
+                    PrivilegedAction<T> action,
+                    final AccessControlContext stack,
+                    final AccessControlContext context)
+                {
+                    if (action == null) {
+                        throw new NullPointerException();
+                    }
+                    return AccessController.doPrivileged(
+                        action,
+                        new AccessControlContext(
+                            stack.getContext(), context).optimize()
+                    );
+                }
+
+                public <T> T doIntersectionPrivilege(
+                    PrivilegedAction<T> action,
+                    AccessControlContext context)
+                {
+                    return doIntersectionPrivilege(action,
+                        AccessController.getContext(), context);
+                }
+            }
+       );
+    }
+
     /* CodeSource */
     private CodeSource codesource ;
 
diff --git a/jdk/src/share/classes/java/text/SimpleDateFormat.java b/jdk/src/share/classes/java/text/SimpleDateFormat.java
index fd2876aca05..a91a2344eca 100644
--- a/jdk/src/share/classes/java/text/SimpleDateFormat.java
+++ b/jdk/src/share/classes/java/text/SimpleDateFormat.java
@@ -504,8 +504,8 @@ public class SimpleDateFormat extends DateFormat {
     /**
      * Cache to hold the DateTimePatterns of a Locale.
      */
-    private static final ConcurrentMap<String, String[]> cachedLocaleData
-        = new ConcurrentHashMap<String, String[]>(3);
+    private static final ConcurrentMap<Locale, String[]> cachedLocaleData
+        = new ConcurrentHashMap<Locale, String[]>(3);
 
     /**
      * Cache NumberFormat instances with Locale key.
@@ -619,8 +619,7 @@ public class SimpleDateFormat extends DateFormat {
         initializeCalendar(loc);
 
         /* try the cache first */
-        String key = getKey();
-        String[] dateTimePatterns = cachedLocaleData.get(key);
+        String[] dateTimePatterns = cachedLocaleData.get(loc);
         if (dateTimePatterns == null) { /* cache miss */
             ResourceBundle r = LocaleData.getDateFormatData(loc);
             if (!isGregorianCalendar()) {
@@ -633,7 +632,7 @@ public class SimpleDateFormat extends DateFormat {
                 dateTimePatterns = r.getStringArray("DateTimePatterns");
             }
             /* update cache */
-            cachedLocaleData.putIfAbsent(key, dateTimePatterns);
+            cachedLocaleData.putIfAbsent(loc, dateTimePatterns);
         }
         formatData = DateFormatSymbols.getInstanceRef(loc);
         if ((timeStyle >= 0) && (dateStyle >= 0)) {
@@ -684,13 +683,6 @@ public class SimpleDateFormat extends DateFormat {
         }
     }
 
-    private String getKey() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getCalendarName()).append('.');
-        sb.append(locale.getLanguage()).append('_').append(locale.getCountry()).append('_').append(locale.getVariant());
-        return sb.toString();
-    }
-
     /**
      * Returns the compiled form of the given pattern. The syntax of
      * the compiled pattern is:
diff --git a/jdk/src/share/classes/javax/swing/JOptionPane.java b/jdk/src/share/classes/javax/swing/JOptionPane.java
index 66154cf39b5..307d834b4e6 100644
--- a/jdk/src/share/classes/javax/swing/JOptionPane.java
+++ b/jdk/src/share/classes/javax/swing/JOptionPane.java
@@ -987,11 +987,33 @@ public class JOptionPane extends JComponent implements Accessible
         }
         dialog.pack();
         dialog.setLocationRelativeTo(parentComponent);
+
+        final PropertyChangeListener listener = new PropertyChangeListener() {
+            public void propertyChange(PropertyChangeEvent event) {
+                // Let the defaultCloseOperation handle the closing
+                // if the user closed the window without selecting a button
+                // (newValue = null in that case).  Otherwise, close the dialog.
+                if (dialog.isVisible() && event.getSource() == JOptionPane.this &&
+                        (event.getPropertyName().equals(VALUE_PROPERTY) ||
+                                event.getPropertyName().equals(INPUT_VALUE_PROPERTY)) &&
+                        event.getNewValue() != null &&
+                        event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
+                    dialog.setVisible(false);
+                }
+            }
+        };
+
         WindowAdapter adapter = new WindowAdapter() {
             private boolean gotFocus = false;
             public void windowClosing(WindowEvent we) {
                 setValue(null);
             }
+
+            public void windowClosed(WindowEvent e) {
+                removePropertyChangeListener(listener);
+                dialog.getContentPane().removeAll();
+            }
+
             public void windowGainedFocus(WindowEvent we) {
                 // Once window gets focus, set initial focus
                 if (!gotFocus) {
@@ -1008,20 +1030,8 @@ public class JOptionPane extends JComponent implements Accessible
                 setValue(JOptionPane.UNINITIALIZED_VALUE);
             }
         });
-        addPropertyChangeListener(new PropertyChangeListener() {
-            public void propertyChange(PropertyChangeEvent event) {
-                // Let the defaultCloseOperation handle the closing
-                // if the user closed the window without selecting a button
-                // (newValue = null in that case).  Otherwise, close the dialog.
-                if (dialog.isVisible() && event.getSource() == JOptionPane.this &&
-                  (event.getPropertyName().equals(VALUE_PROPERTY) ||
-                   event.getPropertyName().equals(INPUT_VALUE_PROPERTY)) &&
-                  event.getNewValue() != null &&
-                  event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
-                    dialog.setVisible(false);
-                }
-            }
-        });
+
+        addPropertyChangeListener(listener);
     }
 
 
diff --git a/jdk/src/share/classes/javax/swing/Timer.java b/jdk/src/share/classes/javax/swing/Timer.java
index 9e98d5f920e..c6c80baeda9 100644
--- a/jdk/src/share/classes/javax/swing/Timer.java
+++ b/jdk/src/share/classes/javax/swing/Timer.java
@@ -35,6 +35,10 @@ import java.util.concurrent.locks.*;
 import java.awt.*;
 import java.awt.event.*;
 import java.io.Serializable;
+import java.io.*;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import javax.swing.event.EventListenerList;
 
 
@@ -208,6 +212,22 @@ public class Timer implements Serializable
         }
     }
 
+    /*
+     * The timer's AccessControlContext.
+     */
+     private transient volatile AccessControlContext acc =
+            AccessController.getContext();
+
+    /**
+      * Returns the acc this timer was constructed with.
+      */
+     final AccessControlContext getAccessControlContext() {
+       if (acc == null) {
+           throw new SecurityException(
+                   "Timer is missing AccessControlContext");
+       }
+       return acc;
+     }
 
     /**
      * DoPostEvent is a runnable class that fires actionEvents to
@@ -587,8 +607,13 @@ public class Timer implements Serializable
 
 
     void post() {
-        if (notify.compareAndSet(false, true) || !coalesce) {
-            SwingUtilities.invokeLater(doPostEvent);
+         if (notify.compareAndSet(false, true) || !coalesce) {
+             AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                 public Void run() {
+                     SwingUtilities.invokeLater(doPostEvent);
+                     return null;
+                }
+            }, getAccessControlContext());
         }
     }
 
@@ -596,6 +621,13 @@ public class Timer implements Serializable
         return lock;
     }
 
+    private void readObject(ObjectInputStream in)
+        throws ClassNotFoundException, IOException
+    {
+        this.acc = AccessController.getContext();
+        in.defaultReadObject();
+    }
+
     /*
      * We have to use readResolve because we can not initialize final
      * fields for deserialized object otherwise
diff --git a/jdk/src/share/classes/javax/swing/TransferHandler.java b/jdk/src/share/classes/javax/swing/TransferHandler.java
index eb7f8d1a644..dd54b259eef 100644
--- a/jdk/src/share/classes/javax/swing/TransferHandler.java
+++ b/jdk/src/share/classes/javax/swing/TransferHandler.java
@@ -42,6 +42,16 @@ import sun.awt.AppContext;
 import sun.swing.*;
 import sun.awt.SunToolkit;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import java.security.AccessControlContext;
+import java.security.ProtectionDomain;
+import sun.misc.SharedSecrets;
+import sun.misc.JavaSecurityAccess;
+
+import sun.awt.AWTAccessor;
+
 /**
  * This class is used to handle the transfer of a <code>Transferable</code>
  * to and from Swing components.  The <code>Transferable</code> is used to
@@ -1686,7 +1696,37 @@ public class TransferHandler implements Serializable {
             return true;
         }
 
-        public void actionPerformed(ActionEvent e) {
+        private static final JavaSecurityAccess javaSecurityAccess =
+            SharedSecrets.getJavaSecurityAccess();
+
+        public void actionPerformed(final ActionEvent e) {
+            final Object src = e.getSource();
+
+            final PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
+                public Void run() {
+                    actionPerformedImpl(e);
+                    return null;
+                }
+            };
+
+            final AccessControlContext stack = AccessController.getContext();
+            final AccessControlContext srcAcc = AWTAccessor.getComponentAccessor().getAccessControlContext((Component)src);
+            final AccessControlContext eventAcc = AWTAccessor.getAWTEventAccessor().getAccessControlContext(e);
+
+                if (srcAcc == null) {
+                    javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc);
+                } else {
+                    javaSecurityAccess.doIntersectionPrivilege(
+                        new PrivilegedAction<Void>() {
+                            public Void run() {
+                                javaSecurityAccess.doIntersectionPrivilege(action, eventAcc);
+                                return null;
+                             }
+                    }, stack, srcAcc);
+                }
+        }
+
+        private void actionPerformedImpl(ActionEvent e) {
             Object src = e.getSource();
             if (src instanceof JComponent) {
                 JComponent c = (JComponent) src;
diff --git a/jdk/src/share/classes/overview-core.html b/jdk/src/share/classes/overview-core.html
index 86f33fe6ce9..c4b518c57b8 100644
--- a/jdk/src/share/classes/overview-core.html
+++ b/jdk/src/share/classes/overview-core.html
@@ -33,7 +33,7 @@ questions.
 
 <body>
 
-This document is the API specification for version&nbsp;6 of the Java&#x2122;
+This document is the API specification for the Java&#x2122;
 Platform, Standard Edition.
 
 </body>
diff --git a/jdk/src/share/classes/sun/applet/resources/MsgAppletViewer.java b/jdk/src/share/classes/sun/applet/resources/MsgAppletViewer.java
index 015bcd3f442..af1f3d5a609 100644
--- a/jdk/src/share/classes/sun/applet/resources/MsgAppletViewer.java
+++ b/jdk/src/share/classes/sun/applet/resources/MsgAppletViewer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -103,7 +103,6 @@ public class MsgAppletViewer extends ListResourceBundle {
             {"appletclassloader.fileexception", "{0} exception when loading: {1}"},
             {"appletclassloader.filedeath", "{0} killed when loading: {1}"},
             {"appletclassloader.fileerror", "{0} error when loading: {1}"},
-            {"appletclassloader.findclass.verbose.findclass", "{0} find class {1}"},
             {"appletclassloader.findclass.verbose.openstream", "Opening stream to: {0} to get {1}"},
             {"appletclassloader.getresource.verbose.forname", "AppletClassLoader.getResource for name: {0}"},
             {"appletclassloader.getresource.verbose.found", "Found resource: {0} as a system resource"},
diff --git a/jdk/src/share/classes/sun/awt/AWTAccessor.java b/jdk/src/share/classes/sun/awt/AWTAccessor.java
index 0e38de6df6f..b88531dfcd2 100644
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java
@@ -33,6 +33,9 @@ import java.awt.image.BufferedImage;
 import sun.misc.Unsafe;
 import java.awt.peer.ComponentPeer;
 
+import java.security.AccessController;
+import java.security.AccessControlContext;
+
 /**
  * The AWTAccessor utility class.
  * The main purpose of this class is to enable accessing
@@ -221,6 +224,13 @@ public final class AWTAccessor {
          * Processes events occurring on this component.
          */
         void processEvent(Component comp, AWTEvent e);
+
+
+        /*
+         * Returns the acc this component was constructed with.
+         */
+        AccessControlContext getAccessControlContext(Component comp);
+
     }
 
     /*
@@ -323,6 +333,13 @@ public final class AWTAccessor {
          * Indicates whether this AWTEvent was generated by the system.
          */
         boolean isSystemGenerated(AWTEvent ev);
+
+
+        /*
+         * Returns the acc this event was constructed with.
+         */
+        AccessControlContext getAccessControlContext(AWTEvent ev);
+
     }
 
     public interface InputEventAccessor {
diff --git a/jdk/src/share/classes/sun/dyn/Access.java b/jdk/src/share/classes/sun/dyn/Access.java
deleted file mode 100644
index 931303b03b6..00000000000
--- a/jdk/src/share/classes/sun/dyn/Access.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.dyn;
-
-import sun.reflect.Reflection;
-
-/**
- * Access control to this package.
- * Classes in other packages can attempt to acquire the access token,
- * but will fail if they are not recognized as friends.
- * Certain methods in this package, although public, require a non-null
- * access token in order to proceed; they act like package-private methods.
- * @author jrose
- */
-
-public class Access {
-
-    private Access() { }
-
-    /**
-     * The heart of this pattern:  The list of classes which are
-     * permitted to acquire the access token, and become honorary
-     * members of this package.
-     */
-    private static final String[] FRIENDS = {
-        "java.dyn.", "sun.dyn."
-    };
-
-    /**
-     * The following object is NOT public.  That's the point of the pattern.
-     * It is package-private, so that any member of this package
-     * can acquire the access token, and give it away to trusted friends.
-     */
-    static final Access TOKEN = new Access();
-
-    /**
-     * @return Access.TOKEN, if the caller is a friend of this package
-     */
-    public static Access getToken() {
-        Class<?> callc = Reflection.getCallerClass(2);
-        if (isFriend(callc))
-            return TOKEN;
-        else
-            throw new IllegalAccessError("bad caller: " + callc);
-    }
-
-    /** Is the given name the name of a class which could be our friend? */
-    public static boolean isFriendName(String name) {
-        for (String friend : FRIENDS) {
-            if (name.startsWith(friend))
-                return true;
-        }
-        return false;
-    }
-
-    /** Is the given class a friend?  True if {@link #isFriendName},
-     *  and the given class also shares a class loader with us.
-     */
-    public static boolean isFriend(Class<?> c) {
-        return isFriendName(c.getName()) && c.getClassLoader() == CLASS_LOADER;
-    }
-
-    private static final ClassLoader CLASS_LOADER = Access.class.getClassLoader();
-
-    /**
-     * Throw an IllegalAccessError if the caller does not possess
-     * the Access.TOKEN.
-     * @param must be Access.TOKEN
-     */
-    public static void check(Access token) {
-        if (token == null)
-            fail();
-        // else it must be the unique Access.TOKEN
-        assert(token == Access.TOKEN);
-    }
-    private static void fail() {
-        final int CALLER_DEPTH = 3;
-        // 0: Reflection.getCC, 1: this.fail, 2: Access.*, 3: caller
-        Class<?> callc = Reflection.getCallerClass(CALLER_DEPTH);
-        throw new IllegalAccessError("bad caller: " + callc);
-    }
-
-    static {
-        //sun.reflect.Reflection.registerMethodsToFilter(MH.class, "getToken");
-    }
-}
diff --git a/jdk/src/share/classes/sun/dyn/CallSiteImpl.java b/jdk/src/share/classes/sun/dyn/CallSiteImpl.java
deleted file mode 100644
index 703788ff484..00000000000
--- a/jdk/src/share/classes/sun/dyn/CallSiteImpl.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.dyn;
-
-import java.dyn.*;
-import static sun.dyn.MemberName.uncaughtException;
-
-/**
- * Parts of CallSite known to the JVM.
- * @author jrose
- */
-public class CallSiteImpl {
-    // this implements the upcall from the JVM, MethodHandleNatives.makeDynamicCallSite:
-    static CallSite makeSite(MethodHandle bootstrapMethod,
-                             // Callee information:
-                             String name, MethodType type,
-                             // Extra arguments for BSM, if any:
-                             Object info,
-                             // Caller information:
-                             MemberName callerMethod, int callerBCI) {
-        Class<?> callerClass = callerMethod.getDeclaringClass();
-        Object caller;
-        if (bootstrapMethod.type().parameterType(0) == Class.class && TRANSITIONAL_BEFORE_PFD)
-            caller = callerClass;  // remove for PFD
-        else
-            caller = MethodHandleImpl.IMPL_LOOKUP.in(callerClass);
-        if (bootstrapMethod == null && TRANSITIONAL_BEFORE_PFD) {
-            // If there is no bootstrap method, throw IncompatibleClassChangeError.
-            // This is a valid generic error type for resolution (JLS 12.3.3).
-            throw new IncompatibleClassChangeError
-                ("Class "+callerClass.getName()+" has not declared a bootstrap method for invokedynamic");
-        }
-        CallSite site;
-        try {
-            Object binding;
-            info = maybeReBox(info);
-            if (info == null) {
-                binding = bootstrapMethod.invokeGeneric(caller, name, type);
-            } else if (!info.getClass().isArray()) {
-                binding = bootstrapMethod.invokeGeneric(caller, name, type, info);
-            } else {
-                Object[] argv = (Object[]) info;
-                if (3 + argv.length > 255)
-                    new InvokeDynamicBootstrapError("too many bootstrap method arguments");
-                MethodType bsmType = bootstrapMethod.type();
-                if (bsmType.parameterCount() == 4 && bsmType.parameterType(3) == Object[].class)
-                    binding = bootstrapMethod.invokeGeneric(caller, name, type, argv);
-                else
-                    binding = MethodHandles.spreadInvoker(bsmType, 3)
-                        .invokeGeneric(bootstrapMethod, caller, name, type, argv);
-            }
-            //System.out.println("BSM for "+name+type+" => "+binding);
-            if (binding instanceof CallSite) {
-                site = (CallSite) binding;
-            } else if (binding instanceof MethodHandle && TRANSITIONAL_BEFORE_PFD) {
-                // Transitional!
-                MethodHandle target = (MethodHandle) binding;
-                site = new ConstantCallSite(target);
-            } else {
-                throw new ClassCastException("bootstrap method failed to produce a CallSite");
-            }
-            if (TRANSITIONAL_BEFORE_PFD)
-                PRIVATE_INITIALIZE_CALL_SITE.invokeExact(site, name, type,
-                                                         callerMethod, callerBCI);
-            assert(site.getTarget() != null);
-            assert(site.getTarget().type().equals(type));
-        } catch (Throwable ex) {
-            InvokeDynamicBootstrapError bex;
-            if (ex instanceof InvokeDynamicBootstrapError)
-                bex = (InvokeDynamicBootstrapError) ex;
-            else
-                bex = new InvokeDynamicBootstrapError("call site initialization exception", ex);
-            throw bex;
-        }
-        return site;
-    }
-
-    private static boolean TRANSITIONAL_BEFORE_PFD = true;  // FIXME: remove for PFD
-
-    private static Object maybeReBox(Object x) {
-        if (x instanceof Integer) {
-            int xi = (int) x;
-            if (xi == (byte) xi)
-                x = xi;  // must rebox; see JLS 5.1.7
-            return x;
-        } else if (x instanceof Object[]) {
-            Object[] xa = (Object[]) x;
-            for (int i = 0; i < xa.length; i++) {
-                if (xa[i] instanceof Integer)
-                    xa[i] = maybeReBox(xa[i]);
-            }
-            return xa;
-        } else {
-            return x;
-        }
-    }
-
-    // This method is private in CallSite because it touches private fields in CallSite.
-    // These private fields (vmmethod, vmindex) are specific to the JVM.
-    private static final MethodHandle PRIVATE_INITIALIZE_CALL_SITE;
-    static {
-        try {
-            PRIVATE_INITIALIZE_CALL_SITE =
-            !TRANSITIONAL_BEFORE_PFD ? null :
-            MethodHandleImpl.IMPL_LOOKUP.findVirtual(CallSite.class, "initializeFromJVM",
-                MethodType.methodType(void.class,
-                                      String.class, MethodType.class,
-                                      MemberName.class, int.class));
-        } catch (ReflectiveOperationException ex) {
-            throw uncaughtException(ex);
-        }
-    }
-
-    public static void setCallSiteTarget(Access token, CallSite site, MethodHandle target) {
-        Access.check(token);
-        MethodHandleNatives.setCallSiteTarget(site, target);
-    }
-}
diff --git a/jdk/src/share/classes/sun/font/FileFont.java b/jdk/src/share/classes/sun/font/FileFont.java
index 22096dda2eb..1c63e9f1159 100644
--- a/jdk/src/share/classes/sun/font/FileFont.java
+++ b/jdk/src/share/classes/sun/font/FileFont.java
@@ -32,22 +32,13 @@ import java.awt.geom.Point2D;
 import java.awt.geom.Rectangle2D;
 import java.io.File;
 import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
 import sun.java2d.Disposer;
 import sun.java2d.DisposerRecord;
 
-import java.lang.ref.WeakReference;
-import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteOrder;
-import java.nio.MappedByteBuffer;
-import java.nio.BufferUnderflowException;
-import java.nio.channels.ClosedChannelException;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.awt.Font;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 public abstract class FileFont extends PhysicalFont {
 
@@ -286,4 +277,49 @@ public abstract class FileFont extends PhysicalFont {
             });
         }
     }
+
+    protected String getPublicFileName() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm == null) {
+            return platName;
+        }
+        boolean canReadProperty = true;
+
+        try {
+            sm.checkPropertyAccess("java.io.tmpdir");
+        } catch (SecurityException e) {
+            canReadProperty = false;
+        }
+
+        if (canReadProperty) {
+            return platName;
+        }
+
+        final File f = new File(platName);
+
+        Boolean isTmpFile = Boolean.FALSE;
+        try {
+            isTmpFile = AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Boolean>() {
+                    public Boolean run() {
+                        File tmp = new File(System.getProperty("java.io.tmpdir"));
+                        try {
+                            String tpath = tmp.getCanonicalPath();
+                            String fpath = f.getCanonicalPath();
+
+                            return (fpath == null) || fpath.startsWith(tpath);
+                        } catch (IOException e) {
+                            return Boolean.TRUE;
+                        }
+                    }
+                }
+            );
+        } catch (PrivilegedActionException e) {
+            // unable to verify whether value of java.io.tempdir will be
+            // exposed, so return only a name of the font file.
+            isTmpFile = Boolean.TRUE;
+        }
+
+        return  isTmpFile ? "temp file" : platName;
+    }
 }
diff --git a/jdk/src/share/classes/sun/font/TrueTypeFont.java b/jdk/src/share/classes/sun/font/TrueTypeFont.java
index e448338a3f3..84cbd2c9a34 100644
--- a/jdk/src/share/classes/sun/font/TrueTypeFont.java
+++ b/jdk/src/share/classes/sun/font/TrueTypeFont.java
@@ -519,7 +519,8 @@ public class TrueTypeFont extends FileFont {
                 break;
 
             default:
-                throw new FontFormatException("Unsupported sfnt " + platName);
+                throw new FontFormatException("Unsupported sfnt " +
+                                              getPublicFileName());
             }
 
             /* Now have the offset of this TT font (possibly within a TTC)
@@ -1680,7 +1681,6 @@ public class TrueTypeFont extends FileFont {
     @Override
     public String toString() {
         return "** TrueType Font: Family="+familyName+ " Name="+fullName+
-            " style="+style+" fileName="+platName;
+            " style="+style+" fileName="+getPublicFileName();
     }
-
 }
diff --git a/jdk/src/share/classes/sun/font/Type1Font.java b/jdk/src/share/classes/sun/font/Type1Font.java
index 48821dd94e5..5fa49bd132d 100644
--- a/jdk/src/share/classes/sun/font/Type1Font.java
+++ b/jdk/src/share/classes/sun/font/Type1Font.java
@@ -677,6 +677,6 @@ public class Type1Font extends FileFont {
 
     public String toString() {
         return "** Type1 Font: Family="+familyName+ " Name="+fullName+
-            " style="+style+" fileName="+platName;
+            " style="+style+" fileName="+getPublicFileName();
     }
 }
diff --git a/jdk/src/share/classes/sun/dyn/WrapperInstance.java b/jdk/src/share/classes/sun/invoke/WrapperInstance.java
similarity index 90%
rename from jdk/src/share/classes/sun/dyn/WrapperInstance.java
rename to jdk/src/share/classes/sun/invoke/WrapperInstance.java
index d6e91fd0d03..ba918b4d9d2 100644
--- a/jdk/src/share/classes/sun/dyn/WrapperInstance.java
+++ b/jdk/src/share/classes/sun/invoke/WrapperInstance.java
@@ -23,14 +23,14 @@
  * questions.
  */
 
-package sun.dyn;
+package sun.invoke;
 
-import java.dyn.MethodHandle;
+import java.lang.invoke.MethodHandle;
 
 /**
- * Private API used inside of java.dyn.MethodHandles.
+ * Private API used inside of java.lang.invoke.MethodHandles.
  * Interface implemented by every object which is produced by
- * {@link java.dyn.MethodHandles#asInstance MethodHandles.asInstance}.
+ * {@link java.lang.invoke.MethodHandles#asInstance MethodHandles.asInstance}.
  * The methods of this interface allow a caller to recover the parameters
  * to {@code asInstance}.
  * This allows applications to repeatedly convert between method handles
diff --git a/jdk/src/share/classes/sun/dyn/anon/AnonymousClassLoader.java b/jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java
similarity index 99%
rename from jdk/src/share/classes/sun/dyn/anon/AnonymousClassLoader.java
rename to jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java
index bd7c5cb59dd..3005a452f71 100644
--- a/jdk/src/share/classes/sun/dyn/anon/AnonymousClassLoader.java
+++ b/jdk/src/share/classes/sun/invoke/anon/AnonymousClassLoader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package sun.dyn.anon;
+package sun.invoke.anon;
 
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
diff --git a/jdk/src/share/classes/sun/dyn/anon/ConstantPoolParser.java b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolParser.java
similarity index 99%
rename from jdk/src/share/classes/sun/dyn/anon/ConstantPoolParser.java
rename to jdk/src/share/classes/sun/invoke/anon/ConstantPoolParser.java
index b68b3f650c9..441ba957336 100644
--- a/jdk/src/share/classes/sun/dyn/anon/ConstantPoolParser.java
+++ b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolParser.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,14 @@
  * questions.
  */
 
-package sun.dyn.anon;
+package sun.invoke.anon;
 
 import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.BufferUnderflowException;
 import java.nio.ByteBuffer;
 
-import static sun.dyn.anon.ConstantPoolVisitor.*;
+import static sun.invoke.anon.ConstantPoolVisitor.*;
 
 /** A constant pool parser.
  */
diff --git a/jdk/src/share/classes/sun/dyn/anon/ConstantPoolPatch.java b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java
similarity index 99%
rename from jdk/src/share/classes/sun/dyn/anon/ConstantPoolPatch.java
rename to jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java
index 87dc97f6025..259d4b2336e 100644
--- a/jdk/src/share/classes/sun/dyn/anon/ConstantPoolPatch.java
+++ b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolPatch.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package sun.dyn.anon;
+package sun.invoke.anon;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -32,7 +32,7 @@ import java.util.HashSet;
 import java.util.IdentityHashMap;
 import java.util.Map;
 
-import static sun.dyn.anon.ConstantPoolVisitor.*;
+import static sun.invoke.anon.ConstantPoolVisitor.*;
 
 /** A class and its patched constant pool.
  *
diff --git a/jdk/src/share/classes/sun/dyn/anon/ConstantPoolVisitor.java b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolVisitor.java
similarity index 98%
rename from jdk/src/share/classes/sun/dyn/anon/ConstantPoolVisitor.java
rename to jdk/src/share/classes/sun/invoke/anon/ConstantPoolVisitor.java
index e882b7d6724..dfec8b41151 100644
--- a/jdk/src/share/classes/sun/dyn/anon/ConstantPoolVisitor.java
+++ b/jdk/src/share/classes/sun/invoke/anon/ConstantPoolVisitor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package sun.dyn.anon;
+package sun.invoke.anon;
 
 /**
  * A visitor called by {@link ConstantPoolParser#parse(ConstantPoolVisitor)}
diff --git a/jdk/src/share/classes/sun/dyn/anon/InvalidConstantPoolFormatException.java b/jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java
similarity index 94%
rename from jdk/src/share/classes/sun/dyn/anon/InvalidConstantPoolFormatException.java
rename to jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java
index 555bb428f3f..d420d34b0d6 100644
--- a/jdk/src/share/classes/sun/dyn/anon/InvalidConstantPoolFormatException.java
+++ b/jdk/src/share/classes/sun/invoke/anon/InvalidConstantPoolFormatException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package sun.dyn.anon;
+package sun.invoke.anon;
 
 /** Exception used when there is an error in the constant pool
  *  format.
diff --git a/jdk/src/share/classes/sun/dyn/empty/Empty.java b/jdk/src/share/classes/sun/invoke/empty/Empty.java
similarity index 90%
rename from jdk/src/share/classes/sun/dyn/empty/Empty.java
rename to jdk/src/share/classes/sun/invoke/empty/Empty.java
index 416a6f128e8..f75d2b3d016 100644
--- a/jdk/src/share/classes/sun/dyn/empty/Empty.java
+++ b/jdk/src/share/classes/sun/invoke/empty/Empty.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,14 +23,14 @@
  * questions.
  */
 
-package sun.dyn.empty;
+package sun.invoke.empty;
 
 /**
  * An empty class in an empty package.
  * Used as a proxy for unprivileged code, since making access checks
  * against it will only succeed against public methods in public types.
  * <p>
- * This class also stands (internally to sun.dyn) for the type of a
+ * This class also stands (internally to sun.invoke) for the type of a
  * value that cannot be produced, because the expression of this type
  * always returns abnormally.  (Cf. Nothing in the closures proposal.)
  * @author jrose
diff --git a/jdk/src/share/classes/sun/dyn/package-info.java b/jdk/src/share/classes/sun/invoke/package-info.java
similarity index 93%
rename from jdk/src/share/classes/sun/dyn/package-info.java
rename to jdk/src/share/classes/sun/invoke/package-info.java
index d129b0f5a27..74999fe6c7e 100644
--- a/jdk/src/share/classes/sun/dyn/package-info.java
+++ b/jdk/src/share/classes/sun/invoke/package-info.java
@@ -24,8 +24,8 @@
  */
 
 /**
- * Implementation details for JSR 292 RI, package java.dyn.
+ * Implementation details for JSR 292 RI, package java.lang.invoke.
  * @author jrose
  */
 
-package sun.dyn;
+package sun.invoke;
diff --git a/jdk/src/share/classes/sun/dyn/util/BytecodeDescriptor.java b/jdk/src/share/classes/sun/invoke/util/BytecodeDescriptor.java
similarity index 97%
rename from jdk/src/share/classes/sun/dyn/util/BytecodeDescriptor.java
rename to jdk/src/share/classes/sun/invoke/util/BytecodeDescriptor.java
index 2c59b918338..ccc313cd41b 100644
--- a/jdk/src/share/classes/sun/dyn/util/BytecodeDescriptor.java
+++ b/jdk/src/share/classes/sun/invoke/util/BytecodeDescriptor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
  * questions.
  */
 
-package sun.dyn.util;
+package sun.invoke.util;
 
-import java.dyn.MethodType;
+import java.lang.invoke.MethodType;
 import java.util.ArrayList;
 import java.util.List;
 
diff --git a/jdk/src/share/classes/sun/dyn/util/BytecodeName.java b/jdk/src/share/classes/sun/invoke/util/BytecodeName.java
similarity index 99%
rename from jdk/src/share/classes/sun/dyn/util/BytecodeName.java
rename to jdk/src/share/classes/sun/invoke/util/BytecodeName.java
index 73be3fb1361..9b8fa35cb70 100644
--- a/jdk/src/share/classes/sun/dyn/util/BytecodeName.java
+++ b/jdk/src/share/classes/sun/invoke/util/BytecodeName.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package sun.dyn.util;
+package sun.invoke.util;
 
 /**
  * Utility routines for dealing with bytecode-level names.
diff --git a/jdk/src/share/classes/sun/dyn/util/ValueConversions.java b/jdk/src/share/classes/sun/invoke/util/ValueConversions.java
similarity index 94%
rename from jdk/src/share/classes/sun/dyn/util/ValueConversions.java
rename to jdk/src/share/classes/sun/invoke/util/ValueConversions.java
index 374bd245058..c6a56abf665 100644
--- a/jdk/src/share/classes/sun/dyn/util/ValueConversions.java
+++ b/jdk/src/share/classes/sun/invoke/util/ValueConversions.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,22 +23,19 @@
  * questions.
  */
 
-package sun.dyn.util;
+package sun.invoke.util;
 
-import java.dyn.*;
-import java.dyn.MethodHandles.Lookup;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodHandles.Lookup;
+import java.lang.invoke.MethodType;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.EnumMap;
 import java.util.List;
-import sun.dyn.Access;
-import sun.dyn.AdapterMethodHandle;
-import sun.dyn.MethodHandleImpl;
-import static sun.dyn.MemberName.uncaughtException;
 
 public class ValueConversions {
-    private static final Access IMPL_TOKEN = Access.getToken();
-    private static final Lookup IMPL_LOOKUP = MethodHandleImpl.getLookup(IMPL_TOKEN);
+    private static final Lookup IMPL_LOOKUP = MethodHandles.lookup();
 
     private static EnumMap<Wrapper, MethodHandle>[] newWrapperCaches(int n) {
         @SuppressWarnings("unchecked")
@@ -157,7 +154,7 @@ public class ValueConversions {
                 mh = null;
             }
         } else {
-            mh = retype(type, unbox(wrap, !exact, raw));
+            mh = unbox(wrap, !exact, raw).asType(type);
         }
         if (mh != null) {
             cache.put(wrap, mh);
@@ -293,7 +290,7 @@ public class ValueConversions {
                 mh = null;
             }
         } else {
-            mh = retype(type.erase(), box(wrap, !exact, raw));
+            mh = box(wrap, !exact, raw).asType(type.erase());
         }
         if (mh != null) {
             cache.put(wrap, mh);
@@ -412,7 +409,7 @@ public class ValueConversions {
                 mh = null;
             }
         } else {
-            mh = retype(IDENTITY.type(), rebox(wrap, !exact));
+            mh = rebox(wrap, !exact).asType(IDENTITY.type());
         }
         if (mh != null) {
             cache.put(wrap, mh);
@@ -504,8 +501,8 @@ public class ValueConversions {
 
         // use the raw method
         Wrapper rawWrap = wrap.rawPrimitive();
-        if (rawWrap != wrap) {
-            mh = retype(type, zeroConstantFunction(rawWrap));
+        if (mh == null && rawWrap != wrap) {
+            mh = MethodHandles.explicitCastArguments(zeroConstantFunction(rawWrap), type);
         }
         if (mh != null) {
             cache.put(wrap, mh);
@@ -552,6 +549,22 @@ public class ValueConversions {
         return x;
     }
 
+    static byte identity(byte x) {
+        return x;
+    }
+
+    static short identity(short x) {
+        return x;
+    }
+
+    static boolean identity(boolean x) {
+        return x;
+    }
+
+    static char identity(char x) {
+        return x;
+    }
+
     /**
      * Identity function on longs.
      * @param x an arbitrary long value
@@ -561,6 +574,14 @@ public class ValueConversions {
         return x;
     }
 
+    static float identity(float x) {
+        return x;
+    }
+
+    static double identity(double x) {
+        return x;
+    }
+
     /**
      * Identity function, with reference cast.
      * @param t an arbitrary reference type
@@ -590,7 +611,9 @@ public class ValueConversions {
             IGNORE = IMPL_LOOKUP.findStatic(ValueConversions.class, "ignore", ignoreType);
             EMPTY = IMPL_LOOKUP.findStatic(ValueConversions.class, "empty", ignoreType.dropParameterTypes(0, 1));
         } catch (Exception ex) {
-            throw uncaughtException(ex);
+            Error err = new InternalError("uncaught exception");
+            err.initCause(ex);
+            throw err;
         }
     }
 
@@ -622,7 +645,8 @@ public class ValueConversions {
             mh = MethodHandles.insertArguments(CAST_REFERENCE, 0, type);
         if (exact) {
             MethodType xmt = MethodType.methodType(type, Object.class);
-            mh = AdapterMethodHandle.makeRetypeRaw(IMPL_TOKEN, xmt, mh);
+            mh = MethodHandles.explicitCastArguments(mh, xmt);
+            //mh = AdapterMethodHandle.makeRetypeRaw(IMPL_TOKEN, xmt, mh);
         }
         if (cache != null)
             cache.put(wrap, mh);
@@ -634,15 +658,11 @@ public class ValueConversions {
     }
 
     public static MethodHandle identity(Class<?> type) {
-        if (type == Object.class)
-            return IDENTITY;
-        else if (!type.isPrimitive())
-            return retype(MethodType.methodType(type, type), IDENTITY);
-        else
-            return identity(Wrapper.forPrimitiveType(type));
+        // This stuff has been moved into MethodHandles:
+        return MethodHandles.identity(type);
     }
 
-    static MethodHandle identity(Wrapper wrap) {
+    public static MethodHandle identity(Wrapper wrap) {
         EnumMap<Wrapper, MethodHandle> cache = CONSTANT_FUNCTIONS[1];
         MethodHandle mh = cache.get(wrap);
         if (mh != null) {
@@ -665,12 +685,6 @@ public class ValueConversions {
             return mh;
         }
 
-        // use a raw conversion
-        if (wrap.isSingleWord() && wrap != Wrapper.INT) {
-            mh = retype(type, identity(Wrapper.INT));
-        } else if (wrap.isDoubleWord() && wrap != Wrapper.LONG) {
-            mh = retype(type, identity(Wrapper.LONG));
-        }
         if (mh != null) {
             cache.put(wrap, mh);
             return mh;
@@ -678,10 +692,6 @@ public class ValueConversions {
         throw new IllegalArgumentException("cannot find identity for " + wrap);
     }
 
-    private static MethodHandle retype(MethodType type, MethodHandle mh) {
-        return AdapterMethodHandle.makeRetypeRaw(IMPL_TOKEN, type, mh);
-    }
-
     private static final Object[] NO_ARGS_ARRAY = {};
     private static Object[] makeArray(Object... args) { return args; }
     private static Object[] array() { return NO_ARGS_ARRAY; }
diff --git a/jdk/src/share/classes/sun/dyn/util/VerifyAccess.java b/jdk/src/share/classes/sun/invoke/util/VerifyAccess.java
similarity index 98%
rename from jdk/src/share/classes/sun/dyn/util/VerifyAccess.java
rename to jdk/src/share/classes/sun/invoke/util/VerifyAccess.java
index 1114bad2695..657aeec23d8 100644
--- a/jdk/src/share/classes/sun/dyn/util/VerifyAccess.java
+++ b/jdk/src/share/classes/sun/invoke/util/VerifyAccess.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,9 @@
  * questions.
  */
 
-package sun.dyn.util;
+package sun.invoke.util;
 
 import java.lang.reflect.Modifier;
-import sun.dyn.MemberName;
-import sun.dyn.MethodHandleImpl;
-import sun.dyn.empty.Empty;
 import static java.lang.reflect.Modifier.*;
 
 /**
diff --git a/jdk/src/share/classes/sun/dyn/util/VerifyType.java b/jdk/src/share/classes/sun/invoke/util/VerifyType.java
similarity index 98%
rename from jdk/src/share/classes/sun/dyn/util/VerifyType.java
rename to jdk/src/share/classes/sun/invoke/util/VerifyType.java
index b6277e4a8a9..39286d09ca4 100644
--- a/jdk/src/share/classes/sun/dyn/util/VerifyType.java
+++ b/jdk/src/share/classes/sun/invoke/util/VerifyType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,10 @@
  * questions.
  */
 
-package sun.dyn.util;
+package sun.invoke.util;
 
-import java.dyn.MethodType;
-import sun.dyn.empty.Empty;
+import java.lang.invoke.MethodType;
+import sun.invoke.empty.Empty;
 
 /**
  * This class centralizes information about the JVM verifier
diff --git a/jdk/src/share/classes/sun/dyn/util/Wrapper.java b/jdk/src/share/classes/sun/invoke/util/Wrapper.java
similarity index 99%
rename from jdk/src/share/classes/sun/dyn/util/Wrapper.java
rename to jdk/src/share/classes/sun/invoke/util/Wrapper.java
index 91b599e8c64..8e2ce578386 100644
--- a/jdk/src/share/classes/sun/dyn/util/Wrapper.java
+++ b/jdk/src/share/classes/sun/invoke/util/Wrapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
  * questions.
  */
 
-package sun.dyn.util;
+package sun.invoke.util;
 
 public enum Wrapper {
     BOOLEAN(Boolean.class, boolean.class, 'Z', (Boolean)false, Format.unsigned(1)),
@@ -267,7 +267,7 @@ public enum Wrapper {
             FROM_WRAP[wi] = w;
             FROM_CHAR[ci] = w;
         }
-        //assert(jdk.sun.dyn.util.WrapperTest.test(false));
+        //assert(jdk.sun.invoke.util.WrapperTest.test(false));
     }
 
     /** What is the primitive type wrapped by this wrapper? */
diff --git a/jdk/src/share/classes/sun/dyn/util/package-info.java b/jdk/src/share/classes/sun/invoke/util/package-info.java
similarity index 88%
rename from jdk/src/share/classes/sun/dyn/util/package-info.java
rename to jdk/src/share/classes/sun/invoke/util/package-info.java
index 0977b22ef94..785ca804302 100644
--- a/jdk/src/share/classes/sun/dyn/util/package-info.java
+++ b/jdk/src/share/classes/sun/invoke/util/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,8 @@
  */
 
 /**
- * Extra support for using JSR 292 RI, package java.dyn.
+ * Extra support for using JSR 292 RI, package java.lang.invoke.
  * @author jrose
  */
 
-package sun.dyn.util;
+package sun.invoke.util;
diff --git a/jdk/src/share/classes/sun/java2d/pisces/Helpers.java b/jdk/src/share/classes/sun/java2d/pisces/Helpers.java
index b91bc6a400a..42c7f2654d3 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/Helpers.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/Helpers.java
@@ -154,9 +154,6 @@ final class Helpers {
     // These use a hardcoded factor of 2 for increasing sizes. Perhaps this
     // should be provided as an argument.
     static float[] widenArray(float[] in, final int cursize, final int numToAdd) {
-        if (in == null) {
-            return new float[5 * numToAdd];
-        }
         if (in.length >= cursize + numToAdd) {
             return in;
         }
diff --git a/jdk/src/share/classes/sun/java2d/pisces/PiscesTileGenerator.java b/jdk/src/share/classes/sun/java2d/pisces/PiscesTileGenerator.java
index ba91edb9819..3d6046bed69 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/PiscesTileGenerator.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/PiscesTileGenerator.java
@@ -191,8 +191,7 @@ final class PiscesTileGenerator implements AATileGenerator {
                     System.out.println("len = "+runLen);
                     System.out.print(cache.toString());
                     e0.printStackTrace();
-                    System.exit(1);
-                    return;
+                    throw e0;
                 }
 
                 int rx0 = cx;
@@ -215,8 +214,7 @@ final class PiscesTileGenerator implements AATileGenerator {
                         System.out.println("len = "+runLen);
                         System.out.print(cache.toString());
                         e.printStackTrace();
-                        System.exit(1);
-                        return;
+                        throw e;
                     }
                 }
                 pos += 2;
@@ -250,4 +248,5 @@ final class PiscesTileGenerator implements AATileGenerator {
      * No further calls will be made on this instance.
      */
     public void dispose() {}
-}
\ No newline at end of file
+}
+
diff --git a/jdk/src/share/classes/sun/java2d/pisces/Renderer.java b/jdk/src/share/classes/sun/java2d/pisces/Renderer.java
index cbfa2897d94..6d07b532e08 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/Renderer.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/Renderer.java
@@ -47,16 +47,16 @@ final class Renderer implements PathConsumer2D {
 
         private static final int INIT_CROSSINGS_SIZE = 10;
 
-        private ScanlineIterator() {
+        // Preconditions: Only subpixel scanlines in the range
+        // (start <= subpixel_y <= end) will be evaluated. No
+        // edge may have a valid (i.e. inside the supplied clip)
+        // crossing that would be generated outside that range.
+        private ScanlineIterator(int start, int end) {
             crossings = new int[INIT_CROSSINGS_SIZE];
             edgePtrs = new int[INIT_CROSSINGS_SIZE];
 
-            // We don't care if we clip some of the line off with ceil, since
-            // no scan line crossings will be eliminated (in fact, the ceil is
-            // the y of the first scan line crossing).
-            final int minY = getFirstScanLineCrossing();
-            nextY = minY;
-            maxY = getScanLineCrossingEnd()-1;
+            nextY = start;
+            maxY = end;
             edgeCount = 0;
         }
 
@@ -148,6 +148,7 @@ final class Renderer implements PathConsumer2D {
     // don't just set NULL to -1, because we want NULL+NEXT to be negative.
     private static final int NULL = -SIZEOF_EDGE;
     private float[] edges = null;
+    private static final int INIT_NUM_EDGES = 8;
     private int[] edgeBuckets = null;
     private int[] edgeBucketCounts = null; // 2*newedges + (1 if pruning needed)
     private int numEdges;
@@ -156,7 +157,7 @@ final class Renderer implements PathConsumer2D {
     private static final float INC_BND = 8f;
 
     // each bucket is a linked list. this method adds eptr to the
-    // start "bucket"th linked list.
+    // start of the "bucket"th linked list.
     private void addEdgeToBucket(final int eptr, final int bucket) {
         edges[eptr+NEXT] = edgeBuckets[bucket];
         edgeBuckets[bucket] = eptr;
@@ -168,7 +169,8 @@ final class Renderer implements PathConsumer2D {
     // X0, Y0, D*[X|Y], COUNT; not variables used for computing scanline crossings).
     private void quadBreakIntoLinesAndAdd(float x0, float y0,
                                           final Curve c,
-                                          final float x2, final float y2) {
+                                          final float x2, final float y2)
+    {
         final float QUAD_DEC_BND = 32;
         final int countlg = 4;
         int count = 1 << countlg;
@@ -204,7 +206,8 @@ final class Renderer implements PathConsumer2D {
     // here, but then too many numbers are passed around.
     private void curveBreakIntoLinesAndAdd(float x0, float y0,
                                            final Curve c,
-                                           final float x3, final float y3) {
+                                           final float x3, final float y3)
+    {
         final int countlg = 3;
         int count = 1 << countlg;
 
@@ -259,8 +262,6 @@ final class Renderer implements PathConsumer2D {
         }
     }
 
-    // Preconditions: y2 > y1 and the curve must cross some scanline
-    // i.e.: y1 <= y < y2 for some y such that boundsMinY <= y < boundsMaxY
     private void addLine(float x1, float y1, float x2, float y2) {
         float or = 1; // orientation of the line. 1 if y increases, 0 otherwise.
         if (y2 < y1) {
@@ -272,12 +273,11 @@ final class Renderer implements PathConsumer2D {
             x1 = or;
             or = 0;
         }
-        final int firstCrossing = Math.max((int) Math.ceil(y1), boundsMinY);
+        final int firstCrossing = Math.max((int)Math.ceil(y1), boundsMinY);
         final int lastCrossing = Math.min((int)Math.ceil(y2), boundsMaxY);
         if (firstCrossing >= lastCrossing) {
             return;
         }
-
         if (y1 < edgeMinY) { edgeMinY = y1; }
         if (y2 > edgeMaxY) { edgeMaxY = y2; }
 
@@ -297,22 +297,10 @@ final class Renderer implements PathConsumer2D {
         edges[ptr+OR] = or;
         edges[ptr+CURX] = x1 + (firstCrossing - y1) * slope;
         edges[ptr+SLOPE] = slope;
-        edges[ptr+YMAX] = y2;
+        edges[ptr+YMAX] = lastCrossing;
         final int bucketIdx = firstCrossing - boundsMinY;
         addEdgeToBucket(ptr, bucketIdx);
-        if (lastCrossing < boundsMaxY) {
-            edgeBucketCounts[lastCrossing - boundsMinY] |= 1;
-        }
-    }
-
-    // preconditions: should not be called before the last line has been added
-    // to the edge list (even though it will return a correct answer at that
-    // point in time, it's not meant to be used that way).
-    private int getFirstScanLineCrossing() {
-        return Math.max(boundsMinY, (int)Math.ceil(edgeMinY));
-    }
-    private int getScanLineCrossingEnd() {
-        return Math.min(boundsMaxY, (int)Math.ceil(edgeMaxY));
+        edgeBucketCounts[lastCrossing - boundsMinY] |= 1;
     }
 
 // END EDGE LIST
@@ -366,9 +354,11 @@ final class Renderer implements PathConsumer2D {
         this.boundsMaxX = (pix_boundsX + pix_boundsWidth) * SUBPIXEL_POSITIONS_X;
         this.boundsMaxY = (pix_boundsY + pix_boundsHeight) * SUBPIXEL_POSITIONS_Y;
 
+        edges = new float[INIT_NUM_EDGES * SIZEOF_EDGE];
+        numEdges = 0;
         edgeBuckets = new int[boundsMaxY - boundsMinY];
         java.util.Arrays.fill(edgeBuckets, NULL);
-        edgeBucketCounts = new int[edgeBuckets.length];
+        edgeBucketCounts = new int[edgeBuckets.length + 1];
     }
 
     private float tosubpixx(float pix_x) {
@@ -394,7 +384,7 @@ final class Renderer implements PathConsumer2D {
         y0 = y1;
     }
 
-    Curve c = new Curve();
+    private Curve c = new Curve();
     @Override public void curveTo(float x1, float y1,
                                   float x2, float y2,
                                   float x3, float y3)
@@ -431,8 +421,8 @@ final class Renderer implements PathConsumer2D {
         throw new InternalError("Renderer does not use a native consumer.");
     }
 
-    private void _endRendering(final int pix_bboxx0, final int pix_bboxy0,
-                               final int pix_bboxx1, final int pix_bboxy1)
+    private void _endRendering(final int pix_bboxx0, final int pix_bboxx1,
+                               int ymin, int ymax)
     {
         // Mask to determine the relevant bit of the crossing sum
         // 0x1 if EVEN_ODD, all bits if NON_ZERO
@@ -455,7 +445,7 @@ final class Renderer implements PathConsumer2D {
         int pix_minX = Integer.MAX_VALUE;
 
         int y = boundsMinY; // needs to be declared here so we emit the last row properly.
-        ScanlineIterator it = this.new ScanlineIterator();
+        ScanlineIterator it = this.new ScanlineIterator(ymin, ymax);
         for ( ; it.hasNext(); ) {
             int numCrossings = it.next();
             int[] crossings = it.crossings;
@@ -477,7 +467,7 @@ final class Renderer implements PathConsumer2D {
                 int curxo = crossings[i];
                 int curx = curxo >> 1;
                 // to turn {0, 1} into {-1, 1}, multiply by 2 and subtract 1.
-                int crorientation = ((curxo & 0x1) << 1) -1;
+                int crorientation = ((curxo & 0x1) << 1) - 1;
                 if ((sum & mask) != 0) {
                     int x0 = Math.max(prev, bboxx0);
                     int x1 = Math.min(curx, bboxx1);
@@ -541,7 +531,7 @@ final class Renderer implements PathConsumer2D {
         }
 
         this.cache = new PiscesCache(pminX, pminY, pmaxX, pmaxY);
-        _endRendering(pminX, pminY, pmaxX, pmaxY);
+        _endRendering(pminX, pmaxX, spminY, spmaxY);
     }
 
     public PiscesCache getCache() {
diff --git a/jdk/src/share/classes/sun/java2d/pisces/Stroker.java b/jdk/src/share/classes/sun/java2d/pisces/Stroker.java
index b898febc4c2..f7323f95adb 100644
--- a/jdk/src/share/classes/sun/java2d/pisces/Stroker.java
+++ b/jdk/src/share/classes/sun/java2d/pisces/Stroker.java
@@ -764,6 +764,11 @@ final class Stroker implements PathConsumer2D {
     private static final int MAX_N_CURVES = 11;
     private float[] subdivTs = new float[MAX_N_CURVES - 1];
 
+    // If this class is compiled with ecj, then Hotspot crashes when OSR
+    // compiling this function. See bugs 7004570 and 6675699
+    // TODO: until those are fixed, we should work around that by
+    // manually inlining this into curveTo and quadTo.
+/******************************* WORKAROUND **********************************
     private void somethingTo(final int type) {
         // need these so we can update the state at the end of this method
         final float xf = middle[type-2], yf = middle[type-1];
@@ -866,6 +871,7 @@ final class Stroker implements PathConsumer2D {
         this.cy0 = yf;
         this.prev = DRAWING_OP_TO;
     }
+****************************** END WORKAROUND *******************************/
 
     // finds values of t where the curve in pts should be subdivided in order
     // to get good offset curves a distance of w away from the middle curve.
@@ -932,18 +938,168 @@ final class Stroker implements PathConsumer2D {
         middle[2] = x1;  middle[3] = y1;
         middle[4] = x2;  middle[5] = y2;
         middle[6] = x3;  middle[7] = y3;
-        somethingTo(8);
-    }
 
-    @Override public long getNativeConsumer() {
-        throw new InternalError("Stroker doesn't use a native consumer");
+        // inlined version of somethingTo(8);
+        // See the TODO on somethingTo
+
+        // need these so we can update the state at the end of this method
+        final float xf = middle[6], yf = middle[7];
+        float dxs = middle[2] - middle[0];
+        float dys = middle[3] - middle[1];
+        float dxf = middle[6] - middle[4];
+        float dyf = middle[7] - middle[5];
+
+        boolean p1eqp2 = (dxs == 0f && dys == 0f);
+        boolean p3eqp4 = (dxf == 0f && dyf == 0f);
+        if (p1eqp2) {
+            dxs = middle[4] - middle[0];
+            dys = middle[5] - middle[1];
+            if (dxs == 0f && dys == 0f) {
+                dxs = middle[6] - middle[0];
+                dys = middle[7] - middle[1];
+            }
+        }
+        if (p3eqp4) {
+            dxf = middle[6] - middle[2];
+            dyf = middle[7] - middle[3];
+            if (dxf == 0f && dyf == 0f) {
+                dxf = middle[6] - middle[0];
+                dyf = middle[7] - middle[1];
+            }
+        }
+        if (dxs == 0f && dys == 0f) {
+            // this happens iff the "curve" is just a point
+            lineTo(middle[0], middle[1]);
+            return;
+        }
+
+        // if these vectors are too small, normalize them, to avoid future
+        // precision problems.
+        if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) {
+            float len = (float)Math.sqrt(dxs*dxs + dys*dys);
+            dxs /= len;
+            dys /= len;
+        }
+        if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) {
+            float len = (float)Math.sqrt(dxf*dxf + dyf*dyf);
+            dxf /= len;
+            dyf /= len;
+        }
+
+        computeOffset(dxs, dys, lineWidth2, offset[0]);
+        final float mx = offset[0][0];
+        final float my = offset[0][1];
+        drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, mx, my);
+
+        int nSplits = findSubdivPoints(middle, subdivTs, 8, lineWidth2);
+
+        int kind = 0;
+        Iterator<Integer> it = Curve.breakPtsAtTs(middle, 8, subdivTs, nSplits);
+        while(it.hasNext()) {
+            int curCurveOff = it.next();
+
+            kind = computeOffsetCubic(middle, curCurveOff, lp, rp);
+            if (kind != 0) {
+                emitLineTo(lp[0], lp[1]);
+                switch(kind) {
+                case 8:
+                    emitCurveTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], lp[6], lp[7], false);
+                    emitCurveTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], rp[6], rp[7], true);
+                    break;
+                case 4:
+                    emitLineTo(lp[2], lp[3]);
+                    emitLineTo(rp[0], rp[1], true);
+                    break;
+                }
+                emitLineTo(rp[kind - 2], rp[kind - 1], true);
+            }
+        }
+
+        this.cmx = (lp[kind - 2] - rp[kind - 2]) / 2;
+        this.cmy = (lp[kind - 1] - rp[kind - 1]) / 2;
+        this.cdx = dxf;
+        this.cdy = dyf;
+        this.cx0 = xf;
+        this.cy0 = yf;
+        this.prev = DRAWING_OP_TO;
     }
 
     @Override public void quadTo(float x1, float y1, float x2, float y2) {
         middle[0] = cx0; middle[1] = cy0;
         middle[2] = x1;  middle[3] = y1;
         middle[4] = x2;  middle[5] = y2;
-        somethingTo(6);
+
+        // inlined version of somethingTo(8);
+        // See the TODO on somethingTo
+
+        // need these so we can update the state at the end of this method
+        final float xf = middle[4], yf = middle[5];
+        float dxs = middle[2] - middle[0];
+        float dys = middle[3] - middle[1];
+        float dxf = middle[4] - middle[2];
+        float dyf = middle[5] - middle[3];
+        if ((dxs == 0f && dys == 0f) || (dxf == 0f && dyf == 0f)) {
+            dxs = dxf = middle[4] - middle[0];
+            dys = dyf = middle[5] - middle[1];
+        }
+        if (dxs == 0f && dys == 0f) {
+            // this happens iff the "curve" is just a point
+            lineTo(middle[0], middle[1]);
+            return;
+        }
+        // if these vectors are too small, normalize them, to avoid future
+        // precision problems.
+        if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) {
+            float len = (float)Math.sqrt(dxs*dxs + dys*dys);
+            dxs /= len;
+            dys /= len;
+        }
+        if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) {
+            float len = (float)Math.sqrt(dxf*dxf + dyf*dyf);
+            dxf /= len;
+            dyf /= len;
+        }
+
+        computeOffset(dxs, dys, lineWidth2, offset[0]);
+        final float mx = offset[0][0];
+        final float my = offset[0][1];
+        drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, mx, my);
+
+        int nSplits = findSubdivPoints(middle, subdivTs, 6, lineWidth2);
+
+        int kind = 0;
+        Iterator<Integer> it = Curve.breakPtsAtTs(middle, 6, subdivTs, nSplits);
+        while(it.hasNext()) {
+            int curCurveOff = it.next();
+
+            kind = computeOffsetQuad(middle, curCurveOff, lp, rp);
+            if (kind != 0) {
+                emitLineTo(lp[0], lp[1]);
+                switch(kind) {
+                case 6:
+                    emitQuadTo(lp[0], lp[1], lp[2], lp[3], lp[4], lp[5], false);
+                    emitQuadTo(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5], true);
+                    break;
+                case 4:
+                    emitLineTo(lp[2], lp[3]);
+                    emitLineTo(rp[0], rp[1], true);
+                    break;
+                }
+                emitLineTo(rp[kind - 2], rp[kind - 1], true);
+            }
+        }
+
+        this.cmx = (lp[kind - 2] - rp[kind - 2]) / 2;
+        this.cmy = (lp[kind - 1] - rp[kind - 1]) / 2;
+        this.cdx = dxf;
+        this.cdy = dyf;
+        this.cx0 = xf;
+        this.cy0 = yf;
+        this.prev = DRAWING_OP_TO;
+    }
+
+    @Override public long getNativeConsumer() {
+        throw new InternalError("Stroker doesn't use a native consumer");
     }
 
     // a stack of polynomial curves where each curve shares endpoints with
diff --git a/jdk/src/share/classes/java/dyn/MethodTypeForm.java b/jdk/src/share/classes/sun/misc/JavaSecurityAccess.java
similarity index 68%
rename from jdk/src/share/classes/java/dyn/MethodTypeForm.java
rename to jdk/src/share/classes/sun/misc/JavaSecurityAccess.java
index 35c59a45c0c..5a3aa513fb8 100644
--- a/jdk/src/share/classes/java/dyn/MethodTypeForm.java
+++ b/jdk/src/share/classes/sun/misc/JavaSecurityAccess.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,17 +23,18 @@
  * questions.
  */
 
-package java.dyn;
+package sun.misc;
 
-/**
- * TO DO:  Temporary shim; remove after refactoring effects are complete in JVM.
- * @author John Rose
- */
-import sun.dyn.MethodTypeImpl;
+import java.security.AccessControlContext;
+import java.security.PrivilegedAction;
 
-class MethodTypeForm extends MethodTypeImpl {
+public interface JavaSecurityAccess {
+
+    <T> T doIntersectionPrivilege(PrivilegedAction<T> action,
+                                  AccessControlContext stack,
+                                  AccessControlContext context);
+
+    <T> T doIntersectionPrivilege(PrivilegedAction<T> action,
+                                  AccessControlContext context);
 
-    MethodTypeForm(MethodType erasedType) {
-        super(erasedType);
-    }
 }
diff --git a/jdk/src/share/classes/sun/misc/SharedSecrets.java b/jdk/src/share/classes/sun/misc/SharedSecrets.java
index 2335b2d68b5..0bd39b4a5d4 100644
--- a/jdk/src/share/classes/sun/misc/SharedSecrets.java
+++ b/jdk/src/share/classes/sun/misc/SharedSecrets.java
@@ -30,6 +30,8 @@ import java.io.Console;
 import java.io.FileDescriptor;
 import java.security.ProtectionDomain;
 
+import java.security.AccessController;
+
 /** A repository of "shared secrets", which are a mechanism for
     calling implementation-private methods in another package without
     using reflection. A package-private class implements a public
@@ -48,6 +50,7 @@ public class SharedSecrets {
     private static JavaNioAccess javaNioAccess;
     private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
     private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess;
+    private static JavaSecurityAccess javaSecurityAccess;
 
     public static JavaUtilJarAccess javaUtilJarAccess() {
         if (javaUtilJarAccess == null) {
@@ -125,4 +128,15 @@ public class SharedSecrets {
                 unsafe.ensureClassInitialized(ProtectionDomain.class);
             return javaSecurityProtectionDomainAccess;
     }
+
+    public static void setJavaSecurityAccess(JavaSecurityAccess jsa) {
+        javaSecurityAccess = jsa;
+    }
+
+    public static JavaSecurityAccess getJavaSecurityAccess() {
+        if (javaSecurityAccess == null) {
+            unsafe.ensureClassInitialized(AccessController.class);
+        }
+        return javaSecurityAccess;
+    }
 }
diff --git a/jdk/src/share/classes/sun/net/ResourceManager.java b/jdk/src/share/classes/sun/net/ResourceManager.java
new file mode 100644
index 00000000000..11bfc464819
--- /dev/null
+++ b/jdk/src/share/classes/sun/net/ResourceManager.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.net;
+
+import java.net.SocketException;
+import java.util.concurrent.atomic.AtomicInteger;
+import sun.security.action.GetPropertyAction;
+
+/**
+ * Manages count of total number of UDP sockets and ensures
+ * that exception is thrown if we try to create more than the
+ * configured limit.
+ *
+ * This functionality could be put in NetHooks some time in future.
+ */
+
+public class ResourceManager {
+
+    /* default maximum number of udp sockets per VM
+     * when a security manager is enabled.
+     * The default is 1024 which is high enough to be useful
+     * but low enough to be well below the maximum number
+     * of port numbers actually available on all OSes for
+     * such sockets (5000 on some versions of windows)
+     */
+
+    private static final int DEFAULT_MAX_SOCKETS = 1024;
+    private static final int maxSockets;
+    private static final AtomicInteger numSockets;
+
+    static {
+        String prop = java.security.AccessController.doPrivileged(
+            new GetPropertyAction("sun.net.maxDatagramSockets")
+        );
+        int defmax = DEFAULT_MAX_SOCKETS;
+        try {
+            if (prop != null) {
+                defmax = Integer.parseInt(prop);
+            }
+        } catch (NumberFormatException e) {}
+        maxSockets = defmax;
+        numSockets = new AtomicInteger(0);
+    }
+
+    public static void beforeUdpCreate() throws SocketException {
+        if (System.getSecurityManager() != null) {
+            if (numSockets.incrementAndGet() > maxSockets) {
+                numSockets.decrementAndGet();
+                throw new SocketException("maximum number of DatagramSockets reached");
+            }
+        }
+    }
+
+    public static void afterUdpClose() {
+        if (System.getSecurityManager() != null) {
+            numSockets.decrementAndGet();
+        }
+    }
+}
diff --git a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
index 69f12a5c601..afc8cea0308 100644
--- a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java
@@ -2173,6 +2173,13 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
                         if (tryTransparentNTLMServer) {
                             tryTransparentNTLMServer =
                                     NTLMAuthenticationProxy.proxy.supportsTransparentAuth;
+                            /* If the platform supports transparent authentication
+                             * then check if we are in a secure environment
+                             * whether, or not, we should try transparent authentication.*/
+                            if (tryTransparentNTLMServer) {
+                                tryTransparentNTLMServer =
+                                        NTLMAuthenticationProxy.proxy.isTrustedSite(url);
+                            }
                         }
                         a = null;
                         if (tryTransparentNTLMServer) {
diff --git a/jdk/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java b/jdk/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java
index a998d2b1226..b235a0bed17 100644
--- a/jdk/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java
@@ -36,12 +36,14 @@ import sun.util.logging.PlatformLogger;
  */
 class NTLMAuthenticationProxy {
     private static Method supportsTA;
+    private static Method isTrustedSite;
     private static final String clazzStr = "sun.net.www.protocol.http.ntlm.NTLMAuthentication";
     private static final String supportsTAStr = "supportsTransparentAuth";
+    private static final String isTrustedSiteStr = "isTrustedSite";
 
     static final NTLMAuthenticationProxy proxy = tryLoadNTLMAuthentication();
     static final boolean supported = proxy != null ? true : false;
-    static final boolean supportsTransparentAuth = supported ? supportsTransparentAuth(supportsTA) : false;
+    static final boolean supportsTransparentAuth = supported ? supportsTransparentAuth() : false;
 
     private final Constructor<? extends AuthenticationInfo> threeArgCtr;
     private final Constructor<? extends AuthenticationInfo> fiveArgCtr;
@@ -82,9 +84,22 @@ class NTLMAuthenticationProxy {
      * authentication (try with the current users credentials before
      * prompting for username and password, etc).
      */
-    private static boolean supportsTransparentAuth(Method method) {
+    private static boolean supportsTransparentAuth() {
         try {
-            return (Boolean)method.invoke(null);
+            return (Boolean)supportsTA.invoke(null);
+        } catch (ReflectiveOperationException roe) {
+            finest(roe);
+        }
+
+        return false;
+    }
+
+    /* Transparent authentication should only be tried with a trusted
+     * site ( when running in a secure environment ).
+     */
+    public static boolean isTrustedSite(URL url) {
+        try {
+            return (Boolean)isTrustedSite.invoke(null, url);
         } catch (ReflectiveOperationException roe) {
             finest(roe);
         }
@@ -112,6 +127,7 @@ class NTLMAuthenticationProxy {
                                             int.class,
                                             PasswordAuthentication.class);
                 supportsTA = cl.getDeclaredMethod(supportsTAStr);
+                isTrustedSite = cl.getDeclaredMethod(isTrustedSiteStr, java.net.URL.class);
                 return new NTLMAuthenticationProxy(threeArg,
                                                    fiveArg);
             }
diff --git a/jdk/src/share/classes/sun/net/www/protocol/http/ntlm/NTLMAuthenticationCallback.java b/jdk/src/share/classes/sun/net/www/protocol/http/ntlm/NTLMAuthenticationCallback.java
new file mode 100644
index 00000000000..92886311e09
--- /dev/null
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/ntlm/NTLMAuthenticationCallback.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.net.www.protocol.http.ntlm;
+
+import java.net.URL;
+
+/**
+ * This class is used to call back to deployment to determine if a given
+ * URL is trusted. Transparent authentication (try with logged in users
+ * credentials without prompting) should only be tried with trusted sites.
+ */
+public abstract class NTLMAuthenticationCallback {
+    private static volatile NTLMAuthenticationCallback callback =
+            new DefaultNTLMAuthenticationCallback();
+
+    public static void setNTLMAuthenticationCallback(
+            NTLMAuthenticationCallback callback) {
+        NTLMAuthenticationCallback.callback = callback;
+    }
+
+    public static NTLMAuthenticationCallback getNTLMAuthenticationCallback() {
+        return callback;
+    }
+
+    /**
+     * Returns true if the given site is trusted, i.e. we can try
+     * transparent Authentication.
+     */
+    public abstract boolean isTrustedSite(URL url);
+
+    static class DefaultNTLMAuthenticationCallback extends NTLMAuthenticationCallback {
+        @Override
+        public boolean isTrustedSite(URL url) { return true; }
+    }
+}
+
diff --git a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
index e63e473ef86..de712d6b64f 100644
--- a/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
+++ b/jdk/src/share/classes/sun/nio/ch/DatagramChannelImpl.java
@@ -32,6 +32,7 @@ import java.nio.ByteBuffer;
 import java.nio.channels.*;
 import java.nio.channels.spi.*;
 import java.util.*;
+import sun.net.ResourceManager;
 
 
 /**
@@ -101,14 +102,22 @@ class DatagramChannelImpl
         throws IOException
     {
         super(sp);
-        this.family = Net.isIPv6Available() ?
-            StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
-        this.fd = Net.socket(family, false);
-        this.fdVal = IOUtil.fdVal(fd);
-        this.state = ST_UNCONNECTED;
+        ResourceManager.beforeUdpCreate();
+        try {
+            this.family = Net.isIPv6Available() ?
+                StandardProtocolFamily.INET6 : StandardProtocolFamily.INET;
+            this.fd = Net.socket(family, false);
+            this.fdVal = IOUtil.fdVal(fd);
+            this.state = ST_UNCONNECTED;
+        } catch (IOException ioe) {
+            ResourceManager.afterUdpClose();
+            throw ioe;
+        }
     }
 
-    public DatagramChannelImpl(SelectorProvider sp, ProtocolFamily family) {
+    public DatagramChannelImpl(SelectorProvider sp, ProtocolFamily family)
+        throws IOException
+    {
         super(sp);
         if ((family != StandardProtocolFamily.INET) &&
             (family != StandardProtocolFamily.INET6))
@@ -957,6 +966,7 @@ class DatagramChannelImpl
     protected void implCloseSelectableChannel() throws IOException {
         synchronized (stateLock) {
             nd.preClose(fd);
+            ResourceManager.afterUdpClose();
 
             // if member of mulitcast group then invalidate all keys
             if (registry != null)
diff --git a/jdk/src/share/classes/sun/nio/ch/Net.java b/jdk/src/share/classes/sun/nio/ch/Net.java
index 4324350e639..58cfe3b1a5b 100644
--- a/jdk/src/share/classes/sun/nio/ch/Net.java
+++ b/jdk/src/share/classes/sun/nio/ch/Net.java
@@ -312,11 +312,12 @@ class Net {                                             // package-private
 
     private static native boolean canJoin6WithIPv4Group0();
 
-    static FileDescriptor socket(boolean stream) {
+    static FileDescriptor socket(boolean stream) throws IOException {
         return socket(UNSPEC, stream);
     }
 
-    static FileDescriptor socket(ProtocolFamily family, boolean stream) {
+    static FileDescriptor socket(ProtocolFamily family, boolean stream)
+        throws IOException {
         boolean preferIPv6 = isIPv6Available() &&
             (family != StandardProtocolFamily.INET);
         return IOUtil.newFD(socket0(preferIPv6, stream, false));
diff --git a/jdk/src/share/classes/sun/text/resources/CollationData_sr_Latn.java b/jdk/src/share/classes/sun/text/resources/CollationData_sr_Latn.java
new file mode 100644
index 00000000000..1c7c5e1e949
--- /dev/null
+++ b/jdk/src/share/classes/sun/text/resources/CollationData_sr_Latn.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ */
+
+/*
+ * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
+ * (C) Copyright IBM Corp. 1996 - 1998 - All Rights Reserved
+ *
+ * The original version of this source code and documentation
+ * is copyrighted and owned by Taligent, Inc., a wholly-owned
+ * subsidiary of IBM. These materials are provided under terms
+ * of a License Agreement between Taligent and Sun. This technology
+ * is protected by multiple US and International patents.
+ *
+ * This notice and attribution to Taligent may not be removed.
+ * Taligent is a registered trademark of Taligent, Inc.
+ *
+ */
+
+package sun.text.resources;
+
+import java.util.ListResourceBundle;
+
+public class CollationData_sr_Latn extends ListResourceBundle {
+
+    protected final Object[][] getContents() {
+        return new Object[][] {
+            { "Rule",
+                /* for sr-Latin, default sorting except for the following: */
+
+                /* add dz "ligature" between d and d<stroke>. */
+                /* add d<stroke> between d and e. */
+                /* add lj "ligature" between l and l<stroke>. */
+                /* add l<stroke> between l and m. */
+                /* add nj "ligature" between n and o. */
+                /* add z<abovedot> after z.       */
+                "& \u200f = \u030c "
+                + "& \u0306 = \u030d "
+                + "& C < c\u030c , C\u030c "  // C < c-caron
+                + "< c\u0301 , C\u0301 "      // c-acute
+                + "& D < \u01f3 , \u01f2 , \u01f1 "  // dz
+                + "< dz , dZ , Dz , DZ "      // dz ligature
+                + "< \u01c6 , \u01c5 , \u01c4 "  // dz-caron
+                + "< \u0111 , \u0110 "           // d-stroke
+                + "& L < lj , lJ , Lj , LJ " // l < lj ligature
+                + "& N < nj , nJ , Nj , NJ " // n < nj ligature
+                + "& S < s\u030c , S\u030c "  // s < s-caron
+                + "& Z < z\u030c , Z\u030c "  // z < z-caron
+            }
+        };
+    }
+}
diff --git a/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn.java b/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn.java
new file mode 100644
index 00000000000..aa9bca860b6
--- /dev/null
+++ b/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+ * Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of the Unicode data files and any associated documentation (the
+ * "Data Files") or Unicode software and any associated documentation
+ * (the "Software") to deal in the Data Files or Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, and/or sell copies of the Data
+ * Files or Software, and to permit persons to whom the Data Files or
+ * Software are furnished to do so, provided that (a) the above copyright
+ * notice(s) and this permission notice appear with all copies of the
+ * Data Files or Software, (b) both the above copyright notice(s) and
+ * this permission notice appear in associated documentation, and (c)
+ * there is clear notice in each modified Data File or in the Software as
+ * well as in the documentation associated with the Data File(s) or
+ * Software that the data or software has been modified.
+ *
+ * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+ * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+ * ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in these Data Files or Software without prior
+ * written authorization of the copyright holder.
+ */
+
+// Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+package sun.text.resources;
+
+import java.util.ListResourceBundle;
+
+public class FormatData_sr_Latn extends ListResourceBundle {
+    protected final Object[][] getContents() {
+        return new Object[][] {
+            { "MonthNames",
+                new String[] {
+                    "januar",
+                    "februar",
+                    "mart",
+                    "april",
+                    "maj",
+                    "jun",
+                    "jul",
+                    "avgust",
+                    "septembar",
+                    "oktobar",
+                    "novembar",
+                    "decembar",
+                    "",
+                }
+            },
+            { "MonthAbbreviations",
+                new String[] {
+                    "jan",
+                    "feb",
+                    "mar",
+                    "apr",
+                    "maj",
+                    "jun",
+                    "jul",
+                    "avg",
+                    "sep",
+                    "okt",
+                    "nov",
+                    "dec",
+                    "",
+                }
+            },
+            { "DayNames",
+                new String[] {
+                    "nedelja",
+                    "ponedeljak",
+                    "utorak",
+                    "sreda",
+                    "\u010detvrtak",
+                    "petak",
+                    "subota",
+                }
+            },
+            { "DayAbbreviations",
+                new String[] {
+                    "ned",
+                    "pon",
+                    "uto",
+                    "sre",
+                    "\u010det",
+                    "pet",
+                    "sub",
+                }
+            },
+            { "Eras",
+                new String[] {
+                    "p. n. e.",
+                    "n. e",
+                }
+            },
+            { "NumberPatterns",
+                new String[] {
+                    "#,##0.###",
+                    "\u00a4\u00a0#,##0.00",
+                    "#,##0%",
+                }
+            },
+            { "NumberElements",
+                new String[] {
+                    ".",
+                    ",",
+                    ";",
+                    "%",
+                    "0",
+                    "#",
+                    "-",
+                    "E",
+                    "\u2030",
+                    "\u221e",
+                    "NaN",
+                }
+            },
+            { "DateTimePatterns",
+                new String[] {
+                    "HH.mm.ss zzzz",
+                    "HH.mm.ss z",
+                    "HH.mm.ss",
+                    "HH.mm",
+                    "EEEE, dd. MMMM y.",
+                    "dd. MMMM y.",
+                    "dd.MM.y.",
+                    "d.M.yy.",
+                    "{1} {0}",
+                }
+            },
+        };
+    }
+}
diff --git a/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn_BA.java b/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn_BA.java
new file mode 100644
index 00000000000..0bdc0061cf9
--- /dev/null
+++ b/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn_BA.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+ * Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of the Unicode data files and any associated documentation (the
+ * "Data Files") or Unicode software and any associated documentation
+ * (the "Software") to deal in the Data Files or Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, and/or sell copies of the Data
+ * Files or Software, and to permit persons to whom the Data Files or
+ * Software are furnished to do so, provided that (a) the above copyright
+ * notice(s) and this permission notice appear with all copies of the
+ * Data Files or Software, (b) both the above copyright notice(s) and
+ * this permission notice appear in associated documentation, and (c)
+ * there is clear notice in each modified Data File or in the Software as
+ * well as in the documentation associated with the Data File(s) or
+ * Software that the data or software has been modified.
+ *
+ * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+ * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+ * ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in these Data Files or Software without prior
+ * written authorization of the copyright holder.
+ */
+
+// Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+package sun.text.resources;
+
+import sun.util.EmptyListResourceBundle;
+
+public class FormatData_sr_Latn_BA extends EmptyListResourceBundle {
+}
diff --git a/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn_ME.java b/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn_ME.java
new file mode 100644
index 00000000000..dcd50585f0a
--- /dev/null
+++ b/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn_ME.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+ * Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of the Unicode data files and any associated documentation (the
+ * "Data Files") or Unicode software and any associated documentation
+ * (the "Software") to deal in the Data Files or Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, and/or sell copies of the Data
+ * Files or Software, and to permit persons to whom the Data Files or
+ * Software are furnished to do so, provided that (a) the above copyright
+ * notice(s) and this permission notice appear with all copies of the
+ * Data Files or Software, (b) both the above copyright notice(s) and
+ * this permission notice appear in associated documentation, and (c)
+ * there is clear notice in each modified Data File or in the Software as
+ * well as in the documentation associated with the Data File(s) or
+ * Software that the data or software has been modified.
+ *
+ * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+ * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+ * ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in these Data Files or Software without prior
+ * written authorization of the copyright holder.
+ */
+
+// Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+package sun.text.resources;
+
+import java.util.ListResourceBundle;
+
+public class FormatData_sr_Latn_ME extends ListResourceBundle {
+    protected final Object[][] getContents() {
+        return new Object[][] {
+            { "DateTimePatterns",
+                new String[] {
+                    "HH.mm.ss zzzz",
+                    "HH.mm.ss z",
+                    "HH.mm.ss",
+                    "HH.mm",
+                    "EEEE, dd. MMMM y.",
+                    "d.MM.yyyy.",
+                    "dd.MM.y.",
+                    "d.M.yy.",
+                    "{1} {0}",
+                }
+            }
+        };
+    }
+}
diff --git a/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn_RS.java b/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn_RS.java
new file mode 100644
index 00000000000..80fba9f0960
--- /dev/null
+++ b/jdk/src/share/classes/sun/text/resources/FormatData_sr_Latn_RS.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * COPYRIGHT AND PERMISSION NOTICE
+ *
+ * Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+ * Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of the Unicode data files and any associated documentation (the
+ * "Data Files") or Unicode software and any associated documentation
+ * (the "Software") to deal in the Data Files or Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, and/or sell copies of the Data
+ * Files or Software, and to permit persons to whom the Data Files or
+ * Software are furnished to do so, provided that (a) the above copyright
+ * notice(s) and this permission notice appear with all copies of the
+ * Data Files or Software, (b) both the above copyright notice(s) and
+ * this permission notice appear in associated documentation, and (c)
+ * there is clear notice in each modified Data File or in the Software as
+ * well as in the documentation associated with the Data File(s) or
+ * Software that the data or software has been modified.
+ *
+ * THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+ * ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+ * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+ * ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in these Data Files or Software without prior
+ * written authorization of the copyright holder.
+ */
+
+// Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+package sun.text.resources;
+
+import sun.util.EmptyListResourceBundle;
+
+public class FormatData_sr_Latn_RS extends EmptyListResourceBundle {
+}
diff --git a/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_ja.java b/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_ja.java
index 35e7286db22..452e620d7f3 100644
--- a/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_ja.java
+++ b/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_ja.java
@@ -44,7 +44,7 @@ import static java.awt.event.KeyEvent.*;
  * or if the keys ends with ".mnemonic", an element
  * representing a mnemomic keycode <code>int</code> or <code>char</code>.
  */
-public class JConsoleResources_ja extends ListResourceBundle {
+public class JConsoleResources_ja extends JConsoleResources {
 
     /**
      * Returns the contents of this <code>ResourceBundle</code>.
diff --git a/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_zh_CN.java b/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_zh_CN.java
index a29aaaf4032..b101429d83c 100644
--- a/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_zh_CN.java
+++ b/jdk/src/share/classes/sun/tools/jconsole/resources/JConsoleResources_zh_CN.java
@@ -44,7 +44,7 @@ import static java.awt.event.KeyEvent.*;
  * or if the keys ends with ".mnemonic", an element
  * representing a mnemomic keycode <code>int</code> or <code>char</code>.
  */
-public class JConsoleResources_zh_CN extends ListResourceBundle {
+public class JConsoleResources_zh_CN extends JConsoleResources {
 
     /**
      * Returns the contents of this <code>ResourceBundle</code>.
diff --git a/jdk/src/share/classes/sun/util/logging/resources/logging.properties b/jdk/src/share/classes/sun/util/logging/resources/logging.properties
index 2cd2bf53ae7..2595b5e1b03 100644
--- a/jdk/src/share/classes/sun/util/logging/resources/logging.properties
+++ b/jdk/src/share/classes/sun/util/logging/resources/logging.properties
@@ -25,13 +25,22 @@
 
 # Localizations for Level names.  For the US locale
 # these are the same as the non-localized level name.
-ALL=ALL
-SEVERE=SEVERE
-WARNING=WARNING
-INFO=INFO
-CONFIG= CONFIG
-FINE=FINE
-FINER=FINER
-FINEST=FINEST
-OFF=OFF
 
+# The following ALL CAPS words should be translated.
+ALL=ALL
+# The following ALL CAPS words should be translated.
+SEVERE=SEVERE
+# The following ALL CAPS words should be translated.
+WARNING=WARNING
+# The following ALL CAPS words should be translated.
+INFO=INFO
+# The following ALL CAPS words should be translated.
+CONFIG= CONFIG
+# The following ALL CAPS words should be translated.
+FINE=FINE
+# The following ALL CAPS words should be translated.
+FINER=FINER
+# The following ALL CAPS words should be translated.
+FINEST=FINEST
+# The following ALL CAPS words should be translated.
+OFF=OFF
diff --git a/jdk/src/share/classes/sun/util/resources/CalendarData_sr_Latn_BA.properties b/jdk/src/share/classes/sun/util/resources/CalendarData_sr_Latn_BA.properties
new file mode 100644
index 00000000000..7d29a94e698
--- /dev/null
+++ b/jdk/src/share/classes/sun/util/resources/CalendarData_sr_Latn_BA.properties
@@ -0,0 +1,66 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# COPYRIGHT AND PERMISSION NOTICE
+#
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of the Unicode data files and any associated documentation (the
+# "Data Files") or Unicode software and any associated documentation
+# (the "Software") to deal in the Data Files or Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, and/or sell copies of the Data
+# Files or Software, and to permit persons to whom the Data Files or
+# Software are furnished to do so, provided that (a) the above copyright
+# notice(s) and this permission notice appear with all copies of the
+# Data Files or Software, (b) both the above copyright notice(s) and
+# this permission notice appear in associated documentation, and (c)
+# there is clear notice in each modified Data File or in the Software as
+# well as in the documentation associated with the Data File(s) or
+# Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+# SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in these Data Files or Software without prior
+# written authorization of the copyright holder.
+
+#
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+#
+minimalDaysInFirstWeek=4
diff --git a/jdk/src/share/classes/sun/util/resources/CalendarData_sr_Latn_ME.properties b/jdk/src/share/classes/sun/util/resources/CalendarData_sr_Latn_ME.properties
new file mode 100644
index 00000000000..7d29a94e698
--- /dev/null
+++ b/jdk/src/share/classes/sun/util/resources/CalendarData_sr_Latn_ME.properties
@@ -0,0 +1,66 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# COPYRIGHT AND PERMISSION NOTICE
+#
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of the Unicode data files and any associated documentation (the
+# "Data Files") or Unicode software and any associated documentation
+# (the "Software") to deal in the Data Files or Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, and/or sell copies of the Data
+# Files or Software, and to permit persons to whom the Data Files or
+# Software are furnished to do so, provided that (a) the above copyright
+# notice(s) and this permission notice appear with all copies of the
+# Data Files or Software, (b) both the above copyright notice(s) and
+# this permission notice appear in associated documentation, and (c)
+# there is clear notice in each modified Data File or in the Software as
+# well as in the documentation associated with the Data File(s) or
+# Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+# SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in these Data Files or Software without prior
+# written authorization of the copyright holder.
+
+#
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+#
+minimalDaysInFirstWeek=4
diff --git a/jdk/src/share/classes/sun/util/resources/CalendarData_sr_Latn_RS.properties b/jdk/src/share/classes/sun/util/resources/CalendarData_sr_Latn_RS.properties
new file mode 100644
index 00000000000..7d29a94e698
--- /dev/null
+++ b/jdk/src/share/classes/sun/util/resources/CalendarData_sr_Latn_RS.properties
@@ -0,0 +1,66 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# COPYRIGHT AND PERMISSION NOTICE
+#
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of the Unicode data files and any associated documentation (the
+# "Data Files") or Unicode software and any associated documentation
+# (the "Software") to deal in the Data Files or Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, and/or sell copies of the Data
+# Files or Software, and to permit persons to whom the Data Files or
+# Software are furnished to do so, provided that (a) the above copyright
+# notice(s) and this permission notice appear with all copies of the
+# Data Files or Software, (b) both the above copyright notice(s) and
+# this permission notice appear in associated documentation, and (c)
+# there is clear notice in each modified Data File or in the Software as
+# well as in the documentation associated with the Data File(s) or
+# Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+# SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in these Data Files or Software without prior
+# written authorization of the copyright holder.
+
+#
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+#
+minimalDaysInFirstWeek=4
diff --git a/jdk/src/share/classes/sun/util/resources/CurrencyNames_pt.properties b/jdk/src/share/classes/sun/util/resources/CurrencyNames_pt.properties
new file mode 100644
index 00000000000..5adb677a5dd
--- /dev/null
+++ b/jdk/src/share/classes/sun/util/resources/CurrencyNames_pt.properties
@@ -0,0 +1,250 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# COPYRIGHT AND PERMISSION NOTICE
+#
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of the Unicode data files and any associated documentation (the "Data
+# Files") or Unicode software and any associated documentation (the
+# "Software") to deal in the Data Files or Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, and/or sell copies of the Data Files or Software, and
+# to permit persons to whom the Data Files or Software are furnished to do
+# so, provided that (a) the above copyright notice(s) and this permission
+# notice appear with all copies of the Data Files or Software, (b) both the
+# above copyright notice(s) and this permission notice appear in associated
+# documentation, and (c) there is clear notice in each modified Data File or
+# in the Software as well as in the documentation associated with the Data
+# File(s) or Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+# THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+# INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+# CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder shall not
+# be used in advertising or otherwise to promote the sale, use or other
+# dealings in these Data Files or Software without prior written
+# authorization of the copyright holder.
+#
+ 
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+
+adp=Peseta de Andorra
+aed=Dir\u00e9m dos Emirados \u00c1rabes Unidos
+afa=Afegane (1927-2002)
+afn=Afegane
+all=Lek Alban\u00eas
+amd=Dram arm\u00eanio
+ang=Guilder das Antilhas Holandesas
+aoa=Cuanza angolano
+ars=Peso argentino
+ats=Xelim austr\u00edaco
+aud=D\u00f3lar australiano
+awg=Guilder de Aruba
+azm=Manat azerbaijano
+azn=Manat do Azerbaij\u00e3o
+bam=Marco b\u00f3snio-herzegovino convers\u00edvel
+bbd=D\u00f3lar de Barbados
+bdt=Taka de Bangladesh
+bef=Franco belga
+bgl=Lev forte b\u00falgaro
+bgn=Lev novo b\u00falgaro
+bhd=Dinar bareinita
+bif=Franco do Burundi
+bmd=D\u00f3lar das Bermudas
+bnd=D\u00f3lar do Brunei
+bov=Mvdol boliviano
+brl=Real brasileiro
+bsd=D\u00f3lar das Bahamas
+btn=Ngultrum do But\u00e3o
+bwp=Pula botsuanesa
+byb=Rublo novo bielo-russo (1994-1999)
+byr=Rublo bielo-russo
+bzd=D\u00f3lar do Belize
+cad=D\u00f3lar canadense
+cdf=Franco congol\u00eas
+chf=Franco su\u00ed\u00e7o
+clf=Unidades de Fomento chilenas
+clp=Peso chileno
+cny=Yuan Renminbi chin\u00eas
+cop=Peso colombiano
+crc=Colon da Costa Rica
+csd=Dinar s\u00e9rvio antigo
+cup=Peso cubano
+cve=Escudo cabo-verdiano
+cyp=Libra cipriota
+czk=Coroa checa
+dem=Marco alem\u00e3o
+djf=Franco do Djibuti
+dkk=Coroa dinamarquesa
+dop=Peso dominicano
+dzd=Dinar argelino
+eek=Coroa estoniana
+egp=Libra eg\u00edpcia
+ern=Nakfa da Eritreia
+esp=Peseta espanhola
+etb=Birr et\u00edope
+fim=Marca finlandesa
+fjd=D\u00f3lar de Fiji
+fkp=Libra das Malvinas
+frf=Franco franc\u00eas
+gbp=Libra esterlina brit\u00e2nica
+gel=Lari georgiano
+ghc=Cedi de Gana (1979-2007)
+ghs=Cedi gan\u00eas
+gip=Libra de Gibraltar
+gmd=Dalasi de G\u00e2mbia
+gnf=Franco de Guin\u00e9
+grd=Dracma grego
+gtq=Quet\u00e7al da Guatemala
+gwp=Peso da Guin\u00e9-Bissau
+gyd=D\u00f3lar da Guiana
+hkd=D\u00f3lar de Hong Kong
+hnl=Lempira de Honduras
+hrk=Kuna croata
+htg=Gurde do Haiti
+huf=Forinte h\u00fangaro
+idr=Rupia indon\u00e9sia
+iep=Libra irlandesa
+ils=Sheqel Novo israelita
+inr=R\u00fapia indiana
+iqd=Dinar iraquiano
+irr=Rial iraniano
+isk=Coroa islandesa
+itl=Lira italiana
+jmd=D\u00f3lar jamaicano
+jod=Dinar jordaniano
+jpy=Iene japon\u00eas
+kes=Xelim queniano
+kgs=Som quirguiz
+khr=Riel cambojano
+kmf=Franco de Comores
+kpw=Won norte-coreano
+krw=Won sul-coreano
+kwd=Dinar coveitiano
+kyd=D\u00f3lar das Ilhas Caiman
+kzt=Tenge do Cazaquist\u00e3o
+lak=Kip de Laos
+lbp=Libra libanesa
+lkr=Rupia do Sri Lanka
+lrd=D\u00f3lar liberiano
+lsl=Loti do Lesoto
+ltl=Lita lituano
+luf=Franco luxemburgu\u00eas
+lvl=Lats let\u00e3o
+lyd=Dinar l\u00edbio
+mad=Dir\u00e9m marroquino
+mdl=Leu mold\u00e1vio
+mga=Ariary de Madagascar
+mgf=Franco de Madagascar
+mkd=Dinar maced\u00f4nio
+mmk=Kyat de Mianmar
+mnt=Tugrik mongol
+mop=Pataca macaense
+mro=Ouguiya da Maurit\u00e2nia
+mtl=Lira maltesa
+mur=Rupia de Maur\u00edcio
+mvr=Rupias das Ilhas Maldivas
+mwk=Cuacha do Mal\u00e1ui
+mxn=Peso mexicano
+mxv=Unidade Mexicana de Investimento (UDI)
+myr=Ringgit malaio
+mzm=Metical antigo de Mo\u00e7ambique
+mzn=Metical do Mo\u00e7ambique
+nad=D\u00f3lar da Nam\u00edbia
+ngn=Naira nigeriana
+nio=C\u00f3rdoba Ouro nicaraguense
+nlg=Florim holand\u00eas
+nok=Coroa norueguesa
+npr=Rupia nepalesa
+nzd=D\u00f3lar da Nova Zel\u00e2ndia
+omr=Rial de Om\u00e3
+pab=Balboa panamenho
+pen=Sol Novo peruano
+pgk=Kina da Papua-Nova Guin\u00e9
+php=Peso filipino
+pkr=Rupia paquistanesa
+pln=Zloti polon\u00eas
+pte=Escudo portugu\u00eas
+pyg=Guarani paraguaio
+qar=Rial catariano
+rol=Leu romeno antigo
+ron=Leu romeno
+rsd=Dinar s\u00e9rvio
+rub=Rublo russo
+rur=Rublo russo (1991-1998)
+rwf=Franco ruand\u00eas
+sar=Rial saudita
+sbd=D\u00f3lar das Ilhas Salom\u00e3o
+scr=Rupia das Seychelles
+sdd=Dinar sudan\u00eas
+sdg=Libra sudanesa
+sek=Coroa sueca
+sgd=D\u00f3lar de Cingapura
+shp=Libra de Santa Helena
+sit=Tolar Bons esloveno
+skk=Coroa eslovaca
+sll=Leone de Serra Leoa
+sos=Xelim somali
+srd=D\u00f3lar do Suriname
+srg=Florim do Suriname
+std=Dobra de S\u00e3o Tom\u00e9 e Pr\u00edncipe
+svc=Colom salvadorenho
+syp=Libra s\u00edria
+szl=Lilangeni da Suazil\u00e2ndia
+thb=Baht tailand\u00eas
+tjs=Somoni tadjique
+tmm=Manat do Turcomenist\u00e3o
+tnd=Dinar tunisiano
+top=Pa\u02bbanga de Tonga
+tpe=Escudo timorense
+trl=Lira turca antiga
+try=Lira turca
+ttd=D\u00f3lar de Trinidad e Tobago
+twd=D\u00f3lar Novo de Taiwan
+tzs=Xelim da Tanz\u00e2nia
+uah=Hryvnia ucraniano
+ugx=Xelim ugandense
+usd=D\u00f3lar norte-americano
+usn=D\u00f3lar norte-americano (Dia seguinte)
+uss=D\u00f3lar norte-americano (Mesmo dia)
+uyu=Peso uruguaio
+uzs=Sum do Usbequist\u00e3o
+veb=Bol\u00edvar venezuelano
+vef=Bol\u00edvar v enezuelano forte
+vnd=Dong vietnamita
+vuv=Vatu de Vanuatu
+wst=Tala samoano
+xaf=Franco CFA BEAC
+xag=Prata
+xau=Ouro
+xba=Unidade Composta Europeia
+xbb=Unidade Monet\u00e1ria Europeia
+xbc=Unidade de Conta Europeia (XBC)
+xbd=Unidade de Conta Europeia (XBD)
+xcd=D\u00f3lar do Caribe Oriental
+xdr=Direitos Especiais de Giro
+xfo=Franco-ouro franc\u00eas
+xfu=Franco UIC franc\u00eas
+xof=Franco CFA BCEAO
+xpd=Pal\u00e1dio
+xpf=Franco CFP
+xpt=Platina
+xts=C\u00f3digo de Moeda de Teste
+xxx=Moeda Desconhecida ou Inv\u00e1lida
+yer=Rial iemenita
+yum=Dinar noviy iugoslavo
+zar=Rand sul-africano
+zmk=Cuacha zambiano
+zwd=D\u00f3lar do Zimb\u00e1bue
diff --git a/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_BA.properties b/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_BA.properties
new file mode 100644
index 00000000000..a5f63a940da
--- /dev/null
+++ b/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_BA.properties
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# COPYRIGHT AND PERMISSION NOTICE
+#
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of the Unicode data files and any associated documentation (the
+# "Data Files") or Unicode software and any associated documentation
+# (the "Software") to deal in the Data Files or Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, and/or sell copies of the Data
+# Files or Software, and to permit persons to whom the Data Files or
+# Software are furnished to do so, provided that (a) the above copyright
+# notice(s) and this permission notice appear with all copies of the
+# Data Files or Software, (b) both the above copyright notice(s) and
+# this permission notice appear in associated documentation, and (c)
+# there is clear notice in each modified Data File or in the Software as
+# well as in the documentation associated with the Data File(s) or
+# Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+# SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in these Data Files or Software without prior
+# written authorization of the copyright holder.
+
+#
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+#
+BAM=KM
+bam=bosansko-hercegova\u010dkih konvertibilnih maraka
+EUR=\u20ac
+eur=evra
diff --git a/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_ME.properties b/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_ME.properties
new file mode 100644
index 00000000000..2746103ca98
--- /dev/null
+++ b/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_ME.properties
@@ -0,0 +1,67 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# COPYRIGHT AND PERMISSION NOTICE
+#
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of the Unicode data files and any associated documentation (the
+# "Data Files") or Unicode software and any associated documentation
+# (the "Software") to deal in the Data Files or Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, and/or sell copies of the Data
+# Files or Software, and to permit persons to whom the Data Files or
+# Software are furnished to do so, provided that (a) the above copyright
+# notice(s) and this permission notice appear with all copies of the
+# Data Files or Software, (b) both the above copyright notice(s) and
+# this permission notice appear in associated documentation, and (c)
+# there is clear notice in each modified Data File or in the Software as
+# well as in the documentation associated with the Data File(s) or
+# Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+# SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in these Data Files or Software without prior
+# written authorization of the copyright holder.
+
+#
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+#
+EUR=\u20ac
+eur=evra
diff --git a/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_RS.properties b/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_RS.properties
new file mode 100644
index 00000000000..34992f0e310
--- /dev/null
+++ b/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_Latn_RS.properties
@@ -0,0 +1,67 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# COPYRIGHT AND PERMISSION NOTICE
+#
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of the Unicode data files and any associated documentation (the
+# "Data Files") or Unicode software and any associated documentation
+# (the "Software") to deal in the Data Files or Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, and/or sell copies of the Data
+# Files or Software, and to permit persons to whom the Data Files or
+# Software are furnished to do so, provided that (a) the above copyright
+# notice(s) and this permission notice appear with all copies of the
+# Data Files or Software, (b) both the above copyright notice(s) and
+# this permission notice appear in associated documentation, and (c)
+# there is clear notice in each modified Data File or in the Software as
+# well as in the documentation associated with the Data File(s) or
+# Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+# SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in these Data Files or Software without prior
+# written authorization of the copyright holder.
+
+#
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+#
+RSD=din.
+rsd=srpski dinari
diff --git a/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_RS.properties b/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_RS.properties
new file mode 100644
index 00000000000..b6153c86f64
--- /dev/null
+++ b/jdk/src/share/classes/sun/util/resources/CurrencyNames_sr_RS.properties
@@ -0,0 +1,43 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+
+#
+# COPYRIGHT AND PERMISSION NOTICE
+#
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of the Unicode data files and any associated documentation (the "Data
+# Files") or Unicode software and any associated documentation (the
+# "Software") to deal in the Data Files or Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, and/or sell copies of the Data Files or Software, and
+# to permit persons to whom the Data Files or Software are furnished to do
+# so, provided that (a) the above copyright notice(s) and this permission
+# notice appear with all copies of the Data Files or Software, (b) both the
+# above copyright notice(s) and this permission notice appear in associated
+# documentation, and (c) there is clear notice in each modified Data File or
+# in the Software as well as in the documentation associated with the Data
+# File(s) or Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
+# THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
+# INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR
+# CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder shall not
+# be used in advertising or otherwise to promote the sale, use or other
+# dealings in these Data Files or Software without prior written
+# authorization of the copyright holder.
+#
+ 
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+
+RSD=\u0434\u0438\u043d.
diff --git a/jdk/src/share/classes/sun/util/resources/LocaleData.java b/jdk/src/share/classes/sun/util/resources/LocaleData.java
index 9686abc8e2f..86d6e92d8bf 100644
--- a/jdk/src/share/classes/sun/util/resources/LocaleData.java
+++ b/jdk/src/share/classes/sun/util/resources/LocaleData.java
@@ -171,16 +171,21 @@ public class LocaleData {
             /* Get the locale string list from LocaleDataMetaInfo class. */
             String localeString = LocaleDataMetaInfo.getSupportedLocaleString(baseName);
 
-            if (localeString.length() == 0) {
+      if (localeString.length() == 0) {
                 return candidates;
             }
 
             for (Iterator<Locale> l = candidates.iterator(); l.hasNext(); ) {
-                String lstr = l.next().toString();
-                /* truncate extra segment introduced by Java 7 for script and extesions */
-                int idx = lstr.indexOf("_#");
-                if (idx >= 0) {
-                    lstr = lstr.substring(0, idx);
+                Locale loc = l.next();
+                String lstr = null;
+                if (loc.getScript().length() > 0) {
+                    lstr = loc.toLanguageTag().replace('-', '_');
+                } else {
+                    lstr = loc.toString();
+                    int idx = lstr.indexOf("_#");
+                    if (idx >= 0) {
+                        lstr = lstr.substring(0, idx);
+                    }
                 }
                 /* Every locale string in the locale string list returned from
                    the above getSupportedLocaleString is enclosed
@@ -265,28 +270,15 @@ public class LocaleData {
 
         Locale[] locales = new Locale[localeStringTokenizer.countTokens()];
         for (int i = 0; i < locales.length; i++) {
-            String currentToken = localeStringTokenizer.nextToken();
-            int p2 = 0;
-            int p1 = currentToken.indexOf('_');
-            String language = "";
-            String country = "";
-            String variant = "";
-
-            if (p1 == -1) {
-                language = currentToken;
-            } else {
-                language = currentToken.substring(0, p1);
-                p2 = currentToken.indexOf('_', p1 + 1);
-                if (p2 == -1) {
-                    country = currentToken.substring(p1 + 1);
-                } else {
-                    country = currentToken.substring(p1 + 1, p2);
-                    if (p2 < currentToken.length()) {
-                        variant = currentToken.substring(p2 + 1);
-                    }
-                }
+            String currentToken = localeStringTokenizer.nextToken().replace('_','-');
+            if (currentToken.equals("ja-JP-JP")) {
+                currentToken = "ja-JP-u-ca-japanese-x-lvariant-JP";
+            } else if (currentToken.equals("th-TH-TH")) {
+                currentToken = "th-TH-u-nu-thai-x-lvariant-TH";
+            } else if (currentToken.equals("no-NO-NY")) {
+                currentToken = "no-NO-x-lvariant-NY";
             }
-            locales[i] = new Locale(language, country, variant);
+            locales[i] = Locale.forLanguageTag(currentToken);
         }
         return locales;
     }
diff --git a/jdk/src/share/classes/sun/util/resources/LocaleNames_sr_Latn.properties b/jdk/src/share/classes/sun/util/resources/LocaleNames_sr_Latn.properties
new file mode 100644
index 00000000000..7cc1c2477c7
--- /dev/null
+++ b/jdk/src/share/classes/sun/util/resources/LocaleNames_sr_Latn.properties
@@ -0,0 +1,471 @@
+#
+# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+#
+# COPYRIGHT AND PERMISSION NOTICE
+#
+# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
+# Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of the Unicode data files and any associated documentation (the
+# "Data Files") or Unicode software and any associated documentation
+# (the "Software") to deal in the Data Files or Software without
+# restriction, including without limitation the rights to use, copy,
+# modify, merge, publish, distribute, and/or sell copies of the Data
+# Files or Software, and to permit persons to whom the Data Files or
+# Software are furnished to do so, provided that (a) the above copyright
+# notice(s) and this permission notice appear with all copies of the
+# Data Files or Software, (b) both the above copyright notice(s) and
+# this permission notice appear in associated documentation, and (c)
+# there is clear notice in each modified Data File or in the Software as
+# well as in the documentation associated with the Data File(s) or
+# Software that the data or software has been modified.
+#
+# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
+# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
+# SOFTWARE.
+#
+# Except as contained in this notice, the name of a copyright holder
+# shall not be used in advertising or otherwise to promote the sale, use
+# or other dealings in these Data Files or Software without prior
+# written authorization of the copyright holder.
+
+#
+# Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
+#
+aa=Afarski
+ab=Abkazijski
+ae=Avestanski
+af=Afrikanerski
+am=Amharski
+an=Aragone\u017eanski
+ar=Arapski
+as=Asemijski
+av=Avarski
+ay=Ajmara
+az=Azerbejd\u017eanski
+ba=Ba\u0161kir
+be=Beloruski
+bg=Bugarski
+bh=Biharski
+bn=Bengalski
+bo=Tibetanski
+br=Bretonski
+bs=Bosanski
+ca=Katalonski
+ce=\u010ce\u010denski
+ch=\u010camoro
+co=Korzikanski
+cr=Kri
+cs=\u010ce\u0161ki
+cu=Staroslovenski
+cv=\u010cuva\u0161ki
+cy=Vel\u0161ki
+da=Danski
+de=Nema\u010dki
+dv=Divehijski
+dz=D\u017eonga
+ee=Eve
+el=Gr\u010dki
+en=Engleski
+eo=Esperanto
+es=\u0160panski
+et=Estonski
+eu=Baskijski
+fa=Persijski
+fi=Finski
+fj=Fid\u017eijski
+fo=Farski
+fr=Francuski
+fy=Frizijski
+ga=Irski
+gd=\u0160kotski Galski
+gl=Galski
+gn=Gvarani
+gu=Gud\u017earati
+gv=Manks
+he=Hebrejski
+hi=Hindi
+hr=Hrvatski
+ht=Hai\u0107anski
+hu=Ma\u0111arski
+hy=Jermenski
+ia=Interlingva
+id=Indonezijski
+ie=Interlingve
+ii=Si\u010duan ji
+ik=Inupiak
+in=Indonezijski
+is=Islandski
+it=Italijanski
+iw=Hebrejski
+ja=Japanski
+ji=Jidi\u0161
+jv=Javanski
+ka=Gruzijski
+ki=Kikuju
+kj=Kuanjama
+kk=Koza\u010dki
+kl=Kalalisutski
+km=Kmerski
+kn=Kanada
+ko=Korejski
+ks=Ka\u0161miri
+ku=Kurdski
+kw=Korni\u0161ki
+ky=Kirgiski
+la=Latinski
+lb=Luksembur\u0161ki
+li=Limburgi\u0161
+lo=Lao\u0161ki
+lt=Litvanski
+lu=Luba-katanga
+lv=Letonski
+mg=Malagazijski
+mh=Mar\u0161alski
+mi=Maorski
+mk=Makedonski
+ml=Malajalam
+mn=Mongolski
+mo=Moldavski
+mr=Marati
+ms=Malajski
+mt=Melte\u0161ki
+my=Burmanski
+nb=Norve\u0161ki bokm\u00e5l
+nd=Severni ndebele
+ne=Nepalski
+nl=Holandski
+nn=Norve\u0161ki njorsk
+no=Norve\u0161ki
+nr=Ju\u017eni ndebele
+nv=Navaho
+ny=Njanja
+oc=Provansalski
+oj=Ojibva
+or=Orijski
+os=Osetski
+pa=Pand\u017eabski
+pl=Poljski
+ps=Pa\u0161tunski
+pt=Portugalski
+qu=Kven\u010da
+rm=Reto-Romanski
+ro=Rumunski
+ru=Ruski
+rw=Kinjarvanda
+sa=Sanskrit
+sc=Sardinijski
+sd=Sindi
+se=Severni sami
+si=Singaleski
+sk=Slova\u010dki
+sl=Slovena\u010dki
+sm=Samoanski
+sn=\u0160ona
+so=Somalski
+sq=Albanski
+sr=Srpski
+ss=Svati
+st=Sesoto
+su=Sudanski
+sv=\u0160vedski
+sw=Svahili
+ta=Tamilski
+tg=Ta\u0111ik
+th=Tajlandski
+ti=Tigrinja
+tk=Turkmenski
+tl=Tagalski
+tn=Tsvana
+tr=Turski
+tt=Tatarski
+tw=Tvi
+ty=Tahi\u0107anski
+ug=Ujgurski
+uk=Ukrajinski
+uz=Uzbe\u010dki
+vi=Vijetnamski
+wa=Valun
+wo=Volof
+xh=Khosa
+yi=Jidi\u0161
+yo=Jorubanski
+za=Zuang
+zh=Kineski
+AD=Andora
+AE=Ujedinjeni Arapski Emirati
+AF=Avganistan
+AG=Antigva i Barbuda
+AI=Angvila
+AL=Albanija
+AM=Armenija
+AN=Holandski Antili
+AO=Angola
+AQ=Antarktika
+AR=Argentina
+AS=Ameri\u010dka Samoa
+AT=Austrija
+AU=Australija
+AW=Aruba
+AX=Alandska ostrva
+AZ=Azerbejd\u017ean
+BA=Bosna i Hercegovina
+BB=Barbados
+BD=Banglade\u0161
+BE=Belgija
+BF=Burkina Faso
+BG=Bugarska
+BH=Bahrein
+BI=Burundi
+BJ=Benin
+BL=Sv. Bartolomej
+BM=Bermuda
+BN=Brunej
+BO=Bolivija
+BR=Brazil
+BS=Bahami
+BT=Butan
+BV=Buve Ostrva
+BW=Bocvana
+BY=Belorusija
+BZ=Belise
+CA=Kanada
+CC=Kokos (Keling) Ostrva
+CD=Demokratska Republika Kongo
+CF=Centralno Afri\u010dka Republika
+CG=Kongo
+CH=\u0160vajcarska
+CI=Obala Slonova\u010de
+CK=Kukova Ostrva
+CL=\u010cile
+CM=Kamerun
+CN=Kina
+CO=Kolumbija
+CR=Kostarika
+CU=Kuba
+CV=Kape Verde
+CX=Bo\u017ei\u0107na Ostrva
+CY=Kipar
+CZ=\u010ce\u0161ka
+DE=Nema\u010dka
+DJ=D\u017eibuti
+DK=Danska
+DM=Dominika
+DO=Dominikanska Republika
+DZ=Al\u017eir
+EC=Ekvador
+EE=Estonija
+EG=Egipat
+EH=Zapadna Sahara
+ER=Eritreja
+ES=\u0160panija
+ET=Etiopija
+FI=Finska
+FJ=Fid\u017ei
+FK=Folklandska Ostrva
+FM=Mikronezija
+FO=Farska Ostrva
+FR=Francuska
+GA=Gabon
+GB=Velika Britanija
+GD=Grenada
+GE=Gruzija
+GF=Francuska Gvajana
+GG=Gurnsi
+GH=Gana
+GI=Gibraltar
+GL=Grenland
+GM=Gambija
+GN=Gvineja
+GP=Gvadelupe
+GQ=Ekvatorijalna Gvineja
+GR=Gr\u010dka
+GS=Ju\u017ena D\u017eord\u017eija i Ju\u017ena Sendvi\u010d Ostrva
+GT=Gvatemala
+GU=Guam
+GW=Gvineja-Bisao
+GY=Gvajana
+HK=Hong Kong (S. A. R. Kina)
+HM=Herd i Mekdonald Ostrva
+HN=Honduras
+HR=Hrvatska
+HT=Haiti
+HU=Ma\u0111arska
+ID=Indonezija
+IE=Irska
+IL=Izrael
+IM=Ostrvo Man
+IN=Indija
+IO=Britansko Indijska Okeanska Teritorija
+IQ=Irak
+IR=Iran
+IS=Island
+IT=Italija
+JE=D\u017eersi
+JM=Jamajka
+JO=Jordan
+JP=Japan
+KE=Kenija
+KG=Kirgizstan
+KH=Kambod\u017ea
+KI=Kiribati
+KM=Komorska Ostrva
+KN=Sent Kits i Nevis
+KP=Severna Koreja
+KR=Ju\u017ena Koreja
+KW=Kuvajt
+KY=Kajmanska Ostrva
+KZ=Kazahstan
+LA=Laos
+LB=Liban
+LC=Sent Lucija
+LI=Lihten\u0161tajn
+LK=\u0160ri Lanka
+LR=Liberija
+LS=Lesoto
+LT=Litvanija
+LU=Luksemburg
+LV=Letonija
+LY=Libija
+MA=Maroko
+MC=Monako
+MD=Moldavija
+ME=Crna Gora
+MF=Sv. Martin
+MG=Madagaskar
+MH=Mar\u0161alska Ostrva
+MK=Makedonija
+ML=Mali
+MM=Mijanmar
+MN=Mongolija
+MO=Makao (S. A. R. Kina)
+MP=Severna Marijanska Ostrva
+MQ=Martinik
+MR=Mauritanija
+MS=Monserat
+MT=Malta
+MU=Mauricius
+MV=Maldivi
+MW=Malavi
+MX=Meksiko
+MY=Malezija
+MZ=Mozambik
+NA=Namibija
+NC=Nova Kaledonija
+NE=Niger
+NF=Norfolk Ostrvo
+NG=Nigerija
+NI=Nikaragva
+NL=Holandija
+NO=Norve\u0161ka
+NP=Nepal
+NR=Nauru
+NU=Niue
+NZ=Novi Zeland
+OM=Oman
+PA=Panama
+PE=Peru
+PF=Francuska Polinezija
+PG=Papua Nova Gvineja
+PH=Filipini
+PK=Pakistan
+PL=Poljska
+PM=Sen Pjer i Mikelon
+PN=Pitcairn
+PR=Porto Riko
+PS=Palestinska Teritorija
+PT=Portugal
+PW=Palau
+PY=Paragvaj
+QA=Katar
+RE=Rejunion
+RO=Rumunija
+RS=Srbija
+RU=Rusija
+RW=Ruanda
+SA=Saudijska Arabija
+SB=Solomonska Ostrva
+SC=Sej\u0161eli
+SD=Sudan
+SE=\u0160vedska
+SG=Singapur
+SH=Sveta Jelena
+SI=Slovenija
+SJ=Svalbard i Janmajen Ostrva
+SK=Slova\u010dka
+SL=Sijera Leone
+SM=San Marino
+SN=Senegal
+SO=Somalija
+SR=Surinam
+ST=Sao Tome i Principe
+SV=Salvador
+SY=Sirija
+SZ=Svazilend
+TC=Turks i Kajkos Ostrva
+TD=\u010cad
+TF=Francuske Ju\u017ene Teritorije
+TG=Togo
+TH=Tajland
+TJ=Tad\u017eikistan
+TK=Tokelau
+TL=Isto\u010dni Timor
+TM=Turkmenistan
+TN=Tunis
+TO=Tonga
+TR=Turska
+TT=Trinidad i Tobago
+TV=Tuvalu
+TW=Tajvan
+TZ=Tanzanija
+UA=Ukrajina
+UG=Uganda
+UM=Manja Udaljena Ostrva SAD
+US=Sjedinjene Ameri\u010dke Dr\u017eave
+UY=Urugvaj
+UZ=Uzbekistan
+VA=Vatikan
+VC=Sent Vinsent i Grenadini
+VE=Venecuela
+VG=Britanska Devi\u010danska Ostrva
+VI=S.A.D. Devi\u010danska Ostrva
+VN=Vijetnam
+VU=Vanuatu
+WF=Valis i Futuna Ostrva
+WS=Samoa
+YE=Jemen
+YT=Majote
+ZA=Ju\u017enoafri\u010dka Republika
+ZM=Zambija
+ZW=Zimbabve
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java
index a5c73549809..0016ae24d20 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"Pierre & Miquelon Standard Time", "PMST",
                                                "Pierre & Miquelon Daylight Time", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java
index b3cb23224fa..0e4d91d94f7 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"Pierre & Miquelon Normalzeit", "PMST",
                                                "Pierre & Miquelon Sommerzeit", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java
index 613cc6419fb..711afc45563 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"Hora est\u00e1ndar de Pierre & Miquelon", "PMST",
                                                "Hora de verano de Pierre & Miquelon", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java
index f1dc5300c25..090820b6742 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"Heure normale de Saint-Pierre et Miquelon", "PMST",
                                                "Heure avanc\u00e9e de Saint-Pierre et Miquelon", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java
index e983872e7a1..6413104ba74 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"Ora solare di Saint-Pierre e Miquelon", "PMST",
                                                "Ora legale di Saint-Pierre e Miquelon", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java
index 56330acf91d..4c1226666c8 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"\u30b5\u30f3\u30d4\u30a8\u30fc\u30eb\u30fb\u30df\u30af\u30ed\u30f3\u8af8\u5cf6\u6a19\u6e96\u6642", "PMST",
                                                "\u30b5\u30f3\u30d4\u30a8\u30fc\u30eb\u30fb\u30df\u30af\u30ed\u30f3\u8af8\u5cf6\u590f\u6642\u9593", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java
index 82edcce1ec5..486e1bdd9a5 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"\ud53c\uc5d0\ub974 \ubbf8\ud06c\ub860 \ud45c\uc900\uc2dc", "PMST",
                                                "\ud53c\uc5d0\ub974 \ubbf8\ud06c\ub860 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java
index d9b83fe0491..7eab4bb48b4 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java
@@ -217,6 +217,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
         {"America/Anchorage", AKST},
         {"AST", AKST},
         {"America/Halifax", AST},
+        {"America/Sitka", AKST},
         {"America/St_Johns", NST},
         {"CNT", NST},
         {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle {
         {"America/Mendoza", AGT},
         {"America/Menominee", CST},
         {"America/Merida", CST},
+        {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                             "Metlakatla Daylight Time", "MeDT"}},
         {"America/Mexico_City", CST},
         {"America/Miquelon", new String[] {"Fuso hor\u00e1rio padr\u00e3o de S\u00e3o Pedro e Miquelon", "PMST",
                            "Hor\u00e1rio de luz natural de S\u00e3o Pedro e Miquelon", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java
index 14108065241..63b5e084523 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"Saint-Pierre-et-Miquelon, normaltid", "PMST",
                                                "Saint-Pierre-et-Miquelon, sommartid", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java
index 4f80a1b739c..b215a186e9a 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"\u76ae\u57c3\u5c14\u5c9b\u53ca\u5bc6\u514b\u9686\u5c9b\u6807\u51c6\u65f6\u95f4", "PMST",
                                                "\u76ae\u57c3\u5c14\u5c9b\u53ca\u5bc6\u514b\u9686\u5c9b\u590f\u4ee4\u65f6", "PMDT"}},
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java
index 5218bed7ed6..7a638641e89 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java
@@ -216,6 +216,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
             {"America/Anchorage", AKST},
             {"AST", AKST},
             {"America/Halifax", AST},
+            {"America/Sitka", AKST},
             {"America/St_Johns", NST},
             {"CNT", NST},
             {"Europe/Paris", CET},
@@ -392,6 +393,8 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle {
             {"America/Mendoza", AGT},
             {"America/Menominee", CST},
             {"America/Merida", CST},
+            {"America/Metlakatla", new String[] {"Metlakatla Standard Time", "MeST",
+                                                 "Metlakatla Daylight Time", "MeDT"}},
             {"America/Mexico_City", CST},
             {"America/Miquelon", new String[] {"\u76ae\u57c3\u723e\u5cf6\u53ca\u5bc6\u514b\u9686\u5cf6\u6a19\u6e96\u6642\u9593", "PMST",
                                                "\u76ae\u57c3\u723e\u5cf6\u53ca\u5bc6\u514b\u9686\u5cf6\u65e5\u5149\u7bc0\u7d04\u6642\u9593", "PMDT"}},
diff --git a/jdk/src/share/demo/jfc/Notepad/resources/Notepad.properties b/jdk/src/share/demo/jfc/Notepad/resources/Notepad.properties
index fdd5c5a2246..ef61d6fd3c4 100644
--- a/jdk/src/share/demo/jfc/Notepad/resources/Notepad.properties
+++ b/jdk/src/share/demo/jfc/Notepad/resources/Notepad.properties
@@ -3,12 +3,15 @@
 
 Title=Notepad
 ElementTreeFrameTitle=Elements
+# The following string should NOT be translated: ViewportBackingStore
 ViewportBackingStore=false
 
 # menubar definition
 #
 # Each of the strings that follow form a key to be 
 # used to the actual menu definition.
+
+# The following string should NOT be translated: menubar
 menubar=file edit debug
 
 # file Menu definition
@@ -20,6 +23,8 @@ menubar=file edit debug
 # new  ->  Notepad.newAction
 # save ->  Notepad.saveAction
 # exit ->  Notepad.exitAction
+
+# The following string should NOT be translated: file
 file=new open save - exit
 fileLabel=File
 openLabel=Open
@@ -36,28 +41,38 @@ exitLabel=Exit
 # cut   -> JTextComponent.cutAction
 # copy  -> JTextComponent.copyAction
 # paste -> JTextComponent.pasteAction
+
+# The following string should NOT be translated: edit
 edit=cut copy paste - undo redo
 editLabel=Edit
 cutLabel=Cut
+# The following string should NOT be translated: cutAction
 cutAction=cut-to-clipboard
 cutImage=resources/cut.gif
 copyLabel=Copy
+# The following string should NOT be translated: copyAction
 copyAction=copy-to-clipboard
 copyImage=resources/copy.gif
 pasteLabel=Paste
+# The following string should NOT be translated: pasteAction
 pasteAction=paste-from-clipboard
 pasteImage=resources/paste.gif
 undoLabel=Undo
+# The following string should NOT be translated: undoAction
 undoAction=Undo
 redoLabel=Redo
+# The following string should NOT be translated: redoAction
 redoAction=Redo
 
 #
 # debug Menu definition
 #
+
+# The following string should NOT be translated: debug
 debug=dump showElementTree
 debugLabel=Debug
 dumpLabel=Dump model to System.err
+# The following string should NOT be translated: dumpAction
 dumpAction=dump-model
 showElementTreeLabel=Show Elements
 
@@ -67,6 +82,8 @@ showElementTreeLabel=Show Elements
 # used as the basis of the tool definition.  Actions
 # are of course sharable, and in this case are shared
 # with the menu items.
+
+# The following string should NOT be translated: toolbar
 toolbar=new open save - cut copy paste
 newTooltip=Create a new file
 openTooltip=Open a file
diff --git a/jdk/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties b/jdk/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties
index 8a40242b9ec..777e1cf72f9 100644
--- a/jdk/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties
+++ b/jdk/src/share/demo/jfc/Notepad/resources/Notepad_ja.properties
@@ -9,7 +9,7 @@ ViewportBackingStore=false
 #
 # Each of the strings that follow form a key to be 
 # used to the actual menu definition.
-menubar=\u30D5\u30A1\u30A4\u30EB \u7DE8\u96C6 \u30C7\u30D0\u30C3\u30B0
+menubar=file edit debug
 
 # file Menu definition
 #
@@ -20,7 +20,7 @@ menubar=\u30D5\u30A1\u30A4\u30EB \u7DE8\u96C6 \u30C7\u30D0\u30C3\u30B0
 # new  ->  Notepad.newAction
 # save ->  Notepad.saveAction
 # exit ->  Notepad.exitAction
-file=\u65B0\u898F \u958B\u304F \u4FDD\u5B58 - \u7D42\u4E86
+file=new open save - exit
 fileLabel=\u30D5\u30A1\u30A4\u30EB
 openLabel=\u958B\u304F
 openImage=resources/open.gif
@@ -36,7 +36,7 @@ exitLabel=\u7D42\u4E86
 # cut   -> JTextComponent.cutAction
 # copy  -> JTextComponent.copyAction
 # paste -> JTextComponent.pasteAction
-edit=\u5207\u53D6\u308A \u30B3\u30D4\u30FC \u8CBC\u4ED8\u3051 - \u5143\u306B\u623B\u3059 \u518D\u5B9F\u884C
+edit=cut copy paste - undo redo
 editLabel=\u7DE8\u96C6
 cutLabel=\u5207\u53D6\u308A
 cutAction=cut-to-clipboard
@@ -48,14 +48,14 @@ pasteLabel=\u8CBC\u4ED8\u3051
 pasteAction=paste-from-clipboard
 pasteImage=resources/paste.gif
 undoLabel=\u5143\u306B\u623B\u3059
-undoAction=\u5143\u306B\u623B\u3059
+undoAction=Undo
 redoLabel=\u518D\u5B9F\u884C
-redoAction=\u518D\u5B9F\u884C
+redoAction=Redo
 
 #
 # debug Menu definition
 #
-debug=showElementTree\u306E\u30C0\u30F3\u30D7
+debug=dump showElementTree
 debugLabel=\u30C7\u30D0\u30C3\u30B0
 dumpLabel=\u30E2\u30C7\u30EB\u3092System.err\u306B\u30C0\u30F3\u30D7
 dumpAction=dump-model
@@ -67,7 +67,7 @@ showElementTreeLabel=\u8981\u7D20\u306E\u8868\u793A
 # used as the basis of the tool definition.  Actions
 # are of course sharable, and in this case are shared
 # with the menu items.
-toolbar=\u65B0\u898F \u958B\u304F \u4FDD\u5B58 - \u5207\u53D6\u308A \u30B3\u30D4\u30FC \u8CBC\u4ED8\u3051
+toolbar=new open save - cut copy paste
 newTooltip=\u30D5\u30A1\u30A4\u30EB\u3092\u65B0\u898F\u4F5C\u6210\u3059\u308B
 openTooltip=\u30D5\u30A1\u30A4\u30EB\u3092\u958B\u304F
 saveTooltip=\u30D5\u30A1\u30A4\u30EB\u306B\u4FDD\u5B58
diff --git a/jdk/src/share/demo/jfc/Notepad/resources/Notepad_zh_CN.properties b/jdk/src/share/demo/jfc/Notepad/resources/Notepad_zh_CN.properties
index 9706f903dad..be6ec0692c1 100644
--- a/jdk/src/share/demo/jfc/Notepad/resources/Notepad_zh_CN.properties
+++ b/jdk/src/share/demo/jfc/Notepad/resources/Notepad_zh_CN.properties
@@ -48,9 +48,9 @@ pasteLabel=\u7C98\u8D34
 pasteAction=paste-from-clipboard
 pasteImage=resources/paste.gif
 undoLabel=\u64A4\u6D88
-undoAction=\u64A4\u6D88
+undoAction=Undo
 redoLabel=\u91CD\u505A
-redoAction=\u91CD\u505A
+redoAction=Redo
 
 #
 # debug Menu definition
diff --git a/jdk/src/share/native/common/check_code.c b/jdk/src/share/native/common/check_code.c
index 00dcdf163b3..dcdaeda58bf 100644
--- a/jdk/src/share/native/common/check_code.c
+++ b/jdk/src/share/native/common/check_code.c
@@ -2685,11 +2685,11 @@ push_stack(context_type *context, unsigned int inumber, stack_info_type *new_sta
                     switch (type_table[operand]) {
                     case JVM_CONSTANT_MethodType:
                       full_info = make_class_info_from_name(context,
-                                                            "java/dyn/MethodType");
+                                                            "java/lang/invoke/MethodType");
                       break;
                     default: //JVM_CONSTANT_MethodHandle
                       full_info = make_class_info_from_name(context,
-                                                            "java/dyn/MethodHandle");
+                                                            "java/lang/invoke/MethodHandle");
                       break;
                     }
                     break;
diff --git a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
index 04a87fd1cac..84b91889725 100644
--- a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
+++ b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
@@ -40,7 +40,7 @@
 #include <setjmp.h>
 #include <assert.h>
 #include <string.h>
-
+#include <limits.h>
 
 /* java native interface headers */
 #include "jni.h"
@@ -2657,7 +2657,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage
         (destWidth < 0) || (destWidth > srcWidth) ||
         (destHeight < 0) ||
         (stepX < 0) || (stepY < 0) ||
-        ((scanLineSize / numBands) < destWidth))  /* destWidth causes an integer overflow */
+        ((INT_MAX / numBands) < destWidth))  /* destWidth causes an integer overflow */
     {
         JNU_ThrowByName(env, "javax/imageio/IIOException",
                         "Invalid argument to native writeImage");
diff --git a/jdk/src/share/native/sun/font/layout/KernTable.cpp b/jdk/src/share/native/sun/font/layout/KernTable.cpp
index 8d368211309..3a9987eb6b9 100644
--- a/jdk/src/share/native/sun/font/layout/KernTable.cpp
+++ b/jdk/src/share/native/sun/font/layout/KernTable.cpp
@@ -210,7 +210,7 @@ void KernTable::process(LEGlyphStorage& storage)
       // all the elements ahead of time and store them in the font
 
       const PairInfo* p = pairs;
-      const PairInfo* tp = (const PairInfo*)(p + rangeShift);
+      const PairInfo* tp = (const PairInfo*)(p + (rangeShift/KERN_PAIRINFO_SIZE)); /* rangeshift is in original table bytes */
       if (key > tp->key) {
         p = tp;
       }
@@ -222,7 +222,7 @@ void KernTable::process(LEGlyphStorage& storage)
       le_uint32 probe = searchRange;
       while (probe > 1) {
         probe >>= 1;
-        tp = (const PairInfo*)(p + probe);
+        tp = (const PairInfo*)(p + (probe/KERN_PAIRINFO_SIZE));
         le_uint32 tkey = tp->key;
 #if DEBUG
         fprintf(stdout, "   %.3d (%0.8x)\n", (tp - pairs), tkey);
diff --git a/jdk/src/share/native/sun/font/layout/LayoutEngine.cpp b/jdk/src/share/native/sun/font/layout/LayoutEngine.cpp
index 6b0aa1baa58..90aafde2a80 100644
--- a/jdk/src/share/native/sun/font/layout/LayoutEngine.cpp
+++ b/jdk/src/share/native/sun/font/layout/LayoutEngine.cpp
@@ -251,6 +251,10 @@ le_int32 LayoutEngine::characterProcessing(const LEUnicode chars[], le_int32 off
         return 0;
     }
 
+    if ((fTypoFlags & 0x4) == 0) { // no canonical processing
+      return count;
+    }
+
     const GlyphSubstitutionTableHeader *canonGSUBTable = (GlyphSubstitutionTableHeader *) CanonShaping::glyphSubstitutionTable;
     LETag scriptTag  = OpenTypeLayoutEngine::getScriptTag(fScriptCode);
     LETag langSysTag = OpenTypeLayoutEngine::getLangSysTag(fLanguageCode);
diff --git a/jdk/src/share/native/sun/java2d/loops/ProcessPath.c b/jdk/src/share/native/sun/java2d/loops/ProcessPath.c
index b4f724752dc..5131a3e22c7 100644
--- a/jdk/src/share/native/sun/java2d/loops/ProcessPath.c
+++ b/jdk/src/share/native/sun/java2d/loops/ProcessPath.c
@@ -118,19 +118,25 @@
         jint Y1 = (fY1) >> MDP_PREC;                                        \
         jint res;                                                           \
                                                                             \
-        /* Checking bounds and clipping if necessary */                     \
+        /* Checking bounds and clipping if necessary.                       \
+         * REMIND: It's temporary solution to avoid OOB in rendering code.  \
+         * Current approach uses float equations which are unreliable for   \
+         * clipping and makes assumptions about the line biases of the      \
+         * rendering algorithm. Also, clipping code should be moved down    \
+         * into only those output renderers that need it.                   \
+         */                                                                 \
         if (checkBounds) {                                                  \
-            TESTANDCLIP(hnd->dhnd->yMin, hnd->dhnd->yMax, Y0, X0, Y1, X1,   \
-                        jint, res);                                         \
+            jfloat xMinf = hnd->dhnd->xMinf + 0.5f;                         \
+            jfloat yMinf = hnd->dhnd->yMinf + 0.5f;                         \
+            jfloat xMaxf = hnd->dhnd->xMaxf + 0.5f;                         \
+            jfloat yMaxf = hnd->dhnd->yMaxf + 0.5f;                         \
+            TESTANDCLIP(yMinf, yMaxf, Y0, X0, Y1, X1, jint, res);           \
             if (res == CRES_INVISIBLE) break;                               \
-            TESTANDCLIP(hnd->dhnd->yMin, hnd->dhnd->yMax, Y1, X1, Y0, X0,   \
-                        jint, res);                                         \
+            TESTANDCLIP(yMinf, yMaxf, Y1, X1, Y0, X0, jint, res);           \
             if (res == CRES_INVISIBLE) break;                               \
-            TESTANDCLIP(hnd->dhnd->xMin, hnd->dhnd->xMax, X0, Y0, X1, Y1,   \
-                        jint, res);                                         \
+            TESTANDCLIP(xMinf, xMaxf, X0, Y0, X1, Y1, jint, res);           \
             if (res == CRES_INVISIBLE) break;                               \
-            TESTANDCLIP(hnd->dhnd->xMin, hnd->dhnd->xMax, X1, Y1, X0, Y0,   \
-                        jint, res);                                         \
+            TESTANDCLIP(xMinf, xMaxf, X1, Y1, X0, Y0, jint, res);           \
             if (res == CRES_INVISIBLE) break;                               \
         }                                                                   \
                                                                             \
diff --git a/jdk/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/jdk/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
index 5ad8b8d54d8..be2426d7f72 100644
--- a/jdk/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
+++ b/jdk/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
@@ -68,6 +68,9 @@ import sun.net.www.protocol.http.HttpURLConnection;
 public class NTLMAuthentication extends AuthenticationInfo {
     private static final long serialVersionUID = 170L;
 
+    private static final NTLMAuthenticationCallback NTLMAuthCallback =
+        NTLMAuthenticationCallback.getNTLMAuthenticationCallback();
+
     private String hostname;
     private static String defaultDomain; /* Domain to use if not specified by user */
 
@@ -81,6 +84,14 @@ public class NTLMAuthentication extends AuthenticationInfo {
         return false;
     }
 
+    /**
+     * Returns true if the given site is trusted, i.e. we can try
+     * transparent Authentication.
+     */
+    public static boolean isTrustedSite(URL url) {
+        return NTLMAuthCallback.isTrustedSite(url);
+    }
+
     private void init0() {
 
         hostname = java.security.AccessController.doPrivileged(
diff --git a/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c b/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c
index 0c1275b3bc2..f84c08edf66 100644
--- a/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c
+++ b/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c
@@ -302,6 +302,7 @@ awt_DrawingSurface_FreeDrawingSurfaceInfo(JAWT_DrawingSurfaceInfo* dsi)
 #ifdef DEBUG
         fprintf(stderr, "Drawing Surface Info is NULL\n");
 #endif
+        return;
     }
     free(dsi->platformInfo);
     free(dsi);
diff --git a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
index 45184950931..b548df4bf5d 100644
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
@@ -240,7 +240,7 @@ makeDefaultConfig(JNIEnv *env, int screen) {
 
     AwtGraphicsConfigDataPtr defaultConfig;
     int xinawareScreen = 0;
-    VisualID forcedVisualID, defaultVisualID;
+    VisualID forcedVisualID = 0, defaultVisualID;
     char *forcedVisualStr;
     XVisualInfo vinfo;
     long mask;
@@ -254,7 +254,7 @@ makeDefaultConfig(JNIEnv *env, int screen) {
 
     if ((forcedVisualStr = getenv("FORCEDEFVIS"))) {
         mask = VisualIDMask | VisualScreenMask;
-        if (sscanf(forcedVisualStr, "%x", &forcedVisualID) > 0 &&
+        if (sscanf(forcedVisualStr, "%lx", &forcedVisualID) > 0 &&
             forcedVisualID > 0)
         {
             vinfo.visualid = forcedVisualID;
diff --git a/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java b/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java
index 65969a877d5..5590523b6ae 100644
--- a/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java
+++ b/jdk/src/windows/classes/java/net/TwoStacksPlainDatagramSocketImpl.java
@@ -26,6 +26,7 @@ package java.net;
 
 import java.io.IOException;
 import java.io.FileDescriptor;
+import sun.net.ResourceManager;
 
 /**
  * This class defines the plain DatagramSocketImpl that is used for all
@@ -108,6 +109,7 @@ class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
     protected void close() {
         if (fd != null || fd1 != null) {
             datagramSocketClose();
+            ResourceManager.afterUdpClose();
             fd = null;
             fd1 = null;
         }
diff --git a/jdk/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java b/jdk/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
index c9c26517d9b..c4b20db6495 100644
--- a/jdk/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
+++ b/jdk/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java
@@ -45,6 +45,9 @@ public class NTLMAuthentication extends AuthenticationInfo {
 
     private static final long serialVersionUID = 100L;
 
+    private static final NTLMAuthenticationCallback NTLMAuthCallback =
+        NTLMAuthenticationCallback.getNTLMAuthenticationCallback();
+
     private String hostname;
     private static String defaultDomain; /* Domain to use if not specified by user */
 
@@ -142,6 +145,14 @@ public class NTLMAuthentication extends AuthenticationInfo {
         return true;
     }
 
+    /**
+     * Returns true if the given site is trusted, i.e. we can try
+     * transparent Authentication.
+     */
+    public static boolean isTrustedSite(URL url) {
+        return NTLMAuthCallback.isTrustedSite(url);
+    }
+
     /**
      * Not supported. Must use the setHeaders() method
      */
diff --git a/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp b/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp
index df0f263ddfc..1deff60252a 100644
--- a/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp
+++ b/jdk/src/windows/native/sun/windows/awt_PrintJob.cpp
@@ -3699,7 +3699,9 @@ static void matchPaperSize(HDC printDC, HGLOBAL hDevMode, HGLOBAL hDevNames,
                            double* newWid, double *newHgt,
                            WORD* paperSize) {
 
-    const double epsilon = 0.50;
+    // Tolerated differences in comparing page dimensions between passed in
+    // "orig" media with that of Windows' device.
+    const double epsilon = 3.6; // (1/72) of an inch
     const double tolerance = (1.0 * 72.0);  // # inches * 72
 
     *newWid = origWid;
diff --git a/jdk/test/java/awt/font/TextLayout/CombiningPerf.java b/jdk/test/java/awt/font/TextLayout/CombiningPerf.java
new file mode 100644
index 00000000000..d51e586e507
--- /dev/null
+++ b/jdk/test/java/awt/font/TextLayout/CombiningPerf.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6328154 6962082
+ * @summary ensure that ascii, and latin-1 text without combining marks, both layout faster
+ *  than latin-1 text with combining marks.  The presumption is then that the canonical
+ *  GSUB table is being run only on the latter and not on either of the former.
+ */
+
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+
+import static java.awt.Font.*;
+
+public class CombiningPerf {
+    private static Font font;
+    private static FontRenderContext frc;
+
+    public static void main(String[] args) throws Exception {
+        System.err.println("start");
+
+        GraphicsEnvironment.getLocalGraphicsEnvironment();
+
+        font = new Font("Lucida Sans Regular", PLAIN, 12);
+        frc = new FontRenderContext(null, false, false);
+
+        String ascii = "the characters are critical noodles?";
+        String french = "l'aper\u00e7u caract\u00e8re one \u00e9t\u00e9 cr\u00e9\u00e9s";
+        String frenchX = "l'aper\u00e7u caracte\u0300re one e\u0301te\u0301 ere\u0301e\u0301s";
+
+        // warmup
+        for (int i = 0; i < 100; ++i) {
+            TextLayout tl = new TextLayout(french, font, frc);
+            tl = new TextLayout(ascii, font, frc);
+            tl = new TextLayout(frenchX, font, frc);
+        }
+        /**/
+        long atime = test(ascii);
+        System.err.println("atime: " + (atime/1000000.0) + " length: " + ascii.length());
+
+        long ftime = test(french);
+        System.err.println("ftime: " + (ftime/1000000.0) + " length: " + french.length());
+
+        long xtime = test(frenchX);
+        System.err.println("xtime: " + (xtime/1000000.0) + " length: " + frenchX.length());
+
+        long limit = xtime * 2 / 3;
+        if (atime > limit || ftime > limit) {
+            throw new Exception("took too long");
+        }
+        /**/
+    }
+
+    private static long test(String text) {
+        long start = System.nanoTime();
+        for (int i = 0; i < 2000; ++i) {
+            TextLayout tl = new TextLayout(text, font, frc);
+        }
+        return System.nanoTime() - start;
+    }
+}
diff --git a/jdk/test/java/awt/font/TextLayout/KernCrash.java b/jdk/test/java/awt/font/TextLayout/KernCrash.java
new file mode 100644
index 00000000000..50e44d4c30d
--- /dev/null
+++ b/jdk/test/java/awt/font/TextLayout/KernCrash.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.awt.*;
+import java.awt.font.*;
+import java.util.*;
+
+/**
+ * Shows (top) with kerning, (middle) without, (bottom) also without.
+ *
+ * @bug 7017324
+ */
+public class KernCrash extends Frame {
+    private static Font font0;
+    private static Font font1;
+    private static Font font2;
+
+    public static void main(String[] args) throws Exception {
+        HashMap attrs = new HashMap();
+        font0 = Font.createFont(Font.TRUETYPE_FONT, new File("Vera.ttf"));
+        System.out.println("using " + font0);
+        attrs.put(TextAttribute.SIZE, new Float(58f));
+        font1 = font0.deriveFont(attrs);
+        attrs.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
+        font2 = font0.deriveFont(attrs);
+
+        KernCrash f = new KernCrash();
+        f.setTitle("Kerning Crash");
+        f.setSize(600, 300);
+        f.setForeground(Color.black);
+        f.show();
+    }
+
+    public void paint(Graphics g) {
+        Graphics2D g2 = (Graphics2D)g;
+        FontRenderContext frc = g2.getFontRenderContext();
+        TextLayout layout = new TextLayout("text", font2, frc);
+        layout.draw(g2, 10, 150);
+
+        String s = "WAVATastic";
+        TextLayout layout2 = new TextLayout(s, font1, frc);
+        layout2.draw(g2, 10, 200);
+        TextLayout layout3 = new TextLayout(s, font2, frc);
+        layout3.draw(g2, 10, 100);
+    }
+}
diff --git a/hotspot/test/compiler/6987555/Test6987555.java b/jdk/test/java/lang/invoke/6987555/Test6987555.java
similarity index 99%
rename from hotspot/test/compiler/6987555/Test6987555.java
rename to jdk/test/java/lang/invoke/6987555/Test6987555.java
index a438fee8dd1..465da236d7c 100644
--- a/hotspot/test/compiler/6987555/Test6987555.java
+++ b/jdk/test/java/lang/invoke/6987555/Test6987555.java
@@ -30,7 +30,7 @@
  * @run main/othervm -Xint -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6987555
  */
 
-import java.dyn.*;
+import java.lang.invoke.*;
 
 public class Test6987555 {
     private static final Class   CLASS = Test6987555.class;
diff --git a/hotspot/test/compiler/6991596/Test6991596.java b/jdk/test/java/lang/invoke/6991596/Test6991596.java
similarity index 98%
rename from hotspot/test/compiler/6991596/Test6991596.java
rename to jdk/test/java/lang/invoke/6991596/Test6991596.java
index aff08c88641..e02bcfc819e 100644
--- a/hotspot/test/compiler/6991596/Test6991596.java
+++ b/jdk/test/java/lang/invoke/6991596/Test6991596.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * @run main/othervm -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6991596
  */
 
-import java.dyn.*;
+import java.lang.invoke.*;
 
 public class Test6991596 {
     private static final Class   CLASS = Test6991596.class;
@@ -47,7 +47,7 @@ public class Test6991596 {
     }
 
     // Helpers to get various methods.
-    static MethodHandle getmh1(Class ret, Class arg) throws NoAccessException {
+    static MethodHandle getmh1(Class ret, Class arg) throws ReflectiveOperationException {
         return MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(ret, arg));
     }
     static MethodHandle getmh2(MethodHandle mh1, Class ret, Class arg) {
diff --git a/jdk/test/java/dyn/ClassValueTest.java b/jdk/test/java/lang/invoke/ClassValueTest.java
similarity index 94%
rename from jdk/test/java/dyn/ClassValueTest.java
rename to jdk/test/java/lang/invoke/ClassValueTest.java
index f917e9581da..59c5a658c7e 100644
--- a/jdk/test/java/dyn/ClassValueTest.java
+++ b/jdk/test/java/lang/invoke/ClassValueTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,21 +26,21 @@
 /* @test
  * @summary tests for class-specific values
  * @compile ClassValueTest.java
- * @run junit/othervm test.java.dyn.ClassValueTest
+ * @run junit/othervm test.java.lang.invoke.ClassValueTest
  */
 
 /*
   Manually:
-   $ $JAVA7X_HOME/bin/javac -d foo -cp $JUNIT4_JAR test/java/dyn/ClassValueTest.java
-   $ $JAVA7X_HOME/bin/java -cp foo:$JUNIT4_JAR org.junit.runner.JUnitCore test.java.dyn.ClassValueTest
+   $ $JAVA7X_HOME/bin/javac -d foo -cp $JUNIT4_JAR test/java/lang/invoke/ClassValueTest.java
+   $ $JAVA7X_HOME/bin/java -cp foo:$JUNIT4_JAR org.junit.runner.JUnitCore test.java.lang.invoke.ClassValueTest
   Output: .testAdd => 1000 : Integer
  */
 
-package test.java.dyn;
+package test.java.lang.invoke;
 
 import java.util.*;
 
-import java.dyn.*;
+import java.lang.invoke.*;
 
 import org.junit.*;
 import static org.junit.Assert.*;
diff --git a/jdk/test/java/dyn/InvokeDynamicPrintArgs.java b/jdk/test/java/lang/invoke/InvokeDynamicPrintArgs.java
similarity index 89%
rename from jdk/test/java/dyn/InvokeDynamicPrintArgs.java
rename to jdk/test/java/lang/invoke/InvokeDynamicPrintArgs.java
index 233c4fc316c..7089e959223 100644
--- a/jdk/test/java/dyn/InvokeDynamicPrintArgs.java
+++ b/jdk/test/java/lang/invoke/InvokeDynamicPrintArgs.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,19 +29,19 @@
  *      indify.Indify
  *      --verify-specifier-count=3 --transitionalJSR292=false
  *      --expand-properties --classpath ${test.classes}
- *      --java test.java.dyn.InvokeDynamicPrintArgs --check-output
+ *      --java test.java.lang.invoke.InvokeDynamicPrintArgs --check-output
  */
 
-package test.java.dyn;
+package test.java.lang.invoke;
 
 import org.junit.Test;
 
 import java.util.*;
 import java.io.*;
 
-import java.dyn.*;
-import static java.dyn.MethodHandles.*;
-import static java.dyn.MethodType.*;
+import java.lang.invoke.*;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
 
 public class InvokeDynamicPrintArgs {
     public static void main(String... av) throws Throwable {
@@ -65,7 +65,7 @@ public class InvokeDynamicPrintArgs {
         String[] args = new String[]{
             "--verify-specifier-count=3", "--transitionalJSR292=false",
             "--expand-properties", "--classpath", testClassPath,
-            "--java", "test.java.dyn.InvokeDynamicPrintArgs", "--check-output"
+            "--java", "test.java.lang.invoke.InvokeDynamicPrintArgs", "--check-output"
         };
         System.err.println("Indify: "+Arrays.toString(args));
         indify.Indify.main(args);
@@ -97,11 +97,11 @@ public class InvokeDynamicPrintArgs {
     }
     private static final String[] EXPECT_OUTPUT = {
         "Printing some argument lists, starting with a empty one:",
-        "[test.java.dyn.InvokeDynamicPrintArgs, nothing, ()void][]",
-        "[test.java.dyn.InvokeDynamicPrintArgs, bar, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar arg, 1]",
-        "[test.java.dyn.InvokeDynamicPrintArgs, bar2, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar2 arg, 222]",
-        "[test.java.dyn.InvokeDynamicPrintArgs, baz, (String,int,double)void, 1234.5][baz arg, 2, 3.14]",
-        "[test.java.dyn.InvokeDynamicPrintArgs, foo, (String)void][foo arg]",
+        "[test.java.lang.invoke.InvokeDynamicPrintArgs, nothing, ()void][]",
+        "[test.java.lang.invoke.InvokeDynamicPrintArgs, bar, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar arg, 1]",
+        "[test.java.lang.invoke.InvokeDynamicPrintArgs, bar2, (String,int)void, class java.lang.Void, void type!, 1, 234.5, 67.5, 89][bar2 arg, 222]",
+        "[test.java.lang.invoke.InvokeDynamicPrintArgs, baz, (String,int,double)void, 1234.5][baz arg, 2, 3.14]",
+        "[test.java.lang.invoke.InvokeDynamicPrintArgs, foo, (String)void][foo arg]",
         "Done printing argument lists."
     };
 
diff --git a/jdk/test/java/dyn/InvokeGenericTest.java b/jdk/test/java/lang/invoke/InvokeGenericTest.java
similarity index 97%
rename from jdk/test/java/dyn/InvokeGenericTest.java
rename to jdk/test/java/lang/invoke/InvokeGenericTest.java
index bae888060a0..f1aaf9eaa71 100644
--- a/jdk/test/java/dyn/InvokeGenericTest.java
+++ b/jdk/test/java/lang/invoke/InvokeGenericTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,16 +24,16 @@
  */
 
 /* @test
- * @summary unit tests for java.dyn.MethodHandle.invokeGeneric
+ * @summary unit tests for java.lang.invoke.MethodHandle.invokeGeneric
  * @compile -XDallowTransitionalJSR292=no -target 7 InvokeGenericTest.java
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.dyn.InvokeGenericTest
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.lang.invoke.InvokeGenericTest
  */
 
-package test.java.dyn;
+package test.java.lang.invoke;
 
-import java.dyn.*;
-import static java.dyn.MethodHandles.*;
-import static java.dyn.MethodType.*;
+import java.lang.invoke.*;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
 import java.lang.reflect.*;
 import java.util.*;
 import org.junit.*;
@@ -49,7 +49,7 @@ public class InvokeGenericTest {
     // How much output?
     static int verbosity = 0;
     static {
-        String vstr = System.getProperty("test.java.dyn.InvokeGenericTest.verbosity");
+        String vstr = System.getProperty("test.java.lang.invoke.InvokeGenericTest.verbosity");
         if (vstr != null)  verbosity = Integer.parseInt(vstr);
     }
 
@@ -216,7 +216,7 @@ public class InvokeGenericTest {
         if (wrap != null) {
             return wrap;
         }
-//        import sun.dyn.util.Wrapper;
+//        import sun.invoke.util.Wrapper;
 //        Wrapper wrap = Wrapper.forBasicType(dst);
 //        if (wrap == Wrapper.OBJECT && Wrapper.isWrapperType(dst))
 //            wrap = Wrapper.forWrapperType(dst);
diff --git a/jdk/test/java/dyn/JavaDocExamplesTest.java b/jdk/test/java/lang/invoke/JavaDocExamplesTest.java
similarity index 88%
rename from jdk/test/java/dyn/JavaDocExamplesTest.java
rename to jdk/test/java/lang/invoke/JavaDocExamplesTest.java
index 72a62851f82..7093ea2005a 100644
--- a/jdk/test/java/dyn/JavaDocExamplesTest.java
+++ b/jdk/test/java/lang/invoke/JavaDocExamplesTest.java
@@ -24,27 +24,27 @@
  */
 
 /* @test
- * @summary example code used in javadoc for java.dyn API
+ * @summary example code used in javadoc for java.lang.invoke API
  * @compile -XDallowTransitionalJSR292=no JavaDocExamplesTest.java
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.dyn.JavaDocExamplesTest
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.lang.invoke.JavaDocExamplesTest
  */
 
 /*
 ---- To run outside jtreg:
 $ $JAVA7X_HOME/bin/javac -cp $JUNIT4_JAR -d /tmp/Classes \
-   $DAVINCI/sources/jdk/test/java/dyn/JavaDocExamplesTest.java
+   $DAVINCI/sources/jdk/test/java/lang/invoke/JavaDocExamplesTest.java
 $ $JAVA7X_HOME/bin/java   -cp $JUNIT4_JAR:/tmp/Classes \
    -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles \
-   -Dtest.java.dyn.JavaDocExamplesTest.verbosity=1 \
-     test.java.dyn.JavaDocExamplesTest
+   -Dtest.java.lang.invoke.JavaDocExamplesTest.verbosity=1 \
+     test.java.lang.invoke.JavaDocExamplesTest
 ----
 */
 
-package test.java.dyn;
+package test.java.lang.invoke;
 
-import java.dyn.*;
-import static java.dyn.MethodHandles.*;
-import static java.dyn.MethodType.*;
+import java.lang.invoke.*;
+import static java.lang.invoke.MethodHandles.*;
+import static java.lang.invoke.MethodType.*;
 
 import java.lang.reflect.*;
 import java.util.*;
@@ -65,7 +65,7 @@ public class JavaDocExamplesTest {
         org.junit.runner.JUnitCore.runClasses(JavaDocExamplesTest.class);
     }
     // How much output?
-    static int verbosity = Integer.getInteger("test.java.dyn.JavaDocExamplesTest.verbosity", 0);
+    static int verbosity = Integer.getInteger("test.java.lang.invoke.JavaDocExamplesTest.verbosity", 0);
 
 {}
 static final private Lookup LOOKUP = lookup();
@@ -108,6 +108,16 @@ assertEquals("xy".hashCode(), (int) HASHCODE_3.invokeExact((Object)"xy"));
 MethodHandle cat = lookup().findVirtual(String.class,
   "concat", methodType(String.class, String.class));
 assertEquals("xy", (String) cat.invokeExact("x", "y"));
+MethodType bigType = cat.type().insertParameterTypes(0, int.class, String.class);
+MethodHandle d0 = dropArguments(cat, 0, bigType.parameterList().subList(0,2));
+assertEquals(bigType, d0.type());
+assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
+            }}
+        {{
+{} /// JAVADOC
+MethodHandle cat = lookup().findVirtual(String.class,
+  "concat", methodType(String.class, String.class));
+assertEquals("xy", (String) cat.invokeExact("x", "y"));
 MethodHandle d0 = dropArguments(cat, 0, String.class);
 assertEquals("yz", (String) d0.invokeExact("x", "y", "z"));
 MethodHandle d1 = dropArguments(cat, 1, String.class);
diff --git a/jdk/test/java/dyn/MethodHandlesTest.java b/jdk/test/java/lang/invoke/MethodHandlesTest.java
similarity index 99%
rename from jdk/test/java/dyn/MethodHandlesTest.java
rename to jdk/test/java/lang/invoke/MethodHandlesTest.java
index b44f262fa02..bae38f766bc 100644
--- a/jdk/test/java/dyn/MethodHandlesTest.java
+++ b/jdk/test/java/lang/invoke/MethodHandlesTest.java
@@ -24,15 +24,15 @@
  */
 
 /* @test
- * @summary unit tests for java.dyn.MethodHandles
+ * @summary unit tests for java.lang.invoke.MethodHandles
  * @compile -source 7 -target 7 -XDallowTransitionalJSR292=no MethodHandlesTest.java
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.dyn.MethodHandlesTest
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.lang.invoke.MethodHandlesTest
  */
 
-package test.java.dyn;
+package test.java.lang.invoke;
 
-import java.dyn.*;
-import java.dyn.MethodHandles.Lookup;
+import java.lang.invoke.*;
+import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.reflect.*;
 import java.util.*;
 import org.junit.*;
@@ -48,7 +48,7 @@ public class MethodHandlesTest {
     // How much output?
     static int verbosity = 0;
     static {
-        String vstr = System.getProperty("test.java.dyn.MethodHandlesTest.verbosity");
+        String vstr = System.getProperty("test.java.lang.invoke.MethodHandlesTest.verbosity");
         if (vstr != null)  verbosity = Integer.parseInt(vstr);
     }
 
@@ -258,7 +258,7 @@ public class MethodHandlesTest {
         if (wrap != null) {
             return wrap;
         }
-//        import sun.dyn.util.Wrapper;
+//        import sun.invoke.util.Wrapper;
 //        Wrapper wrap = Wrapper.forBasicType(dst);
 //        if (wrap == Wrapper.OBJECT && Wrapper.isWrapperType(dst))
 //            wrap = Wrapper.forWrapperType(dst);
@@ -2264,7 +2264,7 @@ public class MethodHandlesTest {
         }
     }
 }
-// Local abbreviated copy of sun.dyn.util.ValueConversions
+// Local abbreviated copy of sun.invoke.util.ValueConversions
 class ValueConversions {
     private static final Lookup IMPL_LOOKUP = MethodHandles.lookup();
     private static final Object[] NO_ARGS_ARRAY = {};
diff --git a/jdk/test/java/dyn/MethodTypeTest.java b/jdk/test/java/lang/invoke/MethodTypeTest.java
similarity index 82%
rename from jdk/test/java/dyn/MethodTypeTest.java
rename to jdk/test/java/lang/invoke/MethodTypeTest.java
index caadaa04a33..5cc32771624 100644
--- a/jdk/test/java/dyn/MethodTypeTest.java
+++ b/jdk/test/java/lang/invoke/MethodTypeTest.java
@@ -24,15 +24,14 @@
  */
 
 /* @test
- * @summary unit tests for java.dyn.MethodType
+ * @summary unit tests for java.lang.invoke.MethodType
  * @compile MethodTypeTest.java
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.dyn.MethodTypeTest
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles test.java.lang.invoke.MethodTypeTest
  */
 
-package test.java.dyn;
+package test.java.lang.invoke;
 
-import sun.dyn.MemberName;
-import java.dyn.MethodType;
+import java.lang.invoke.MethodType;
 import java.lang.reflect.Method;
 
 import java.util.*;
@@ -163,18 +162,6 @@ public class MethodTypeTest {
         assertSame(expResult, result);
     }
 
-    /**
-     * Test of make method, of class MethodType.
-     */
-    @Test
-    public void testMake_Method() {
-        System.out.println("make (via MemberName.getMethodType)");
-        MethodType expResult = MethodType.methodType(int.class, String.class);
-        MemberName name = new MemberName(compareTo);
-        MethodType result = name.getMethodType();
-        assertSame(expResult, result);
-    }
-
     /**
      * Test of make method, of class MethodType.
      */
@@ -476,10 +463,13 @@ public class MethodTypeTest {
     @Test
     public void testPortableSerialFormat() throws Throwable {
         System.out.println("portable serial format");
+        boolean generateData = false;
+        //generateData = true;  // set this true to generate the following input data:
         Object[][] cases = {
             { mt_vv, new byte[] {  // ()void
-                    (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x13,
-                    (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x64, (byte)0x79, (byte)0x6e,
+                    (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x1b,
+                    (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e,
+                    (byte)0x67, (byte)0x2e, (byte)0x69, (byte)0x6e, (byte)0x76, (byte)0x6f, (byte)0x6b, (byte)0x65,
                     (byte)0x2e, (byte)0x4d, (byte)0x65, (byte)0x74, (byte)0x68, (byte)0x6f, (byte)0x64, (byte)0x54,
                     (byte)0x79, (byte)0x70, (byte)0x65, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
                     (byte)0x00, (byte)0x01, (byte)0x24, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
@@ -493,8 +483,9 @@ public class MethodTypeTest {
                     (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78,
                 } },
             { mt_OO, new byte[] {  // (Object)Object
-                    (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x13,
-                    (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x64, (byte)0x79, (byte)0x6e,
+                    (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x1b,
+                    (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e,
+                    (byte)0x67, (byte)0x2e, (byte)0x69, (byte)0x6e, (byte)0x76, (byte)0x6f, (byte)0x6b, (byte)0x65,
                     (byte)0x2e, (byte)0x4d, (byte)0x65, (byte)0x74, (byte)0x68, (byte)0x6f, (byte)0x64, (byte)0x54,
                     (byte)0x79, (byte)0x70, (byte)0x65, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
                     (byte)0x00, (byte)0x01, (byte)0x24, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
@@ -509,14 +500,47 @@ public class MethodTypeTest {
                     (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01,
                     (byte)0x71, (byte)0x00, (byte)0x7e, (byte)0x00, (byte)0x03, (byte)0x78,
                 } },
+            { mt_vOiSzA, new byte[] {  // (Object,int,String,boolean,Object[])void
+                    (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x1b,
+                    (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e,
+                    (byte)0x67, (byte)0x2e, (byte)0x69, (byte)0x6e, (byte)0x76, (byte)0x6f, (byte)0x6b, (byte)0x65,
+                    (byte)0x2e, (byte)0x4d, (byte)0x65, (byte)0x74, (byte)0x68, (byte)0x6f, (byte)0x64, (byte)0x54,
+                    (byte)0x79, (byte)0x70, (byte)0x65, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x00, (byte)0x01, (byte)0x24, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
+                    (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x04, (byte)0x76, (byte)0x6f, (byte)0x69, (byte)0x64,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x75, (byte)0x72, (byte)0x00,
+                    (byte)0x12, (byte)0x5b, (byte)0x4c, (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e,
+                    (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2e, (byte)0x43, (byte)0x6c, (byte)0x61,
+                    (byte)0x73, (byte)0x73, (byte)0x3b, (byte)0xab, (byte)0x16, (byte)0xd7, (byte)0xae, (byte)0xcb,
+                    (byte)0xcd, (byte)0x5a, (byte)0x99, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x05, (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x10,
+                    (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e,
+                    (byte)0x67, (byte)0x2e, (byte)0x4f, (byte)0x62, (byte)0x6a, (byte)0x65, (byte)0x63, (byte)0x74,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x76, (byte)0x72, (byte)0x00,
+                    (byte)0x03, (byte)0x69, (byte)0x6e, (byte)0x74, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78,
+                    (byte)0x70, (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x10, (byte)0x6a, (byte)0x61, (byte)0x76,
+                    (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2e, (byte)0x53,
+                    (byte)0x74, (byte)0x72, (byte)0x69, (byte)0x6e, (byte)0x67, (byte)0xa0, (byte)0xf0, (byte)0xa4,
+                    (byte)0x38, (byte)0x7a, (byte)0x3b, (byte)0xb3, (byte)0x42, (byte)0x02, (byte)0x00, (byte)0x00,
+                    (byte)0x78, (byte)0x70, (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x07, (byte)0x62, (byte)0x6f,
+                    (byte)0x6f, (byte)0x6c, (byte)0x65, (byte)0x61, (byte)0x6e, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
+                    (byte)0x78, (byte)0x70, (byte)0x76, (byte)0x72, (byte)0x00, (byte)0x13, (byte)0x5b, (byte)0x4c,
+                    (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e,
+                    (byte)0x67, (byte)0x2e, (byte)0x4f, (byte)0x62, (byte)0x6a, (byte)0x65, (byte)0x63, (byte)0x74,
+                    (byte)0x3b, (byte)0x90, (byte)0xce, (byte)0x58, (byte)0x9f, (byte)0x10, (byte)0x73, (byte)0x29,
+                    (byte)0x6c, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70, (byte)0x78,
+                } },
         };
-        boolean generateData = false;
-        //generateData = true;
         for (Object[] c : cases) {
             MethodType mt = (MethodType) c[0];
             System.out.println("deserialize "+mt);
             byte[] wire = (byte[]) c[1];
             if (generateData) {
+                System.out.println("<generateData>");
                 wire = writeSerial(mt);
                 final String INDENT = "                ";
                 System.out.print("{  // "+mt);
@@ -528,6 +552,7 @@ public class MethodTypeTest {
                 }
                 System.out.println();
                 System.out.println(INDENT+"}");
+                System.out.println("</generateData>");
                 System.out.flush();
             }
             Object decode;
diff --git a/jdk/test/java/dyn/indify/Indify.java b/jdk/test/java/lang/invoke/indify/Indify.java
similarity index 98%
rename from jdk/test/java/dyn/indify/Indify.java
rename to jdk/test/java/lang/invoke/indify/Indify.java
index ba24b79a9d9..ac0485a5ebc 100644
--- a/jdk/test/java/dyn/indify/Indify.java
+++ b/jdk/test/java/lang/invoke/indify/Indify.java
@@ -47,9 +47,9 @@ import java.util.regex.*;
  * and {@code CONSTANT_MethodType} "ldc" instructions.
  * The stereotyped code must create method types by calls to {@code methodType} or
  * {@code fromMethodDescriptorString}.  The "lookup" argument must be created
- * by calls to {@code java.dyn.MethodHandles#lookup MethodHandles.lookup}.
+ * by calls to {@code java.lang.invoke.MethodHandles#lookup MethodHandles.lookup}.
  * The class and string arguments must be constant.
- * The following methods of {@code java.dyn.MethodHandle.Lookup Lookup} are
+ * The following methods of {@code java.lang.invoke.MethodHandle.Lookup Lookup} are
  * allowed for method handle creation: {@code findStatic}, {@code findVirtual},
  * {@code findConstructor}, {@code findSpecial},
  * {@code findGetter}, {@code findSetter},
@@ -350,10 +350,15 @@ public class Indify {
         }
         protected Class<?> findClass(String name) throws ClassNotFoundException {
             try {
-                return transformAndLoadClass(findClassInPath(name));
+                File f = findClassInPath(name);
+                if (f != null) {
+                    Class<?> c = transformAndLoadClass(f);
+                    if (c != null)  return c;
+                }
             } catch (IOException ex) {
                 throw new ClassNotFoundException("IO error", ex);
             }
+            throw new ClassNotFoundException();
         }
         private Class<?> transformAndLoadClass(File f) throws ClassNotFoundException, IOException {
             if (verbose)  System.err.println("Loading class from "+f);
@@ -592,7 +597,9 @@ public class Indify {
             if (s.startsWith("MT_"))                return 'T';
             else if (s.startsWith("MH_"))           return 'H';
             else if (s.startsWith("INDY_"))         return 'I';
-            else if (s.startsWith("java/dyn/"))     return 'D';
+            else if (transitionalJSR292 &&
+                     s.startsWith("java/dyn/"))     return 'D';
+            else if (s.startsWith("java/lang/invoke/"))  return 'D';
             else if (s.startsWith("java/lang/"))    return 'J';
             return 0;
         }
@@ -605,15 +612,24 @@ public class Indify {
             String descr = cf.pool.getString(CONSTANT_Utf8, n2);
             String requiredType;
             switch (poolMarks[(char)n1]) {
-            case 'H': requiredType = "()Ljava/dyn/MethodHandle;";  break;
-            case 'T': requiredType = "()Ljava/dyn/MethodType;";    break;
-            case 'I': requiredType = "()Ljava/dyn/MethodHandle;";  break;
+            case 'H': requiredType = "()Ljava/lang/invoke/MethodHandle;";  break;
+            case 'T': requiredType = "()Ljava/lang/invoke/MethodType;";    break;
+            case 'I': requiredType = "()Ljava/lang/invoke/MethodHandle;";  break;
             default:  return 0;
             }
-            if (descr.equals(requiredType))  return mark;
+            if (matchType(descr, requiredType))  return mark;
             return 0;
         }
 
+        boolean matchType(String descr, String requiredType) {
+            if (descr.equals(requiredType))  return true;
+            if (transitionalJSR292) {
+                String oldType = requiredType.replace("Ljava/lang/invoke/", "Ljava/dyn/");
+                if (descr.equals(oldType))  return true;
+            }
+            return false;
+        }
+
         private class JVMState {
             final List<Object> stack = new ArrayList<>();
             int sp() { return stack.size(); }
diff --git a/jdk/test/javax/swing/JOptionPane/6464022/bug6464022.java b/jdk/test/javax/swing/JOptionPane/6464022/bug6464022.java
new file mode 100644
index 00000000000..9554ae9828e
--- /dev/null
+++ b/jdk/test/javax/swing/JOptionPane/6464022/bug6464022.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6464022
+ * @summary Memory leak in JOptionPane.createDialog
+ * @author Pavel Porvatov
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main bug6464022
+ */
+
+import javax.swing.*;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.List;
+
+public class bug6464022 {
+    private static JOptionPane pane;
+
+    public static void main(String[] args) throws Exception {
+        final List<WeakReference<JDialog>> references = new ArrayList<WeakReference<JDialog>>();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                pane = new JOptionPane(null, JOptionPane.UNDEFINED_CONDITION);
+
+                for (int i = 0; i < 10; i++) {
+                    JDialog dialog = pane.createDialog(null, "Test " + i);
+
+                    references.add(new WeakReference<JDialog>(dialog));
+
+                    dialog.dispose();
+
+                    System.out.println("Disposing Dialog:" + dialog.hashCode());
+                }
+            }
+        });
+
+        Util.generateOOME();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                int allocatedCount = 0;
+
+                for (WeakReference<JDialog> ref : references) {
+                    if (ref.get() != null) {
+                        allocatedCount++;
+
+                        System.out.println(ref.get().hashCode() + " is still allocated");
+                    }
+                }
+
+                if (allocatedCount > 0) {
+                    throw new RuntimeException("Some dialogs still exist in memory. Test failed");
+                } else {
+                    System.out.println("All dialogs were GCed. Test passed.");
+                }
+            }
+        });
+    }
+}
diff --git a/jdk/test/javax/swing/UIDefaults/6795356/bug6795356.java b/jdk/test/javax/swing/UIDefaults/6795356/bug6795356.java
index 781f57d3872..698dc00e22f 100644
--- a/jdk/test/javax/swing/UIDefaults/6795356/bug6795356.java
+++ b/jdk/test/javax/swing/UIDefaults/6795356/bug6795356.java
@@ -26,6 +26,8 @@
  * @bug 6795356
  * @summary Leak caused by javax.swing.UIDefaults.ProxyLazyValue.acc
  * @author Alexander Potochkin
+ * @library ../../regtesthelpers
+ * @build Util
  * @run main bug6795356
  */
 
@@ -58,43 +60,11 @@ public class bug6795356 {
         weakRef = new WeakReference<ProtectionDomain>(domain);
         domain = null;
 
-        // Generate OutOfMemory and check the weak ref
-        generateOOME();
+        Util.generateOOME();
 
         if (weakRef.get() != null) {
             throw new RuntimeException("Memory leak found!");
         }
         System.out.println("Test passed");
     }
-
-    static void generateOOME() {
-        List<Object> bigLeak = new LinkedList<Object>();
-        boolean oome = false;
-        System.out.print("Filling the heap");
-        try {
-            for(int i = 0; true ; i++) {
-                // Now, use up all RAM
-                bigLeak.add(new byte[1024 * 1024]);
-                System.out.print(".");
-
-                // Give the GC a change at that weakref
-                if (i % 10 == 0) {
-                    System.gc();
-                    try {
-                        Thread.sleep(100);
-                    } catch (InterruptedException e) {
-                        e.printStackTrace();
-                    }
-                }
-            }
-        } catch (OutOfMemoryError e) {
-            bigLeak = null;
-            oome = true;
-        }
-        System.out.println("");
-        if (!oome) {
-            throw new RuntimeException("Problem with test case - never got OOME");
-        }
-        System.out.println("Got OOME");
-    }
 }
diff --git a/jdk/test/javax/swing/regtesthelpers/Util.java b/jdk/test/javax/swing/regtesthelpers/Util.java
index 5da14b9396a..76217ae8687 100644
--- a/jdk/test/javax/swing/regtesthelpers/Util.java
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java
@@ -24,6 +24,8 @@
 import javax.swing.*;
 import java.awt.*;
 import java.awt.image.BufferedImage;
+import java.util.LinkedList;
+import java.util.List;
 
 /**
  * <p>This class contains utilities useful for regression testing.
@@ -72,4 +74,46 @@ public class Util {
 
         return true;
     }
+
+    /**
+     * Fills the heap until OutOfMemoryError occurs. This method is useful for
+     * WeakReferences removing.
+     */
+    public static void generateOOME() {
+        List<Object> bigLeak = new LinkedList<Object>();
+
+        boolean oome = false;
+
+        System.out.print("Filling the heap");
+
+        try {
+            for(int i = 0; true ; i++) {
+                // Now, use up all RAM
+                bigLeak.add(new byte[1024 * 1024]);
+
+                System.out.print(".");
+
+                // Give the GC a change at that weakref
+                if (i % 10 == 0) {
+                    System.gc();
+                    try {
+                        Thread.sleep(100);
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        } catch (OutOfMemoryError e) {
+            bigLeak = null;
+            oome = true;
+        }
+
+        System.out.println("");
+
+        if (!oome) {
+            throw new RuntimeException("Problem with test case - never got OOME");
+        }
+
+        System.out.println("Got OOME");
+    }
 }
diff --git a/jdk/test/sun/java2d/pipe/Test7027667.java b/jdk/test/sun/java2d/pipe/Test7027667.java
new file mode 100644
index 00000000000..08f478f60b1
--- /dev/null
+++ b/jdk/test/sun/java2d/pipe/Test7027667.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug     7027667, 7023591
+ *
+ * @summary Verifies that aa clipped rectangles are drawn, not filled.
+ *
+ * @run     main Test7027667
+ */
+
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.image.*;
+import static java.awt.RenderingHints.*;
+
+public class Test7027667 {
+    public static void main(String[] args) throws Exception {
+        BufferedImage bImg = new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g2d = (Graphics2D) bImg.getGraphics();
+        g2d.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
+        g2d.setClip(new Ellipse2D.Double(0, 0, 100, 100));
+        g2d.drawRect(10, 10, 100, 100);
+        if (new Color(bImg.getRGB(50, 50)).equals(Color.white)) {
+            throw new Exception("Rectangle should be drawn, not filled");
+        }
+    }
+}
diff --git a/jdk/test/sun/java2d/pisces/Renderer/Test7019861.java b/jdk/test/sun/java2d/pisces/Renderer/Test7019861.java
new file mode 100644
index 00000000000..7c262b961cf
--- /dev/null
+++ b/jdk/test/sun/java2d/pisces/Renderer/Test7019861.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug     7019861
+ *
+ * @summary Verifies that the last scanline isn't skipped when doing
+ *          antialiased rendering.
+ *
+ * @run     main Test7019861
+ */
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.geom.Path2D;
+import java.awt.image.BufferedImage;
+import java.util.Arrays;
+
+import static java.awt.RenderingHints.*;
+
+public class Test7019861 {
+
+    public static void main(String[] argv) throws Exception {
+        BufferedImage im = getWhiteImage(30, 30);
+        Graphics2D g2 = (Graphics2D)im.getGraphics();
+        g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
+        g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
+        g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
+        g2.setBackground(Color.white);
+        g2.setColor(Color.black);
+
+        Path2D p = getPath(0, 0, 20);
+        g2.draw(p);
+
+        if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) {
+            throw new Exception("This pixel should be black");
+        }
+    }
+
+    private static Path2D getPath(int x, int y, int len) {
+        Path2D p = new Path2D.Double();
+        p.moveTo(x, y);
+        p.quadTo(x + len, y, x + len, y + len);
+        return p;
+    }
+
+    private static BufferedImage getWhiteImage(int w, int h) {
+        BufferedImage ret = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+        final int[] white = new int[w * h];
+        Arrays.fill(white, 0xffffff);
+        ret.setRGB(0, 0, w, h, white, 0, w);
+        return ret;
+    }
+}
diff --git a/jdk/test/sun/text/resources/LocaleData b/jdk/test/sun/text/resources/LocaleData
index 090b73c8d12..36f17917d12 100644
--- a/jdk/test/sun/text/resources/LocaleData
+++ b/jdk/test/sun/text/resources/LocaleData
@@ -6101,3 +6101,258 @@ LocaleNames/nl/ZM=Zambia
 
 # bug 6919624
 CalendarData/hu/minimalDaysInFirstWeek=4
+
+# bug 6998391
+CalendarData/sr-Latn/firstDayOfWeek=2
+CalendarData/sr-Latn-BA/firstDayOfWeek=2
+CalendarData/sr-Latn-ME/firstDayOfWeek=2
+CalendarData/sr-Latn-RS/firstDayOfWeek=2
+#
+CalendarData/sr-Latn/minimalDaysInFirstWeek=1
+CalendarData/sr-Latn-BA/minimalDaysInFirstWeek=4
+CalendarData/sr-Latn-ME/minimalDaysInFirstWeek=4
+CalendarData/sr-Latn-RS/minimalDaysInFirstWeek=4
+#
+LocaleNames/sr-Latn/SR=Surinam
+LocaleNames/sr-Latn-BA/SR=Surinam
+LocaleNames/sr-Latn-ME/SR=Surinam
+LocaleNames/sr-Latn-RS/SR=Surinam
+#
+FormatData/sr-Latn/MonthNames/2=mart
+FormatData/sr-Latn-BA/MonthNames/4=maj
+FormatData/sr-Latn-ME/MonthNames/7=avgust
+FormatData/sr-Latn-RS/MonthNames/8=septembar
+#
+FormatData/sr-Latn/DayNames/1=ponedeljak
+FormatData/sr-Latn-BA/DayNames/2=utorak
+FormatData/sr-Latn-ME/DayNames/3=sreda
+FormatData/sr-Latn-RS/DayNames/4=\u010detvrtak
+#
+FormatData/sr-Latn/DayAbbreviations/1=pon
+FormatData/sr-Latn-BA/DayAbbreviations/2=uto
+FormatData/sr-Latn-ME/DayAbbreviations/3=sre
+FormatData/sr-Latn-RS/DayAbbreviations/4=\u010det
+#
+CurrencyNames/sr-Latn/EUR=EUR
+CurrencyNames/sr-Latn-BA/EUR=\u20ac
+CurrencyNames/sr-Latn-BA/BAM=KM
+CurrencyNames/sr-Latn-ME/EUR=\u20ac
+CurrencyNames/sr-Latn-RS/EUR=EUR
+#
+FormatData/sr-Latn/DateTimePatterns/1=HH.mm.ss z
+FormatData/sr-Latn-BA/DateTimePatterns/2=HH.mm.ss
+FormatData/sr-Latn-ME/DateTimePatterns/5=d.MM.yyyy.
+FormatData/sr-Latn-RS/DateTimePatterns/5=dd. MMMM y.
+
+# bug 7019267
+CurrencyNames/pt/adp=Peseta de Andorra
+CurrencyNames/pt/aed=Dir\u00e9m dos Emirados \u00c1rabes Unidos
+CurrencyNames/pt/afa=Afegane (1927-2002)
+CurrencyNames/pt/afn=Afegane
+CurrencyNames/pt/all=Lek Alban\u00eas
+CurrencyNames/pt/amd=Dram arm\u00eanio
+CurrencyNames/pt/ang=Guilder das Antilhas Holandesas
+CurrencyNames/pt/aoa=Cuanza angolano
+CurrencyNames/pt/ars=Peso argentino
+CurrencyNames/pt/ats=Xelim austr\u00edaco
+CurrencyNames/pt/aud=D\u00f3lar australiano
+CurrencyNames/pt/awg=Guilder de Aruba
+CurrencyNames/pt/azm=Manat azerbaijano
+CurrencyNames/pt/azn=Manat do Azerbaij\u00e3o
+CurrencyNames/pt/bam=Marco b\u00f3snio-herzegovino convers\u00edvel
+CurrencyNames/pt/bbd=D\u00f3lar de Barbados
+CurrencyNames/pt/bdt=Taka de Bangladesh
+CurrencyNames/pt/bef=Franco belga
+CurrencyNames/pt/bgl=Lev forte b\u00falgaro
+CurrencyNames/pt/bgn=Lev novo b\u00falgaro
+CurrencyNames/pt/bhd=Dinar bareinita
+CurrencyNames/pt/bif=Franco do Burundi
+CurrencyNames/pt/bmd=D\u00f3lar das Bermudas
+CurrencyNames/pt/bnd=D\u00f3lar do Brunei
+CurrencyNames/pt/bov=Mvdol boliviano
+CurrencyNames/pt/brl=Real brasileiro
+CurrencyNames/pt/bsd=D\u00f3lar das Bahamas
+CurrencyNames/pt/btn=Ngultrum do But\u00e3o
+CurrencyNames/pt/bwp=Pula botsuanesa
+CurrencyNames/pt/byb=Rublo novo bielo-russo (1994-1999)
+CurrencyNames/pt/byr=Rublo bielo-russo
+CurrencyNames/pt/bzd=D\u00f3lar do Belize
+CurrencyNames/pt/cad=D\u00f3lar canadense
+CurrencyNames/pt/cdf=Franco congol\u00eas
+CurrencyNames/pt/chf=Franco su\u00ed\u00e7o
+CurrencyNames/pt/clf=Unidades de Fomento chilenas
+CurrencyNames/pt/clp=Peso chileno
+CurrencyNames/pt/cny=Yuan Renminbi chin\u00eas
+CurrencyNames/pt/cop=Peso colombiano
+CurrencyNames/pt/crc=Colon da Costa Rica
+CurrencyNames/pt/csd=Dinar s\u00e9rvio antigo
+CurrencyNames/pt/cup=Peso cubano
+CurrencyNames/pt/cve=Escudo cabo-verdiano
+CurrencyNames/pt/cyp=Libra cipriota
+CurrencyNames/pt/czk=Coroa checa
+CurrencyNames/pt/dem=Marco alem\u00e3o
+CurrencyNames/pt/djf=Franco do Djibuti
+CurrencyNames/pt/dkk=Coroa dinamarquesa
+CurrencyNames/pt/dop=Peso dominicano
+CurrencyNames/pt/dzd=Dinar argelino
+CurrencyNames/pt/eek=Coroa estoniana
+CurrencyNames/pt/egp=Libra eg\u00edpcia
+CurrencyNames/pt/ern=Nakfa da Eritreia
+CurrencyNames/pt/esp=Peseta espanhola
+CurrencyNames/pt/etb=Birr et\u00edope
+CurrencyNames/pt/fim=Marca finlandesa
+CurrencyNames/pt/fjd=D\u00f3lar de Fiji
+CurrencyNames/pt/fkp=Libra das Malvinas
+CurrencyNames/pt/frf=Franco franc\u00eas
+CurrencyNames/pt/gbp=Libra esterlina brit\u00e2nica
+CurrencyNames/pt/gel=Lari georgiano
+CurrencyNames/pt/ghc=Cedi de Gana (1979-2007)
+CurrencyNames/pt/ghs=Cedi gan\u00eas
+CurrencyNames/pt/gip=Libra de Gibraltar
+CurrencyNames/pt/gmd=Dalasi de G\u00e2mbia
+CurrencyNames/pt/gnf=Franco de Guin\u00e9
+CurrencyNames/pt/grd=Dracma grego
+CurrencyNames/pt/gtq=Quet\u00e7al da Guatemala
+CurrencyNames/pt/gwp=Peso da Guin\u00e9-Bissau
+CurrencyNames/pt/gyd=D\u00f3lar da Guiana
+CurrencyNames/pt/hkd=D\u00f3lar de Hong Kong
+CurrencyNames/pt/hnl=Lempira de Honduras
+CurrencyNames/pt/hrk=Kuna croata
+CurrencyNames/pt/htg=Gurde do Haiti
+CurrencyNames/pt/huf=Forinte h\u00fangaro
+CurrencyNames/pt/idr=Rupia indon\u00e9sia
+CurrencyNames/pt/iep=Libra irlandesa
+CurrencyNames/pt/ils=Sheqel Novo israelita
+CurrencyNames/pt/inr=R\u00fapia indiana
+CurrencyNames/pt/iqd=Dinar iraquiano
+CurrencyNames/pt/irr=Rial iraniano
+CurrencyNames/pt/isk=Coroa islandesa
+CurrencyNames/pt/itl=Lira italiana
+CurrencyNames/pt/jmd=D\u00f3lar jamaicano
+CurrencyNames/pt/jod=Dinar jordaniano
+CurrencyNames/pt/jpy=Iene japon\u00eas
+CurrencyNames/pt/kes=Xelim queniano
+CurrencyNames/pt/kgs=Som quirguiz
+CurrencyNames/pt/khr=Riel cambojano
+CurrencyNames/pt/kmf=Franco de Comores
+CurrencyNames/pt/kpw=Won norte-coreano
+CurrencyNames/pt/krw=Won sul-coreano
+CurrencyNames/pt/kwd=Dinar coveitiano
+CurrencyNames/pt/kyd=D\u00f3lar das Ilhas Caiman
+CurrencyNames/pt/kzt=Tenge do Cazaquist\u00e3o
+CurrencyNames/pt/lak=Kip de Laos
+CurrencyNames/pt/lbp=Libra libanesa
+CurrencyNames/pt/lkr=Rupia do Sri Lanka
+CurrencyNames/pt/lrd=D\u00f3lar liberiano
+CurrencyNames/pt/lsl=Loti do Lesoto
+CurrencyNames/pt/ltl=Lita lituano
+CurrencyNames/pt/luf=Franco luxemburgu\u00eas
+CurrencyNames/pt/lvl=Lats let\u00e3o
+CurrencyNames/pt/lyd=Dinar l\u00edbio
+CurrencyNames/pt/mad=Dir\u00e9m marroquino
+CurrencyNames/pt/mdl=Leu mold\u00e1vio
+CurrencyNames/pt/mga=Ariary de Madagascar
+CurrencyNames/pt/mgf=Franco de Madagascar
+CurrencyNames/pt/mkd=Dinar maced\u00f4nio
+CurrencyNames/pt/mmk=Kyat de Mianmar
+CurrencyNames/pt/mnt=Tugrik mongol
+CurrencyNames/pt/mop=Pataca macaense
+CurrencyNames/pt/mro=Ouguiya da Maurit\u00e2nia
+CurrencyNames/pt/mtl=Lira maltesa
+CurrencyNames/pt/mur=Rupia de Maur\u00edcio
+CurrencyNames/pt/mvr=Rupias das Ilhas Maldivas
+CurrencyNames/pt/mwk=Cuacha do Mal\u00e1ui
+CurrencyNames/pt/mxn=Peso mexicano
+CurrencyNames/pt/mxv=Unidade Mexicana de Investimento (UDI)
+CurrencyNames/pt/myr=Ringgit malaio
+CurrencyNames/pt/mzm=Metical antigo de Mo\u00e7ambique
+CurrencyNames/pt/mzn=Metical do Mo\u00e7ambique
+CurrencyNames/pt/nad=D\u00f3lar da Nam\u00edbia
+CurrencyNames/pt/ngn=Naira nigeriana
+CurrencyNames/pt/nio=C\u00f3rdoba Ouro nicaraguense
+CurrencyNames/pt/nlg=Florim holand\u00eas
+CurrencyNames/pt/nok=Coroa norueguesa
+CurrencyNames/pt/npr=Rupia nepalesa
+CurrencyNames/pt/nzd=D\u00f3lar da Nova Zel\u00e2ndia
+CurrencyNames/pt/omr=Rial de Om\u00e3
+CurrencyNames/pt/pab=Balboa panamenho
+CurrencyNames/pt/pen=Sol Novo peruano
+CurrencyNames/pt/pgk=Kina da Papua-Nova Guin\u00e9
+CurrencyNames/pt/php=Peso filipino
+CurrencyNames/pt/pkr=Rupia paquistanesa
+CurrencyNames/pt/pln=Zloti polon\u00eas
+CurrencyNames/pt/pte=Escudo portugu\u00eas
+CurrencyNames/pt/pyg=Guarani paraguaio
+CurrencyNames/pt/qar=Rial catariano
+CurrencyNames/pt/rol=Leu romeno antigo
+CurrencyNames/pt/ron=Leu romeno
+CurrencyNames/pt/rsd=Dinar s\u00e9rvio
+CurrencyNames/pt/rub=Rublo russo
+CurrencyNames/pt/rur=Rublo russo (1991-1998)
+CurrencyNames/pt/rwf=Franco ruand\u00eas
+CurrencyNames/pt/sar=Rial saudita
+CurrencyNames/pt/sbd=D\u00f3lar das Ilhas Salom\u00e3o
+CurrencyNames/pt/scr=Rupia das Seychelles
+CurrencyNames/pt/sdd=Dinar sudan\u00eas
+CurrencyNames/pt/sdg=Libra sudanesa
+CurrencyNames/pt/sek=Coroa sueca
+CurrencyNames/pt/sgd=D\u00f3lar de Cingapura
+CurrencyNames/pt/shp=Libra de Santa Helena
+CurrencyNames/pt/sit=Tolar Bons esloveno
+CurrencyNames/pt/skk=Coroa eslovaca
+CurrencyNames/pt/sll=Leone de Serra Leoa
+CurrencyNames/pt/sos=Xelim somali
+CurrencyNames/pt/srd=D\u00f3lar do Suriname
+CurrencyNames/pt/srg=Florim do Suriname
+CurrencyNames/pt/std=Dobra de S\u00e3o Tom\u00e9 e Pr\u00edncipe
+CurrencyNames/pt/svc=Colom salvadorenho
+CurrencyNames/pt/syp=Libra s\u00edria
+CurrencyNames/pt/szl=Lilangeni da Suazil\u00e2ndia
+CurrencyNames/pt/thb=Baht tailand\u00eas
+CurrencyNames/pt/tjs=Somoni tadjique
+CurrencyNames/pt/tmm=Manat do Turcomenist\u00e3o
+CurrencyNames/pt/tnd=Dinar tunisiano
+CurrencyNames/pt/top=Pa\u02bbanga de Tonga
+CurrencyNames/pt/tpe=Escudo timorense
+CurrencyNames/pt/trl=Lira turca antiga
+CurrencyNames/pt/try=Lira turca
+CurrencyNames/pt/ttd=D\u00f3lar de Trinidad e Tobago
+CurrencyNames/pt/twd=D\u00f3lar Novo de Taiwan
+CurrencyNames/pt/tzs=Xelim da Tanz\u00e2nia
+CurrencyNames/pt/uah=Hryvnia ucraniano
+CurrencyNames/pt/ugx=Xelim ugandense
+CurrencyNames/pt/usd=D\u00f3lar norte-americano
+CurrencyNames/pt/usn=D\u00f3lar norte-americano (Dia seguinte)
+CurrencyNames/pt/uss=D\u00f3lar norte-americano (Mesmo dia)
+CurrencyNames/pt/uyu=Peso uruguaio
+CurrencyNames/pt/uzs=Sum do Usbequist\u00e3o
+CurrencyNames/pt/veb=Bol\u00edvar venezuelano
+CurrencyNames/pt/vef=Bol\u00edvar v enezuelano forte
+CurrencyNames/pt/vnd=Dong vietnamita
+CurrencyNames/pt/vuv=Vatu de Vanuatu
+CurrencyNames/pt/wst=Tala samoano
+CurrencyNames/pt/xaf=Franco CFA BEAC
+CurrencyNames/pt/xag=Prata
+CurrencyNames/pt/xau=Ouro
+CurrencyNames/pt/xba=Unidade Composta Europeia
+CurrencyNames/pt/xbb=Unidade Monet\u00e1ria Europeia
+CurrencyNames/pt/xbc=Unidade de Conta Europeia (XBC)
+CurrencyNames/pt/xbd=Unidade de Conta Europeia (XBD)
+CurrencyNames/pt/xcd=D\u00f3lar do Caribe Oriental
+CurrencyNames/pt/xdr=Direitos Especiais de Giro
+CurrencyNames/pt/xfo=Franco-ouro franc\u00eas
+CurrencyNames/pt/xfu=Franco UIC franc\u00eas
+CurrencyNames/pt/xof=Franco CFA BCEAO
+CurrencyNames/pt/xpd=Pal\u00e1dio
+CurrencyNames/pt/xpf=Franco CFP
+CurrencyNames/pt/xpt=Platina
+CurrencyNames/pt/xts=C\u00f3digo de Moeda de Teste
+CurrencyNames/pt/xxx=Moeda Desconhecida ou Inv\u00e1lida
+CurrencyNames/pt/yer=Rial iemenita
+CurrencyNames/pt/yum=Dinar noviy iugoslavo
+CurrencyNames/pt/zar=Rand sul-africano
+CurrencyNames/pt/zmk=Cuacha zambiano
+CurrencyNames/pt/zwd=D\u00f3lar do Zimb\u00e1bue
+
+# bug 7020960
+CurrencyNames/sr_RS/RSD=\u0434\u0438\u043d.
diff --git a/jdk/test/sun/text/resources/LocaleDataTest.java b/jdk/test/sun/text/resources/LocaleDataTest.java
index 2a04cd973db..5cf693cc1aa 100644
--- a/jdk/test/sun/text/resources/LocaleDataTest.java
+++ b/jdk/test/sun/text/resources/LocaleDataTest.java
@@ -33,7 +33,7 @@
  *      6379214 6485516 6486607 4225362 4494727 6533691 6531591 6531593 6570259
  *      6509039 6609737 6610748 6645271 6507067 6873931 6450945 6645268 6646611
  *      6645405 6650730 6910489 6573250 6870908 6585666 6716626 6914413 6916787
- *      6919624
+ *      6919624 6998391 7019267 7020960
  * @summary Verify locale data
  *
  */
@@ -91,6 +91,10 @@
  *        LocaleNames/fr_FR/US=\u00c9tats-Unis
  *        LocaleNames/fr_FR/FR=France</pre>
  *
+ *    You can use language tag with '-' in locale field like this:<pre>
+ *        LocaleNames/sr-Latn/SR=Surinam
+ *        FormatData/sr-Latn-BA/DayNames/2=utorak</pre>
+ *
  *    The command-line syntax of this test is
  *        <tt>java LocaleDataTest [-w] [{ -s | <filename> }]</tt>
  *
@@ -242,7 +246,9 @@ public class LocaleDataTest
         if (index == -1 || index + 1 == key.length())
             throw new Exception("Malformed input file: \"" + key + "\" is missing locale name");
         localeName = key.substring(oldIndex, index);
-        if (localeName.length() > 0) {
+        boolean use_tag = localeName.indexOf("-") != -1;
+
+        if (use_tag == false && localeName.length() > 0) {
             language = localeName.substring(0, 2);
             if (localeName.length() > 3) {
                 country = localeName.substring(3, 5);
@@ -283,8 +289,14 @@ public class LocaleDataTest
             } else {
                 fullName = "sun.text.resources." + rbName;
             }
+            Locale locale;
+            if (use_tag) {
+                locale = Locale.forLanguageTag(localeName);
+            } else {
+                locale = new Locale(language, country, variant);
+            }
             ResourceBundle bundle = ResourceBundle.getBundle(fullName,
-                           new Locale(language, country, variant),
+                           locale,
                            ResourceBundle.Control.getNoFallbackControl(Control.FORMAT_DEFAULT));
             resource = bundle.getObject(resTag);
         }
diff --git a/langtools/.hgtags b/langtools/.hgtags
index 04cc0b5bcb3..3dc82c74e43 100644
--- a/langtools/.hgtags
+++ b/langtools/.hgtags
@@ -108,3 +108,5 @@ d7225b476a5d1aebffb8827e7c72ba2e1651f4e7 jdk7-b128
 67221b8643b478c4fceacc89240db876455aae76 jdk7-b131
 e3d011d59a33acef79eff7523bef069557e91002 jdk7-b132
 e77e98f936e83d94c9b56cc7af218dc822a06122 jdk7-b133
+3d7acdbb72cab55deedfd35f60d4732abc9d6ac4 jdk7-b134
+9d0a61ac567b983da7cc8f4a7030f2245bb6dbab jdk7-b135
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
index 9db6e97bb3d..bbac0b65cb1 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -305,11 +305,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
             tr.addContent(tdFirst);
             HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
             tdLast.addStyle(HtmlStyle.colLast);
-            if (pkg != null) {
-                addSummaryComment(pkg, tdLast);
-            } else {
-                tdLast.addContent(getSpace());
-            }
+            addSummaryComment(pkg, tdLast);
             tr.addContent(tdLast);
             tbody.addContent(tr);
         }
@@ -355,10 +351,7 @@ public class ClassUseWriter extends SubWriterHolderWriter {
         contentTree.addContent(tdFirst);
         HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
         tdLast.addStyle(HtmlStyle.colLast);
-        if (pkg != null)
-            addSummaryComment(pkg, tdLast);
-        else
-            tdLast.addContent(getSpace());
+        addSummaryComment(pkg, tdLast);
         contentTree.addContent(tdLast);
     }
 
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
index e162075a636..ba6f921e61c 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
@@ -283,23 +283,32 @@ public class HelpWriter extends HtmlDocletWriter {
         Content framePara = HtmlTree.P(line26);
         liFrame.addContent(framePara);
         ul.addContent(liFrame);
+        Content allclassesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.All_Classes"));
+        Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead);
+        Content line27 = getResource("doclet.Help_line_27",
+                getHyperLinkString("allclasses-noframe.html",
+                configuration.getText("doclet.All_Classes")));
+        Content allclassesPara = HtmlTree.P(line27);
+        liAllClasses.addContent(allclassesPara);
+        ul.addContent(liAllClasses);
         Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
                 getResource("doclet.Serialized_Form"));
         Content liSerial = HtmlTree.LI(HtmlStyle.blockList, sHead);
-        Content line27 = getResource("doclet.Help_line_27");
-        Content serialPara = HtmlTree.P(line27);
+        Content line28 = getResource("doclet.Help_line_28");
+        Content serialPara = HtmlTree.P(line28);
         liSerial.addContent(serialPara);
         ul.addContent(liSerial);
         Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
                 getResource("doclet.Constants_Summary"));
         Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead);
-        Content line28 = getResource("doclet.Help_line_28");
-        Content constPara = HtmlTree.P(line28);
+        Content line29 = getResource("doclet.Help_line_29");
+        Content constPara = HtmlTree.P(line29);
         liConst.addContent(constPara);
         ul.addContent(liConst);
         Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul);
-        Content line29 = HtmlTree.EM(getResource("doclet.Help_line_29"));
-        divContent.addContent(line29);
+        Content line30 = HtmlTree.EM(getResource("doclet.Help_line_30"));
+        divContent.addContent(line30);
         contentTree.addContent(divContent);
     }
 
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
index 5bea2d75204..4e9019a1d98 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -246,10 +246,7 @@ public class PackageUseWriter extends SubWriterHolderWriter {
         contentTree.addContent(tdFirst);
         HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
         tdLast.addStyle(HtmlStyle.colLast);
-        if (pkg != null)
-            addSummaryComment(pkg, tdLast);
-        else
-            tdLast.addContent(getSpace());
+        addSummaryComment(pkg, tdLast);
         contentTree.addContent(tdLast);
     }
 
diff --git a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
index 16fdd9497de..b59771f2c42 100644
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties
@@ -167,7 +167,7 @@ doclet.Window_Help_title=API Help
 doclet.Help_line_1=How This API Document Is Organized
 doclet.Help_line_2=This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
 doclet.Help_line_3=The {0} page is the front page of this API document and provides a list of all packages with a summary for each.  This page can also contain an overall description of the set of packages.
-doclet.Help_line_4=Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
+doclet.Help_line_4=Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
 doclet.Help_line_5=Class/Interface
 doclet.Help_line_6=Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
 doclet.Help_line_7=Class inheritance diagram
@@ -190,9 +190,10 @@ doclet.Help_line_23=Prev/Next
 doclet.Help_line_24=These links take you to the next or previous class, interface, package, or related page.
 doclet.Help_line_25=Frames/No Frames
 doclet.Help_line_26=These links show and hide the HTML frames.  All pages are available with or without frames.
-doclet.Help_line_27=Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
-doclet.Help_line_28=The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.
-doclet.Help_line_29=This help file applies to API documentation generated using the standard doclet.
+doclet.Help_line_27=The {0} link shows all classes and interfaces except non-static nested types.
+doclet.Help_line_28=Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+doclet.Help_line_29=The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.
+doclet.Help_line_30=This help file applies to API documentation generated using the standard doclet.
 doclet.Help_enum_line_1=Each enum has its own separate page with the following sections:
 doclet.Help_enum_line_2=Enum declaration
 doclet.Help_enum_line_3=Enum description
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
index 07e39a8c3bd..17f894a09a0 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -129,19 +129,11 @@ public class JavacTaskImpl extends JavacTask {
 
     public Boolean call() {
         if (!used.getAndSet(true)) {
-            beginContext();
+            initContext();
             notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
-            try {
-                compilerMain.setFatalErrors(true);
-                result = compilerMain.compile(args, context, fileObjects, processors);
-            } finally {
-                endContext();
-            }
-            compilerMain = null;
-            args = null;
-            context = null;
-            fileObjects = null;
-            notYetEntered = null;
+            compilerMain.setFatalErrors(true);
+            result = compilerMain.compile(args, context, fileObjects, processors);
+            cleanup();
             return result == 0;
         } else {
             throw new IllegalStateException("multiple calls to method 'call'");
@@ -163,8 +155,11 @@ public class JavacTaskImpl extends JavacTask {
     }
 
     private void prepareCompiler() throws IOException {
-        if (!used.getAndSet(true)) {
-            beginContext();
+        if (used.getAndSet(true)) {
+            if (compiler == null)
+                throw new IllegalStateException();
+        } else {
+            initContext();
             compilerMain.setOptions(Options.instance(context));
             compilerMain.filenames = new ListBuffer<File>();
             List<File> filenames = compilerMain.processArgs(CommandLine.parse(args));
@@ -185,13 +180,12 @@ public class JavacTaskImpl extends JavacTask {
         }
     }
 
-    private void beginContext() {
+    private void initContext() {
         context.put(JavacTaskImpl.class, this);
         if (context.get(TaskListener.class) != null)
             context.put(TaskListener.class, (TaskListener)null);
         if (taskListener != null)
             context.put(TaskListener.class, wrap(taskListener));
-        tool.beginContext(context);
         //initialize compiler's default locale
         JavacMessages.instance(context).setCurrentLocale(locale);
     }
@@ -218,8 +212,15 @@ public class JavacTaskImpl extends JavacTask {
         };
     }
 
-    private void endContext() {
-        tool.endContext();
+    void cleanup() {
+        if (compiler != null)
+            compiler.close();
+        compiler = null;
+        compilerMain = null;
+        args = null;
+        context = null;
+        fileObjects = null;
+        notYetEntered = null;
     }
 
     /**
@@ -446,12 +447,12 @@ public class JavacTaskImpl extends JavacTask {
             }
             if (genList.isEmpty()) {
                 compiler.reportDeferredDiagnostics();
-                compiler.log.flush();
-                endContext();
+                cleanup();
             }
         }
         finally {
-            compiler.log.flush();
+            if (compiler != null)
+                compiler.log.flush();
         }
         return results;
     }
diff --git a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java
index 354f5fad5fd..23405f6e1d4 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java
@@ -152,36 +152,6 @@ public final class JavacTool implements JavaCompiler {
         return new JavacFileManager(context, true, charset);
     }
 
-    private boolean compilationInProgress = false;
-
-    /**
-     * Register that a compilation is about to start.
-     */
-    void beginContext(Context context) {
-        if (compilationInProgress)
-            throw new IllegalStateException("Compilation in progress");
-        compilationInProgress = true;
-        final JavaFileManager givenFileManager = context.get(JavaFileManager.class);
-        context.put(JavaFileManager.class, (JavaFileManager)null);
-        context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
-            public JavaFileManager make(Context c) {
-                if (givenFileManager != null) {
-                    c.put(JavaFileManager.class, givenFileManager);
-                    return givenFileManager;
-                } else {
-                    return new JavacFileManager(c, true, null);
-                }
-            }
-        });
-    }
-
-    /**
-     * Register that a compilation is completed.
-     */
-    void endContext() {
-        compilationInProgress = false;
-    }
-
     public JavacTask getTask(Writer out,
                              JavaFileManager fileManager,
                              DiagnosticListener<? super JavaFileObject> diagnosticListener,
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java
index b4bb52cfbf9..3ecbf5a3b89 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java
@@ -131,6 +131,12 @@ public enum Source {
     public boolean allowMulticatch() {
         return compareTo(JDK1_7) >= 0;
     }
+    public boolean allowImprovedRethrowAnalysis() {
+        return compareTo(JDK1_7) >= 0;
+    }
+    public boolean allowImprovedCatchAnalysis() {
+        return compareTo(JDK1_7) >= 0;
+    }
     public boolean allowEnums() {
         return compareTo(JDK1_5) >= 0;
     }
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
index 46c1982b40e..2f224ebd27b 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -3004,6 +3004,30 @@ public class Attr extends JCTree.Visitor {
         throw new AssertionError();
     }
 
+    /**
+     * Attribute an env for either a top level tree or class declaration.
+     */
+    public void attrib(Env<AttrContext> env) {
+        if (env.tree.getTag() == JCTree.TOPLEVEL)
+            attribTopLevel(env);
+        else
+            attribClass(env.tree.pos(), env.enclClass.sym);
+    }
+
+    /**
+     * Attribute a top level tree. These trees are encountered when the
+     * package declaration has annotations.
+     */
+    public void attribTopLevel(Env<AttrContext> env) {
+        JCCompilationUnit toplevel = env.toplevel;
+        try {
+            annotate.flush();
+            chk.validateAnnotations(toplevel.packageAnnotations, toplevel.packge);
+        } catch (CompletionFailure ex) {
+            chk.completionError(toplevel.pos(), ex);
+        }
+    }
+
     /** Main method: attribute class definition associated with given class symbol.
      *  reporting completion failures at the given position.
      *  @param pos The source position at which completion errors are to be
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java
index 89191201de1..8b07d8e9040 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java
@@ -190,7 +190,8 @@ public class Flow extends TreeScanner {
     private final Resolve rs;
     private Env<AttrContext> attrEnv;
     private       Lint lint;
-    private final boolean allowRethrowAnalysis;
+    private final boolean allowImprovedRethrowAnalysis;
+    private final boolean allowImprovedCatchAnalysis;
 
     public static Flow instance(Context context) {
         Flow instance = context.get(flowKey);
@@ -209,7 +210,8 @@ public class Flow extends TreeScanner {
         lint = Lint.instance(context);
         rs = Resolve.instance(context);
         Source source = Source.instance(context);
-        allowRethrowAnalysis = source.allowMulticatch();
+        allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis();
+        allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis();
     }
 
     /** A flag that indicates whether the last statement could
@@ -1046,7 +1048,9 @@ public class Flow extends TreeScanner {
             }
         }
         scanStat(tree.body);
-        List<Type> thrownInTry = thrown;
+        List<Type> thrownInTry = allowImprovedCatchAnalysis ?
+            chk.union(thrown, List.of(syms.runtimeExceptionType, syms.errorType)) :
+            thrown;
         thrown = thrownPrev;
         caught = caughtPrev;
         boolean aliveEnd = alive;
@@ -1081,16 +1085,7 @@ public class Flow extends TreeScanner {
                     ctypes = ctypes.append(exc);
                     if (types.isSameType(exc, syms.objectType))
                         continue;
-                    if (chk.subset(exc, caughtInTry)) {
-                        log.error(l.head.pos(),
-                                  "except.already.caught", exc);
-                    } else if (!chk.isUnchecked(l.head.pos(), exc) &&
-                               exc.tsym != syms.throwableType.tsym &&
-                               exc.tsym != syms.exceptionType.tsym &&
-                               !chk.intersects(exc, thrownInTry)) {
-                        log.error(l.head.pos(),
-                                  "except.never.thrown.in.try", exc);
-                    }
+                    checkCaughtType(l.head.pos(), exc, thrownInTry, caughtInTry);
                     caughtInTry = chk.incl(exc, caughtInTry);
                 }
             }
@@ -1154,6 +1149,29 @@ public class Flow extends TreeScanner {
         uninitsTry.andSet(uninitsTryPrev).andSet(uninits);
     }
 
+    void checkCaughtType(DiagnosticPosition pos, Type exc, List<Type> thrownInTry, List<Type> caughtInTry) {
+        if (chk.subset(exc, caughtInTry)) {
+            log.error(pos, "except.already.caught", exc);
+        } else if (!chk.isUnchecked(pos, exc) &&
+                exc.tsym != syms.throwableType.tsym &&
+                exc.tsym != syms.exceptionType.tsym &&
+                !chk.intersects(exc, thrownInTry)) {
+            log.error(pos, "except.never.thrown.in.try", exc);
+        } else if (allowImprovedCatchAnalysis) {
+            List<Type> catchableThrownTypes = chk.intersect(List.of(exc), thrownInTry);
+            // 'catchableThrownTypes' cannnot possibly be empty - if 'exc' was an
+            // unchecked exception, the result list would not be empty, as the augmented
+            // thrown set includes { RuntimeException, Error }; if 'exc' was a checked
+            // exception, that would have been covered in the branch above
+            if (chk.diff(catchableThrownTypes, caughtInTry).isEmpty()) {
+                String key = catchableThrownTypes.length() == 1 ?
+                        "unreachable.catch" :
+                        "unreachable.catch.1";
+                log.warning(pos, key, catchableThrownTypes);
+            }
+        }
+    }
+
     public void visitConditional(JCConditional tree) {
         scanCond(tree.cond);
         Bits initsBeforeElse = initsWhenFalse;
@@ -1238,7 +1256,7 @@ public class Flow extends TreeScanner {
             sym.kind == VAR &&
             (sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 &&
             preciseRethrowTypes.get(sym) != null &&
-            allowRethrowAnalysis) {
+            allowImprovedRethrowAnalysis) {
             for (Type t : preciseRethrowTypes.get(sym)) {
                 markThrown(tree, t);
             }
diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
index 8e89af024de..ff10fd3ed36 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java
@@ -89,7 +89,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
 
     private FSInfo fsInfo;
 
-    private boolean useZipFileIndex;
+    private boolean contextUseOptimizedZip;
     private ZipFileIndexCache zipFileIndexCache;
 
     private final File uninited = new File("U N I N I T E D");
@@ -164,8 +164,8 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
 
         fsInfo = FSInfo.instance(context);
 
-        useZipFileIndex = options.isSet("useOptimizedZip");
-        if (useZipFileIndex)
+        contextUseOptimizedZip = options.getBoolean("useOptimizedZip", true);
+        if (contextUseOptimizedZip)
             zipFileIndexCache = ZipFileIndexCache.getSharedInstance();
 
         mmappedIO = options.isSet("mmappedIO");
@@ -471,9 +471,27 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
     private static final RelativeDirectory symbolFilePrefix
             = new RelativeDirectory("META-INF/sym/rt.jar/");
 
+    /*
+     * This method looks for a ZipFormatException and takes appropriate
+     * evasive action. If there is a failure in the fast mode then we
+     * fail over to the platform zip, and allow it to deal with a potentially
+     * non compliant zip file.
+     */
+    protected Archive openArchive(File zipFilename) throws IOException {
+        try {
+            return openArchive(zipFilename, contextUseOptimizedZip);
+        } catch (IOException ioe) {
+            if (ioe instanceof ZipFileIndex.ZipFormatException) {
+                return openArchive(zipFilename, false);
+            } else {
+                throw ioe;
+            }
+        }
+    }
+
     /** Open a new zip file directory, and cache it.
      */
-    protected Archive openArchive(File zipFileName) throws IOException {
+    private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException {
         File origZipFileName = zipFileName;
         if (!ignoreSymbolFile && paths.isDefaultBootClassPathRtJar(zipFileName)) {
             File file = zipFileName.getParentFile().getParentFile(); // ${java.home}
@@ -495,7 +513,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
             boolean usePreindexedCache = false;
             String preindexCacheLocation = null;
 
-            if (!useZipFileIndex) {
+            if (!useOptimizedZip) {
                 zdir = new ZipFile(zipFileName);
             } else {
                 usePreindexedCache = options.isSet("usezipindex");
@@ -524,23 +542,22 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
             }
 
             if (origZipFileName == zipFileName) {
-                if (!useZipFileIndex) {
+                if (!useOptimizedZip) {
                     archive = new ZipArchive(this, zdir);
                 } else {
                     archive = new ZipFileIndexArchive(this,
-                                zipFileIndexCache.getZipFileIndex(zipFileName,
+                                    zipFileIndexCache.getZipFileIndex(zipFileName,
                                     null,
                                     usePreindexedCache,
                                     preindexCacheLocation,
                                     options.isSet("writezipindexfiles")));
                 }
             } else {
-                if (!useZipFileIndex) {
+                if (!useOptimizedZip) {
                     archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix);
-                }
-                else {
+                } else {
                     archive = new ZipFileIndexArchive(this,
-                                zipFileIndexCache.getZipFileIndex(zipFileName,
+                                    zipFileIndexCache.getZipFileIndex(zipFileName,
                                     symbolFilePrefix,
                                     usePreindexedCache,
                                     preindexCacheLocation,
@@ -549,6 +566,8 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil
             }
         } catch (FileNotFoundException ex) {
             archive = new MissingArchive(zipFileName);
+        } catch (ZipFileIndex.ZipFormatException zfe) {
+            throw zfe;
         } catch (IOException ex) {
             if (zipFileName.exists())
                 log.error("error.reading.file", zipFileName, getMessage(ex));
diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java b/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java
index fc9d1b3789f..1bee909914f 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java
@@ -492,10 +492,32 @@ public class ZipFileIndex {
         public ZipDirectory(RandomAccessFile zipRandomFile, long start, long end, ZipFileIndex index) throws IOException {
             this.zipRandomFile = zipRandomFile;
             this.zipFileIndex = index;
-
+            hasValidHeader();
             findCENRecord(start, end);
         }
 
+        /*
+         * the zip entry signature should be at offset 0, otherwise allow the
+         * calling logic to take evasive action by throwing ZipFormatException.
+         */
+        private boolean hasValidHeader() throws IOException {
+            final long pos = zipRandomFile.getFilePointer();
+            try {
+                if (zipRandomFile.read() == 'P') {
+                    if (zipRandomFile.read() == 'K') {
+                        if (zipRandomFile.read() == 0x03) {
+                            if (zipRandomFile.read() == 0x04) {
+                                return true;
+                            }
+                        }
+                    }
+                }
+            } finally {
+                zipRandomFile.seek(pos);
+            }
+            throw new ZipFormatException("invalid zip magic");
+        }
+
         /*
          * Reads zip file central directory.
          * For more details see readCEN in zip_util.c from the JDK sources.
@@ -529,7 +551,13 @@ public class ZipFileIndex {
                     zipDir = new byte[get4ByteLittleEndian(endbuf, i + 12) + 2];
                     zipDir[0] = endbuf[i + 10];
                     zipDir[1] = endbuf[i + 11];
-                    zipRandomFile.seek(start + get4ByteLittleEndian(endbuf, i + 16));
+                    int sz = get4ByteLittleEndian(endbuf, i + 16);
+                    // a negative offset or the entries field indicates a
+                    // potential zip64 archive
+                    if (sz < 0 || get2ByteLittleEndian(zipDir, 0) == 0xffff) {
+                        throw new ZipFormatException("detected a zip64 archive");
+                    }
+                    zipRandomFile.seek(start + sz);
                     zipRandomFile.readFully(zipDir, 2, zipDir.length - 2);
                     return;
                 } else {
@@ -1127,4 +1155,18 @@ public class ZipFileIndex {
         }
     }
 
+    /*
+     * Exception primarily used to implement a failover, used exclusively here.
+     */
+
+    static final class ZipFormatException extends IOException {
+        private static final long serialVersionUID = 8000196834066748623L;
+        protected ZipFormatException(String message) {
+            super(message);
+        }
+
+        protected ZipFormatException(String message, Throwable cause) {
+            super(message, cause);
+        }
+    }
 }
diff --git a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
index d7107ad5626..fe1cb42db0b 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java
@@ -638,6 +638,19 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
         }
     }
 
+    /** Resolve an identifier which may be the binary name of a class or
+     * the Java name of a class or package.
+     * @param name      The name to resolve
+     */
+    public Symbol resolveBinaryNameOrIdent(String name) {
+        try {
+            Name flatname = names.fromString(name.replace("/", "."));
+            return reader.loadClass(flatname);
+        } catch (CompletionFailure ignore) {
+            return resolveIdent(name);
+        }
+    }
+
     /** Resolve an identifier.
      * @param name      The identifier to resolve
      */
@@ -1058,7 +1071,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                 } else {
                     boolean errors = false;
                     for (String nameStr : classnames) {
-                        Symbol sym = resolveIdent(nameStr);
+                        Symbol sym = resolveBinaryNameOrIdent(nameStr);
                         if (sym == null || (sym.kind == Kinds.PCK && !processPcks)) {
                             log.error("proc.cant.find.class", nameStr);
                             errors = true;
@@ -1166,7 +1179,7 @@ public class JavaCompiler implements ClassReader.SourceCompleter {
                                   env.enclClass.sym.sourcefile :
                                   env.toplevel.sourcefile);
         try {
-            attr.attribClass(env.tree.pos(), env.enclClass.sym);
+            attr.attrib(env);
             if (errorCount() > 0 && !shouldStop(CompileState.ATTR)) {
                 //if in fail-over mode, ensure that AST expression nodes
                 //are correctly initialized (e.g. they have a type/symbol)
diff --git a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java
index 3af480c9385..5e34ee484fa 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacTypes.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,9 +73,14 @@ public class JavacTypes implements javax.lang.model.util.Types {
 
     public Element asElement(TypeMirror t) {
         Type type = cast(Type.class, t);
-        if (type.tag != TypeTags.CLASS && type.tag != TypeTags.TYPEVAR)
-            return null;
-        return type.asElement();
+        switch (type.tag) {
+            case TypeTags.CLASS:
+            case TypeTags.ERROR:
+            case TypeTags.TYPEVAR:
+                return type.asElement();
+            default:
+                return null;
+        }
     }
 
     public boolean isSameType(TypeMirror t1, TypeMirror t2) {
diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
index eee56d25725..e83c477b2af 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java
@@ -820,13 +820,17 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         /** The set of package-info files to be processed this round. */
         List<PackageSymbol> packageInfoFiles;
 
+        /** The number of Messager errors generated in this round. */
+        int nMessagerErrors;
+
         /** Create a round (common code). */
-        private Round(Context context, int number, int priorWarnings) {
+        private Round(Context context, int number, int priorErrors, int priorWarnings) {
             this.context = context;
             this.number = number;
 
             compiler = JavaCompiler.instance(context);
             log = Log.instance(context);
+            log.nerrors = priorErrors;
             log.nwarnings += priorWarnings;
             log.deferDiagnostics = true;
 
@@ -840,7 +844,7 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
 
         /** Create the first round. */
         Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols) {
-            this(context, 1, 0);
+            this(context, 1, 0, 0);
             this.roots = roots;
             genClassFiles = new HashMap<String,JavaFileObject>();
 
@@ -860,7 +864,10 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
         /** Create a new round. */
         private Round(Round prev,
                 Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
-            this(prev.nextContext(), prev.number+1, prev.compiler.log.nwarnings);
+            this(prev.nextContext(),
+                    prev.number+1,
+                    prev.nMessagerErrors,
+                    prev.compiler.log.nwarnings);
             this.genClassFiles = prev.genClassFiles;
 
             List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
@@ -1014,6 +1021,8 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea
                 if (taskListener != null)
                     taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
             }
+
+            nMessagerErrors = messager.errorCount();
         }
 
         void showDiagnostics(boolean showAll) {
diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
index 4a3a5fa5bfb..889e2293bf3 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
@@ -1102,6 +1102,16 @@ compiler.warn.inexact.non-varargs.call=\
     cast to {0} for a varargs call\n\
     cast to {1} for a non-varargs call and to suppress this warning
 
+# 0: list of type
+compiler.warn.unreachable.catch=\
+    unreachable catch clause\n\
+    thrown type {0} has already been caught
+
+# 0: list of type
+compiler.warn.unreachable.catch.1=\
+    unreachable catch clause\n\
+    thrown types {0} have already been caught
+
 # 0: symbol
 compiler.warn.long.SVUID=\
     serialVersionUID must be of type long in class {0}
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java b/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
index 033c385ef5d..cec4b954b4e 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.javac.util;
 
 import java.util.Collection;
+import java.util.EnumMap;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Locale;
@@ -226,17 +227,14 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
                             DiagnosticPart.SOURCE));
             initFormat();
             initIndentation();
+            if (options.isSet("oldDiags"))
+                initOldFormat();
             String fmt = options.get("diagsFormat");
             if (fmt != null) {
-                String[] formats = fmt.split("\\|");
-                switch (formats.length) {
-                    case 3:
-                        setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]);
-                    case 2:
-                        setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]);
-                    default:
-                        setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]);
-                }
+                if (fmt.equals("OLD"))
+                    initOldFormat();
+                else
+                    initFormats(fmt);
             }
             String srcPos = null;
             if ((((srcPos = options.get("sourcePosition")) != null)) &&
@@ -280,14 +278,35 @@ public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
             initFormat();
             initIndentation();
         }
-        //where
+
         private void initFormat() {
-            availableFormats = new HashMap<BasicFormatKind, String>();
-            setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, "%f:%l:%_%t%L%m");
-            setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, "%p%L%m");
-            setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, "%f:%_%t%L%m");
+            initFormats("%f:%l:%_%p%L%m", "%p%L%m", "%f:%_%p%L%m");
         }
-        //where
+
+        private void initOldFormat() {
+            initFormats("%f:%l:%_%t%L%m", "%p%L%m", "%f:%_%t%L%m");
+        }
+
+        private void initFormats(String pos, String nopos, String clazz) {
+            availableFormats = new EnumMap<BasicFormatKind, String>(BasicFormatKind.class);
+            setFormat(BasicFormatKind.DEFAULT_POS_FORMAT,    pos);
+            setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, nopos);
+            setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT,  clazz);
+        }
+
+        @SuppressWarnings("fallthrough")
+        private void initFormats(String fmt) {
+            String[] formats = fmt.split("\\|");
+            switch (formats.length) {
+                case 3:
+                    setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]);
+                case 2:
+                    setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]);
+                default:
+                    setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]);
+            }
+        }
+
         private void initIndentation() {
             indentationLevels = new HashMap<DiagnosticPart, Integer>();
             setIndentation(DiagnosticPart.SUMMARY, 0);
diff --git a/langtools/src/share/classes/com/sun/tools/javac/util/Options.java b/langtools/src/share/classes/com/sun/tools/javac/util/Options.java
index c44cfa960a1..1f68ddb1a35 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Options.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Options.java
@@ -75,6 +75,22 @@ public class Options {
         return values.get(name.optionName);
     }
 
+    /**
+     * Get the boolean value for an option, patterned after Boolean.getBoolean,
+     * essentially will return true, iff the value exists and is set to "true".
+     */
+    public boolean getBoolean(String name) {
+        return getBoolean(name, false);
+    }
+
+    /**
+     * Get the boolean with a default value if the option is not set.
+     */
+    public boolean getBoolean(String name, boolean defaultValue) {
+        String value = get(name);
+        return (value == null) ? defaultValue : Boolean.parseBoolean(value);
+    }
+
     /**
      * Check if the value for an undocumented option has been set.
      */
diff --git a/langtools/src/share/classes/javax/lang/model/element/Element.java b/langtools/src/share/classes/javax/lang/model/element/Element.java
index 522faa6405b..f46c2cf26f5 100644
--- a/langtools/src/share/classes/javax/lang/model/element/Element.java
+++ b/langtools/src/share/classes/javax/lang/model/element/Element.java
@@ -197,11 +197,12 @@ public interface Element {
      * <li> If this is a {@linkplain
      * PackageElement#getEnclosingElement package}, {@code null} is
      * returned.
-
+     *
      * <li> If this is a {@linkplain
      * TypeParameterElement#getEnclosingElement type parameter},
-     * {@code null} is returned.
-
+     * {@linkplain TypeParameterElement#getGenericElement the
+     * generic element} of the type parameter is returned.
+     *
      * </ul>
      *
      * @return the enclosing element, or {@code null} if there is none
diff --git a/langtools/src/share/classes/javax/lang/model/element/TypeParameterElement.java b/langtools/src/share/classes/javax/lang/model/element/TypeParameterElement.java
index e6a0536bc5a..f9b128e2490 100644
--- a/langtools/src/share/classes/javax/lang/model/element/TypeParameterElement.java
+++ b/langtools/src/share/classes/javax/lang/model/element/TypeParameterElement.java
@@ -64,9 +64,9 @@ public interface TypeParameterElement extends Element {
     List<? extends TypeMirror> getBounds();
 
     /**
-     * Returns {@code null}.
+     * Returns the {@linkplain TypeParameterElement#getGenericElement generic element} of this type parameter.
      *
-     * @return {@code null}
+     * @return the generic element of this type parameter
      */
     @Override
     Element getEnclosingElement();
diff --git a/langtools/test/com/sun/javadoc/testUseOption/C.java b/langtools/test/com/sun/javadoc/testUseOption/C.java
new file mode 100644
index 00000000000..419d36ba73c
--- /dev/null
+++ b/langtools/test/com/sun/javadoc/testUseOption/C.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Class in an unnamed package.
+ */
+
+public class C {
+
+    /**
+     * Field in C.
+     */
+    public UsedInC fieldInC;
+
+    /**
+     * Method in C.
+     */
+    public UsedInC methodInC(UsedInC p) {
+        return p;
+    }
+}
diff --git a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java
index f03f24002bc..58f56073a38 100644
--- a/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java
+++ b/langtools/test/com/sun/javadoc/testUseOption/TestUseOption.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4496290 4985072
+ * @bug 4496290 4985072 7006178
  * @summary A simple test to determine if -use works.
  * @author jamieh
  * @library ../lib/
@@ -34,7 +34,7 @@
 
 public class TestUseOption extends JavadocTester {
 
-    private static final String BUG_ID = "4496290-4985072";
+    private static final String BUG_ID = "4496290-4985072-7006178";
 
     //Input for string search tests.
     private static final String[] TEST2 = {
@@ -54,6 +54,16 @@ public class TestUseOption extends JavadocTester {
         "Method in C8.",
     };
 
+    private static final String[][] TEST3 = {
+        {BUG_ID + "-3" + FS + "class-use" + FS + "UsedInC.html", "Uses of <a href=" +
+                 "\"../UsedInC.html\" title=\"class in &lt;Unnamed&gt;\">" +
+                 "UsedInC</a> in <a href=\"../package-summary.html\">&lt;Unnamed&gt;</a>"
+        },
+        {BUG_ID + "-3" + FS + "package-use.html", "<td class=\"colOne\">" +
+                 "<a href=\"class-use/UsedInC.html#&lt;Unnamed&gt;\">UsedInC</a>&nbsp;</td>"
+        }
+    };
+
     private static final String[] ARGS = new String[] {
         "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
     };
@@ -62,6 +72,10 @@ public class TestUseOption extends JavadocTester {
         "-d", BUG_ID+"-2", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
     };
 
+    private static final String[] ARGS3 = new String[] {
+        "-d", BUG_ID + "-3", "-sourcepath", SRC_DIR, "-use", SRC_DIR + FS + "C.java", SRC_DIR + FS + "UsedInC.java"
+    };
+
     /**
      * The entry point of the test.
      * @param args the array of command line arguments.
@@ -93,6 +107,8 @@ public class TestUseOption extends JavadocTester {
             prevIndex = currentIndex;
         }
         tester.printSummary();
+        run(tester, ARGS3, TEST3, NO_TEST);
+        tester.printSummary();
     }
 
     /**
diff --git a/langtools/test/com/sun/javadoc/testUseOption/UsedInC.java b/langtools/test/com/sun/javadoc/testUseOption/UsedInC.java
new file mode 100644
index 00000000000..61b43eda51d
--- /dev/null
+++ b/langtools/test/com/sun/javadoc/testUseOption/UsedInC.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class UsedInC
+{
+}
diff --git a/langtools/test/tools/apt/Compile/golden.txt b/langtools/test/tools/apt/Compile/golden.txt
index 42ee8bd867b..180efe276d2 100644
--- a/langtools/test/tools/apt/Compile/golden.txt
+++ b/langtools/test/tools/apt/Compile/golden.txt
@@ -1,6 +1,6 @@
 error: It's a mad, mad, mad, mad world
 error: Something wicked this way comes
-HelloWorld.java:2: Boring class name
+HelloWorld.java:2: error: Boring class name
 public class HelloWorld {
        ^
 3 errors
diff --git a/langtools/test/tools/javac/4846262/Test.out b/langtools/test/tools/javac/4846262/Test.out
index 254d9d2f644..175101fa83a 100644
--- a/langtools/test/tools/javac/4846262/Test.out
+++ b/langtools/test/tools/javac/4846262/Test.out
@@ -1,7 +1,7 @@
-Test.java:4: not a statement
+Test.java:4: error: not a statement
         abcdefg
         ^
-Test.java:4: ';' expected
+Test.java:4: error: ';' expected
         abcdefg
                ^
 2 errors
diff --git a/langtools/test/tools/javac/6508981/TestInferBinaryName.java b/langtools/test/tools/javac/6508981/TestInferBinaryName.java
index aeb91cfebba..b14bdc01894 100644
--- a/langtools/test/tools/javac/6508981/TestInferBinaryName.java
+++ b/langtools/test/tools/javac/6508981/TestInferBinaryName.java
@@ -139,9 +139,8 @@ public class TestInferBinaryName {
             throws IOException {
         Context ctx = new Context();
         Options options = Options.instance(ctx);
-        // uugh, ugly back door, should be cleaned up, someday
-        if (zipFileIndexKind == USE_ZIP_FILE_INDEX)
-            options.put("useOptimizedZip", "true");
+        options.put("useOptimizedZip",
+                Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX));
 
         if (symFileKind == IGNORE_SYMBOL_FILE)
             options.put("ignore.symbol.file", "true");
diff --git a/langtools/test/tools/javac/6558548/T6558548.java b/langtools/test/tools/javac/6558548/T6558548.java
new file mode 100644
index 00000000000..09bbda66237
--- /dev/null
+++ b/langtools/test/tools/javac/6558548/T6558548.java
@@ -0,0 +1,300 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     6558548
+ * @summary The compiler needs to be aligned with clarified specification of throws
+ * @compile/fail/ref=T6558548_latest.out -XDrawDiagnostics T6558548.java
+ * @compile/fail/ref=T6558548_6.out -source 6 -XDrawDiagnostics T6558548.java
+ */
+
+class T6558548 {
+
+    void nothing() {}
+    void checked() throws InterruptedException {}
+    void runtime() throws IllegalArgumentException {}
+
+    void m1() {
+        try {
+            throw new java.io.FileNotFoundException();
+        }
+        catch(java.io.FileNotFoundException exc) { }
+        catch(java.io.IOException exc) { } // 6: ok; latest: unreachable
+    }
+
+    void m1a() {
+        try {
+            throw new java.io.IOException();
+        }
+        catch(java.io.FileNotFoundException exc) { }
+        catch(java.io.IOException exc) { } //ok
+    }
+
+    void m2() {
+        try {
+            nothing();
+        }
+        catch(Exception exc) { } // ok
+    }
+
+    void m3() {
+        try {
+            checked();
+        }
+        catch(Exception exc) { } //ok
+    }
+
+    void m4() {
+        try {
+            runtime();
+        }
+        catch(Exception exc) { } //ok
+    }
+
+    void m5() {
+        try {
+            nothing();
+        }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m6() {
+        try {
+            checked();
+        }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m7() {
+        try {
+            runtime();
+        }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m9() {
+        try {
+            checked();
+        }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m10() {
+        try {
+            runtime();
+        }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m11() {
+        try {
+            nothing();
+        }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m12() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Throwable exc) { } // ok
+    }
+
+    void m13() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Throwable exc) { } // ok
+    }
+
+    void m14() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Throwable exc) { } // ok
+    }
+
+    void m15() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } //ok
+    }
+
+    void m16() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m17() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m18() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(InterruptedException exc) { }
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m19() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(InterruptedException exc) { } //never thrown in try
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m20() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(InterruptedException exc) { } //never thrown in try
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m21() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } // ok
+    }
+
+    void m22() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } // 6: ok; latest: unreachable
+    }
+
+    void m23() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } // 6: ok; latest: unreachable
+    }
+
+    void m24() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m25() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m26() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m27() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(InterruptedException exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m28() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(InterruptedException exc) { } //never thrown in try
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m29() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(InterruptedException exc) { } //never thrown in try
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m30() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m31() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m32() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m33() {
+        try {
+            checked();
+        }
+        catch(InterruptedException exc) { } //ok
+    }
+
+    void m34() {
+        try {
+            runtime();
+        }
+        catch(InterruptedException exc) { } //never thrown in try
+    }
+
+    void m35() {
+        try {
+            nothing();
+        }
+        catch(InterruptedException exc) { } //never thrown in try
+    }
+}
diff --git a/langtools/test/tools/javac/6558548/T6558548_6.out b/langtools/test/tools/javac/6558548/T6558548_6.out
new file mode 100644
index 00000000000..551ed33e503
--- /dev/null
+++ b/langtools/test/tools/javac/6558548/T6558548_6.out
@@ -0,0 +1,9 @@
+- compiler.warn.source.no.bootclasspath: 1.6
+T6558548.java:159:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:168:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:239:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:249:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:291:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:298:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+6 errors
+1 warning
diff --git a/langtools/test/tools/javac/6558548/T6558548_latest.out b/langtools/test/tools/javac/6558548/T6558548_latest.out
new file mode 100644
index 00000000000..ee686cb4a6a
--- /dev/null
+++ b/langtools/test/tools/javac/6558548/T6558548_latest.out
@@ -0,0 +1,23 @@
+T6558548.java:20:9: compiler.warn.unreachable.catch: java.io.FileNotFoundException
+T6558548.java:134:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:142:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:151:9: compiler.warn.unreachable.catch.1: java.lang.InterruptedException,java.lang.RuntimeException
+T6558548.java:159:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:160:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:168:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:169:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:185:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:193:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:211:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:220:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:230:9: compiler.warn.unreachable.catch.1: java.lang.InterruptedException,java.lang.RuntimeException,java.lang.Error
+T6558548.java:239:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:240:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:249:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:250:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:268:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:277:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:291:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:298:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+6 errors
+15 warnings
diff --git a/langtools/test/tools/javac/Diagnostics/6769027/T6769027.java b/langtools/test/tools/javac/Diagnostics/6769027/T6769027.java
index 84d096a4ff1..922b00fcebd 100644
--- a/langtools/test/tools/javac/Diagnostics/6769027/T6769027.java
+++ b/langtools/test/tools/javac/Diagnostics/6769027/T6769027.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -261,7 +261,7 @@ public class T6769027 {
 
     enum PositionKind {
         NOPOS(Position.NOPOS, "- ", "error: "),
-        POS(5, "Test.java:1:6: ", "/Test.java:1: ");
+        POS(5, "Test.java:1:6: ", "/Test.java:1: error: ");
 
         int pos;
         String rawOutput;
diff --git a/langtools/test/tools/javac/Diagnostics/7010608/Test.java b/langtools/test/tools/javac/Diagnostics/7010608/Test.java
new file mode 100644
index 00000000000..d0b718ddebc
--- /dev/null
+++ b/langtools/test/tools/javac/Diagnostics/7010608/Test.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7010608
+ * @summary the string 'error' should appear in error messages
+ */
+
+import java.io.*;
+import java.net.URI;
+import java.util.*;
+import javax.tools.*;
+import javax.tools.JavaCompiler.CompilationTask;
+
+public class Test {
+    public static void main(String... args) throws Exception {
+        new Test().run();
+    }
+
+    void run() throws Exception {
+        Locale prev = Locale.getDefault();
+        Locale.setDefault(Locale.ENGLISH);
+        try {
+            test(Arrays.<String>asList(),
+                    "myfo://test:1: error: cannot find symbol");
+            test(Arrays.asList("-XDdiagsFormat=OLD"),
+                    "myfo://test:1: cannot find symbol");
+            test(Arrays.asList("-XDoldDiags"),
+                    "myfo://test:1: cannot find symbol");
+        } finally {
+            Locale.setDefault(prev);
+        }
+    }
+
+    void test(List<String> options, String expect) throws Exception {
+        System.err.println("test: " + options);
+        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        JavaFileObject f = new MyFileObject("myfo://test", "class Bad { Missing x; }");
+        List<? extends JavaFileObject> files = Arrays.asList(f);
+        CompilationTask task = javac.getTask(pw, null, null, options, null, files);
+        boolean ok = task.call();
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (ok)
+            throw new Exception("Compilation succeeded unexpectedly");
+        if (!out.contains(expect))
+            throw new Exception("expected text not found: " + expect);
+    }
+
+    class MyFileObject extends SimpleJavaFileObject {
+        MyFileObject(String uri, String text) {
+            super(URI.create(uri), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+        @Override
+        public String getName() {
+            return uri.toString();
+        }
+        @Override
+        public String getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+        final String text;
+    }
+}
+
+
diff --git a/langtools/test/tools/javac/annotations/TestAnnotationPackageInfo.java b/langtools/test/tools/javac/annotations/TestAnnotationPackageInfo.java
new file mode 100644
index 00000000000..ac7593c3d49
--- /dev/null
+++ b/langtools/test/tools/javac/annotations/TestAnnotationPackageInfo.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6993311
+ * @summary annotations on packages are not validated
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.tools.*;
+import com.sun.source.util.*;
+
+public class TestAnnotationPackageInfo {
+    public static void main(String... args) throws Exception {
+        new TestAnnotationPackageInfo().run();
+    }
+
+    static class MyFileObject extends SimpleJavaFileObject {
+        private String text;
+        public MyFileObject(String fileName, String text) {
+            super(URI.create("myfo:/" + fileName), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+
+    public void run() throws Exception {
+        final String bootPath = System.getProperty("sun.boot.class.path");
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        JavaFileObject test_java = new MyFileObject("test/Test.java",
+            "package test; public @interface Test {\n" +
+            "    public int mandatory();\n" +
+            "}\n");
+
+        JavaFileObject package_info_java = new MyFileObject("test/package-info.java",
+            "@Test package test;");
+
+        DiagnosticCollector<JavaFileObject> coll = new DiagnosticCollector<JavaFileObject>();
+
+        List<String> options = Arrays.asList("-bootclasspath",  bootPath);
+        List<? extends JavaFileObject> files = Arrays.asList(test_java, package_info_java);
+        JavacTask ct = (JavacTask)tool.getTask(null, null, coll, options, null, files);
+        ct.analyze();
+
+        String expectedCode = "compiler.err.annotation.missing.default.value";
+        List<Diagnostic<? extends JavaFileObject>> diags = coll.getDiagnostics();
+        switch (diags.size()) {
+            case 0:
+                throw new Exception("no diagnostics reported");
+            case 1:
+                String code = diags.get(0).getCode();
+                if (code.equals(expectedCode))
+                    return;
+                throw new Exception("unexpected diag: " + diags.get(0));
+            default:
+                throw new Exception("unexpected diags reported: " + diags);
+        }
+    }
+}
diff --git a/langtools/test/tools/javac/annotations/pos/package-info.java b/langtools/test/tools/javac/annotations/pos/package-info.java
index dc18796ac39..460a0fcb7d9 100644
--- a/langtools/test/tools/javac/annotations/pos/package-info.java
+++ b/langtools/test/tools/javac/annotations/pos/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,12 @@
 
 /*
  * @test
- * @bug 4901290
+ * @bug 4901290 6993311
  * @summary Package annotations
  * @author gafter
  *
  * @compile package-info.java
  */
 
-@java.lang.annotation.Documented
+@Deprecated
 package foo.bar;
diff --git a/langtools/test/tools/javac/api/6411310/Test.java b/langtools/test/tools/javac/api/6411310/Test.java
index b7702d705a6..aec6c7db615 100644
--- a/langtools/test/tools/javac/api/6411310/Test.java
+++ b/langtools/test/tools/javac/api/6411310/Test.java
@@ -153,14 +153,12 @@ public class Test {
         Context c = new Context();
         Options options = Options.instance(c);
 
-            if (useOptimizedZip) {
-                options.put("useOptimizedZip", "true");
-            }
+        options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
 
-            if (!useSymbolFile) {
-                options.put("ignore.symbol.file", "true");
-            }
-            return new JavacFileManager(c, false, null);
+        if (!useSymbolFile) {
+            options.put("ignore.symbol.file", "true");
+        }
+        return new JavacFileManager(c, false, null);
     }
 
     File createDir(String name, String... entries) throws Exception {
diff --git a/langtools/test/tools/javac/api/6557752/T6557752.java b/langtools/test/tools/javac/api/6557752/T6557752.java
index c920a953e6e..fe748bee53e 100644
--- a/langtools/test/tools/javac/api/6557752/T6557752.java
+++ b/langtools/test/tools/javac/api/6557752/T6557752.java
@@ -118,7 +118,8 @@ public class T6557752 {
 
                 Types types = task.getTypes();
 
-                if (types.asElement(trees.getOriginalType((ErrorType)typeMirror)) != null) {
+                str1 = types.asElement(trees.getOriginalType((ErrorType)typeMirror)).toString();
+                if (!str1.equals("FooBar")) {
                     throw new AssertionError("Types.asElement() error!");
                 }
                 foundError = true;
diff --git a/langtools/test/tools/javac/api/T6838467.java b/langtools/test/tools/javac/api/T6838467.java
index daa5a654a76..b08412d6f79 100644
--- a/langtools/test/tools/javac/api/T6838467.java
+++ b/langtools/test/tools/javac/api/T6838467.java
@@ -178,12 +178,10 @@ public class T6838467 {
         return fm;
     }
 
-    JavacFileManager createFileManager(boolean useOptimedZipIndex) {
+    JavacFileManager createFileManager(boolean useOptimizedZip) {
         Context ctx = new Context();
-        if (useOptimedZipIndex) {
-            Options options = Options.instance(ctx);
-            options.put("useOptimizedZip", "true");
-        }
+        Options options = Options.instance(ctx);
+        options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
         return new JavacFileManager(ctx, false, null);
     }
 
diff --git a/langtools/test/tools/javac/api/T6877206.java b/langtools/test/tools/javac/api/T6877206.java
index 5a8442ad22a..3c82bb3e500 100644
--- a/langtools/test/tools/javac/api/T6877206.java
+++ b/langtools/test/tools/javac/api/T6877206.java
@@ -168,9 +168,7 @@ public class T6877206 {
     JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
         Context ctx = new Context();
         Options options = Options.instance(ctx);
-        if (useOptimizedZip) {
-            options.put("useOptimizedZip", "true");
-        }
+        options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
         if (!useSymbolFile) {
             options.put("ignore.symbol.file", "true");
         }
diff --git a/langtools/test/tools/javac/api/TestJavacTask_Lock.java b/langtools/test/tools/javac/api/TestJavacTask_Lock.java
new file mode 100644
index 00000000000..cc27c11765b
--- /dev/null
+++ b/langtools/test/tools/javac/api/TestJavacTask_Lock.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7026509
+ * @summary Cannot use JavaCompiler to create multiple CompilationTasks for partial compilations
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+import javax.tools.JavaCompiler.CompilationTask;
+import com.sun.source.util.*;
+
+public class TestJavacTask_Lock {
+    public static void main(String... args) throws Exception {
+        new TestJavacTask_Lock().run();
+    }
+
+    enum MethodKind {
+        CALL {
+            int test(CompilationTask t) {
+                boolean ok = t.call();
+                if (!ok)
+                    throw new Error("compilation failed");
+                return 1;
+            }
+        },
+        PARSE {
+            int test(CompilationTask t) {
+                try {
+                    ((JavacTask) t).parse();
+                return 1;
+                } catch (IOException ex) {
+                    throw new Error(ex);
+                }
+            }
+
+        };
+        abstract int test(CompilationTask t);
+    }
+
+    JavaCompiler comp;
+    StandardJavaFileManager fm;
+
+    void run() throws Exception {
+        comp = ToolProvider.getSystemJavaCompiler();
+        fm = comp.getStandardFileManager(null, null, null);
+
+        for (MethodKind first: MethodKind.values()) {
+            for (MethodKind second: MethodKind.values()) {
+                test(first, second);
+            }
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void test(MethodKind first, MethodKind second) {
+        System.err.println("test: " + first + ", " + second);
+        File testSrc = new File(System.getProperty("test.src"));
+        String thisClassName = TestJavacTask_Lock.class.getName();
+        Iterable<? extends JavaFileObject> files =
+                fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java"));
+        File tmpDir = new File(first + "_" + second);
+        tmpDir.mkdirs();
+        List<String> options = Arrays.asList( "-d", tmpDir.getPath() );
+        CompilationTask t = comp.getTask(null, fm, null, options, null, files);
+
+        try {
+            first.test(t);
+            second.test(t);
+            error("No exception thrown");
+        } catch (IllegalStateException e) {
+            System.err.println("Expected exception caught: " + e);
+        } catch (Exception e) {
+            error("Unexpected exception caught: " + e);
+            e.printStackTrace(System.err);
+        }
+
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/langtools/test/tools/javac/api/TestJavacTask_Multiple.java b/langtools/test/tools/javac/api/TestJavacTask_Multiple.java
new file mode 100644
index 00000000000..c80cc6e00cf
--- /dev/null
+++ b/langtools/test/tools/javac/api/TestJavacTask_Multiple.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7026509
+ * @summary Cannot use JavaCompiler to create multiple CompilationTasks for partial compilations
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+import javax.tools.JavaCompiler.CompilationTask;
+import com.sun.source.util.*;
+
+public class TestJavacTask_Multiple {
+    public static void main(String... args) throws Exception {
+        new TestJavacTask_Multiple().run();
+    }
+
+    final int MAX_TASKS = 3;
+
+    enum TestKind {
+        CALL {
+            int test(CompilationTask t) {
+                boolean ok = t.call();
+                if (!ok)
+                    throw new Error("compilation failed");
+                return 1;
+            }
+        },
+        PARSE {
+            int test(CompilationTask t) {
+                try {
+                    ((JavacTask) t).parse();
+                return 1;
+                } catch (IOException ex) {
+                    throw new Error(ex);
+                }
+            }
+
+        };
+        abstract int test(CompilationTask t);
+    }
+
+    int count;
+
+    void run() throws Exception {
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+        for (TestKind tk: TestKind.values()) {
+            test(comp, fm, tk);
+        }
+
+        int expect = TestKind.values().length * MAX_TASKS;
+        if (count != expect) {
+            throw new Exception("Unexpected number of tests completed: " + count
+                    + ", expected: " + expect);
+        }
+
+    }
+
+    void test(JavaCompiler comp, StandardJavaFileManager fm, TestKind tk) {
+        System.err.println("test " + tk);
+        File testSrc = new File(System.getProperty("test.src"));
+        String thisClassName = TestJavacTask_Multiple.class.getName();
+        Iterable<? extends JavaFileObject> files =
+                fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java"));
+
+        List<CompilationTask> tasks = new ArrayList<CompilationTask>();
+        for (int i = 1; i <= MAX_TASKS; i++) {
+            File tmpDir = new File(tk + "_" + i);
+            tmpDir.mkdirs();
+            List<String> options = Arrays.asList( "-d", tmpDir.getPath() );
+            CompilationTask t = comp.getTask(null, fm, null, options, null, files);
+            ((JavacTask) t).setTaskListener(createTaskListener(tk, i));
+            tasks.add(t);
+        }
+
+        for (CompilationTask t: tasks)
+            count += tk.test(t);
+
+        System.err.println();
+    }
+
+    TaskListener createTaskListener(final TestKind tk, final int i) {
+        return new TaskListener() {
+
+            public void started(TaskEvent e) {
+                System.err.println(tk + "." + i + ": " + e + " started");
+            }
+
+            public void finished(TaskEvent e) {
+                System.err.println(tk + "." + i + ": " + e + " finished");
+            }
+        };
+    }
+}
diff --git a/langtools/test/tools/javac/api/TestJavacTask_ParseAttrGen.java b/langtools/test/tools/javac/api/TestJavacTask_ParseAttrGen.java
new file mode 100644
index 00000000000..e318b3e0a58
--- /dev/null
+++ b/langtools/test/tools/javac/api/TestJavacTask_ParseAttrGen.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7026509
+ * @summary Cannot use JavaCompiler to create multiple CompilationTasks for partial compilations
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+
+public class TestJavacTask_ParseAttrGen {
+    public static void main(String... args) throws Exception {
+        new TestJavacTask_ParseAttrGen().run();
+    }
+
+    JavaCompiler comp;
+    StandardJavaFileManager fm;
+
+    void run() throws Exception {
+        comp = ToolProvider.getSystemJavaCompiler();
+        fm = comp.getStandardFileManager(null, null, null);
+
+        final boolean[] booleanValues = { false, true };
+        for (boolean pk: booleanValues) {
+            for (boolean ak: booleanValues) {
+                for (boolean gk: booleanValues) {
+                    test(pk, ak, gk);
+                }
+            }
+        }
+    }
+
+    void test(boolean pk, boolean ak, boolean gk) throws Exception {
+        if (!pk && !ak && !gk)  // nothing to do
+            return;
+
+        System.err.println("test: pk:" + pk + ", ak:" + ak + ", gk: " + gk);
+        File testSrc = new File(System.getProperty("test.src"));
+        String thisClassName = TestJavacTask_ParseAttrGen.class.getName();
+        Iterable<? extends JavaFileObject> files =
+                fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java"));
+        File tmpDir = new File((pk ? "p" : "") + (ak ? "a" : "") + (gk ? "g" : ""));
+        tmpDir.mkdirs();
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));
+        JavacTask t = (JavacTask) comp.getTask(null, fm, null, null, null, files);
+        //t.setTaskListener(createTaskListener());
+
+        try {
+            if (pk) {
+                Iterable<? extends CompilationUnitTree> trees = t.parse();
+                System.err.println(count(trees) + " trees parsed");
+            }
+
+            if (ak) {
+                Iterable<? extends Element> elems = t.analyze();
+                System.err.println(count(elems) + " elements analyzed");
+            }
+
+            if (gk) {
+                Iterable<? extends JavaFileObject> classfiles = t.generate();
+                System.err.println(count(classfiles) + " class files generated");
+            }
+        } catch (IOException e) {
+            error("unexpected exception caught: " + e);
+        }
+
+        File[] genFiles = tmpDir.listFiles();
+        int expect = (gk ? 2 : 0); // main class and anon class for TaskListener
+        if (genFiles.length != expect)
+            error("unexpected number of files generated: " + genFiles.length
+                    + ", expected: " + expect);
+
+        System.err.println();
+    }
+
+    TaskListener createTaskListener() {
+        return new TaskListener() {
+            public void started(TaskEvent e) {
+                System.err.println(e + " started");
+            }
+
+            public void finished(TaskEvent e) {
+                System.err.println(e + " finished");
+            }
+        };
+    }
+
+    <T> int count(Iterable<T> items) {
+        int count = 0;
+        for (T item: items)
+            count++;
+        return count;
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
diff --git a/langtools/test/tools/javac/diags/examples/CountError.java b/langtools/test/tools/javac/diags/examples/CountError.java
index 782d45d9241..2d09842c12a 100644
--- a/langtools/test/tools/javac/diags/examples/CountError.java
+++ b/langtools/test/tools/javac/diags/examples/CountError.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 // key: compiler.misc.count.error
 // key: compiler.err.unreported.exception.need.to.catch.or.throw
+// key: compiler.err.error
 // run: backdoor
 
 class CountError {
diff --git a/langtools/test/tools/javac/diags/examples/CountErrorPlural.java b/langtools/test/tools/javac/diags/examples/CountErrorPlural.java
index efd8dc4255b..9d5ecb98c80 100644
--- a/langtools/test/tools/javac/diags/examples/CountErrorPlural.java
+++ b/langtools/test/tools/javac/diags/examples/CountErrorPlural.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 
 // key: compiler.misc.count.error.plural
 // key: compiler.err.unreported.exception.need.to.catch.or.throw
+// key: compiler.err.error
 // run: backdoor
 
 class CountErrorPlural {
diff --git a/langtools/test/tools/javac/diags/examples/IdentifierExpected.java b/langtools/test/tools/javac/diags/examples/IdentifierExpected.java
index 440b2688dd8..f36b8ad2161 100644
--- a/langtools/test/tools/javac/diags/examples/IdentifierExpected.java
+++ b/langtools/test/tools/javac/diags/examples/IdentifierExpected.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 // key: compiler.err.expected
 // key: compiler.err.invalid.binary.number
 // key: compiler.misc.count.error.plural
+// key: compiler.err.error
 // run: backdoor
 
 class IdentifierExpected {
diff --git a/langtools/test/tools/javac/diags/examples/KindnameClass.java b/langtools/test/tools/javac/diags/examples/KindnameClass.java
index 245e75332c3..4f856607cc4 100644
--- a/langtools/test/tools/javac/diags/examples/KindnameClass.java
+++ b/langtools/test/tools/javac/diags/examples/KindnameClass.java
@@ -25,6 +25,7 @@
 // key: compiler.err.cant.resolve.location
 // key: compiler.misc.location
 // key: compiler.misc.count.error
+// key: compiler.err.error
 // run: backdoor
 
 class KindnameClass {
diff --git a/langtools/test/tools/javac/diags/examples/KindnameConstructor.java b/langtools/test/tools/javac/diags/examples/KindnameConstructor.java
index c451c3a3ad9..21396b58b98 100644
--- a/langtools/test/tools/javac/diags/examples/KindnameConstructor.java
+++ b/langtools/test/tools/javac/diags/examples/KindnameConstructor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
 // key: compiler.misc.arg.length.mismatch
 // key: compiler.misc.no.conforming.assignment.exists
 // key: compiler.misc.count.error.plural
+// key: compiler.err.error
 // run: backdoor
 
 class KindnameConstructor {
diff --git a/langtools/test/tools/javac/diags/examples/KindnameMethod.java b/langtools/test/tools/javac/diags/examples/KindnameMethod.java
index 3bcb7605585..7dd283fe4ca 100644
--- a/langtools/test/tools/javac/diags/examples/KindnameMethod.java
+++ b/langtools/test/tools/javac/diags/examples/KindnameMethod.java
@@ -26,6 +26,7 @@
 // key: compiler.err.cant.resolve.location.args
 // key: compiler.misc.location
 // key: compiler.misc.count.error
+// key: compiler.err.error
 // run: backdoor
 
 class KindnameMethod {
diff --git a/langtools/test/tools/javac/diags/examples/KindnameVariable.java b/langtools/test/tools/javac/diags/examples/KindnameVariable.java
index 894322b1a48..e88f30f7aa0 100644
--- a/langtools/test/tools/javac/diags/examples/KindnameVariable.java
+++ b/langtools/test/tools/javac/diags/examples/KindnameVariable.java
@@ -26,6 +26,7 @@
 // key: compiler.err.cant.resolve.location
 // key: compiler.misc.location
 // key: compiler.misc.count.error
+// key: compiler.err.error
 // run: backdoor
 
 class KindnameVariable {
diff --git a/langtools/test/tools/javac/diags/examples/UnreachableCatch.java b/langtools/test/tools/javac/diags/examples/UnreachableCatch.java
new file mode 100644
index 00000000000..5189e7a2757
--- /dev/null
+++ b/langtools/test/tools/javac/diags/examples/UnreachableCatch.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.unreachable.catch
+
+class UnreachableCatch {
+
+    void test() {
+        try {
+            throw new java.io.FileNotFoundException();
+        }
+        catch(java.io.FileNotFoundException exc) { }
+        catch(java.io.IOException exc) { } //unreachable
+    }
+}
diff --git a/langtools/test/tools/javac/diags/examples/UnreachableCatch1.java b/langtools/test/tools/javac/diags/examples/UnreachableCatch1.java
new file mode 100644
index 00000000000..3cf6ac32c7b
--- /dev/null
+++ b/langtools/test/tools/javac/diags/examples/UnreachableCatch1.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.unreachable.catch.1
+
+class UnreachableCatch1 {
+
+    void test() {
+        try {
+            throw new IllegalArgumentException();
+        }
+        catch(Error err) { }
+        catch(RuntimeException rex) { }
+        catch(Throwable t) { } //unreachable
+    }
+}
diff --git a/langtools/test/tools/javac/file/zip/T6836682.java b/langtools/test/tools/javac/file/zip/T6836682.java
new file mode 100644
index 00000000000..c25779b6112
--- /dev/null
+++ b/langtools/test/tools/javac/file/zip/T6836682.java
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6836682 7025988
+ * @summary JavacFileManager handling of zip64 archives (Scenario A and B)
+ * @compile  -XDignore.symbol.file T6836682.java Utils.java
+ * @run main T6836682
+ */
+/*
+ * This test consists of two scenarios:
+ *
+ * Scenario A: create a jar with entries exceeding 64K, and see if the javac
+ * can handle this large jar on the classpath. Generally this test completes
+ * within a minute
+ *
+ * Scenario B: create a jar with a large enough file exceeding 4GB, and
+ * similarly test javac. This test is known to be slow and problematic on
+ * certain operating systems, thus this test can be selected by passing a
+ * property through jtreg as follows:
+ * -javaoptions=-DT6836682.testScenarioB=true.
+ * Note this test will only run iff all the disk requirements are met at runtime.
+ */
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class T6836682 {
+
+    private static final long GIGA = 1024 * 1024 * 1024;
+    private static final int BUFFER_LEN = Short.MAX_VALUE * 2;
+
+    static long getCount(long minlength) {
+        return (minlength / BUFFER_LEN) + 1;
+    }
+
+    static long computeCRC(long minlength) {
+        CRC32 crc = new CRC32();
+        byte[] buffer = new byte[BUFFER_LEN];
+        long count = getCount(minlength);
+        for (long i = 0; i < count; i++) {
+            crc.update(buffer);
+        }
+        return crc.getValue();
+    }
+
+    static long computeCRC(File inFile) throws IOException {
+        byte[] buffer = new byte[8192];
+        CRC32 crc = new CRC32();
+        FileInputStream fis = null;
+        BufferedInputStream bis = null;
+        try {
+            fis = new FileInputStream(inFile);
+            bis = new BufferedInputStream(fis);
+            int n = bis.read(buffer);
+            while (n > 0) {
+                crc.update(buffer, 0, n);
+                n = bis.read(buffer);
+            }
+        } finally {
+            Utils.close(bis);
+            Utils.close(fis);
+        }
+        return crc.getValue();
+    }
+
+    static void createLargeFile(OutputStream os, long minlength) throws IOException {
+        byte[] buffer = new byte[BUFFER_LEN];
+        long count = getCount(minlength);
+        for (long i = 0; i < count; i++) {
+            os.write(buffer);
+        }
+        os.flush();
+    }
+
+    static void createJarWithLargeFile(File jarFile, File javaFile,
+            long minlength) throws IOException {
+        Utils.createClassFile(javaFile, null, true);
+        File classFile = new File(Utils.getClassFileName(javaFile));
+        ZipOutputStream zos = null;
+        BufferedOutputStream bos = null;
+        FileInputStream fis = null;
+        try {
+            zos = new ZipOutputStream(new FileOutputStream(jarFile));
+            zos.setLevel(ZipOutputStream.STORED);
+            zos.setMethod(0);
+            bos = new BufferedOutputStream(zos);
+
+            ZipEntry ze = new ZipEntry("large.data");
+            ze.setCompressedSize(getCount(minlength) * BUFFER_LEN);
+            ze.setSize(getCount(minlength) * BUFFER_LEN);
+            ze.setCrc(computeCRC(minlength));
+            ze.setMethod(ZipEntry.STORED);
+            zos.putNextEntry(ze);
+            createLargeFile(bos, minlength);
+
+            ze = new ZipEntry(classFile.getName());
+            ze.setCompressedSize(classFile.length());
+            ze.setSize(classFile.length());
+            ze.setCrc(computeCRC(classFile));
+            ze.setMethod(ZipEntry.STORED);
+            zos.putNextEntry(ze);
+            fis = new FileInputStream(classFile);
+            Utils.copyStream(fis, bos);
+            bos.flush();
+            zos.closeEntry();
+        } finally {
+            Utils.close(bos);
+            Utils.close(zos);
+            Utils.close(fis);
+        }
+        // deleted to prevent accidental linkage
+        new File(Utils.getClassFileName(javaFile)).delete();
+    }
+
+    static void createLargeJar(File jarFile, File javaFile) throws IOException {
+        File classFile = new File(Utils.getClassFileName(javaFile));
+        Utils.createClassFile(javaFile, null, true);
+        ZipOutputStream zos = null;
+        FileInputStream fis = null;
+        final int MAX = Short.MAX_VALUE * 2 + 10;
+        ZipEntry ze = null;
+        try {
+            zos = new ZipOutputStream(new FileOutputStream(jarFile));
+            zos.setLevel(ZipOutputStream.STORED);
+            zos.setMethod(ZipOutputStream.STORED);
+            for (int i = 0; i < MAX ; i++) {
+                ze = new ZipEntry("X" + i + ".txt");
+                ze.setSize(0);
+                ze.setCompressedSize(0);
+                ze.setCrc(0);
+                zos.putNextEntry(ze);
+            }
+
+            // add a class file
+            ze = new ZipEntry(classFile.getName());
+            ze.setCompressedSize(classFile.length());
+            ze.setSize(classFile.length());
+            ze.setCrc(computeCRC(classFile));
+            zos.putNextEntry(ze);
+            fis = new FileInputStream(classFile);
+            Utils.copyStream(fis, zos);
+        } finally {
+            Utils.close(zos);
+            Utils.close(fis);
+        // deleted to prevent accidental linkage
+        new File(Utils.getClassFileName(javaFile)).delete();
+    }
+    }
+
+    // a jar with entries exceeding 64k + a class file for the existential test
+    public static void testScenarioA(String... args) throws IOException {
+        File largeJar = new File("large.jar");
+        File javaFile = new File("Foo.java");
+        createLargeJar(largeJar, javaFile);
+
+        File testFile = new File("Bar.java");
+        try {
+            Utils.createJavaFile(testFile, javaFile);
+            if (!Utils.compile("-doe", "-verbose", "-cp",
+                    largeJar.getAbsolutePath(), testFile.getAbsolutePath())) {
+                throw new IOException("test failed");
+            }
+        } finally {
+            Utils.deleteFile(largeJar);
+        }
+    }
+
+    // a jar with an enormous file + a class file for the existential test
+    public static void testScenarioB(String... args) throws IOException {
+        final File largeJar = new File("huge.jar");
+        final File javaFile = new File("Foo.java");
+
+        final Path path = largeJar.getAbsoluteFile().getParentFile().toPath();
+        final long available = Files.getFileStore(path).getUsableSpace();
+        final long MAX_VALUE = 0xFFFF_FFFFL;
+
+        final long absolute  = MAX_VALUE + 1L;
+        final long required  = (long)(absolute * 1.1); // pad for sundries
+        System.out.println("\tavailable: " + available / GIGA + " GB");
+        System.out.println("\trequired: " + required / GIGA + " GB");
+
+        if (available > required) {
+            createJarWithLargeFile(largeJar, javaFile, absolute);
+            File testFile = new File("Bar.java");
+            Utils.createJavaFile(testFile, javaFile);
+            try {
+                if (!Utils.compile("-doe", "-verbose", "-cp",
+                        largeJar.getAbsolutePath(), testFile.getAbsolutePath())) {
+                    throw new IOException("test failed");
+                }
+            } finally {
+                Utils.deleteFile(largeJar);
+            }
+        } else {
+            System.out.println("Warning: testScenarioB passes vacuously," +
+                    " requirements exceeds available space");
+        }
+    }
+
+    public static void main(String... args) throws IOException {
+        testScenarioA();
+        System.out.println("testScenarioA: PASS");
+        if (Boolean.getBoolean("T6836682.testScenarioB")) {
+            testScenarioB();
+            System.out.println("testScenarioB: PASS");
+        } else {
+            System.out.println("Warning: testScenarioB, large file test skipped");
+        }
+    }
+}
diff --git a/langtools/test/tools/javac/file/zip/T6865530.java b/langtools/test/tools/javac/file/zip/T6865530.java
new file mode 100644
index 00000000000..62d410429a6
--- /dev/null
+++ b/langtools/test/tools/javac/file/zip/T6865530.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6865530
+ * @summary ensure JavacFileManager handles non-standard zipfiles.
+ * @compile  -XDignore.symbol.file T6865530.java
+ * @run main T6865530
+ */
+
+
+import java.io.File;
+
+
+public class T6865530 {
+
+    public static void main(String... args) throws Exception {
+        File badFile = new File("bad.exe");
+        File testJar = new File("test.jar");
+        File fooJava = new File("Foo.java");
+        File barJava = new File("Bar.java");
+
+        // create a jar by compiling a file, and append the jar to some
+        // arbitrary data to offset the start of the zip/jar archive
+        Utils.createJavaFile(fooJava);
+        Utils.compile("-doe", "-verbose", fooJava.getName());
+        String[] jarArgs = {
+            "cvf", testJar.getAbsolutePath(), "Foo.class"
+        };
+        Utils.jarTool.run(jarArgs);
+        Utils.cat(badFile, fooJava, testJar);
+
+        // create test file and use the above file as a classpath
+        Utils.createJavaFile(barJava);
+        try {
+            if (!Utils.compile("-doe", "-verbose", "-cp", badFile.getAbsolutePath(), "Bar.java")) {
+                throw new RuntimeException("test fails javac did not compile");
+            }
+        } finally {
+            Utils.deleteFile(badFile);
+            Utils.deleteFile(testJar);
+        }
+    }
+}
+
diff --git a/langtools/test/tools/javac/file/zip/Utils.java b/langtools/test/tools/javac/file/zip/Utils.java
new file mode 100644
index 00000000000..2f5f31b329b
--- /dev/null
+++ b/langtools/test/tools/javac/file/zip/Utils.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+public class Utils {
+
+    static final sun.tools.jar.Main jarTool =
+            new sun.tools.jar.Main(System.out, System.err, "jar-tool");
+
+    static final com.sun.tools.javac.Main javac =
+            new com.sun.tools.javac.Main();
+
+    private Utils(){}
+
+    public static boolean compile(String... args) {
+        return javac.compile(args) == 0;
+    }
+
+    public static void createClassFile(File javaFile, File superClass,
+            boolean delete) throws IOException {
+        createJavaFile(javaFile, superClass);
+        if (!compile(javaFile.getName())) {
+            throw new RuntimeException("compile failed unexpectedly");
+        }
+        if (delete) javaFile.delete();
+    }
+
+    public static void createJavaFile(File outFile) throws IOException {
+        createJavaFile(outFile, null);
+    }
+
+    public static void createJavaFile(File outFile, File superClass) throws IOException {
+        PrintStream ps = null;
+        String srcStr = "public class " + getSimpleName(outFile) + " ";
+        if (superClass != null) {
+            srcStr = srcStr.concat("extends " + getSimpleName(superClass) + " ");
+        }
+        srcStr = srcStr.concat("{}");
+        try {
+            FileOutputStream fos = new FileOutputStream(outFile);
+            ps = new PrintStream(fos);
+            ps.println(srcStr);
+        } finally {
+            close(ps);
+        }
+    }
+
+    static String getClassFileName(File javaFile) {
+        return javaFile.getName().endsWith(".java")
+                ? javaFile.getName().replace(".java", ".class")
+                : null;
+    }
+
+    static String getSimpleName(File inFile) {
+        String fname = inFile.getName();
+        return fname.substring(0, fname.indexOf("."));
+    }
+
+    public static void copyStream(InputStream in, OutputStream out) throws IOException {
+        byte[] buf = new byte[8192];
+        int n = in.read(buf);
+        while (n > 0) {
+            out.write(buf, 0, n);
+            n = in.read(buf);
+        }
+    }
+
+    public static void close(Closeable c) {
+        if (c != null) {
+            try {
+                c.close();
+            } catch (IOException ignore) {}
+        }
+    }
+
+    public static void deleteFile(File f) {
+        if (!f.delete()) {
+            throw new RuntimeException("could not delete file: " + f.getAbsolutePath());
+        }
+    }
+
+    public static void cat(File output, File... files) throws IOException {
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
+        FileOutputStream fos = null;
+        try {
+            fos = new FileOutputStream(output);
+            bos = new BufferedOutputStream(fos);
+            for (File x : files) {
+                FileInputStream fis = new FileInputStream(x);
+                bis = new BufferedInputStream(fis);
+                copyStream(bis, bos);
+                Utils.close(bis);
+            }
+        } finally {
+            Utils.close(bis);
+            Utils.close(bos);
+            Utils.close(fos);
+        }
+    }
+}
diff --git a/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java b/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java
index 2706782b10d..4960cacde5e 100644
--- a/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java
+++ b/langtools/test/tools/javac/lib/JavacTestingAbstractProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,6 @@
 import java.util.*;
 import javax.annotation.processing.*;
 import javax.lang.model.SourceVersion;
-import static javax.lang.model.SourceVersion.*;
-import javax.lang.model.element.*;
 import javax.lang.model.util.*;
 
 /**
diff --git a/langtools/test/tools/javac/processing/6430209/b6341534.java b/langtools/test/tools/javac/processing/6430209/b6341534.java
index 5dfad046c90..567a02484be 100644
--- a/langtools/test/tools/javac/processing/6430209/b6341534.java
+++ b/langtools/test/tools/javac/processing/6430209/b6341534.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,7 +56,9 @@ public class b6341534 extends JavacTestingAbstractProcessor {
         // on round 1, expect errorRaised == false && processingOver == false
         // on round 2, expect errorRaised == true && processingOver == true
         if( renv.errorRaised() != renv.processingOver()) {
-            messager.printMessage(ERROR, "FAILED");
+            messager.printMessage(ERROR, "FAILED: round:" + r
+                + ", errorRaised:" + renv.errorRaised()
+                + ", processingOver:" + renv.processingOver());
         }
         return true;
     }
diff --git a/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.2.out b/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.2.out
index 6a48a0e137b..37632783d8f 100644
--- a/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.2.out
+++ b/langtools/test/tools/javac/processing/6994946/SemanticErrorTest.2.out
@@ -1,4 +1,4 @@
 SemanticErrorTest.java:11:46: compiler.err.repeated.interface
 - compiler.err.proc.messager: Deliberate Error
 SemanticErrorTest.java:11:46: compiler.err.repeated.interface
-1 error
+2 errors
diff --git a/langtools/test/tools/javac/processing/environment/round/TestContext.java b/langtools/test/tools/javac/processing/environment/round/TestContext.java
index ddcba25fe80..deed69202bc 100644
--- a/langtools/test/tools/javac/processing/environment/round/TestContext.java
+++ b/langtools/test/tools/javac/processing/environment/round/TestContext.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@ import java.io.*;
 import java.util.*;
 import javax.annotation.processing.*;
 import javax.lang.model.element.*;
-import javax.tools.*;
 import static javax.tools.Diagnostic.Kind.*;
 
 import com.sun.source.util.Trees;
diff --git a/langtools/test/tools/javac/processing/errors/TestErrorCount.java b/langtools/test/tools/javac/processing/errors/TestErrorCount.java
new file mode 100644
index 00000000000..1f40ae8ad58
--- /dev/null
+++ b/langtools/test/tools/javac/processing/errors/TestErrorCount.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6988079
+ * @summary Errors reported via Messager.printMessage(ERROR,"error message") are not tallied correctly
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor TestErrorCount
+ * @compile/fail/ref=TestErrorCount.out -XDrawDiagnostics -processor TestErrorCount TestErrorCount.java
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+
+public class TestErrorCount extends JavacTestingAbstractProcessor {
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        messager.printMessage(Diagnostic.Kind.ERROR, "intentional error");
+        return true;
+    }
+}
+
diff --git a/langtools/test/tools/javac/processing/errors/TestErrorCount.out b/langtools/test/tools/javac/processing/errors/TestErrorCount.out
new file mode 100644
index 00000000000..ccd4db7e5b2
--- /dev/null
+++ b/langtools/test/tools/javac/processing/errors/TestErrorCount.out
@@ -0,0 +1,3 @@
+- compiler.err.proc.messager: intentional error
+- compiler.err.proc.messager: intentional error
+2 errors
diff --git a/langtools/test/tools/javac/processing/filer/TestPackageInfo.java b/langtools/test/tools/javac/processing/filer/TestPackageInfo.java
index 7a905467370..651f9b7ba45 100644
--- a/langtools/test/tools/javac/processing/filer/TestPackageInfo.java
+++ b/langtools/test/tools/javac/processing/filer/TestPackageInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6380018 6392177
+ * @bug 6380018 6392177 6993311
  * @summary Test the ability to create and process package-info.java files
  * @author  Joseph D. Darcy
  * @library ../../lib
@@ -60,7 +60,7 @@ public class TestPackageInfo extends JavacTestingAbstractProcessor {
 
         // Verify annotations are as expected
         Set<TypeElement> expectedAnnotations = new HashSet<TypeElement>();
-        expectedAnnotations.add(eltUtils.getTypeElement("java.lang.SuppressWarnings"));
+        expectedAnnotations.add(eltUtils.getTypeElement("java.lang.Deprecated"));
 
         if (!roundEnv.processingOver()) {
             System.out.println("\nRound " + round);
@@ -90,7 +90,7 @@ public class TestPackageInfo extends JavacTestingAbstractProcessor {
                     } catch(FilerException fe) {}
 
                     PrintWriter pw = new PrintWriter(filer.createSourceFile("foo.package-info").openWriter());
-                    pw.println("@SuppressWarnings(\"\")");
+                    pw.println("@Deprecated");
                     pw.println("package foo;");
                     pw.close();
 
diff --git a/langtools/test/tools/javac/processing/filer/foo/bar/package-info.java b/langtools/test/tools/javac/processing/filer/foo/bar/package-info.java
index eb666f4a02e..b4cbbe5803a 100644
--- a/langtools/test/tools/javac/processing/filer/foo/bar/package-info.java
+++ b/langtools/test/tools/javac/processing/filer/foo/bar/package-info.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,5 +24,5 @@
 /**
  * Javadoc for the foo.bar package!
  */
-@SuppressWarnings("deprecation")
+@Deprecated
 package foo.bar;
diff --git a/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java b/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java
index d602bc08ead..df7e6d08c9b 100644
--- a/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java
+++ b/langtools/test/tools/javac/processing/model/element/TestAnonClassNames.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6449781
+ * @bug 6449781 6930508
  * @summary Test that reported names of anonymous classes are non-null.
  * @author  Joseph D. Darcy
  * @library ../../../lib
@@ -93,6 +93,7 @@ public class TestAnonClassNames {
             TestAnonClassNames.class,
         };
 
+        List<String> names = new ArrayList<String>();
         for(Class<?> clazz : classes) {
             String name = clazz.getName();
             Nesting anno = clazz.getAnnotation(Nesting.class);
@@ -100,7 +101,14 @@ public class TestAnonClassNames {
                               clazz.getName(),
                               anno == null ? "(unset/ANONYMOUS)" : anno.value());
             testClassName(name);
+            names.add(name);
         }
+
+        // test all names together
+        testClassNames(names);
+
+        if (errors > 0)
+            throw new RuntimeException(errors + " errors occurred");
     }
 
     /**
@@ -109,15 +117,23 @@ public class TestAnonClassNames {
      * input classes are modeled as elements.
      */
     static void testClassName(String className) {
-        JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
-        List<String> classNames = new ArrayList<String>();
-        classNames.add(className);
+        testClassNames(Arrays.asList(className));
+    }
+
+    /**
+     * Perform annotation processing on a list of class file names and verify
+     * the existence of different flavors of class names when the
+     * input classes are modeled as elements.
+     */
+    static void testClassNames(List<String> classNames) {
+        System.out.println("test: " + classNames);
 
         List<String> options = new ArrayList<String>();
         options.add("-proc:only");
         options.add("-classpath");
         options.add(System.getProperty("test.classes"));
 
+        JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
         JavaCompiler.CompilationTask compileTask =
             javaCompiler.getTask(null, // Output
                                  null, // File manager
@@ -130,9 +146,16 @@ public class TestAnonClassNames {
         compileTask.setProcessors(processors);
         Boolean goodResult = compileTask.call();
         if (!goodResult) {
-            throw new RuntimeException("Errors found during compile.");
+            error("Errors found during compile.");
         }
     }
+
+    static int errors = 0;
+
+    static void error(String msg) {
+        System.out.println("Error: " + msg);
+        errors++;
+    }
 }
 
 @Retention(RUNTIME)
diff --git a/langtools/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java b/langtools/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java
index 0bbff60766b..ec1fe05015e 100644
--- a/langtools/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java
@@ -24,7 +24,7 @@
 
 /*
  * @test
- * @bug 6639645
+ * @bug 6639645 7026414
  * @summary Modeling type implementing missing interfaces
  * @library ../../../../lib
  * @build JavacTestingAbstractProcessor TestMissingElement
@@ -112,6 +112,7 @@ public class TestMissingElement extends JavacTestingAbstractProcessor {
 
             @Override
             public String visitDeclared(DeclaredType t, Void ignore) {
+                checkEqual(t.asElement(), types.asElement(t));
                 String s = asString(t.asElement());
                 List<? extends TypeMirror> args = t.getTypeArguments();
                 if (!args.isEmpty())
@@ -179,6 +180,13 @@ public class TestMissingElement extends JavacTestingAbstractProcessor {
         return (e != null && e.getKind() == ElementKind.PACKAGE
                 && ((PackageElement) e).isUnnamed());
     }
+
+    void checkEqual(Element e1, Element e2) {
+        if (e1 != e2) {
+            throw new AssertionError("elements not equal as expected: "
+                + e1 + ", " + e2);
+        }
+    }
 }
 
 
diff --git a/langtools/test/tools/javac/processing/options/testCommandLineClasses/Test.java b/langtools/test/tools/javac/processing/options/testCommandLineClasses/Test.java
new file mode 100644
index 00000000000..f9287e695d8
--- /dev/null
+++ b/langtools/test/tools/javac/processing/options/testCommandLineClasses/Test.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6930508
+ * @summary Passing nested class names on javac command line interfere with subsequent name -> class lookup
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor p.NestedExamples Test
+ * @run main Test
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.ElementFilter;
+import javax.tools.*;
+
+import p.NestedExamples;
+
+public class Test extends JavacTestingAbstractProcessor {
+    public static void main(String... args) throws Exception {
+        new Test().run();
+    }
+
+    void run() throws Exception {
+        NestedExamples e = new NestedExamples();
+        List<String> names = getNames(e.getClasses());
+        test(names);
+        test(reverse(names));
+        names = Arrays.asList(e.getClassNames());
+        test(names);
+        test(reverse(names));
+
+        if (errors > 0)
+            throw new RuntimeException(errors + " errors occurred");
+    }
+
+    List<String> getNames(Class<?>[] classes) {
+        List<String> names = new ArrayList<String>();
+        for (Class<?> c: classes)
+            names.add(c.getName());
+        return names;
+    }
+
+    void test(List<String> names) throws Exception {
+        System.err.println("test: " + names);
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
+        File testClasses = new File(System.getProperty("test.classes"));
+        fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses));
+        JavaCompiler.CompilationTask task = compiler.getTask(
+                null, null, null, Arrays.asList("-proc:only"), names, null);
+        task.setProcessors(Arrays.asList(new Test()));
+        boolean ok = task.call();
+        if (!ok)
+            error("compilation failed");
+        System.err.println();
+    }
+
+    <T> List<T> reverse(List<T> list) {
+        List<T> newList = new ArrayList<T>(list);
+        Collections.reverse(newList);
+        return newList;
+    }
+
+    int errors = 0;
+
+    void error(String msg) {
+        System.out.println("Error: " + msg);
+        errors++;
+    }
+
+    //----------
+
+    public boolean process(Set<? extends TypeElement> annotations,
+                           RoundEnvironment roundEnv) {
+        if (!roundEnv.processingOver()) {
+            for (TypeElement typeElt : ElementFilter.typesIn(roundEnv.getRootElements())) {
+                messager.printMessage(Diagnostic.Kind.NOTE, "processing " + typeElt);
+            }
+        }
+        return true;
+    }
+}
diff --git a/langtools/test/tools/javac/processing/options/testCommandLineClasses/p/NestedExamples.java b/langtools/test/tools/javac/processing/options/testCommandLineClasses/p/NestedExamples.java
new file mode 100644
index 00000000000..80a344c1b5f
--- /dev/null
+++ b/langtools/test/tools/javac/processing/options/testCommandLineClasses/p/NestedExamples.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+public class NestedExamples {
+    static class MemberClass1 { }
+
+    class MemberClass2 { }
+
+    class Win$$AtVegas { } // Class with funny name.
+
+    public Class<?>[] getClasses() {
+        class LocalClass { }
+
+        Object o = new Object() { // An anonymous class
+            @Override
+            public String toString() {
+                return "I have no name!";
+            }
+        };
+
+        return new Class<?>[] {
+            NestedExamples.class,
+            MemberClass1.class,
+            MemberClass2.class,
+            Win$$AtVegas.class,
+            LocalClass.class,
+            o.getClass()
+        };
+    }
+
+    public String[] getClassNames() {
+        return new String[] {
+            "p.NestedExamples",
+            "p.NestedExamples.MemberClass1",
+            "p.NestedExamples.MemberClass2",
+            "p.NestedExamples.Win$$AtVegas"
+        };
+    }
+}
+
+
diff --git a/langtools/test/tools/javac/processing/options/testPrintProcessorInfo/Test.java b/langtools/test/tools/javac/processing/options/testPrintProcessorInfo/Test.java
new file mode 100644
index 00000000000..c16ccc6606c
--- /dev/null
+++ b/langtools/test/tools/javac/processing/options/testPrintProcessorInfo/Test.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6987384
+ * @summary -XprintProcessorRoundsInfo message printed with different timing than previous
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor Test
+ * @compile/fail/ref=Test.out -XDrawDiagnostics -XprintProcessorInfo -Werror -proc:only -processor Test Test.java
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+import javax.tools.*;
+
+public class Test extends JavacTestingAbstractProcessor {
+    final int MAX_ROUNDS = 3;
+    int round = 0;
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        round++;
+        messager.printMessage(Diagnostic.Kind.NOTE, "round " + round);
+        if (round <= MAX_ROUNDS)
+            generateSource("Gen" + round);
+        if (roundEnv.processingOver())
+            messager.printMessage(Diagnostic.Kind.WARNING, "last round");
+        return true;
+    }
+
+    void generateSource(String name) {
+        String text = "class " + name + " { }\n";
+
+        // avoid try-with-resources so test can be run on older builds
+        try {
+            Writer out = filer.createSourceFile(name).openWriter();
+            try {
+                out.write(text);
+            } finally {
+                out.close();
+            }
+        } catch (IOException e) {
+            throw new Error(e);
+        }
+    }
+}
+
+
+
diff --git a/langtools/test/tools/javac/processing/options/testPrintProcessorInfo/Test.out b/langtools/test/tools/javac/processing/options/testPrintProcessorInfo/Test.out
new file mode 100644
index 00000000000..0e22a7f5240
--- /dev/null
+++ b/langtools/test/tools/javac/processing/options/testPrintProcessorInfo/Test.out
@@ -0,0 +1,13 @@
+Processor Test matches [java.lang.Override] and returns true.
+- compiler.note.proc.messager: round 1
+Processor Test matches [] and returns true.
+- compiler.note.proc.messager: round 2
+Processor Test matches [] and returns true.
+- compiler.note.proc.messager: round 3
+Processor Test matches [] and returns true.
+- compiler.note.proc.messager: round 4
+- compiler.note.proc.messager: round 5
+- compiler.warn.proc.messager: last round
+- compiler.err.warnings.and.werror
+1 error
+1 warning